a2pr_all = a2pr_all + a2pr a2pr_tc = a2pr_tc + a2prtmp_tc a2pr_c = a2pr_c + a2prtmp_c a2pr_fbc = a2pr_fbc + a2prtmp_fbc a2pr_ot = a2pr_ot + a2prtmp_ot #***************************** # convert unit to mm/s #--------------------- if prtype in ["GPCP1DD"]: coef = 1.0/(60*60*24.0) else: coef = 1.0 #-- totaltimes = ctrack_para.ret_totaldays(year,year,mon)*len(lhour) # a2pr_all = a2pr_all *coef/ totaltimes a2pr_tc = a2pr_tc *coef/ totaltimes a2pr_c = a2pr_c *coef/ totaltimes a2pr_fbc = a2pr_fbc *coef/ totaltimes a2pr_ot = a2pr_ot *coef/ totaltimes #***************************** #-- save monthly data --- #----------------------------- sodir_root = "/media/disk2/out/JRA25/sa.one.%s/6hr/tagpr/ind.c%02dh.tc%02dh.%stc%04d.c%04d.f%04d"%(sresol, thdura_c, thdura_tc, tctype, dist_tc, dist_c, dist_f) # sodir = sodir_root + "/%04d%02d"%(year, mon) ctrack_func.mk_dir(sodir) #
thwcore = tc_para.ret_thwcore(model) # lmon = ctrack_para.ret_lmon(season) #------------------ a2num = zeros([ny,nx],float32) for year in lyear: for mon in lmon: sidir_root = "/media/disk2/out/JRA25/sa.one.%s/6hr/tc/freq.%02dh.wc%4.2f.sst%02d.wind%02d.vor%.1e"%(model,thdura,thwcore,thsst-273.15,thwind,thrvort) #sidir_root = "/media/disk2/out/JRA25/sa.one.%s/6hr/tc/freq.%02dh"%(model,thdura) sidir = sidir_root + "/%04d"%(year) siname = sidir + "/num.tc.rad%04dkm.%04d.%02d.sa.one"%(countrad,year,mon) a2num_tmp = fromfile(siname, float32).reshape(ny,nx) a2num = a2num + a2num_tmp #----------------------------------------- totalnum = ctrack_para.ret_totaldays(iyear,eyear,season) * 4.0 a2freq = a2num / totalnum sodir_root = sidir_root sodir = sodir_root + "/%04d-%04d.%s"%(iyear,eyear,season) ctrack_func.mk_dir(sodir) soname = sodir + "/freq.tc.rad%04dkm.%04d-%04d.%s.sa.one"%(countrad,iyear,eyear,season) a2freq.tofile(soname) print soname #******************************* # Figure #----------- if len(lmon) ==12: if sum3x3flag == True: #bnd = [0.01,0.25,0.5,1.0,2.0,4.0] bnd = [0.1,0.25,0.5,1.0,2.0,4.0] elif sum3x3flag == False:
figname = figdir + "/3x3.freq.t.front.%s.%s.rad%04dkm.M1_%4.2f_M2_%3.1f.%04d-%04d.%s.png"%(model,ens,countrad,thfmask1t,thfmask2t,iyear,eyear,season) elif (filterflag == False)&(sum3x3flag==False): figname = figdir + "/freq.t.front.%s.%s.rad%04dkm.M1_%4.2f_M2_%3.1f.%04d-%04d.%s.png"%(model,ens,countrad,thfmask1t,thfmask2t,iyear,eyear,season) #----------- if sum3x3flag == True: cbarname = figname[:-4] + ".3x3.cbar.png" elif sum3x3flag == False: cbarname = figname[:-4] + ".cbar.png" #---------- stitle = "freq. front.t: %s %s season:%s %04d-%04d"%(model, ens, season,iyear, eyear) mycm = "Spectral" datname = oname a2figdat = fromfile(datname, float32).reshape(ny,nx) #------------------------------- #--- unit ---- totaldays = ctrack_para.ret_totaldays(iyear,eyear,season) a2figdat = ma.masked_equal(a2figdat, miss).filled(0.0) * 100.0 #a2figdat = ma.masked_equal(a2figdat, miss).filled(0.0) * totaldays / len(lyear) #-- filter -------------- if filterflag == True: #a2figdat = myfunc_fsub.mk_a2convolution(a2figdat.T, a2filter.T, miss).T a2figdat = ctrack_fsub.mk_a2radsum_saone(a2figdat.T, filtradkm, miss).T a2figdat = a2figdat / a2areanum elif filterflag ==False: pass else: print "check filterflag",filterflag sys.exit() #------------------------ #-- per 3.0 degree box --
idir_root = "/media/disk2/data/GSMaP/sa.one/1hr/ptot" odir_root = "/media/disk2/data/GSMaP/sa.one/1hr/ptot/ptile" #*********************************************** lhour = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23] #------ function ------------------------------- def nonzero(a1in): return (a1in !=0.0) #** def nonmiss(a1in): return (a1in !=miss) #----------------------------------------------- for season in lseason: for nhour in lnhour: #----------------------------------------------- tottimes = ctrack_para.ret_totaldays(iyear,eyear,season) * len(lhour) if ( 1 <=100-percent <10): ntoprat = 0.1 ntop = ceil(tottimes* ntoprat) segpercent = round(percent%10.0*10) elif (0.1 <=100-percent <1): ntoprat = 0.01 ntop = ceil(tottimes* ntoprat) segpercent = round(percent%1.0*100) elif (0.01 <=100-percent <0.1): ntoprat = 0.001 ntop = ceil(tottimes*ntoprat) segpercent = round(percent%0.1*1000) elif (0.001 <=100-percent <0.01): ntoprat = 0.0001 ntop = ceil(tottimes*ntoprat)
a2frontgrad_tmp = ma.masked_equal(a2frontgrad_tmp, miss).filled(0.0) a2frontgrade_tmp = ma.masked_equal(a2frontgrade_tmp, miss).filled(0.0) a2num_tmp = ma.masked_where(a2front !=ftype, ones([ny,nx],float32)).filled(0.0) da2frontgrad[ftype] = da2frontgrad[ftype] + a2frontgrad_tmp da2frontgrade[ftype] = da2frontgrade[ftype] + a2frontgrade_tmp da2num[ftype] = da2num[ftype] + a2num_tmp #-------------- #*** output data ********* totaltimes = ctrack_para.ret_totaldays(year,year,mon) *4.0 a2gradtheta = a2gradtheta / totaltimes a2gradthetae = a2gradthetae / totaltimes for ftype in lftype: da2frontgrad[ftype] = (ma.masked_where(da2num[ftype]==0.0, da2frontgrad[ftype]) / da2num[ftype] ).filled(miss) da2frontgrade[ftype] = (ma.masked_where(da2num[ftype]==0.0, da2frontgrade[ftype]) / da2num[ftype] ).filled(miss) #-------------------- #*** write **************** odir = "/media/disk2/out/obj.valid/gradtheta/%04d"%(year) ctrack_func.mk_dir(odir) thetaname = odir + "/anl_p.plain.gradtheta.%04d.%02d.sa.one"%(year,mon) thetaename = odir + "/anl_p.plain.gradtheta_e.%04d.%02d.sa.one"%(year,mon)
soname_all = odir + "/freq.all.sa.one" # figname_warm = figdir + "/freq.warm.%s.png"%(season) figname_cold = figdir + "/freq.cold.%s.png"%(season) figname_occ = figdir + "/freq.occ.%s.png"%(season) figname_stat = figdir + "/freq.stat.%s.png"%(season) figname_all = figdir + "/freq.all.%s.png"%(season) #--- init ------------------- a2warm = zeros([ny,nx], float32) a2cold = zeros([ny,nx], float32) a2occ = zeros([ny,nx], float32) a2stat = zeros([ny,nx], float32) a2all = zeros([ny,nx], float32) #---------------------------- totaltimes = ctrack_para.ret_totaldays(iyear, eyear, season)*4.0 print totaltimes lmon = ctrack_para.ret_lmon(season) for year in range(iyear, eyear+1): for mon in lmon: #-------------------- idir = idir_root + "/%04d/%02d"%(year,mon) if rad != "": siname_warm = idir + "/count.rad%04dkm.warm.sa.one"%(rad) siname_cold = idir + "/count.rad%04dkm.cold.sa.one"%(rad) siname_occ = idir + "/count.rad%04dkm.occ.sa.one"%(rad) siname_stat = idir + "/count.rad%04dkm.stat.sa.one"%(rad) else: siname_warm = idir + "/count.warm.sa.one" siname_cold = idir + "/count.cold.sa.one" siname_occ = idir + "/count.occ.sa.one"
a2tup = fromfile(tupname, float32).reshape(ny, nx) a2ulow = fromfile(ulowname, float32).reshape(ny, nx) a2uup = fromfile(uupname, float32).reshape(ny, nx) a2vlow = fromfile(vlowname, float32).reshape(ny, nx) a2vup = fromfile(vupname, float32).reshape(ny, nx) #-------------------------------- #tout = ctrack_fsub.find_tc_saone(\ # a2pgrad.T, a2life.T, a2lastpos.T, a2lastflag.T, a2tlow.T, a2tmid.T, a2tup.T, a2ulow.T, a2uup.T, a2vlow.T, a2vup.T, a2landsea.T\ # , thpgrad, thdura, thlat, thwind, thrvort, initflag, miss) ## tout = ctrack_fsub.find_tc_saone(\ a2pgrad.T, a2life.T, a2lastpos.T, a2lastflag.T, a2tlow.T, a2tmid.T, a2tup.T, a2ulow.T, a2uup.T, a2vlow.T, a2vup.T, a2sst.T, a2landsea.T\ , thpgrad, thdura, thsst, thwind, thrvort, initflag, miss) # a2tcloc = tout[0].T a2lastflag = tout[1].T # a2tcloc = ma.masked_less(a2tcloc, thwcore).filled(miss) a2tcloc = ma.masked_not_equal(a2tcloc, miss).filled(1.0) a2tcloc = ma.masked_equal(a2tcloc, miss).filled(0.0) # #--------------------------------- a2num = a2num + a2tcloc #--- num -> freq ---- totalnum = ctrack_para.ret_totaldays(year, year, mon) * len(lhour) a2freq = a2num / totalnum #--- write to file -- soname = sodir + "/freq.tc.%02dh.w%3.1f.sst%d.wind%d.vor%.1e.sa.one"%(thdura, thwcore,thsst-273.15, thwind, thrvort) a2freq.tofile(soname) print soname
dlon = 1.0 #------------------------ #--- region ----- lregion = ["PNW", "PNE","INN","INS", "PSW","ATN"] da2regmask = {} for region in lregion: lllat, lllon, urlat, urlon = ctrack_para.ret_tcregionlatlon(region) da2regmask[region] = ctrack_func.mk_region_mask(lllat, urlat, lllon, urlon, nx, ny, lat_first, lon_first, dlat, dlon) #---------------- dmfreq_bst = {} dmfreq_obj = {} #---------------- for year in range(iyear, eyear+1): for mon in lmon: totalnum_mon = ctrack_para.ret_totaldays(year,year,mon)*4.0 #*************************** # best track #--------------------------- idir_bst = "/media/disk2/out/ibtracs/sa.one/%04d/%02d"%(year, mon) iname_bst = idir_bst + "/freq.ibtracs_all.v03r04.sa.one" a2freq_bst_mon = fromfile(iname_bst, float32).reshape(ny,nx) for region in lregion: a2freq_bst_temp = ma.masked_where(da2regmask[region] !=1.0, a2freq_bst_mon) dmfreq_bst[region, year, mon] = a2freq_bst_temp.mean() #**************************** # multi resolition #---------------------------- for model in lmodel: #-------------------
#-- dummy ------------------- a2ptot_warm = zeros([ny,nx], float32) a2ptot_cold = zeros([ny,nx], float32) a2ptot_occ = zeros([ny,nx], float32) a2ptot_stat = zeros([ny,nx], float32) a2ptot_all = zeros([ny,nx], float32) #********************************************** # fraction #---------------------------------------------- for year in range(iyear, eyear+1): lmon = ctrack_para.ret_lmon(season) for mon in lmon: idir = idir_root + "/%04d/%02d"%(year, mon) itimes_mon = ctrack_para.ret_totaldays(year,year, mon) * 4.0 #-- ptot name -- ptotname_warm = idir + "/rad%04d.warm.sa.one"%(thdist) ptotname_cold = idir + "/rad%04d.cold.sa.one"%(thdist) ptotname_occ = idir + "/rad%04d.occ.sa.one"%(thdist) ptotname_stat = idir + "/rad%04d.stat.sa.one"%(thdist) ptotname_all = idir + "/rad%04d.all.sa.one"%(thdist) #-- fig: load ptot --- a2ptot_warm_temp = fromfile(ptotname_warm, float32).reshape(ny,nx) a2ptot_cold_temp = fromfile(ptotname_cold, float32).reshape(ny,nx) a2ptot_occ_temp = fromfile(ptotname_occ, float32).reshape(ny,nx) a2ptot_stat_temp = fromfile(ptotname_stat, float32).reshape(ny,nx) a2ptot_all_temp = fromfile(ptotname_all, float32).reshape(ny,nx) #-- fig: mask - a2ptot_warm_temp = ma.masked_equal(a2ptot_warm_temp, miss).filled(0.0)
prtype, iyear, eyear, bstflag_tc, dist_tc / 1000.0, dist_c / 1000.0, dist_f / 1000.0, ) mycm = "jet_r" # -- load ----- a2figdat = fromfile(sname, float32).reshape(ny, nx) a2figdat = ma.masked_equal(a2figdat, miss).filled(0.0) # -- convert unit: mm/sec --> mm/season nsec = ctrack_para.ret_totaldays(iyear, eyear, season) * 24.0 * 60.0 * 60.0 a2figdat = a2figdat * nsec / nmon # -- draw ------ ctrack_fig.mk_pict_saone_reg( a2figdat, bnd=bnd, mycm=mycm, soname=figname, stitle=stitle, miss=miss, a2shade=a2shade, cbarname=cbarname, lllat=lllat, lllon=lllon, urlat=urlat,