Example #1
0
    def getWeeklyList(self,weekday):
        '''

        WeekList = getWeekList(weekday)
        Weekday is the same of the datetime.isoweekay() method.
        Monday == 1 ... Sunday == 7

        Returns an ordered list of requestors, Weekly_req objects.
        '''

        PossibleShifts=[3,2,1,-0,-1,-2,-3]
        for counter,day in enumerate(range(weekday-3,weekday+4)):
            interested_weekday = (day)%7
            if interested_weekday ==0 : interested_weekday = 7
            if interested_weekday == self.timeinterval.start_time.isoweekday():
                index = counter

        starting_centered_day = self.timeinterval.start_time + datetime.timedelta(days=PossibleShifts[index])

        TL=DL.getTimeList(starting_centered_day,self.Timelist[-1] , "days=7")
        REQ_LIST=[]
        for t in TL:
            m = requestors.Weekly_req(t.year,t.month,t.day)
            indexes,_ = self.select(m)
            if len(indexes)>0:
                REQ_LIST.append(m)
        return REQ_LIST
Example #2
0
 def getSpecificIntervalList(self,deltastr='days=10',starttime="19971001-12:00:00"):
     '''
     Useful in case of 10 days average, for example
     '''
     REQ_LIST=[]
     dl=DL.getTimeList(starttime, self.timeinterval.end_time.strftime("%Y%m%d-%H:%M:%S"), deltastr)
     for dateobj in dl:
         req= requestors.Interval_req(dateobj.year,dateobj.month,dateobj.day, deltastr)
         REQ_LIST.append(req)
     return REQ_LIST
Example #3
0
 def getDailyList(self):
     '''
     Tested only for mooring case, interval = 3 hours
     '''
     REQ_LIST=[]
     t = self.Timelist[0]
     starting_centered_day = datetime.datetime(t.year,t.month,t.day)
     TL=DL.getTimeList(starting_centered_day,self.Timelist[-1] , "days=1")
     for t in TL:
         d = requestors.Daily_req(t.year,t.month,t.day)
         indexes,_ = self.select(d)
         if len(indexes)>0:
             REQ_LIST.append(d)
     return REQ_LIST
Example #4
0
        '''
        Finds the nearest
        Argument:
         a datetime object
        Returns the index of the nearest element
        '''
        D=np.zeros(self.nTimes)
        for i, d in enumerate(self.Timelist):
            diff=d-datetimeObj
            D[i]=np.abs(diff.total_seconds())
        return D.argmin()



if __name__ == '__main__':
    yearly=DL.getTimeList("19970101-00:00:00", "20150502-12:00:00", "years=1")
    TLY = TimeList(yearly)
    REQSY=TLY.getOwnList()
    r=REQSY[0]
    ii,weights = TLY.select(r)

    monthly=DL.getTimeList("19970601-00:00:00", "20150502-12:00:00", "months=1")
    TLM = TimeList(monthly)
    for iSeas in range(4):
        m = requestors.Clim_season(iSeas,seasonobj)
        TLM.select(m)

    for imonth in range(1,13):
        m = requestors.Clim_month(imonth)
        TLM.select(m)