Example #1
0
def save_clist(var, a1dat, Year, Mon):
    clistDir, clistPath = cy.path_clist(var, Year, Mon)
    detect_func.mk_dir(clistDir)
    dNumType = cy.dNumType

    array(a1dat, dtype=dNumType[var]).tofile(clistPath)
    print clistPath
Example #2
0
def save_clist(var, a1dat, Year, Mon):
  clistDir, clistPath = cyclone.path_clist(var, Year, Mon)
  detect_func.mk_dir(clistDir)
  dNumType            = cyclone.dNumType

  array(a1dat, dtype=dNumType[var]).tofile(clistPath)  
  print clistPath
Example #3
0
def save_csv(var, ldat):
  """
  var: rvort, dt, wmeanlow, wmeanup
  """
  ldat   = sort(ldat)
  lendat = len(ldat)

  dunit  = {"rvort":"s-1",
            "dt"   :"K",
            "wLow_Up":"m/s"
           }

  sout = "frac/%s(%s),%s\n"%(model,var,dunit[var])
  for i,dat in enumerate(ldat):
    frac = (i+1)/float(lendat)
    sout = sout + "%f,%f\n"%(frac,dat)

  #
  odir   = "/media/disk2/out/obj.valid/tc.%s/%s"%(var, region)
  detect_func.mk_dir(odir)
  oname  = odir + "/%s.%s.%04d-%04d.%s.csv"%(var,model,iYear,eYear,region)

  f = open(oname,"w");  f.write(sout);  f.close()
  print oname
Example #4
0
res    = "bn"
#tctype = "obj"
tctype = "bst"
radkm  = 1000.

for Year in lYear:
  for Mon in lMon:
    #--- init ----
    Cy   = Cyclone.Cyclone_2D(Year,Mon,model=model, res=res, tctype=tctype)
    #-------------
    iDay = 1
    eDay = calendar.monthrange(Year,Mon)[1]
    for Day,Hour in [[Day,Hour] for Day in range(iDay, eDay+1) for Hour in lHour]:
      DTime = datetime(Year,Mon,Day,Hour)
            
      a2exc = Cy.mkMask_exc(DTime, radkm=radkm) 
      a2tc  = Cy.mkMask_tc (DTime, radkm=radkm)

      oDir_exc, oPath_exc = Cy.path_Mask_exc(DTime)
      oDir_tc,  oPath_tc  = Cy.path_Mask_tc (DTime)

      detect_func.mk_dir(oDir_exc)
      detect_func.mk_dir(oDir_tc )

      a2exc.tofile(oPath_exc)
      a2tc .tofile(oPath_tc)
      print oPath_exc



Example #5
0
  #eDTime = datetime(2014,1,5,0)
  eDTime = datetime(Year,12,31,0)
  dDTime = timedelta(hours=24)
  lDTime = ret_lDTime(iDTime, eDTime, dDTime)
  nDay   = len(lDTime)
  a3dat  = zeros([nDay, ny, nx], float32)
  
  for i,DTime in enumerate(lDTime):
    #a2in  = ra.time_ave(var, DTime, DTime+timedelta(hours=23), timedelta(hours=6),lev=lev)
    a2in   = ret_a2var(var, lev=lev)
    a3dat[i] = a2in
  #
  a2max = a3dat.max(axis=0)
  a2min = a3dat.min(axis=0)

  #odir_root = "/".join(ra.path_6hr(var, iDTime, lev).srcDir.split("/")[:-2])
  odir_root = "/tank/utsumi/out/JRA55/bn/6hr"
  Maxdir    = odir_root + "/ms.max/%s"%(var)
  Mindir    = odir_root + "/ms.min/%s"%(var)
  MaxPath   = Maxdir + "/max.%s.%s.%04d.bn"%(dstype[var],var,Year)
  MinPath   = Mindir + "/min.%s.%s.%04d.bn"%(dstype[var],var,Year)

  detect_func.mk_dir(Maxdir)
  detect_func.mk_dir(Mindir) 
  a2max.astype(float32).tofile(MaxPath)
  a2min.astype(float32).tofile(MinPath)
  print MaxPath
  
  
    
Example #6
0
#eYear  = 2010
eYear  = 2015
lYear  = range(iYear, eYear+1)
lMon   = range(1,12+1)
lHour  = [0,6,12,18]
#lHour  = [0]

F  = Front.Front(model=model, res=res)

for Year in lYear:
  for Mon in lMon:
    iDay  = 1
    eDay  = calendar.monthrange(Year, Mon)[1]
    for Day, Hour in [[Day,Hour] for Day in range(iDay, eDay+1) for Hour in lHour]:
      DTime    = datetime(Year,Mon,Day,Hour)
      oDir_t, oPath_t = F.path_finloc(DTime, tq="t")
      oDir_q, oPath_q = F.path_finloc(DTime, tq="q")

      loc_t  = F.mk_tfront(DTime)
      loc_q  = F.mk_qfront(DTime)

      detect_func.mk_dir(oDir_t)
      detect_func.mk_dir(oDir_q)

      loc_t.tofile(oPath_t)
      loc_q.tofile(oPath_q)
      print oPath_t



Example #7
0
  return a2loc1, a2loc2

#******************************************************
##-- orog & grad orog ----

a2orog  = ra.load_const(var="topo").Data

#******************************************************
for year in lyear:
  for mon in lmon:
    eday  = calendar.monthrange(year,mon)[1]
    for tq in ltq:
      var = dvar[tq]
      #-----------
      for day in range(iday, eday+1):
        for hour in lhour:
          DTime   = datetime.datetime(year,mon,day,hour)
          ##******************************************************
          a2thermo  = ra.load_6hr(var, DTime, plev).Data
          a2loc1,a2loc2  = mk_front_loc_contour(a2thermo, a1lon, a1lat, miss)
          sodir, soname1, soname2   = front.path_potloc(DTime, tq)
          detect_func.mk_dir(sodir)
          #------
          a2loc1.tofile(soname1)
          a2loc2.tofile(soname2)
          print soname1
          print soname2
  
 
    da1["lon"].extend(a1lon_tmp)
    da1["ipos"].extend(a1ipos_tmp)
    da1["epos"].extend(a1epos_tmp)
    da1["idate"].extend(a1idate_tmp)
    da1["nowpos"].extend(a1nowpos_tmp)
    da1["time"].extend(a1time_tmp)
    da1["prepos"].extend(a1prepos_tmp)
    da1["nextpos"].extend(a1nextpos_tmp)

    if ((DTime == lDTime[-1]) or (DTime.month != lDTime[idt + 1].month)):
        ##---- iedist ------------------------
        da1["iedist"] = ret_a1iedist(da1["ipos"], da1["epos"])

        #----- make dir ----
        sodir = cy.path_clist("ipos", year, mon)[0]
        detect_func.mk_dir(sodir)

        #---- save --
        _lstype = lstype_ex + ["iedist"]
        #_lstype = lstype_ex

        for stype in _lstype:
            soname = cy.path_clist(stype, year, mon)[1]

            if stype in [
                    "dura", "ipos", "epos", "idate", "nowpos", "time",
                    "prepos", "nextpos"
            ]:
                a1out = array(da1[stype], int32)
            else:
                a1out = array(da1[stype], float32)