예제 #1
0
 def _get_met_hours(self, met_file_info):
     first_hour = parse_datetime(met_file_info['first_hour'], 'first_hour')
     last_hour = parse_datetime(met_file_info['last_hour'], 'last_hour')
     hours = [
         first_hour + datetime.timedelta(hours=n) for n in range(
             int((last_hour - first_hour).total_seconds() / 3600) + 1)
     ]
     return hours
예제 #2
0
    def _filter_locations(self, start_s):
        locations = [
            l for l in self._locations
            if parse_datetime(l._active_area['start']) <= start_s
            and parse_datetime(l._active_area['end']) > start_s
        ]

        return locations
예제 #3
0
def season_from_date(date_obj):
    # TODO: should we have more sophisticated logic, or
    #    location-specific season date ranges
    if date_obj:
        date_obj = parse_datetime(date_obj)
        l = int(calendar.isleap(date_obj.year))
        doy = int(date_obj.strftime('%j'))
        return next(season for season, e in SEASON_END_DATES if doy <= e + l)