for day in range(1,eday+1): for hour in lhour: frontname = "/media/disk2/out/chart/ASAS/front/%04d%02d/front.ASAS.%04d.%02d.%02d.%02d.saone"%(year,mon,year,mon,day,hour) a2front = fromfile(frontname,float32).reshape(180,360) a2frontw = ma.masked_not_equal(a2front, 1).filled(miss) a2frontc = ma.masked_not_equal(a2front, 2).filled(miss) # a2terrw = ctrack_fsub.mk_territory_saone((ma.masked_equal(a2front,1.0).filled(miss)).T, dist_mask*1000., miss, lat_first, dlat, dlon).T a2terrc = ctrack_fsub.mk_territory_saone((ma.masked_equal(a2front,2.0).filled(miss)).T, dist_mask*1000., miss, lat_first, dlat, dlon).T a2frontinw = ma.masked_where(a2terrw ==miss, a2frontw).filled(miss) a2frontinc = ma.masked_where(a2terrc ==miss, a2frontc).filled(miss) #----------------------- a2gsmap = gsmap_func.timeave_gsmap_backward_saone(year,mon,day,hour+1,2) a2gsmap = gsmap_func.gsmap2global_one(a2gsmap, miss) #----------------------- a2prw = ma.masked_where(a2front !=1.0 , a2gsmap) a2prc = ma.masked_where(a2front !=2.0 , a2gsmap) # a2prinw = ma.masked_where(a2frontinw ==miss, a2gsmap) a2princ = ma.masked_where(a2frontinc ==miss, a2gsmap) #----------------------- prw = ma.masked_equal( a2prw, miss).filled(0.0).sum()*60*60. prc = ma.masked_equal( a2prc, miss).filled(0.0).sum()*60*60. # prinw = ma.masked_equal( a2prinw, miss).filled(0.0).sum()*60*60. princ = ma.masked_equal( a2princ, miss).filled(0.0).sum()*60*60. # numw = ma.count( ma.masked_equal(a2prw, miss))
#-------------------- for day in range(iday, eday+1): print prtype, season, year, mon, day for hour in lhour: #-- prec name ---- if prtype == "GSMaP": prname = prdir + "/gsmap_mvk.3rh.%04d%02d%02d.%02d00.v5.222.1.sa.one"%(year, mon, day, hour) elif prtype == "JRA": prname = prdir + "/fcst_phy2m.PR.%04d%02d%02d%02d.sa.one"%(year, mon, day, hour) elif prtype == "GPCP1DD": prname = prdir + "/gpcp_1dd_v1.2_p1d.%04d%02d%02d.bn"%(year, mon, day) #-- load prec ---- if prtype == "GSMaP": a2pr = fromfile(prname, float32).reshape(120, 360) a2pr = gsmap_func.gsmap2global_one(a2pr, miss_out) elif prtype == "JRA": a2pr = fromfile(prname, float32).reshape(ny, nx) elif prtype == "GPCP1DD": a2pr = flipud(fromfile(prname, float32).reshape(ny, nx)) a2pr = ma.masked_equal(a2pr, miss_gpcp).filled(0.0) #***************************** # load corresponding tags #----------------------------- lhtag_inc = ret_lhtag_inc(timestep, hour) now = datetime.datetime(year, mon, day, hour) #------------------ a2tagtmp_tc = a2zero a2tagtmp_c = a2zero a2tagtmp_fbc = a2zero
elif vtype == "JRA": diname["pr"] = didir["pr"] + "/fcst_phy2m.PR.%04d%02d%02d%02d.sa.one"%(year_target, mon_target, day_target, hour_target) print year, mon, day, hour, target elif vtype == "GPCP1DD": diname["pr"] = didir["pr"] + "/gpcp_1dd_v1.1_p1d.%04d%02d%02d.bn"%(year_target, mon_target, day_target) print year, mon, day, hour, target elif vtype == "APHRO_MA": diname["pr"] = didir["pr"] + "/APHRO_MA_025deg_V1101.%04d.%02d.%02d.sa.one"%(year_target, mon_target, day_target) #----------------------- if var == "pr": #-- load ----- if vtype == "GSMaP": a2invar_temp = fromfile(diname[var], float32).reshape(120, 360) a2invar_temp = gsmap_func.gsmap2global_one(a2invar_temp, miss_out) elif vtype == "JRA": a2invar_temp = fromfile(diname[var], float32).reshape(ny_org, nx_org) elif vtype == "GPCP1DD": a2invar_temp = flipud(fromfile(diname[var], float32).reshape(ny_org, nx_org)) a2invar_temp = ma.masked_equal(a2invar_temp, miss_gpcp).filled(0.0) elif vtype == "APHRO_MA": a2invar_temp = fromfile(diname[var], float32).reshape(70,90) a2invar_temp = aphro_func.aphro2global_one(a2invar_temp, "MA", miss_out) #------ da2in[var] = da2in[var] + ma.masked_equal(a2invar_temp, miss_out) #--------------- da2in[var] = da2in[var] / len(lhour_inc) if type(da2in[var]) == ma.core.MaskedArray: da2in[var] = da2in[var].filled(miss_out)
elif prtype == "JRA": diname["pr"] = didir["pr"] + "/fcst_phy2m.PR.%04d%02d%02d%02d.sa.one"%(year, mon, day, hour) elif prtype == "GPCP1DD": diname["pr"] = didir["pr"] + "/gpcp_1dd_v1.1_p1d.%04d%02d%02d.bn"%(year, mon, day) #--------------- diname["life"] = didir["life"] + "/life.%04d%02d%02d%02d.sa.one"%(year, mon, day, hour) diname["pgrad"] = didir["pgrad"] + "/pgrad.%04d%02d%02d%02d.sa.one"%(year, mon, day, hour) #diname["wap"] = didir["wap"] + "/%s_day_%s_%s_%s_%04d%02d%02d00.bn"%(model, expr, ens, year, mon, day) #--- load ------------ da2in = {} #-- prec load -- if var == "pr": if prtype == "GSMaP": da2in[var] = fromfile(diname[var], float32).reshape(120, 360) da2in[var] = gsmap_func.gsmap2global_one(da2in[var], miss_out) elif prtype == "JRA": da2in[var] = fromfile(diname[var], float32).reshape(ny_org, nx_org) elif prtype == "GPCP1DD": da2in[var] = flipud(fromfile(diname[var], float32).reshape(ny_org, nx_org)) #--------------- da2in["pgrad"] = fromfile(diname["pgrad"],float32).reshape(ny_org, nx_org) #da2in["life"] = fromfile(diname["life"], int32).reshape(ny_org, nx_org) #--- original --> fine grid --- a2in_fin = cf.biIntp(a1lat_org, a1lon_org, da2in[var], a1lat_fin, a1lon_fin, miss=miss_out)[0] #--- cyclone center data ------------- da2in["center"] = ma.masked_less(da2in["pgrad"], 0.0).filled(0.0) da2in["center"] = ma.masked_greater(da2in["center"], 0.0).filled(1.0) #-------------------------------------
a2prc = ma.masked_where(a2countc==0.0, fromfile(prc,float32).reshape(180,360))*60*60. a2prw = ma.masked_where(a2countw==0.0, fromfile(prw,float32).reshape(180,360))*60*60. countinc = idir + "/num.maskrad.in.%04dkm.0000km.cold.sa.one"%(rad) countinw = idir + "/num.maskrad.in.%04dkm.0000km.warm.sa.one"%(rad) princ = idir + "/pr.maskrad.in.%04dkm.0000km.cold.sa.one"%(rad) prinw = idir + "/pr.maskrad.in.%04dkm.0000km.warm.sa.one"%(rad) a2countinc = fromfile(countinc,float32).reshape(180,360) a2countinw = fromfile(countinw,float32).reshape(180,360) a2princ = ma.masked_where(a2countinc ==0.0, fromfile(princ,float32).reshape(180,360))*60.*60. a2prinw = ma.masked_where(a2countinw ==0.0, fromfile(prinw,float32).reshape(180,360))*60.*60 frontname1 = "/media/disk2/out/chart/ASAS/front/200404/front.ASAS.2004.04.05.00.saone" frontname2 = "/media/disk2/out/chart/ASAS/front/200404/front.ASAS.2004.04.05.18.saone" a2front1 = fromfile(frontname1,float32).reshape(180,360) a2front2 = fromfile(frontname2,float32).reshape(180,360) #----------------------- a2gsmap1 = gsmap_func.timeave_gsmap_backward_saone(2004,4,5,0+1,2)*60*60. a2gsmap2 = gsmap_func.timeave_gsmap_backward_saone(2004,4,5,18+1,2)*60*60. a2gsmap1 = ma.masked_equal(gsmap_func.gsmap2global_one(a2gsmap1, miss), miss).filled(0.0) a2gsmap2 = ma.masked_equal(gsmap_func.gsmap2global_one(a2gsmap2, miss), miss).filled(0.0) #----------------------- a2prmanw1 = ma.masked_where(a2front1 !=1.0 , a2gsmap1) a2prmanc1 = ma.masked_where(a2front1 !=2.0 , a2gsmap1)
thpgrad = dpgradrange[0][0] #--- value ------------------ a2v = zeros([ny, nx]) a2num = zeros([ny, nx]) a2one = ones([ny, nx]) # if vtype == "GSMaP": lhour_inc = [-3, 0, 3, 6] for hour_inc in lhour_inc: (year_t, mon_t, day_t, hour_t) = shifttime(year, mon, day, hour, hour_inc) print day, year_t, mon_t, day_t, hour_t vdir_root = "/media/disk2/data/GSMaP/sa.one/3hr/ptot" vdir = vdir_root + "/%04d%02d"%(year_t, mon_t) vname = vdir + "/gsmap_mvk.3rh.%04d%02d%02d.%02d00.v5.222.1.sa.one"%(year_t, mon_t, day_t, hour_t) a2v_t = fromfile(vname, float32).reshape(120, 360) a2v_t = gsmap_func.gsmap2global_one(a2v_t, -9999.0) a2num_t = ma.masked_where(a2v_t ==-9999.0, a2one).filled(0.0) a2num = a2num + a2num_t a2v = a2v + ma.masked_equal(a2v_t, -9999.0) #-- #a2v = ma.masked_where(a2num < len(lhour_inc), a2v)/a2num a2v = a2v / len(lhour_inc) a2v = a2v*60*60*24.0 a2v = a2v.filled(-9999.0) a2mask = a2v if day == 22: array(a2v,float32).tofile("./temp.sa.one") array(a2num, float32).tofile("./num.sa.one")