Esempio n. 1
0
    def __init__(self, time1, time2=None):
        # these vars are only calculated if requested
        self.__hash = None
        self.__start = None
        self.__end = None
        self.__duration = None

        # Single argument assumes a passed in java timerange
        if time2 == None:
            self.__tr = time1
            return

        # Check to see if abstimes or java classes are passed in
        if isinstance(time1, AbsTime.AbsTime):
            time1_java = time1.javaDate()
            self.__start = time1
        else:
            time1_java = time1

        if isinstance(time2, AbsTime.AbsTime):
            time2_java = time2.javaDate()
            self.__end = time2
        else:
            time2_java = time2
        self.__tr = JavaTimeRange(time1_java, time2_java)
Esempio n. 2
0
    def __init__(self, time1, time2=None):        
        # these vars are only calculated if requested
        self.__hash = None
        self.__start = None
        self.__end = None
        self.__duration = None
        
        # Single argument assumes a passed in java timerange
        if time2 == None:
            self.__tr = time1
            return

        # Check to see if abstimes or java classes are passed in
        if isinstance(time1, AbsTime.AbsTime):
            time1_java = time1.javaDate()
            self.__start = time1
        else:
            time1_java = time1
            
        if isinstance(time2, AbsTime.AbsTime):
            time2_java = time2.javaDate()
            self.__end = time2
        else:
            time2_java = time2
        self.__tr = JavaTimeRange(time1_java, time2_java)
Esempio n. 3
0
    def __convertJavaObjToPyWrapper(self, javaObj):
        objtype = javaObj.java_name
        if objtype == "com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID":
            retVal = DatabaseID.DatabaseID(javaObj)
        elif objtype == "com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID":
            retVal = ParmID.ParmID(javaObj)
        elif objtype == "com.raytheon.uf.common.time.TimeRange":
            retVal = TimeRange.TimeRange(javaObj)
        else:
            retVal = None

        return retVal
Esempio n. 4
0
    def _makeRecordWithoutVTEC(self, ugcstring, segment, segmentText, cities,
                               purgeTime, ugcs):
        records = []

        #construct the active table entries, without the geography
        template = {}
        template['segText'] = segmentText
        template['overviewText'] = self._overviewText
        template['seg'] = segment
        startTime = self._issueTime * 1000
        ddhhmmz = ugcstring[-7:-1]
        endTime = self._dtgFromDDHHMM(ddhhmmz) * 1000
        template['startTime'] = long(startTime)
        template['endTime'] = long(endTime)
        template['ufn'] = True  # is this correct?
        if self._officeFromWMO:
            template['officeid'] = self._officeFromWMO

        template['purgeTime'] = long(
            self._dtgFromDDHHMM(purgeTime, self._issueTime) * 1000)
        template['issueTime'] = long(self._issueTime * 1000)
        template['state'] = "Decoded"
        template['xxxid'] = self._completeProductPil[3:]
        template['countyheader'] = ugcstring[:-8]
        if self._productPil[:3] in ACCURATE_CITIES_PILS:
            template['cities'] = cities
        template['pil'] = self._productPil
        template['ugcZoneList'] = ", ".join(ugcs)
        state = ugcstring[0:2]
        if REGIONS.has_key(state):
            template['region'] = REGIONS[state]
        else:
            template['region'] = 'DEFAULT'
        template['wmoid'] = self._wmoid
        template['geometry'] = self._polygon
        try:
            from com.raytheon.uf.common.time import DataTime, TimeRange
            valid = TimeRange(long(startTime), long(endTime))
            template['dataTime'] = DataTime(long(startTime), valid)
        except:
            template['dataTime'] = long(endTime)

        template['rawmessage'] = self._rawMessage
        if self._storm is not None:
            template['motdir'] = self._storm[0]
            template['motspd'] = self._storm[1]
            template['loc'] = self._storm[2]

        records.append(template)

        return records
