mean_month=np.mean(Sktm_temp_1999_2011[1:13,:],axis=1)
max_month=np.max(Sktm_temp_1999_2011[1:13,:],axis=1)
min_month=np.min(Sktm_temp_1999_2011[1:13,:],axis=1)
np.savetxt('temp_mean_max_min.txt',np.concatenate((mean_month,max_month,min_month),axis=1),fmt='%1.1f')
Without your data (in array Sktm_temp_1999_2011), it's not clear what you're trying to do, or where the error occurs. It looks like some kind of monthly temperature data for years 1999-2011. :-) (12 months, 13 years)
First, check your range for np.mean, np.max and np.min. Do you really want 1:13, or did you intend 0:13 to get statistics for each month over 13 years?
Also, axis=1 uses the second index. Is this the index to months in your data?
To show how this could work , I created some data for Sktm_temp_1999_2011, size [13,12]. Rows are years, columns are months. I calculated the statistics (w/ axis=0 to get monthly data in each column). The 3 arrays are then copied to a new array. You could also concatenate, but not sure why you would want mean,max,min in a 1d array. From here you can format as desired for printing.
Sktm_temp_1999_2011 = np.arange(156).reshape(13,12)
mean_month=np.mean(Sktm_temp_1999_2011[0:13,:],axis=0)
max_month=np.max(Sktm_temp_1999_2011[0:13,:],axis=0)
min_month=np.min(Sktm_temp_1999_2011[0:13,:],axis=0)
stat_data=np.zeros([3,12])
stat_data[0,:]=mean_month
stat_data[1,:]=max_month
stat_data[2,:]=min_month
print (stat_data)
Output:
[[ 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83.]
[ 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155.]
[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.]]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.