for year in lyear:
    for mon in lmon:
      #----------------------------
      print "agg.exist.front.cmip","rad",countrad,year,mon
      #-- load ----------------
      #idir_root  = "/media/disk2/out/CMIP5/sa.one.MIROC5.historical/6hr/front.t/freq"
      idir_root  = "/media/disk2/out/CMIP5/sa.one.%s.%s/6hr/front.t/freq"%(model,expr)
      idir       = idir_root + "/%04d"%(year)
      iname      = idir + "/num.t.front.%s.%s.rad%04dkm.M1_%s_M2_%s.%04d.%02d.sa.one"%(model,ens, countrad, thfmask1t, thfmask2t, year, mon)
      a2count_tmp= fromfile(iname, float32).reshape(ny,nx)
      a2count    = a2count + a2count_tmp

  #****************************
  # write
  #-----------------
  totaltime = cmip_para.ret_totaldays_cmip(iyear,eyear,season,sunit=sunit,scalendar=scalendar) *4.0
  a2freq   = a2count / totaltime
  odir_root= idir_root
  odir     = odir_root + "/%04d-%04d.%s"%(iyear,eyear,season)

  oname    = odir + "/freq.t.front.%s.%s.rad%04dkm.M1_%4.2f_M2_%3.1f.%04d-%04d.%s.sa.one"%(model,ens, countrad, thfmask1t, thfmask2t, iyear,eyear,season)
  #--- write -----
  ctrack_func.mk_dir(odir)
  a2freq.tofile(oname)
  print oname

  #***************
  # figure
  #---------------
  if figflag == True:
    #--- shade       ------
Example #2
0
#***************************************
llkey = [[model,expr] for model in lmodel for expr in lexpr]
for model, expr in llkey:
  #------
  iyear,eyear  = dyrange[expr]
  ens   = cmip_para.ret_ens(model, expr, "psl")
  sunit, scalendar = cmip_para.ret_unit_calendar(model,expr)
  a1dtime,a1tnum   = cmip_func.ret_times(iyear,eyear,lmon,sunit,scalendar,stepday,model=model)
  #--------------------------------
  a2one    = ones([ny,nx],float32)
  a2zero   = zeros([ny,nx],float32)
  #--------------------------------
  for year in range(iyear, eyear+1):
    #-----------------
    for mon in lmon:
      eday = cmip_para.ret_totaldays_cmip(year,year,mon,sunit,scalendar)
      #** init precip ******
      a2pr = a2zero.copy()

      #*********************
      for dtime, tnum in map(None, a1dtime, a1tnum):
        yearloop, monloop, dayloop = dtime.year, dtime.month, dtime.day
        #--- check year and month ---
        if not (yearloop==year)&(monloop==mon):
          continue
        #----------------------------

        print "agg.pr.plain.cmip", model, expr, yearloop,monloop,dayloop


        #-- load prec ---
Example #3
0
  for stype, dectype in [[stype,dectype] for stype in lstype for dectype in ldectype]:

    #** init ******
    a2one    = ones ([ny,nx],float32)
    a2mdpr   = zeros([ny,nx],float32)
    a2nposi  = zeros([ny,nx],float32)
    a2nnega  = zeros([ny,nx],float32)
    totaltimes = 0.0
    #--------------
    for model in lmodel:
      #------
      ens   = cmip_para.ret_ens(model, exprfut, "psl")
      sunit, scalendar = cmip_para.ret_unit_calendar(model,exprfut)
      iyear,eyear  = dyrange[exprfut]

      totaltimes_model = cmip_para.ret_totaldays_cmip(iyear,eyear,season,sunit,scalendar)
      totaltimes       = totaltimes_model

      #------
      #idir  = "/media/disk2/out/CMIP5/sa.one.MIROC5.rcp85/6hr/tagpr/c48h.tc48h/2080-2099.ALL.decomp"\
      idir  = "/media/disk2/out/CMIP5/sa.one.%s.%s/6hr/tagpr/c%02dh.tc%02dh/%04d-%04d.%s.decomp"\
           %(model,exprfut,thdura_c,thdura_tc,iyear,eyear,season)
   
      #iname = idir + "/dpr.c.dNI.MIROC5.rcp85.r1i1p1.tc1000.c1000.f0500.2080-2099.ALL.sa.one"
      iname = idir + "/dpr.%s.%s.%s.%s.%s.tc%04d.c%04d.f%04d.%04d-%04d.%s.sa.one"\
                     %(stype,dectype,model,exprfut,ens,dist_tc,dist_c,dist_f,iyear,eyear,season)
  
      a2dpr   = fromfile(iname, float32).reshape(ny,nx)
      a2mdpr  = a2mdpr + a2dpr

      a2nposi = a2nposi + ma.masked_where( a2dpr <=0.0, a2one).filled(0.0)
Example #4
0
  a2shade  = ma.masked_where( a2orog >=thorog, a2one).filled(miss)
  #----------
  bnd        = [-20,-15,-10,-5,5,10,15,20]
  #----------
  stitle   = "dif. mm/month %s %s %s season:%s %04d-%04d"%(model,exprfut,ens,season,iyear_fut, eyear_fut)
  mycm     = "RdBu"

  datdir_root= "/".join(futdir.split("/")[:-1])
  datdir     = datdir_root + "/%04d-%04d.%s"%(iyear_fut, eyear_fut, season)
  datname    = datdir    + "/dif.pr.%s.%s.%s.%04d-%04d.%s.sa.one"%(model,exprfut,ens,iyear_fut,eyear_fut,season)
  #----
  if region == "GLOB":
    bnd        = [-40,-20,-10,-5,5,10,20,40]
    figdir     = datdir
  if region == "JPN":
    bnd        = [-40,-20,-10,-5,5,10,20,40]
    figdir     = datdir_root + "/%04d-%04d.%s.%s"%(iyear_fut,eyear_fut,season,region)
  #----
  totaltimes   = cmip_para.ret_totaldays_cmip(iyear_fut,eyear_fut,season,sunit,scalendar)
  mons         = len(lyear)*len(lmon)

  a2figdat = fromfile(datname,float32).reshape(ny,nx) *60*60*24.*totaltimes /mons  # (mm/month)
  cbarname   = figdir + "/dif.pr.cbar.png"
  figname    = figdir + "/" + datname.split("/")[-1][:-7] + ".png"
  ctrack_func.mk_dir(figdir)
  #-------------------------------
  ctrack_fig.mk_pict_saone_reg_symm(a2figdat, lllat=lllat, lllon=lllon, urlat=urlat, urlon=urlon, bnd=bnd, mycm=mycm, soname=figname, stitle=stitle, miss=miss, a2shade=a2shade, cbarname=cbarname)
  print figname