Bacancy Technology
Bacancy Technology represents the connected world, offering innovative and customer-centric information technology experiences, enabling Enterprises, Associates and the Society to Rise™.
12+
Countries where we have happy customers
1050+
Agile enabled employees
06
World wide offices
12+
Years of Experience
05
Agile Coaches
14
Certified Scrum Masters
1000+
Clients projects
1458
Happy customers
Artificial Intelligence
Machine Learning
Salesforce
Microsoft
SAP
November 21, 2023
To fix this, you can open the file in append mode (‘a’) and then use np.savetxt to write to that file.
import numpy as np from scipy.stats.stats import pearsonr list = ['01', '02','03','04','05','06','07','08','09','10'] month='NOV2016' # Open the file in append mode with open('result.dat', 'a') as f: for date in list: path='D:/Match-Nov2016/24-match-ground-imsra-0.25/' data=np.loadtxt(path+'3DIMG_'+date+month+'_DAILY.dat') lats=data[:,0] lons=data[:,1] ground=data[:,2] model=data[:,5] bias=np.mean(model-ground) rms=np.sqrt(np.mean((ground-model)**2)) std=np.std(ground-model) corr=pearsonr(ground,model) corr=corr[0] bias=np.round(bias,2) rms=np.round(rms,2) std=np.round(std,2) corr=np.round(corr,2) stat=np.zeros((np.size(bias),4)) stat[:,0]=np.reshape(bias,(np.size(bias))) stat[:,1]=np.reshape(rms,(np.size(rms))) stat[:,2]=np.reshape(std,(np.size(std))) stat[:,3]=np.reshape(corr,(np.size(corr))) print(stat) # Use np.savetxt to write to the file np.savetxt(f, stat, fmt='%9.2f')