field = 'sicn' # @@ check what the units are: are they all fraction? fhadsic = basepath + 'HadISST/hadisst1.1_bc_128_64_1870_2013m03_sicn_' + timeper + 'climo.nc' #SICN, 129x64 fhadsicts = basepath2 + 'HadISST/SICN_BC_HadISST_' + timeper + '_1870010100-2011020100.nc' #0000120100-0125120100.nc' # test matlab generated BC file fhurrsic = basepath + 'HURRELL/MODEL_ICE.T42_' + timeper + 'climo.nc' #SEAICE (%), 128x64 fnsidcsic = basepath + 'NSIDC/nsidc_bt_128x64_1978m11_2011m12_sicn_' + timeper + 'climo.nc' #SICN, 129x64 fhadsicp = basepath + 'HadISST/hadisst1.1_bc_128_64_1870_2013m03_sicn_' + timeperp2 + 'climo.nc' #SICN, 129x64 fhadsicpts = basepath2 + 'HadISST/SICN_BC_HadISST_' + timeperp2 + '_1870010100-2011020100.nc' #0000120100-0125120100.nc' # test matlab generated BC file fhurrsicp = basepath + 'HURRELL/MODEL_ICE.T42_' + timeperp2 + 'climo.nc' #SEAICE (%), 128x64 fnsidcsicp = basepath + 'NSIDC/nsidc_bt_128x64_1978m11_2011m12_sicn_' + timeperp2 + 'climo.nc' #SICN, 129x64 hadsicc = cnc.getNCvar(fhadsic,'SICN') hadsiccts = cnc.getNCvar(fhadsicts,'SICN') hadsiccclimo,junk = cutl.climatologize3d(hadsiccts) hurrsicc = cnc.getNCvar(fhurrsic,'SEAICE')/100. hurrtimes = cnc.getNCvar(fhurrsic,'time') #hurrsicc.resize(hadsicc.shape) # can't resize like this. ?? #np.append(hurrsicc,hurrsicc[:,:,0])#,axis=2) # could not get append to work #hurrsicc[:,:,len(lon)-1] = hurrsicc[:,:,0] # add a wraparound. nope. hurrsicc = np.flipud(hurrsicc) # the lats are flipped compared to hadisst and nsidc nsidcsicc = cnc.getNCvar(fnsidcsic,'SICN') hadsicp = cnc.getNCvar(fhadsicp,'SICN') hadsicpts = cnc.getNCvar(fhadsicpts,'SICN') hadsicpclimo,junk = cutl.climatologize3d(hadsicpts) hadsicc = hadsicc[...,:-1] hadsicp = hadsicp[...,:-1]
# monthly global mean time-series gmc = cutl.global_mean_areawgted3d(fldc, lat, lon) gmp1 = cutl.global_mean_areawgted3d(fldp1, lat, lon) gmp2 = cutl.global_mean_areawgted3d(fldp2, lat, lon) gmp3 = cutl.global_mean_areawgted3d(fldp3, lat, lon) # monthly polar (>=60N) mean time-series pmc = cutl.polar_mean_areawgted3d(fldc, lat, lon) pmp1 = cutl.polar_mean_areawgted3d(fldp1, lat, lon) pmp2 = cutl.polar_mean_areawgted3d(fldp2, lat, lon) pmp3 = cutl.polar_mean_areawgted3d(fldp3, lat, lon) # monthly climatology and standard dev (3d) (climoc, stdc) = cutl.climatologize3d(fldc) (climop1, stdp1) = cutl.climatologize3d(fldp1) (climop2, stdp2) = cutl.climatologize3d(fldp2) (climop3, stdp3) = cutl.climatologize3d(fldp3) # global mean monthly climatology climogmc = cutl.global_mean_areawgted3d(climoc, lat, lon) climogmp1 = cutl.global_mean_areawgted3d(climop1, lat, lon) climogmp2 = cutl.global_mean_areawgted3d(climop2, lat, lon) climogmp3 = cutl.global_mean_areawgted3d(climop3, lat, lon) # polar (>=60N) mean monthly climatology climopmc = cutl.polar_mean_areawgted3d(climoc, lat, lon) climopmp1 = cutl.polar_mean_areawgted3d(climop1, lat, lon) climopmp2 = cutl.polar_mean_areawgted3d(climop2, lat, lon) climopmp3 = cutl.polar_mean_areawgted3d(climop3, lat, lon)
else: fnamec = basepath + casename + subdir + casename + '_' + field + '_' + timstr + '_ts.nc' fnamep1 = basepath + casenamep1 + subdir + casenamep1 + '_' + field + '_' + timstrp + '_ts.nc' fnamep2 = basepath + casenamep2 + subdir + casenamep2 + '_' + field + '_' + timstrp + '_ts.nc' fnamep3 = basepath + casenamep3 + subdir + casenamep3 + '_' + field + '_' + timstrp + '_ts.nc' fldc = cnc.getNCvar(fnamec,field.upper(),timesel=timesel)*conv fldp1 = cnc.getNCvar(fnamep1,field.upper(),timesel=timesel)*conv fldp2 = cnc.getNCvar(fnamep2,field.upper(),timesel=timesel)*conv fldp3 = cnc.getNCvar(fnamep3,field.upper(),timesel=timesel)*conv lat = cnc.getNCvar(fnamec,'lat') lon = cnc.getNCvar(fnamec,'lon') fldcclim,fldcstd = cutl.climatologize3d(fldc) fldp1clim,fldp1std = cutl.climatologize3d(fldp1) fldp2clim,fldp2std = cutl.climatologize3d(fldp2) fldp3clim,fldp3std = cutl.climatologize3d(fldp3) if avgtype == 'gt' + str(latlim) + 'Nmasked': print avgtype + '!!!' fldc = ma.masked_where(fldc==0,fldc) fldp1 = ma.masked_where(fldp1==0,fldp1) fldp2 = ma.masked_where(fldp2==0,fldp2) fldp3 = ma.masked_where(fldp3==0,fldp3) fldcpm = cutl.polar_mean_areawgted3d(fldc,lat,lon,latlim=latlim) fldp1pm = cutl.polar_mean_areawgted3d(fldp1,lat,lon,latlim=latlim) fldp2pm = cutl.polar_mean_areawgted3d(fldp2,lat,lon,latlim=latlim) fldp3pm = cutl.polar_mean_areawgted3d(fldp3,lat,lon,latlim=latlim)
fnamecs = basepath + casename + subdir + casename + "_" + fields + "_" + timstr + "_ts.nc" fnamep2s = basepath + casenamep2 + subdir + casenamep2 + "_" + fields + "_" + timstr + "_ts.nc" fldcs = cnc.getNCvar(fnamecs, fields.upper(), timesel="0002-01-01,0111-12-31") * convs fldp2s = cnc.getNCvar(fnamep2s, fields.upper(), timesel="0002-01-01,0111-12-31") * convs fnamecg = basepath + casename + subdir + casename + "_" + fieldg + "_" + timstr + "_ts.nc" fnamep2g = basepath + casenamep2 + subdir + casenamep2 + "_" + fieldg + "_" + timstr + "_ts.nc" fldcg = cnc.getNCvar(fnamecg, fieldg.upper(), timesel="0002-01-01,0111-12-31") * convg fldp2g = cnc.getNCvar(fnamep2g, fieldg.upper(), timesel="0002-01-01,0111-12-31") * convg lat = cnc.getNCvar(fnamecs, "lat") lon = cnc.getNCvar(fnamecs, "lon") fldcsclim, fldcsstd = cutl.climatologize3d(fldcs) fldpsclim, fldpsstd = cutl.climatologize3d(fldp2s) fldcgclim, fldcgstd = cutl.climatologize3d(fldcg) fldpgclim, fldpgstd = cutl.climatologize3d(fldp2g) print fldcgclim.shape lons, lats = np.meshgrid(lon, lat) plotfldg = fldcgclim[2, :, :] # test Jan sst plotflds = fldcsclim[2, :, :] # test Jan sicn plotflds = ma.masked_where(plotflds <= 0, plotflds)
cnc.getNCvar(fnamec2, ncfield, calc="zm", seas="DJF") * conv, axis=0, ) fldczmnewdjftm = np.mean(fldczmnewdjf, 0) fldczmnewjja = np.append( cnc.getNCvar(fnamec, ncfield, calc="zm", seas="JJA") * conv, cnc.getNCvar(fnamec2, ncfield, calc="zm", seas="JJA") * conv, axis=0, ) fldczmnewjjatm = np.mean(fldczmnewjja, 0) ### test climatologize3d() fldczmnewclimo, std = cutl.climatologize3d(fldczmnew) ################################# PY/NC ######################################## lat = cnc.getNCvar(fnamec, "lat") lev = cnc.getNCvar(fnamec, "plev") # fldczm = cnc.getNCvar_old(fnamec,ncfield,calc='zm',timechunk=((styr-1)*12,enyr*12+1) )*conv fldczm = cnc.getNCvar_old(fnamec, ncfield, calc="zm") * conv fldczmtm = np.mean(cutl.annualize_monthlyts(fldczm), 0) fldczmtm2 = np.average(fldczm, 0) # not month-weighted lats, levs = np.meshgrid(lat, lev)