Ejemplo n.º 1
0
def test_pvfactors_timeseries():
    """ Test that pvfactors is functional, using the TLDR section inputs of the
    package github repo README.md file:
    https://github.com/SunPower/pvfactors/blob/master/README.md#tldr---quick-start"""

    # Create some inputs
    timestamps = pd.DatetimeIndex([datetime(2017, 8, 31, 11),
                                   datetime(2017, 8, 31, 12)]
                                  ).set_names('timestamps')
    solar_zenith = [20., 10.]
    solar_azimuth = [110., 140.]
    surface_tilt = [10., 0.]
    surface_azimuth = [90., 90.]
    dni = [1000., 300.]
    dhi = [50., 500.]
    gcr = 0.4
    pvrow_height = 1.75
    pvrow_width = 2.44
    albedo = 0.2
    n_pvrows = 3
    index_observed_pvrow = 1
    rho_front_pvrow = 0.03
    rho_back_pvrow = 0.05
    horizon_band_angle = 15.

    # Expected values
    expected_ipoa_front = pd.Series([1034.96216923, 795.4423259],
                                    index=timestamps,
                                    name=(1, 'front', 'qinc'))
    expected_ipoa_back = pd.Series([92.11871485, 70.39404124],
                                   index=timestamps,
                                   name=(1, 'back', 'qinc'))

    # Test serial calculations
    ipoa_front, ipoa_back, df_registries = pvfactors_timeseries(
        solar_azimuth, solar_zenith, surface_azimuth, surface_tilt,
        timestamps, dni, dhi, gcr, pvrow_height, pvrow_width, albedo,
        n_pvrows=n_pvrows, index_observed_pvrow=index_observed_pvrow,
        rho_front_pvrow=rho_front_pvrow, rho_back_pvrow=rho_back_pvrow,
        horizon_band_angle=horizon_band_angle,
        run_parallel_calculations=False, n_workers_for_parallel_calcs=None)

    pd.testing.assert_series_equal(ipoa_front, expected_ipoa_front)
    pd.testing.assert_series_equal(ipoa_back, expected_ipoa_back)
    pd.testing.assert_index_equal(timestamps, df_registries.index.unique())

    # Run calculations in parallel
    ipoa_front, ipoa_back, df_registries = pvfactors_timeseries(
        solar_azimuth, solar_zenith, surface_azimuth, surface_tilt,
        timestamps, dni, dhi, gcr, pvrow_height, pvrow_width, albedo,
        n_pvrows=n_pvrows, index_observed_pvrow=index_observed_pvrow,
        rho_front_pvrow=rho_front_pvrow, rho_back_pvrow=rho_back_pvrow,
        horizon_band_angle=horizon_band_angle,
        run_parallel_calculations=True, n_workers_for_parallel_calcs=None)

    pd.testing.assert_series_equal(ipoa_front, expected_ipoa_front)
    pd.testing.assert_series_equal(ipoa_back, expected_ipoa_back)
    pd.testing.assert_index_equal(timestamps, df_registries.index.unique())
Ejemplo n.º 2
0
def test_pvfactors_timeseries(run_parallel_calculations):
    """ Test that pvfactors is functional, using the TLDR section inputs of the
    package github repo README.md file:
    https://github.com/SunPower/pvfactors/blob/master/README.md#tldr---quick-start"""

    # Create some inputs
    timestamps = pd.DatetimeIndex(
        [datetime(2017, 8, 31, 11),
         datetime(2017, 8, 31, 12)]).set_names('timestamps')
    solar_zenith = [20., 10.]
    solar_azimuth = [110., 140.]
    surface_tilt = [10., 0.]
    surface_azimuth = [90., 90.]
    axis_azimuth = 0.
    dni = [1000., 300.]
    dhi = [50., 500.]
    gcr = 0.4
    pvrow_height = 1.75
    pvrow_width = 2.44
    albedo = 0.2
    n_pvrows = 3
    index_observed_pvrow = 1
    rho_front_pvrow = 0.03
    rho_back_pvrow = 0.05
    horizon_band_angle = 15.

    # Expected values
    expected_ipoa_front = pd.Series([1034.95474708997, 795.4423259036623],
                                    index=timestamps,
                                    name=('total_inc_front'))
    expected_ipoa_back = pd.Series([91.88707460262768, 78.05831585685215],
                                   index=timestamps,
                                   name=('total_inc_back'))

    # Run calculation
    ipoa_front, ipoa_back = pvfactors_timeseries(
        solar_azimuth,
        solar_zenith,
        surface_azimuth,
        surface_tilt,
        axis_azimuth,
        timestamps,
        dni,
        dhi,
        gcr,
        pvrow_height,
        pvrow_width,
        albedo,
        n_pvrows=n_pvrows,
        index_observed_pvrow=index_observed_pvrow,
        rho_front_pvrow=rho_front_pvrow,
        rho_back_pvrow=rho_back_pvrow,
        horizon_band_angle=horizon_band_angle,
        run_parallel_calculations=run_parallel_calculations,
        n_workers_for_parallel_calcs=-1)

    pd.testing.assert_series_equal(ipoa_front, expected_ipoa_front)
    pd.testing.assert_series_equal(ipoa_back, expected_ipoa_back)