Esempio n. 5
0
    def _expandVTEC(self, ugcstring, vtecStrings, segment, segmentText, cities,
                    purgeTime):
        #Routine takes a list of vtec strings and expands them out into
        #the format of the active table.
        #Returns the records.
        ugcs = self._expandUGC(ugcstring)
        records = []
        for vtecS, hvtec in vtecStrings:
            search = re.search(self._vtecRE, vtecS)

            #construct the active table entries, without the geography
            template = {}
            template['vtecstr'] = search.group(0)
            template['etn'] = search.group(5)
            template['sig'] = search.group(4)
            template['phen'] = search.group(3)
            template['segText'] = segmentText
            template['overviewText'] = self._overviewText
            template['phensig'] = template['phen'] + '.' + template['sig']
            template['act'] = search.group(1)
            template['seg'] = segment
            startTime, zeros = self._calcTime(search.group(6), search.group(7),
                                              self._issueTime * 1000)
            endTime, ufn = self._calcTime(search.group(8), search.group(9),
                                          self._maxFutureTime * 1000)
            template['startTime'] = long(startTime)
            template['endTime'] = long(endTime)
            template['ufn'] = ufn
            template['officeid'] = search.group(2)
            template['purgeTime'] = long(
                self._dtgFromDDHHMM(purgeTime, self._issueTime) * 1000)
            template['issueTime'] = long(self._issueTime * 1000)
            template['state'] = "Decoded"
            template['xxxid'] = self._completeProductPil[3:]
            if (self._hasDTG):
                template['countyheader'] = ugcstring[:-8]
            else:
                template['countyheader'] = ugcstring
            if self._productPil[:3] in ACCURATE_CITIES_PILS:
                template['cities'] = cities

            #remap pil if in mappedPils table to relate events that are
            #issued in one product, and updated in another product
            template['pil'] = self._remapPil(template['phen'], template['sig'],
                                             self._productPil)

            template['ugcZoneList'] = ", ".join(ugcs)
            state = ugcstring[0:2]
            if REGIONS.has_key(state):
                template['region'] = REGIONS[state]
            else:
                template['region'] = 'DEFAULT'
            template['wmoid'] = self._wmoid
            template['productClass'] = template['vtecstr'][1]
            template['geometry'] = self._polygon
            try:
                from com.raytheon.uf.common.time import DataTime, TimeRange
                valid = TimeRange(long(startTime), long(endTime))
                template['dataTime'] = DataTime(long(startTime), valid)
            except:
                template['dataTime'] = long(endTime)

            template['rawmessage'] = self._rawMessage
            if self._storm is not None:
                template['motdir'] = self._storm[0]
                template['motspd'] = self._storm[1]
                template['loc'] = self._storm[2]

            if hvtec is not None:
                hsearch = re.search(self._hVtecRE, hvtec)
                template['locationID'] = hsearch.group(1)
                template['floodSeverity'] = hsearch.group(2)
                template['immediateCause'] = hsearch.group(3)
                template['floodRecordStatus'] = hsearch.group(10)

                if template['phensig'] in PHENSIGS_IGNORE_HVTEC:
                    fakeBeginTime = None
                    fakeEndTime = None
                    fakeCrestTime = None
                else:
                    fakeBeginTime = template['issueTime']
                    fakeEndTime = long(self._maxFutureTime * 1000)
                    fakeCrestTime = fakeEndTime
                template['floodBegin'] = self._calcTime(
                    hsearch.group(4), hsearch.group(5), fakeBeginTime)[0]
                template['floodCrest'] = self._calcTime(
                    hsearch.group(6), hsearch.group(7), fakeCrestTime)[0]
                template['floodEnd'] = self._calcTime(hsearch.group(8),
                                                      hsearch.group(9),
                                                      fakeEndTime)[0]

            records.append(template)

        return records
