-
VEc       sJ     d  k  Z   d  k Z  d  k Z  d  k Z  d  k Z  d  k Z  d  k Z 	 d  k Z  e i Z  d   Z	  d   Z
 " d   Z & d   Z * d   Z H d   Z ] d   Z r d e e e e e d	 d
  Z  d d  Z  d d d  Z 3d   Z <e d  Z Fe d  Z We d  Z cd   Z od   Z d   Z d Z d Z e e d  Z e d  Z e d  Z 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( <d) e  d* <d+ e  d, <d- e  d. <d/ e  d0 <d1 e  d2 <d3 e  d4 <d5 e  d6 <d7 e  d8 <d9 e  d: <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( <d) e! d* <d< e! d, <d= e! d. <d> e! d0 <d? e! d2 <d@ e! d4 <dA e! d6 <dB e! d8 <dC e! d: <dD dE dF dG dH dI dJ g Z" e dK  Z# 9e dL  Z$ Be dM  Z% Kd  k& Z Me i' dN Z( Ne( dO Z) Pe i* i* e) dP  Z+ RdQ   Z, ZdR   Z- ^dS   Z. adT   Z/ d  S(U   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      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   " # 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  * 1 2 y1 3 |  \ } } 4 | \ } } 5 | \ } } Wn 6 7 d Sn X9 | | j o : d Sn ; | | j o < d Sn = | | j o > d Sn ? | | j o @ d Sn B | | j o$ | | j o | | j o
 | | j o C d Sn E d Sd S(   sJ  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   H M Q |  d } R | d } U | | j  o V d Sn# W | | j o X d Sn Z 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   sortByIssueTimeH s   c    s   ] ^ a d } c t i d } f | d } h d } i | | 7} j | d |  | f 7} k | d 7} m t i i	 | d  o n d } n p | 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  r   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(   se  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   getValidFileListr 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:

       Config.{ConfigSet}.{Product}.{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   	
 		i   c    s(   t  |  d j ot i   } | d }
 |
 d } | | } | | } #| o
 | | j  o $t i d |  | f  )| oq *xg | D*]\ }
 +|
 d }	 ,d |	 t  |	  d  } -t i d |	 f  .t i d | f  q Wn /g  } n n 0| Sd S(   sK  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:

       Config.{ConfigSet}.{Product}.{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   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$   	

 	c    sp   34| t j o
 | d j o 5d | f Sn< 6|  t j o
 |  d j o 7d |  f Sn 9t t f Sd  S(   NiP   s
   HEAT INDEXi(   s
   WIND CHILL(   s	   heatIndexs   Nones	   windChill(   s	   windChills	   heatIndex(    (    s   dataUtil.pys   formatApparentTemp3s
   c    sq   <=xB | D=]7 \ } } } >|  | j o
 |  | j o ?| Sn q WA| t j o Bd Sn C| 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   FGd d d f d d d f d d d	 f d
 d d f d d d f g } Ot |  | |  } Q|  d j o Rd }  n T|  | 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   formatUVIndexFs
   Ec    sk   WX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   formatAirQualityCategoryWs   Qc    sZ   cdh  d d <d d <d d <d d <d	 d
 <d d <} l| 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   formatPrimaryPollutantcs   ?c    s  op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- <} | i |   o | |  } n
 t } | 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   formatTrafficTypeos    .	c    s?   d d f d d f d d f d d f f } | |  Sd  S(   Ns   HIGH IMPACTs   /rsrc/images/highImpactObjs   MEDIUM IMPACTs   /rsrc/images/medImpactObjs
   LOW IMPACT(   s   impacts   crit(   s   crits   impact(    (    s   dataUtil.pys   formatTrafficImpact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 | |  } t |  d j o> t |   d j o t i d |  f  n | } nN t |   d j o$ t i d | f  d } n d | |  f } Wn' t i d | |  f  n X| Sd  S(   Ns    i    s6   formatWindText error windSpeed = %d while windDir == 0s5   formatWindText error windSpeed = 0 while windDir = %ss   Calms   %s %ds;   formatWindText caught exception windDir = %s windSpeed = %s(	   s   windTexts   formatWindDirections   windDirs   langs   windDirections   ints	   windSpeeds   Logs   warning(   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 d d f Sn d d f Sd  S(   Ni   s   /rsrc/images/arrowUpi   s   /rsrc/images/arrowDowni    s   Es   S(   s   pts   langs   SPANISH(   s   pts   lang(    (    s   dataUtil.pys   formatPressureTendencys   s   Calms   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   Vari   s   Calmas   SSOs   SOs   OSOs   Os   ONOs   NOs   NNOs   VARs   Mondays   Tuesdays	   Wednesdays   Thursdays   Fridays   Saturdays   Sundayc  )  s  d d d f d d d f d d d	 f d
 d d f d d d f d d d f d d d f d d d f d d d f d d d f d d  d! f d" d# d$ f d% d& d' f d( d) d* f d+ d, d- f d. d/ d0 f d1 d2 d3 f d4 d5 d6 f d7 d8 d9 f d: d; d< f d= d> d? f d@ dA dB f dC dD dE f dF dG dH f dI dJ dK f dL dM dN f dO dP dQ f dR dS dT f dU dV dW f dX dY dZ f d[ d\ d] f d^ d_ d` f da db dc f dd de df f dg dh di f dj dk dl f dm dn do f dp dq dr f ds dt du f g' } 6t |  | |  Sd  S(v   Ni9is
   WELL_BELOWiis   BELOWi    i	   s   SINGLEi
   i   s   L10Si   i   s   M10Si   i   s   H10Si   i   s   L20Si   i   s   M20Si   i   s   H20Si   i!   s   L30Si"   i$   s   M30Si%   i'   s   H30Si(   i+   s   L40Si,   i.   s   M40Si/   i1   s   H40Si2   i5   s   L50Si6   i8   s   M50Si9   i;   s   H50Si<   i?   s   L60Si@   iB   s   M60SiC   iE   s   H60SiF   iI   s   L70SiJ   iL   s   M70SiM   iO   s   H70SiP   iS   s   L80SiT   iV   s   M80SiW   iY   s   H80SiZ   i]   s   L90Si^   i`   s   M90Sia   ic   s   H90Sid   ig   s   L100Sih   ij   s   M100Sik   im   s   H100Sin   iq   s   L110Sir   it   s   M110Siu   iw   s   H110Six   i{   s   L120Si|   i   s   120Si   i   s   130S(   s   rangess   formatValues   temperatures   default(   s   temperatures   defaults   ranges(    (    s   dataUtil.pys   getVocalExtFcstTempRanges    )c    sG   9:d d d f d d d f d d d	 f g } ?t |  | |  Sd  S(
   Ni9iE   s   mildiF   iT   s   warmiU   i   s   hot(   s   rangess   formatValues   temperatures   default(   s   temperatures   defaults   ranges(    (    s   dataUtil.pys   formatHighTempDesc9s   -c    sG   BCd d d f d d d f d d d	 f g } Ht |  | |  Sd  S(
   Ni9i'   s   coldi(   iE   s   cooliF   i   s   mild(   s   rangess   formatValues   temperatures   default(   s   temperatures   defaults   ranges(    (    s   dataUtil.pys   formatLowTempDescBs   -s
   TWCPERSDIRs   /plugin/misc/bucketss   bucketsc    sV   RSt  i |  } T| i |   } Uy Vt t |  SWn WXt	 Sn Xd  S(   N(
   s   _pmSkyGroupings   retrievePlugins   locales   plugins   getSkyCondGroupings   skyConds   groupings   applys   _makeSCGs   None(   s   skyConds   locales   plugins   grouping(    (    s   dataUtil.pys   getSkyCondGroupingRs   c    s   Z[t  |  d  Sd  S(   Ns   Observation(   s   getSkyCondGroupings   skyCond(   s   skyCond(    (    s   dataUtil.pys   getObsSkyCondGroupingZs   c    s   ^_t  |  d  Sd  S(   Ns   Forecast(   s   getSkyCondGroupings   skyCond(   s   skyCond(    (    s   dataUtil.pys   getFcstSkyCondGrouping^s   c    sk   abt  i d |  d | dd | d | ed | d | fd | d | gd	 | d
 |	 hd |
 d |  Sd  S(   Ns   widespreadRains   scatteredRains   widespreadSnows   scatteredSnows   ices   windys   cloudys   partlyCloudys   clears   thunders   fogs   severe(   s	   twccommons   Datas   wrs   srs   wss   sss   is   ws   cs   pcs   cls   ts   fs   sv(   s   wrs   srs   wss   sss   is   ws   cs   pcs   cls   ts   fs   sv(    (    s   dataUtil.pys   _makeSCGas   (0   s   globs   oss   os.paths   strings   times   twcs	   twccommons   twccommon.Logs   Logs	   findfirsts   removeCharss   secondsToFramess   formatDayOfWeeks   isPointInsideBoxs   sortByIssueTimes   isMapAvailables   Nones   getValidFileLists   getValidImageLists   checkImageListForGapss   formatApparentTemps   formatValues   formatUVIndexs   formatAirQualityCategorys   formatPrimaryPollutants   formatTrafficTypes   formatTrafficImpacts   ENGLISHs   SPANISHs   formatWindDirections   formatWindTexts   formatPressureTendencys   _windDirectionTables   _windDirectionTableSpanishs   _weeks   getVocalExtFcstTempRanges   formatHighTempDescs   formatLowTempDescs   twccommon.PluginManagers   environs
   TWCPERSDIRs   plugInGroupingRoots   PluginManagers   _pmSkyGroupings   getSkyCondGroupings   getObsSkyCondGroupings   getFcstSkyCondGroupings   _makeSCG(*   s   Logs   formatTrafficTypes	   twccommons   formatApparentTemps   getValidFileLists   _makeSCGs   formatWindTexts   formatTrafficImpacts   ENGLISHs   _pmSkyGroupings   _windDirectionTableSpanishs   getVocalExtFcstTempRanges	   findfirsts   isPointInsideBoxs   sortByIssueTimes   _weeks   formatHighTempDescs   SPANISHs   formatPressureTendencys
   TWCPERSDIRs   formatPrimaryPollutants   formatDayOfWeeks   strings   twcs   globs   times   formatWindDirections   getSkyCondGroupings   secondsToFramess   isMapAvailables   formatAirQualityCategorys   getObsSkyCondGroupings   removeCharss   checkImageListForGapss   formatLowTempDescs   getValidImageLists   getFcstSkyCondGroupings   formatValues   plugInGroupingRoots   formatUVIndexs   _windDirectionTables   os(    (    s   dataUtil.pys   ? s   		!W64	
5				-		