Beispiel #1
0
def test_back_surface_luminance():
    """
    The model didn't calculate cases when the sun would hit the back surface
    because the perez model would return 0 circumsolar (not calculated for
    back surface). Fix was implemented, and this should check for it.
    """
    pvarray_parameters = {
        'array_azimuth': 90,
        'array_tilt': 0.0,
        'gcr': 0.3,
        'n_pvrows': 3,
        'pvrow_height': 1.5,
        'pvrow_width': 1.0,
        'rho_back_pvrow': 0.03,
        'rho_front_pvrow': 0.01,
        'rho_ground': 0.2,
        'solar_azimuth': 90.0,
        'solar_zenith': 20.0
    }

    input_filename = 'file_test_back_surface_luminance.csv'

    df_inputs = pd.read_csv(os.path.join(TEST_DATA, input_filename),
                            index_col=0)
    df_inputs.index = pd.DatetimeIndex(
        df_inputs.index).tz_localize('UTC').tz_convert('US/Arizona')

    args = (pvarray_parameters, df_inputs)
    df_outputs, _, _, _ = calculate_radiosities_serially_perez(args)

    vf_ipoa_front = df_outputs.loc[:, IDX_SLICE[1, 'front', 'qinc']]
    vf_ipoa_back = df_outputs.loc[:, IDX_SLICE[1, 'back', 'qinc']]

    assert isinstance(vf_ipoa_front[0], float)
    assert isinstance(vf_ipoa_back[0], float)
Beispiel #2
0
def test_negativevf_and_flatcasenoon():

    pvarray_parameters = {
        'array_azimuth': 90,
        'array_tilt': 0.0,
        'gcr': 0.3,
        'n_pvrows': 3,
        'pvrow_height': 1.5,
        'pvrow_width': 1.0,
        'rho_back_pvrow': 0.03,
        'rho_front_pvrow': 0.01,
        'rho_ground': 0.2,
        'solar_azimuth': 90.0,
        'solar_zenith': 20.0
    }

    input_filename = 'file_test_negativevf_and_flatcasenoon.csv'
    df_inputs = pd.read_csv(os.path.join(TEST_DATA, input_filename),
                            index_col=0)
    df_inputs.index = pd.DatetimeIndex(
        df_inputs.index).tz_localize('UTC').tz_convert('US/Arizona')

    args = (pvarray_parameters, df_inputs)
    df_outputs, _, _, _ = calculate_radiosities_serially_perez(args)

    vf_ipoa_front = df_outputs.loc[:, IDX_SLICE[1, 'front', 'qinc']]
    vf_ipoa_back = df_outputs.loc[:, IDX_SLICE[1, 'back', 'qinc']]

    # The model should calculate for all daytime points now since we fixed
    # the solar noon case (almost flat but not really), and we allowed
    # negative vf values early and late in the day
    expected_n_calculated_values = 13

    assert np.sum(vf_ipoa_front.notnull()) == expected_n_calculated_values
    assert np.sum(vf_ipoa_back.notnull()) == expected_n_calculated_values
Beispiel #3
0
def test_serial_calculation():
    """
    Make sure that the calculations using the Perez model stay consistent for
    all the modeled surfaces. Also testing that there is no unexpected NaN.
    """
    # Create array
    arguments = {
        'n_pvrows': 2,
        'pvrow_height': 1.5,
        'pvrow_width': 1.,
        'array_azimuth': 270,
        'array_tilt': -20.,
        'gcr': 0.3,
        'solar_zenith': 30.,
        'solar_azimuth': 90.,
        'rho_ground': 0.22,
        'rho_pvrow_front': 0.01,
        'rho_pvrow_back': 0.03
    }

    # Import simulation inputs for calculation
    filename = "file_test_multiprocessing_inputs.csv"
    df_inputs_simulation = pd.read_csv(os.path.join(TEST_DATA, filename),
                                       index_col=0)
    df_inputs_simulation.index = pd.DatetimeIndex(df_inputs_simulation.index)
    idx_subset = 10
    df_inputs_simulation = df_inputs_simulation.iloc[0:idx_subset, :]

    # Run calculation in 1 process only
    (df_outputs, df_bifacial, _, _) = (
        calculate_radiosities_serially_perez((arguments, df_inputs_simulation))
    )

    # Did the outputs remain consistent?
    assert values_are_consistent(df_outputs)