Ejemplo n.º 3
0
def test_pvfactors_timeseries_pandas(example_values):
    """Test basic pvfactors functionality with Series inputs"""

    inputs, outputs = example_values
    for key in ['solar_zenith', 'solar_azimuth', 'surface_tilt',
                'surface_azimuth', 'dni', 'dhi']:
        inputs[key] = pd.Series(inputs[key], index=inputs['timestamps'])

    ipoa_inc_front, ipoa_inc_back, _, _ = pvfactors_timeseries(**inputs)
    assert_series_equal(ipoa_inc_front, outputs['expected_ipoa_front'])
    assert_series_equal(ipoa_inc_back, outputs['expected_ipoa_back'])
Ejemplo n.º 4
0
def test_pvfactors_scalar_orientation(example_values):
    """test that surface_tilt and surface_azimuth inputs can be scalars"""
    # GH 1127, GH 1332
    inputs, outputs = example_values
    inputs['surface_tilt'] = 10.
    inputs['surface_azimuth'] = 90.
    # the second tilt is supposed to be zero, so we need to
    # update the expected irradiances too:
    outputs['expected_ipoa_front'].iloc[1] = 800.6524022701132
    outputs['expected_ipoa_back'].iloc[1] = 81.72135884745822

    ipoa_inc_front, ipoa_inc_back, _, _ = pvfactors_timeseries(**inputs)
    assert_series_equal(ipoa_inc_front, outputs['expected_ipoa_front'])
    assert_series_equal(ipoa_inc_back, outputs['expected_ipoa_back'])
Ejemplo n.º 5
0
def test_pvfactors_timeseries_pandas_inputs():
    """ Test that pvfactors is functional, using the TLDR section inputs of the
    package github repo README.md file, but converted to pandas Series:
    https://github.com/SunPower/pvfactors/blob/master/README.md#tldr---quick-start"""

    # Create some inputs
    timestamps = pd.DatetimeIndex([datetime(2017, 8, 31, 11),
                                   datetime(2017, 8, 31, 12)]
                                  ).set_names('timestamps')
    solar_zenith = pd.Series([20., 10.])
    solar_azimuth = pd.Series([110., 140.])
    surface_tilt = pd.Series([10., 0.])
    surface_azimuth = pd.Series([90., 90.])
    axis_azimuth = 0.
    dni = pd.Series([1000., 300.])
    dhi = pd.Series([50., 500.])
    gcr = 0.4
    pvrow_height = 1.75
    pvrow_width = 2.44
    albedo = 0.2
    n_pvrows = 3
    index_observed_pvrow = 1
    rho_front_pvrow = 0.03
    rho_back_pvrow = 0.05
    horizon_band_angle = 15.

    # Expected values
    expected_ipoa_front = pd.Series([1034.95474708997, 795.4423259036623],
                                    index=timestamps,
                                    name=('total_inc_front'))
    expected_ipoa_back = pd.Series([92.12563846416197, 78.05831585685098],
                                   index=timestamps,
                                   name=('total_inc_back'))

    # Run calculation
    ipoa_inc_front, ipoa_inc_back, _, _ = pvfactors_timeseries(
        solar_azimuth, solar_zenith, surface_azimuth, surface_tilt,
        axis_azimuth,
        timestamps, dni, dhi, gcr, pvrow_height, pvrow_width, albedo,
        n_pvrows=n_pvrows, index_observed_pvrow=index_observed_pvrow,
        rho_front_pvrow=rho_front_pvrow, rho_back_pvrow=rho_back_pvrow,
        horizon_band_angle=horizon_band_angle)

    assert_series_equal(ipoa_inc_front, expected_ipoa_front)
    assert_series_equal(ipoa_inc_back, expected_ipoa_back)
