Beispiel #1
0
def get_weather_normal_source(site, use_cz2010=False):
    ''' Finds most relevant WeatherSource given project site.

    Parameters
    ----------
    site : eemeter.structures.ZIPCodeSite
        Site to match to weather source data.
    use_cz2010 : boolean, default False
        Indicates whether or not to use CZ2010 mapping.

    Returns
    -------
    weather_normal_source : eemeter.weather.TMY3WeatherSource or eemeter.weather.CZ2010WeatherSource or None
        Closest data-validated TMY3 weather normal source in the same climate zone as
        project ZIP code, if available. If use_cz2010 is True, returns the
        corresponding CZ2010WeatherSource.
        If no station can be found, returns None.
    '''

    zipcode = site.zipcode

    if use_cz2010:
        station = zipcode_to_cz2010_station(zipcode)
        station_type = 'CZ2010'
    else:
        station = zipcode_to_tmy3_station(zipcode)
        station_type = 'TMY3'

    if station is None:
        logger.error('Could not find appropriate {} weather normal station'
                     ' for zipcode {}.'.format(station_type, zipcode))
        return None

    logger.debug('Mapped ZIP code {} to {} station {}'.format(
        zipcode, station_type, station))

    try:
        weather_normal_source = WeatherSource(station,
                                              normalized=True,
                                              use_cz2010=use_cz2010)
    except ValueError:
        logger.error(
            "Could not create normalized WeatherSource for station {}.".format(
                station))
        return None

    logger.debug('Created {}WeatherSource using station {}'.format(
        station_type, station))

    return weather_normal_source
Beispiel #2
0
def get_weather_normal_source(project):
    ''' Finds most relevant WeatherSource given project site.

    Parameters
    ----------
    project : eemeter.structures.Project
        Project for which to find weather source data.

    Returns
    -------
    weather_source : eemeter.weather.TMY3WeatherSource
        Closest data-validated weather source in the same climate zone as
        project ZIP code, if available.
    '''

    zipcode = project.site.zipcode
    station = zipcode_to_tmy3_station(zipcode)

    if station is None:
        logger.error(
            "Could not find appropriate TMY3 station for zipcode {}."
            .format(zipcode)
        )
        return None

    logger.info(
        "Mapped ZIP code {} to TMY3 station {}"
        .format(zipcode, station)
    )

    try:
        weather_normal_source = TMY3WeatherSource(station)
    except ValueError:
        logger.error(
            "Could not create TMY3WeatherSource for station {}."
            .format(station)
        )
        return None

    logger.info("Created TMY3WeatherSource using station {}".format(station))

    return weather_normal_source
Beispiel #3
0
def test_zipcode_to_tmy3_station():
    assert zipcode_to_tmy3_station('19975') == '724088'
    assert zipcode_to_tmy3_station('94403') == '745090'
Beispiel #4
0
def test_zipcode_to_tmy3_station():
    assert zipcode_to_tmy3_station('19975') == '745966'
    assert zipcode_to_tmy3_station('94403') == '724940'