Ejemplo n.º 1
0
def mk_dtcloc(year,mon):
  da1       = {}
  lstype  = ["dura","pgrad","nowpos","nextpos","time","iedist","rvort","dtlow","dtmid","dtup","initsst","initland"]
  for stype in lstype:
     da1[stype]  = cy.load_clist(stype, year, mon)

  #**** make dictionary ***
  stepflag = 0
  dtcloc   = {}
  nlist    = len(da1["dura"])
  for i in range(nlist):
    dura        = da1["dura"    ][i]
    pgrad       = da1["pgrad"   ][i]
    nowpos      = da1["nowpos"  ][i]
    time        = da1["time"    ][i]
    iedist      = da1["iedist"  ][i]
    rvort       = abs(da1["rvort"   ][i])
    dtlow       = da1["dtlow"   ][i]
    dtmid       = da1["dtmid"   ][i]
    dtup        = da1["dtup"    ][i]
    initsst     = da1["initsst" ][i]
    initland    = da1["initland"][i]
    nextpos     = da1["nextpos" ][i]
    #---- check time ----
    ### This section should be prior to the condition filtering

    if (i == nlist-1):
      stepflag = 1
    else:
      timenext    = da1["time"][i+1]
      if (timenext != time):
        stepflag = 1

    #---- dura -------
    if dura < thdura:
      print "dura",dura,"<",thdura
      continue
    #---- thpgrad ----
    if pgrad < thpgrad:
      print "pgrad",pgrad,"<",thpgrad
      continue

    #---- thrvort ----
    if rvort < thrvort:
      print "rvort",rvort,"<",thrvort
      continue

    #---- thwcore ----
    if dtup + dtmid + dtlow < thwcore:
      print "thwcore",dtup+dtmid+dtlow,"<",thwcore
      continue

    #---- initsst ----
    if initsst < thinitsst:
      print "initsst",initsst,"<",thinitsst
      continue 

    #---- initland ----
    if initland > 0.0:
      print "initland",initland,">",0.0
      continue 


#    #---- iedist -----
#    if iedist < dura*unitdist:
#      print "iedist",iedist,"<",dura*unitdist
#      continue

    #---- time ------
    yeart,mont,dayt,hourt = detect_func.solve_time(time)

    #---- location --
    ix, iy            = detect_func.fortpos2pyxy( nowpos, nx, -9999)



    #---- dictionary --
    if dtcloc.has_key((dayt,hourt)):
      dtcloc[dayt,hourt].append([ix,iy,nextpos])
    else:
      dtcloc[dayt,hourt] = [[ix,iy, nextpos]]
  #------------------
  return dtcloc
Ejemplo n.º 2
0
     for day in range(iday, eday+1):
       print "tracklines",model,year, mon, day
       for hour in [0, 6, 12, 18]:
         #---------------------------
         DTime  = datetime(year,mon,day,hour)
 
         #-- check exc existence ----
         if not dtcloc.has_key((day,hour)):
           continue
         #---------------------------
         ldat    = dtcloc[day,hour]
         for locdat in ldat:
           ix,iy,nextpos = locdat
     
           #-- nextpos ------------
           x_next, y_next = detect_func.fortpos2pyxy(nextpos, nx, miss_int)
     
           if ( (x_next == miss_int) & (y_next == miss_int) ):
             continue            
           #-----------------------
           lat       = a1lat[iy]
           lon       = a1lon[ix]
     
           lat_next  = a1lat[y_next]
           lon_next  = a1lon[x_next]
           #
           ltrack.append([[year, mon, day, hour],[lat, lon, lat_next, lon_next]])
     
     
 ##*************\***********
 # Basemap