Ejemplo n.º 6
0
def test_pvfactors_timeseries_list(example_values):
    """Test basic pvfactors functionality with list inputs"""
    inputs, outputs = example_values
    ipoa_inc_front, ipoa_inc_back, _, _ = pvfactors_timeseries(**inputs)
    assert_series_equal(ipoa_inc_front, outputs['expected_ipoa_front'])
    assert_series_equal(ipoa_inc_back, outputs['expected_ipoa_back'])
Ejemplo n.º 7
0
def test_pvfactors_timeseries_pandas_inputs():
    """ Test that pvfactors is functional, using the TLDR section inputs of the
    package github repo README.md file, but converted to pandas Series:
    https://github.com/SunPower/pvfactors/blob/master/README.md#tldr---quick-start"""

    # Create some inputs
    timestamps = pd.DatetimeIndex(
        [datetime(2017, 8, 31, 11),
         datetime(2017, 8, 31, 12)]).set_names('timestamps')
    solar_zenith = pd.Series([20., 10.])
    solar_azimuth = pd.Series([110., 140.])
    surface_tilt = pd.Series([10., 0.])
    surface_azimuth = pd.Series([90., 90.])
    dni = pd.Series([1000., 300.])
    dhi = pd.Series([50., 500.])
    gcr = 0.4
    pvrow_height = 1.75
    pvrow_width = 2.44
    albedo = 0.2
    n_pvrows = 3
    index_observed_pvrow = 1
    rho_front_pvrow = 0.03
    rho_back_pvrow = 0.05
    horizon_band_angle = 15.

    # Expected values
    expected_ipoa_front = pd.Series([1034.96216923, 795.4423259],
                                    index=timestamps,
                                    name=(1, 'front', 'qinc'))
    expected_ipoa_back = pd.Series([92.11871485, 70.39404124],
                                   index=timestamps,
                                   name=(1, 'back', 'qinc'))

    # Test serial calculations
    ipoa_front, ipoa_back, df_registries = pvfactors_timeseries(
        solar_azimuth,
        solar_zenith,
        surface_azimuth,
        surface_tilt,
        timestamps,
        dni,
        dhi,
        gcr,
        pvrow_height,
        pvrow_width,
        albedo,
        n_pvrows=n_pvrows,
        index_observed_pvrow=index_observed_pvrow,
        rho_front_pvrow=rho_front_pvrow,
        rho_back_pvrow=rho_back_pvrow,
        horizon_band_angle=horizon_band_angle,
        run_parallel_calculations=False,
        n_workers_for_parallel_calcs=None)

    pd.testing.assert_series_equal(ipoa_front, expected_ipoa_front)
    pd.testing.assert_series_equal(ipoa_back, expected_ipoa_back)
    pd.testing.assert_index_equal(timestamps, df_registries.index.unique())

    # Run calculations in parallel
    ipoa_front, ipoa_back, df_registries = pvfactors_timeseries(
        solar_azimuth,
        solar_zenith,
        surface_azimuth,
        surface_tilt,
        timestamps,
        dni,
        dhi,
        gcr,
        pvrow_height,
        pvrow_width,
        albedo,
        n_pvrows=n_pvrows,
        index_observed_pvrow=index_observed_pvrow,
        rho_front_pvrow=rho_front_pvrow,
        rho_back_pvrow=rho_back_pvrow,
        horizon_band_angle=horizon_band_angle,
        run_parallel_calculations=True,
        n_workers_for_parallel_calcs=None)

    pd.testing.assert_series_equal(ipoa_front, expected_ipoa_front)
    pd.testing.assert_series_equal(ipoa_back, expected_ipoa_back)
    pd.testing.assert_index_equal(timestamps, df_registries.index.unique())