Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #Historical (1950-2020) data
  2. ncin_1 = Dataset("/project/wca/AR5/CanESM2/monthly/histr1/tas_Amon_CanESM2_historical-r1_r1i1p1_195001-202012.nc") #Import data file
  3. tash1 = ncin_1.variables['tas'][:] #extract tas (temperature) variable
  4. ncin_1.close() #close to save memory
  5.  
  6. #Repeat for future (2021-2100) data
  7. ncin_1 = Dataset("/project/wca/AR5/CanESM2/monthly/histr1/tas_Amon_CanESM2_historical-r1_r1i1p1_202101-210012.nc")
  8. tasr1 = ncin_1.variables['tas'][:]
  9. ncin_1.close()
  10.  
  11. #Concatenate historical & future files together to make one time series array
  12. tas11 = np.concatenate((tash1,tasr1),axis=0)
  13.  
  14. #Subtract the 1950-1979 mean to obtain anomalies
  15. tas11 = tas11 - np.mean(tas11[0:359],axis=0,dtype=np.float64)
  16.  
  17. #Move all tas data to one array
  18. alltas = np.zeros((1812,64,128,51)) #years, lat, lon, members (no ensemble mean value yet)
  19. alltas[:,:,:,0] = tas11
  20. (...)
  21. alltas[:,:,:,49] = tas50
  22.  
  23. #Calculate ensemble mean & fill into 51st slot in axis 3
  24. alltas[:,:,:,50] = np.mean(alltas,axis=3,dtype=np.float64)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement