-
2Fc       s     d  k  Z   d  k Z  d  k Z  d  k Z  d  k Z  d  k Z  d  k Z 	 d  k Z  d   Z  d   Z	  d   Z
  d   Z ( d   Z F d   Z [ d   Z q d e e e e e d	 d
  Z  d d  Z  d d  Z 'd d d  Z [d d d d f d  Z d   Z e d  Z e d  Z e d  Z e d  Z d   Z e d  Z e d  Z d   Z d Z d Z e e d  Z  e d  Z! *e d  Z" 4d   Z# jd   Z$ yh  Z% zd  e% d <{d! e% d <|d" e% d# <}d$ e% d% <~d& e% d' <d( e% d) <d* e% d+ <d, e% d- <d. e% d/ <d0 e% d1 <d2 e% d3 <d4 e% d5 <d6 e% d7 <d8 e% d9 <d: e% d; <d< e% d= <d> e% d? <d@ e% dA <h  Z& d  e& d <d! e& d <d" e& d# <d$ e& d% <d& e& d' <d( e& d) <d* e& d+ <d, e& d- <d. e& d/ <d0 e& d1 <dB e& d3 <dC e& d5 <dD e& d7 <dE e& d9 <dF e& d; <dG e& d= <dH e& d? <d@ e& dA <dI dJ dK dL dM dN dO g Z' d  S(P   Nc    sY      d }  x9 |  D ]. }  | | j o  | Sn  | d } q W d Sd S(   s.   find first of any char that is in s in charseti    i   iN(   s   indexs   ss   cs   charset(   s   ss   charsets   indexs   c(    (    s   dataUtil.pys	   findfirst s   	
 	c    s     d |  Sd  S(   Ni   (   s   frames(   s   frames(    (    s   dataUtil.pys   secondsToFrames s   c    s     t  |  d Sd  S(   Ni   (   s   _weeks   dow(   s   dow(    (    s   dataUtil.pys   formatDayOfWeek s   c    s      ! xo | D! ]d } " t i |  |  } # xC # | d j o2 $ |  |  |  | d }  % t i |  |  } q4 Wq W& |  Sd S(   s'   remove all characters in charset from sii   N(   s   charsets   cs   strings   finds   ss   n(   s   ss   charsets   cs   n(    (    s   dataUtil.pys   removeChars s   
 	 c 	   s  ( / 0 y1 1 |  \ } } 2 | \ } } 3 | \ } } Wn 4 5 d Sn X7 | | j o 8 d Sn 9 | | j o : d Sn ; | | j o < d Sn = | | j o > d Sn @ | | j o$ | | j o | | j o
 | | j o A d Sn C d Sd S(   sQ  Determine if the point (x,y) is inside the bounding box
       defined by a lower left corner 'lowerLeftBBox' (llx, lly)
       and an upper right corner 'upperRightBBox' (urx, ury).
       
       Returns: -1 error answer cannot be determined - bad args?
                 1 point is inside box
                 0 point is not inside boxii   i    N(	   s   xyPoints   xs   ys   lowerLeftBBoxs   llxs   llys   upperRightBBoxs   urxs   ury(	   s   xyPoints   lowerLeftBBoxs   upperRightBBoxs   llys   llxs   xs   ys   urxs   ury(    (    s   dataUtil.pys   isPointInsideBox( s$   7c    sa   F K O |  d } P | d } S | | j  o T d Sn# U | | j o V d Sn X d Sd S(   sk   Sort Image Files by issue time.

       Assumes items are in the format:
           (time_t, filename)
    i    i   iN(   s   lhss   ltimes   rhss   rtime(   s   lhss   rhss   rtimes   ltime(    (    s   dataUtil.pys   sortByIssueTimeF s   c    s   [ \ _ d } a t i d } d | d } f d } g | | 7} h | d |  | f 7} i | d 7} k t i i	 | d  o l d } n n | Sd	 S(
   s@   Is the map cut for a given map product created and ready to use?i   s
   TWCPERSDIRs   /data/map.cuts/s    s   Config.%d.%ss   .maps   .tifi    N(
   s   mapAvailables   oss   environs
   TWCPERSDIRs   mapPaths   mapFiles	   configSets   products   paths   exists(   s	   configSets   products   mapAvailables   mapFiles   mapPaths
   TWCPERSDIR(    (    s   dataUtil.pys   isMapAvailable[ s   		s   ./s   .c    s0  q   g  }  |  }  | o  | | | 7} n  | d 7}  | o  | | | 7} n  t i |  }  t |  d j o  | Sn  t	 i	   }
  xO| D ]D}  t i i |  }  t i | |  }  | t j	 oK  y1  t | |  }  |
 | j o
  w n Wn   q n Xn  | t j	 oK  y1  t | |  }	  |
 |	 j  o
  w n Wn   q n Xn  | o>  y$  | i t | |  | f  Wn   q n Xn  | i d | f  q W | o
 t |  o  | i t  n  | Sd S(   sC  Return a list of matching files.

       Given a list of filenames return the names of the valid images
          and their sort value as a list of tuples: (sortedVal, filename).
       Validation is based on the current system time (compared to numeric parts of the filename which
          represent time_t values) as well as flags in the arg list.

       The filenames generally have the following format: (NOT all fields are required)
          {dataPath}{prefix}{sep}{start_time_t}{sep}{end_time_t}{sep}{suffix}
          where {prefix} is an optional part of the filename which precedes the timestamps
          where {suffix} is an optional part of the filename which follows the timestamps

       Set startTimeNdx to the position of the startTime field (use a negative number to count from the end)
          if you want to ignore files intended to be used in the future.
       Set endTimeNdx to the position of the endTime field if you want to ignore files which are expired.
       Set sortIndex (usually equal to startTimeNdx or endTimeNdx) to cause the list to be sorted.
    s   *[0-9]i    N(   s
   returnLists   dataPaths	   imageDatas   prefixs   seps   suffixs   globs	   imageLists   lens   times   nows   filenames   oss   paths   basenames   filebases   strings   splits	   filePartss
   endTimeNdxs   Nones   longs   endTimes   startTimeNdxs	   startTimes	   sortIndexs   appends   sorts   sortByIssueTime(   s   dataPaths   prefixs   suffixs   startTimeNdxs
   endTimeNdxs	   sortIndexs   seps   filebases	   imageDatas	   startTimes   nows
   returnLists   filenames	   filePartss	   imageLists   endTime(    (    s   dataUtil.pys   getValidFileListq sN   		


 	
$i    c    sW     g  }  |  | d }  t i |  }
  t |
  d j o  | Sn  t i   }  x |
 D ] }	  t
 i i |	  }  t i | d  }  y*  t | d  }  t | d  } Wn   d }  d } n X | d j o  | | j o
  ql n n  | |	 f }  | i |  ql W | i t   | Sd S(   s  Return a list of valid image files sorted by issue time.

       Given a list of image filenames return the names of the valid images
       and their issue times as a list of tuples: (issueTime, filename).

       A valid image is one that has an issue time between now and N seconds
       ago - where N is the expirationTime in seconds. The input imageList must
       have filenames in the following format:

       {Pkg}.{PkgInst}.{Prod}.{ProdInst}.{issue_time_t}.{expiration_time_t}.tif
    s   .*[0-9].tifi    s   .i   i   i   N(   s
   sortedLists   dataPaths   productStrings	   imageDatas   globs	   imageLists   lens   times   nows   filenames   oss   paths   basenames   filebases   strings   splits	   filePartss   longs	   issueTimes   expirationTimes   ignoreExpirations   datas   appends   sorts   sortByIssueTime(   s   dataPaths   productStrings   ignoreExpirations   datas	   issueTimes	   filePartss	   imageDatas   filebases
   sortedLists   filenames	   imageLists   nows   expirationTime(    (    s   dataUtil.pys   getValidImageList s0   	
 		c    sw     |  d | d }
 t i |
  } t |  d j o t Sn t i   } g  } x | D] } t i i |  } t i | d  } y t | d  } Wn d } n X| d j o | | j o
 qp n n | | f } | i |  qp Wt |  d j o t Sn !| i t  #| d \ } }	 $|	 d  Sd S(   s   Return the latest(highest expiration time_t) movie that 
       matches and has not expired.

       The movies have filenames in the following format:

       {issue_time_t}.{expiration_time_t}.{region}.mpg
    s   /*.s   .mpgi    s   .i   iN(   s   dataPaths   regions	   movieDatas   globs	   movieLists   lens   Nones   times   nows
   sortedLists   filenames   oss   paths   basenames   filebases   strings   splits	   filePartss   longs   expirationTimes   ignoreExpirations   datas   appends   sorts   sortByIssueTimes   expTimes   movie(   s   dataPaths   regions   ignoreExpirations   filebases	   filePartss
   sortedLists   nows   datas	   movieLists   movies	   movieDatas   filenames   expirationTimes   expTime(    (    s   dataUtil.pys   getValidMovie s2   	
 	i   c    s+  '0<t  |  d j o>t i   } ?| d }
 B|
 d } E| | } F| | } K| o
 | | j  o Lt i i d |  | f  Q| oz Rxg | DR]\ }
 S|
 d }	 Td |	 t  |	  d  } Ut i d |	 f  Vt i d | f  q WWg  } n n n X| Sd S(   sP  Given a list of images in chronological order, check for time gaps.

       Checks a list of chronological images for gaps based on the
       expected image frequency. The image list must be in the format
       (issueTime, filename). And the fileinames must have the format:

       {Pkg}.{PkgInst}.{Prod}.{ProdInst}.{time_t}.tif
    i    sM   Time gap found in %s. No images in last %d seconds! Resetting animation loop!i   s   %s.data.statsi   s   rm %sN(   s   lens	   imageLists   times   nows   files	   issueTimes   maxGaps   imageFrequencys   gapDurations   maxAllowedGaps   ignoreTimeGapss	   twccommons   Logs   warnings   products   purgeImagesOnGaps	   imageNames	   statsNames   oss   system(   s   products	   imageLists   imageFrequencys   maxGaps   ignoreTimeGapss   purgeImagesOnGaps   maxAllowedGaps	   statsNames   gapDurations	   imageNames   files   nows	   issueTime(    (    s   dataUtil.pys   checkImageListForGaps's$   	

 	f0.92000000000000004c 	   s]  [ag  } bg  } d|  d j o6 ed } f| | | f } g| i |  h| Sni|  d j o6 jd } k| | | f } l| i |  m| Snn|  d j  oe od |  } p| | | f } q| i |  rd } s| | | f } t| i |  u| SnDw|  d } x|  d } y| d j o^ zd | } {| | | f } || i |  }d } ~| | | f } | i |  n d | } | | | f } | i |  d } | | | f } | i |  d	 | } | | | f } | i |  d } | | | f } | i |  | Sd  S(
   Ni  s   Closedi    s   No Delayi<   s   %ds    mins    hrs    %d(
   s   strDatas   strLists   delays   strs   textFonts   colors   appends   numFonts   hrs   min(	   s   delays   numFonts   textFonts   colors   strs   mins   strLists   strDatas   hr(    (    s   dataUtil.pys   formatAirportDelay[sT   								c    sy   | t j o
 | d j o d d | f SnB |  t j o
 |  d j o d d |  f Sn d d d f Sd  S(	   NiP   i   s
   Heat Indexi(   i   s
   Wind Chilli    s    (   s	   heatIndexs   Nones	   windChill(   s	   windChills	   heatIndex(    (    s   dataUtil.pys   formatApparentTemps
   c    sq   xB | D]7 \ } } } |  | j o
 |  | j o | Sn q W| t j o d Sn | Sd  S(   Ns	   No Report(   s	   rangeLists   mins   maxs
   displayStrs   vals   defaults   None(   s   vals	   rangeLists   defaults
   displayStrs   mins   max(    (    s   dataUtil.pys   formatValues   
 c    s   d d d f d d d f d d d	 f d
 d d f d d d f g } t |  | |  } |  d j o d }  n |  | f Sd  S(   Ni    i   s   Lowi   i   s   Moderatei   i   s   Highi   i
   s	   Very Highi   i   s   Extremes   10+(   s   rangess   formatValues   uvIndexs   defaults   phrase(   s   uvIndexs   defaults   rangess   phrase(    (    s   dataUtil.pys   formatUVIndexs
   Ec    s_   d d d f d d d f d d d	 f d
 d d f d d d f g } t |  | |  Sd  S(   Ni   i   s   Minimali   i   s   Lowi   i   s   Moderatei   i   s   Highi	   i
   s	   Very High(   s   rangess   formatValues   achesPainsIndexs   default(   s   achesPainsIndexs   defaults   ranges(    (    s   dataUtil.pys   formatAchesPainsIndexs   Ec    sk   d d d f d d d f d d d f d d d f d	 d	 d
 f d d d f g } t |  | |  Sd  S(   Ni    s   Goodi   s   Moderatei   s   Unhealthy for sensitive groupsi   s	   Unhealthyi   s   Very Unhealthyi   s   Extreme(   s   rangess   formatValues   vals   default(   s   vals   defaults   ranges(    (    s   dataUtil.pys   formatAirQualityCategorys   Qc    sZ   h  d d <d d <d d <d d <d	 d
 <d d <} | t i |   Sd  S(   Ns   Ozones   OZONEs   Coarse Particulatess   PM10s   Fine Particulatess   PM2.5s   Carbon Monoxides   COs   Nitrogen Dioxides   NO2s   Sulfur Dioxides   SO2(   s	   pollutants   strings   uppers   primaryPollutant(   s   primaryPollutants	   pollutant(    (    s   dataUtil.pys   formatPrimaryPollutants   ?c    s_   d d d f d d d f d d d f d d d f d	 d	 d
 f g } t |  | |  Sd  S(   Ni    s   Nonei   s   Lowi   s   Moderatei   s   Highi   s	   Very High(   s   rangess   formatValues   pollenIndexs   default(   s   pollenIndexs   defaults   ranges(    (    s   dataUtil.pys   formatPollenIndexs   Ec    s_   d d d f d d d f d d d	 f d
 d d f d d d f g } t |  | |  Sd  S(   Ni   i   s	   Very Poori   i   s   Poori   i   s   Fairi   i   s   Goodi	   i
   s	   Very Good(   s   rangess   formatValues   respiratoryIndexs   default(   s   respiratoryIndexs   defaults   ranges(    (    s   dataUtil.pys   formatRespiratoryIndexs   Ec    s  h  d d <d d <d d <d d <d	 d
 <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d  <d! d" <d# d$ <d% d& <d' d( <d) d* <d+ d, <d- d. <d/ d0 <d1 d2 <d3 d4 <} | |  Sd  S(5   Ns   Alders   As   Aspens   Bs   Cedars   Ds
   Cottonwoods   Es   Cypresss   Fs   Dogwoods   Gs   Elms   Hs   Firs   Is   Junipers   Js   Maples   Ks   Oaks   Ls   Olives   Ms   Pines   Os   Poplars   Qs   Redwoods   Rs   Sweetgums   Ss   Sycamores   Ts   Plums   Us   Mulberrys   Vs   Beechs   Ws   Pecans   Xs   Unknowns   Zs   Ashs   AAs   Birchs   BBs   Hickorys   HHs   Willows   WW(   s	   treeTypess   treeCode(   s   treeCodes	   treeTypes(    (    s   dataUtil.pys   formatTreeSpeciess   c    s1   | t j o t |  Sn t |  Sd  S(   N(   s   langs   SPANISHs   _windDirectionTableSpanishs   windDirs   _windDirectionTable(   s   windDirs   langs   default(    (    s   dataUtil.pys   formatWindDirections   c    s   d } y} t | |  } |  d j o
 | t j o d } n> |  d j o
 | t j o  d } n "d | |  f } Wn %&n X(| Sd  S(   Ns    i    s   Calms   Calmas   %s %d(   s   windTexts   formatWindDirections   windDirs   langs   windDirections	   windSpeeds   ENGLISHs   SPANISH(   s	   windSpeeds   windDirs   langs   windTexts   windDirection(    (    s   dataUtil.pys   formatWindTexts   	c    s   *+|  d j o ,d d f Sn] -|  d j o .d d f Sn< /|  d j o
 | t j o 0d d f Sn 2d d f Sd  S(   Ni   s   /rsrc/images/up_arrowi   s   /rsrc/images/down_arrowi    s   Es   S(   s   pts   langs   SPANISH(   s   pts   lang(    (    s   dataUtil.pys   formatPressureTendency*s   c    s  45h  d d <d d <d d <d d <d d <d d <d d <d d	 <d d
 <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d <d d  <d d! <d d" <d d# <d d$ <d d% <d d& <d d' <d d( <d d) <d d* <d+ d, <d+ d- <} c| i |   o d| |  } n
 ft } g| Sd  S(.   Ns   Incidents   ACCs   ACC?s   ACC>Ss   ACCLRs   ACCSs   BFIRs   BFIR?s   CRFRs   CRFR?s   DBUSs   DBUS?s   DTRKs   DTRK?s   DTTs   DTT?s   DVEHs   DVEH?s   JTTs   JTT?s   MCACCs   MVACCs   MVACC?s   OCARs   OCAR?s   OTRKs   OTRK?s   OTTs   OTT?s   OVEHs   OVEH?s   SPILLs   SPILL?s   STTs   STT?s   TRKFRs   TRKFR?s   TTACCs   TTFRs   TTFR?s   VFRs   VFR?s   Constructions   CONSTs   CONST?(   s   trafficGroups   has_keys   trafficTypes   types   None(   s   trafficTypes   types   trafficGroup(    (    s   dataUtil.pys   formatTrafficType4s    .	c    s?   jqd d f d d f d d f d d f f } v| |  Sd  S(   Ns   HIGH IMPACTs   /rsrc/images/highImpactObjs   MEDIUM IMPACTs   /rsrc/images/medImpactObjs
   LOW IMPACT(   s   impacts   crit(   s   crits   impact(    (    s   dataUtil.pys   formatTrafficImpactjs   -s   Lights   Ns   NNEi   s   NEi   s   ENEi   s   Ei   s   ESEi   s   SEi   s   SSEi   s   Si	   s   SSWi
   s   SWi   s   WSWi   s   Wi   s   WNWi   s   NWi   s   NNWi   s   Variablei   s   SSOs   SOs   OSOs   Os   ONOs   NOs   NNOs   Mondays   Tuesdays	   Wednesdays   Thursdays   Fridays   Saturdays   Sunday((   s   globs   oss   os.paths   strings   times   twcs	   twccommons   twccommon.Logs	   findfirsts   secondsToFramess   formatDayOfWeeks   removeCharss   isPointInsideBoxs   sortByIssueTimes   isMapAvailables   Nones   getValidFileLists   getValidImageLists   getValidMovies   checkImageListForGapss   formatAirportDelays   formatApparentTemps   formatValues   formatUVIndexs   formatAchesPainsIndexs   formatAirQualityCategorys   formatPrimaryPollutants   formatPollenIndexs   formatRespiratoryIndexs   formatTreeSpeciess   ENGLISHs   SPANISHs   formatWindDirections   formatWindTexts   formatPressureTendencys   formatTrafficTypes   formatTrafficImpacts   _windDirectionTables   _windDirectionTableSpanishs   _week(%   s   formatRespiratoryIndexs   strings   formatTrafficTypes   globs   SPANISHs   formatPollenIndexs   formatApparentTemps   _windDirectionTableSpanishs   formatWindDirections   getValidFileLists   formatWindTexts   secondsToFramess   ENGLISHs   formatAirportDelays   formatAirQualityCategorys   removeCharss   formatTreeSpeciess   checkImageListForGapss   twcs   _windDirectionTables   formatTrafficImpacts   getValidMovies   getValidImageLists   formatValues	   findfirsts   isPointInsideBoxs   sortByIssueTimes   _weeks	   twccommons   formatDayOfWeeks   times   formatPressureTendencys   isMapAvailables   formatPrimaryPollutants   formatAchesPainsIndexs   oss   formatUVIndex(    (    s   dataUtil.pys   ? s   		!M8145
 		
6		