Esempio n. 6
0
    def _makeRecordWithoutVTEC(self, ugcstring, vtecStrings, segment,
                               segmentText, cities, purgeTime, ugcs):
        records = []
        #for vtecS, hvtec in vtecStrings:
        #search = re.search(self._vtecRE, vtecS)

        #construct the active table entries, without the geography
        template = {}
        #template['vtecstr'] = search.group(0)
        #template['etn'] = search.group(5)
        #template['sig'] = search.group(4)
        #template['phen'] = search.group(3)
        template['segText'] = segmentText
        template['overviewText'] = self._overviewText
        #template['phensig'] = template['phen'] + '.' + template['sig']
        #template['act'] = search.group(1)
        template['seg'] = segment
        #startTime, zeros = self._calcTime(search.group(6),
        #  search.group(7), self._issueTime * 1000)
        startTime = self._issueTime * 1000
        #endTime, ufn = self._calcTime(search.group(8),
        #  search.group(9), self._maxFutureTime * 1000)
        ddhhmmz = ugcstring[-7:-1]
        endTime = self._dtgFromDDHHMM(ddhhmmz) * 1000
        template['startTime'] = long(startTime)
        template['endTime'] = long(endTime)
        #if ufn:
        template['ufn'] = True
        #else:
        #    template['ufn'] = False
        #template['officeid'] = search.group(2)
        if self._officeFromWMO:
            template['officeid'] = self._officeFromWMO

        template['purgeTime'] = long(
            self._dtgFromDDHHMM(purgeTime, self._issueTime) * 1000)
        template['issueTime'] = long(self._issueTime * 1000)
        template['state'] = "Decoded"
        template['xxxid'] = self._completeProductPil[3:]
        template['countyheader'] = ugcstring[:-8]
        if self._productPil[:3] in ACCURATE_CITIES_PILS:
            template['cities'] = cities

        #remap pil if in mappedPils table to relate events that are
        #issued in one product, and updated in another product
        #template['pil'] = self._remapPil(template['phen'],
        #  template['sig'], self._productPil)
        template['pil'] = self._productPil
        template['ugcs'] = ugcs
        state = ugcstring[0:2]
        if REGIONS.has_key(state):
            template['region'] = REGIONS[state]
        else:
            template['region'] = 'DEFAULT'
        template['wmoid'] = self._wmoid
        #template['productClass'] = template['vtecstr'][1]
        template['geometry'] = self._polygon
        try:
            from com.raytheon.uf.common.time import DataTime, TimeRange
            valid = TimeRange(long(startTime), long(endTime))
            template['dataTime'] = DataTime(long(startTime), valid)
        except:
            template['dataTime'] = long(endTime)

        template['rawmessage'] = self._rawMessage
        if self._storm is not None:
            template['motdir'] = self._storm[0]
            template['motspd'] = self._storm[1]
            template['loc'] = self._storm[2]

        #if hvtec is not None:
        #    hsearch = re.search(self._hVtecRE, hvtec)
        #    template['locationID'] = hsearch.group(1)
        #    template['floodSeverity'] = hsearch.group(2)
        #    template['immediateCause'] = hsearch.group(3)
        #    template['floodRecordStatus'] = hsearch.group(10)
        #    template['floodBegin'] = long(self._calcTime(hsearch.group(4), hsearch.group(5), self._issueTime)[0])
        #    template['floodCrest'] = long(self._calcTime(hsearch.group(6), hsearch.group(7), self._issueTime)[0])
        #    template['floodEnd'] = long(self._calcTime(hsearch.group(8), hsearch.group(9), self._issueTime)[0])

        records.append(template)
        #expand the template out by the ugcs
        #for geo in ugcs:
        #    dict = copy.deepcopy(template)
        #    dict['id'] = geo
        #    records.append(dict)

        return records
Esempio n. 7
0
class TimeRange(JUtil.JavaWrapperClass):
    def __init__(self, time1, time2=None):
        # these vars are only calculated if requested
        self.__hash = None
        self.__start = None
        self.__end = None
        self.__duration = None

        # Single argument assumes a passed in java timerange
        if time2 == None:
            self.__tr = time1
            return

        # Check to see if abstimes or java classes are passed in
        if isinstance(time1, AbsTime.AbsTime):
            time1_java = time1.javaDate()
            self.__start = time1
        else:
            time1_java = time1

        if isinstance(time2, AbsTime.AbsTime):
            time2_java = time2.javaDate()
            self.__end = time2
        else:
            time2_java = time2
        self.__tr = JavaTimeRange(time1_java, time2_java)

    def startTime(self):
        if not self.__start:
            self.__start = self.__asAbsTime(self.__tr.getStart())
        return self.__start

    def endTime(self):
        if not self.__end:
            self.__end = self.__asAbsTime(self.__tr.getEnd())
        return self.__end

    def __asAbsTime(self, date):
        if date is None:
            return None

        A = date.getTime()
        return AbsTime.AbsTime(A / 1000)

    def duration(self):
        if not self.__duration:
            self.__duration = self.__tr.getDuration() / 1000
        return self.__duration

    def toJavaObj(self):
        return self.__tr

    def contains(self, timeOrTimeRange):
        if isinstance(timeOrTimeRange, AbsTime.AbsTime):
            return self.__tr.contains(timeOrTimeRange.javaDate())
        if isinstance(timeOrTimeRange, TimeRange):
            return self.__tr.contains(timeOrTimeRange.toJavaObj())

    def overlaps(self, timeRange):
        return self.__tr.overlaps(timeRange.toJavaObj())

    def isAdjacentTo(self, timeRange):
        return self.__tr.isAdjacentTo(timeRange.toJavaObj())

    def join(self, timeRange):
        return TimeRange(self.__tr.join(timeRange.toJavaObj()))

    def intersection(self, timeRange):
        return TimeRange(self.__tr.intersection(timeRange.toJavaObj()))

    def gap(self, timeRange):
        return TimeRange(self.__tr.gap(timeRange.toJavaObj()))

    def span(self, timeRange):
        return TimeRange(self.__tr.span(timeRange.toJavaObj()))

    def combineWith(self, timeRange):
        return TimeRange(self.__tr.combineWith(timeRange.toJavaObj()))

    def isValid(self):
        return self.__tr.isValid()

    def __eq__(self, other):
        return self.__tr.equals(other.toJavaObj())

    def __ne__(self, other):
        return not self == other

    def __lt__(self, other):
        return self.__tr.compareTo(other.toJavaObj()) < 0

    def __le__(self, other):
        return self.__tr.compareTo(other.toJavaObj()) <= 0

    def __gt__(self, other):
        return self.__tr.compareTo(other.toJavaObj()) > 0

    def __ge__(self, other):
        return self.__tr.compareTo(other.toJavaObj()) >= 0

    def __hash__(self):
        if not self.__hash:
            self.__hash = self.startTime().unixTime() ^ self.endTime(
            ).unixTime()
        return self.__hash

    def __str__(self):
        return str(self.__tr.toString())

    def __repr__(self):
        return str(self.__tr.toString())
