How to use the eeweather.ISDStation function in eeweather

To help you get started, we’ve selected a few eeweather examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opentaps / opentaps_seas / opentaps_seas / core / utils.py View on Github external
start_date = end_date - timedelta(hours=days_from_today*24)
        logger.info('get_weather_history_for_station: using default start_date %s', start_date)
        given_start = False

    # Get last update datetime
    if not given_start:
        try:
            last_record = WeatherHistory.objects.filter(weather_station=weather_station).order_by('-as_of_datetime').first()
            if last_record:
                start_date = last_record.as_of_datetime + timedelta(minutes=1)
                logger.info('get_weather_history_for_station: last record start_date %s', start_date)
        except Exception as e:
            logging.warning(e)

    # Get weather station
    station = eeweather.ISDStation(weather_station.weather_station_code)

    # Make sure all dates are UTC
    start_date = start_date.replace(tzinfo=pytz.UTC)
    end_date = end_date.replace(tzinfo=pytz.UTC)
    logger.info('get_weather_history_for_station: from %s to %s',
                start_date, end_date)
    temp_degC, warnings = station.load_isd_hourly_temp_data(
                            start_date,
                            end_date,
                            read_from_cache=False)
    logger.info('get_weather_history_for_station: got %s / %s', temp_degC, warnings)
    WeatherHistory.objects.filter(as_of_datetime__gte=start_date).filter(as_of_datetime__lte=end_date).delete()
    for dt, deg_c in temp_degC.iteritems():
        if dt < start_date:
            continue
        elif numpy.isnan(deg_c):
github openeemeter / eemeter / eemeter / weather / eeweather_wrapper.py View on Github external
def __init__(self, usaf_id, normalized, use_cz2010):
        self.usaf_id = usaf_id
        self.station = eeweather.ISDStation(usaf_id)
        self.normalized = normalized
        self.use_cz2010 = use_cz2010
        self.resource_loc = None
        self._assign_station_type_and_loc(normalized, use_cz2010)
        self.tempC = pd.Series(dtype=float)