Beispiel #4
0
def test_serial_circumsolar_shading_calculation():
    """
    Calculate and save results from front surface circumsolar shading on
    pvrows. Test that it functions with the given data.
    """

    # Choose a PV array configuration and pass the arguments necessary for
    # the calculation to be triggered:
    # eg 'calculate_front_circ_horizon_shading'
    arguments = {
        'array_azimuth': 90.0,
        'array_tilt': 20.0,
        'cut': [(1, 5, 'front')],
        'gcr': 0.3,
        'n_pvrows': 2,
        'pvrow_height': 1.5,
        'pvrow_width': 1.,
        'rho_ground': 0.2,
        'rho_pvrow_back': 0.03,
        'rho_pvrow_front': 0.01,
        'solar_azimuth': 90.0,
        'solar_zenith': 30.0,
        'circumsolar_angle': 50.,
        'horizon_band_angle': 6.5,
        'calculate_front_circ_horizon_shading': True,
        'circumsolar_model': 'gaussian'
    }
    save = (1, 'front')
    # Load inputs for the serial calculation
    test_file = os.path.join(
        TEST_DATA, 'file_test_serial_circumsolar_shading_calculation.csv')
    df_inputs = pd.read_csv(test_file, index_col=0)
    df_inputs.index = pd.DatetimeIndex(df_inputs.index)

    # Create shapely PV array
    array = Array(**arguments)

    # Run the calculation for functional testing
    df_outputs, df_bifacial, df_inputs_perez, df_outputs_segments = (
        calculate_radiosities_serially_perez((arguments, df_inputs, save))
    )
Beispiel #5
0
def test_save_all_outputs_calculate_perez():
    """
    Make sure that the serial and parallel calculations are able to save all
    the requested data on discretized segments (instead of averaging them by
    default). Check the consistency of the results.
    """
    # Load timeseries input data
    df_inputs_clearday = pd.read_csv(FILE_PATH)
    df_inputs_clearday = df_inputs_clearday.set_index('datetime', drop=True)
    df_inputs_clearday.index = (pd.DatetimeIndex(df_inputs_clearday.index)
                                .tz_localize('UTC').tz_convert('Etc/GMT+7')
                                .tz_localize(None))
    idx_subset = 10

    # Adjustment in angles needed: need to keep azimuth constant and change
    # tilt angle only
    df_inputs_clearday.loc[
        (df_inputs_clearday.solar_azimuth <= 180.), 'array_azimuth'] = (
            df_inputs_clearday.loc[:, 'array_azimuth'][-1])
    df_inputs_clearday.loc[
        (df_inputs_clearday.solar_azimuth <= 180.), 'array_tilt'] *= (-1)

    # PV array parameters for test
    arguments = {
        'n_pvrows': 3,
        'pvrow_height': 1.5,
        'pvrow_width': 1.,
        'gcr': 0.4,
        'rho_ground': 0.8,
        'rho_back_pvrow': 0.03,
        'rho_front_pvrow': 0.01,
        'cut': [(1, 3, 'front')]
    }

    # We want to save the results from the front side of tracker #2 (index 1)
    save_segments = (1, 'front')
    args = (arguments, df_inputs_clearday.iloc[:idx_subset], save_segments)

    # Run the serial calculation
    _, _, _, df_outputs_segments_serial = (
        calculate_radiosities_serially_perez(args))

    _, _, _, df_outputs_segments_parallel = (
        calculate_radiosities_parallel_perez(
            arguments, df_inputs_clearday.iloc[:idx_subset],
            save_segments=save_segments
        ))

    # Load files with expected outputs
    expected_ipoa_dict_qinc = np.array([
        [842.43691838, 842.54795737, 842.52912932],
        [839.30539601, 839.30285394, 839.29810984],
        [839.17118976, 839.17513111, 839.17725576],
        [842.24681064, 842.26195526, 842.15463995]])

    # Perform the comparisons
    rtol = 1e-7
    atol = 0
    assert np.allclose(expected_ipoa_dict_qinc,
                       df_outputs_segments_serial.loc[:, idx_slice['qinc', :]]
                       .values,
                       atol=atol, rtol=rtol)
    assert np.allclose(expected_ipoa_dict_qinc,
                       df_outputs_segments_parallel.loc[:,
                                                        idx_slice['qinc', :]]
                       .values,
                       atol=atol, rtol=rtol)