Esempio n. 8
0
def allTimes():
    tr = JavaTimeRange.allTimes()
    return TimeRange(tr.getStart(), tr.getEnd())
Esempio n. 9
0
def maxFutureTime():
    from com.raytheon.uf.common.time import TimeRange as JavaTimeRange
    tr = JavaTimeRange.allTimes()
    return AbsTime(tr.getEnd())
Esempio n. 10
0
class TimeRange(JUtil.JavaWrapperClass):
    def __init__(self, time1, time2=None):        
        # these vars are only calculated if requested
        self.__hash = None
        self.__start = None
        self.__end = None
        self.__duration = None
        
        # Single argument assumes a passed in java timerange
        if time2 == None:
            self.__tr = time1
            return

        # Check to see if abstimes or java classes are passed in
        if isinstance(time1, AbsTime.AbsTime):
            time1_java = time1.javaDate()
            self.__start = time1
        else:
            time1_java = time1
            
        if isinstance(time2, AbsTime.AbsTime):
            time2_java = time2.javaDate()
            self.__end = time2
        else:
            time2_java = time2
        self.__tr = JavaTimeRange(time1_java, time2_java)
 

    def startTime(self):
        if not self.__start:
            self.__start = self.__asAbsTime(self.__tr.getStart()) 
        return self.__start
    
    def endTime(self):
        if not self.__end:
            self.__end = self.__asAbsTime(self.__tr.getEnd())
        return self.__end
    
    def __asAbsTime(self, date):
        if date is None:
            return None
        
        A = date.getTime() 
        return AbsTime.AbsTime(A / 1000);
    
    def duration(self):
        if not self.__duration:
            self.__duration = self.__tr.getDuration() / 1000 
        return self.__duration
    
    def toJavaObj(self):
        return self.__tr
    
    def contains(self, timeOrTimeRange):
        if isinstance(timeOrTimeRange, AbsTime.AbsTime):
            return self.__tr.contains(timeOrTimeRange.javaDate())
        if isinstance(timeOrTimeRange, TimeRange):
            return self.__tr.contains(timeOrTimeRange.toJavaObj())
    
    def overlaps(self, timeRange):
        return self.__tr.overlaps(timeRange.toJavaObj())

    def isAdjacentTo(self, timeRange):
        return self.__tr.isAdjacentTo(timeRange.toJavaObj())
    
    def join(self, timeRange):
        return TimeRange(self.__tr.join(timeRange.toJavaObj()))
 
    def intersection(self, timeRange):
        return TimeRange(self.__tr.intersection(timeRange.toJavaObj()))

    def gap(self, timeRange):
        return TimeRange(self.__tr.gap(timeRange.toJavaObj()))

    def span(self, timeRange):
        return TimeRange(self.__tr.span(timeRange.toJavaObj()))

    def combineWith(self, timeRange):
        return TimeRange(self.__tr.combineWith(timeRange.toJavaObj()))
 
    def isValid(self):
        return self.__tr.isValid()
    
    def __eq__(self, other):
        return self.__tr.equals(other.toJavaObj())
    
    def __ne__(self, other):
        return not self == other
    
    def __lt__(self, other):
        return self.__tr.compareTo(other.toJavaObj()) < 0

    def __le__(self, other):
        return self.__tr.compareTo(other.toJavaObj()) <= 0

    def __gt__(self, other):
        return self.__tr.compareTo(other.toJavaObj()) > 0

    def __ge__(self, other):
        return self.__tr.compareTo(other.toJavaObj()) >= 0

    def __hash__(self):
        if not self.__hash:
            self.__hash = self.startTime().unixTime() ^ self.endTime().unixTime()
        return self.__hash
    
    def __str__(self):
        return str(self.__tr.toString())

    def __repr__(self):
        return str(self.__tr.toString())
Esempio n. 11
0
def allTimes():
    tr = JavaTimeRange.allTimes()
    return TimeRange(tr.getStart(), tr.getEnd())
Esempio n. 12
0
def toJavaTimeRange(tr):
    return TimeRange(long(tr[0]) * long(1000), long(tr[1]) * long(1000))
Esempio n. 13
0
def maxFutureTime():
    from com.raytheon.uf.common.time import TimeRange as JavaTimeRange
    tr = JavaTimeRange.allTimes()
    return AbsTime(tr.getEnd())