Ejemplo n.º 1
0
def test_ordered_pvarray_from_dict(params):
    """Test that can successfully create ordered pvarray from parameters dict,
    and that the axis azimuth convention works correctly (via normal vector)
    """
    pvarray = OrderedPVArray.from_dict(params)

    # Test that ground is created successfully
    assert isinstance(pvarray.ground, PVGround)
    assert pvarray.ground.length == (MAX_X_GROUND - MIN_X_GROUND)

    # Test the front and back sides
    assert len(pvarray.pvrows) == 3
    np.testing.assert_array_equal(pvarray.pvrows[0].front.n_vector,
                                  -pvarray.pvrows[0].back.n_vector)
    assert pvarray.pvrows[0].front.shaded_length == 0
    assert pvarray.gcr == params['gcr']
    assert pvarray.surface_tilt == params['surface_tilt']
    assert pvarray.surface_azimuth == params['surface_azimuth']
    assert pvarray.solar_zenith == params['solar_zenith']
    assert pvarray.solar_azimuth == params['solar_azimuth']
    assert pvarray.pvrows[0].front.n_vector[0] > 0

    # Orient the array the other way
    params.update({'surface_azimuth': 270.})
    pvarray = OrderedPVArray.from_dict(params)
    assert pvarray.pvrows[0].front.n_vector[0] < 0
Ejemplo n.º 2
0
def test_orderedpvarray_neighbors(params):
    """Check that pvrow neighbors are determined correctly"""

    pvarray_right = OrderedPVArray.from_dict(params)
    params.update({'surface_azimuth': 270})
    pvarray_left = OrderedPVArray.from_dict(params)

    # Check
    l1 = [None, 0, 1]
    l2 = [1, 2, None]
    np.testing.assert_array_equal(pvarray_right.front_neighbors, l2)
    np.testing.assert_array_equal(pvarray_right.back_neighbors, l1)
    np.testing.assert_array_equal(pvarray_left.front_neighbors, l1)
    np.testing.assert_array_equal(pvarray_left.back_neighbors, l2)
Ejemplo n.º 3
0
def test_surface_params(params):

    surface_params = ['qinc']
    pvarray = OrderedPVArray.from_dict(params, surface_params=surface_params)
    pvarray.cast_shadows()
    pvarray.cuts_for_pvrow_view()

    # Set all surfaces parameters to 1
    pvarray.update_params({'qinc': 1})

    # Check that all surfaces of the correct surface params
    all_surfaces = pvarray.all_surfaces
    for surf in all_surfaces:
        assert surf.surface_params == surface_params
        assert surf.get_param('qinc') == 1

    # Check weighted values
    np.testing.assert_almost_equal(pvarray.ground.get_param_weighted('qinc'),
                                   1)
    np.testing.assert_almost_equal(pvarray.ground.get_param_ww('qinc'),
                                   pvarray.ground.length)
    for pvrow in pvarray.pvrows:
        # Front
        np.testing.assert_almost_equal(pvrow.front.get_param_weighted('qinc'),
                                       1)
        np.testing.assert_almost_equal(pvrow.front.get_param_ww('qinc'),
                                       pvrow.front.length)
        # Back
        np.testing.assert_almost_equal(pvrow.back.get_param_weighted('qinc'),
                                       1)
        np.testing.assert_almost_equal(pvrow.back.get_param_ww('qinc'),
                                       pvrow.back.length)
Ejemplo n.º 4
0
def test_ordered_pvarray_gnd_pvrow_shadow_casting_back(params_direct_shading):

    params_direct_shading.update({'solar_azimuth': 270, 'surface_tilt': 120})

    # Test front shading on right
    ordered_pvarray = OrderedPVArray.from_dict(params_direct_shading)
    ordered_pvarray.cast_shadows()
    assert ordered_pvarray.illum_side == 'back'
    # Check shadow casting on ground
    assert len(ordered_pvarray.ground.list_segments[0].shaded_collection.
               list_surfaces) == 1
    assert len(ordered_pvarray.ground.list_segments[0].illum_collection.
               list_surfaces) == 2
    assert ordered_pvarray.ground.length == MAX_X_GROUND - MIN_X_GROUND

    # Shading length should be identical as in previous test for front surface,
    # but now with back surface
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[2].back.shaded_length, 0.33333333333333254)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[1].back.shaded_length, 0.33333333333333254)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[0].back.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[2].front.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[1].front.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[0].front.shaded_length, 0.)
Ejemplo n.º 5
0
def test_ordered_pvarray_gnd_pvrow_shadow_casting_left(params_direct_shading):

    params_direct_shading.update({
        'solar_azimuth': 270,
        'surface_azimuth': 270
    })
    # Test front shading on right
    ordered_pvarray = OrderedPVArray.from_dict(params_direct_shading)
    ordered_pvarray.cast_shadows()
    # Check shadow casting on ground
    assert len(ordered_pvarray.ground.list_segments[0].shaded_collection.
               list_surfaces) == 1
    assert len(ordered_pvarray.ground.list_segments[0].illum_collection.
               list_surfaces) == 2
    assert ordered_pvarray.ground.length == MAX_X_GROUND - MIN_X_GROUND

    assert ordered_pvarray.illum_side == 'front'
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[2].front.shaded_length, 0.33333333333333254)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[1].front.shaded_length, 0.33333333333333254)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[0].front.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[2].back.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[1].back.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[0].back.shaded_length, 0.)
Ejemplo n.º 6
0
def test_time_ordered_pvarray(params):

    # params.update({'surface_tilt': 0})
    from pvfactors.viewfactors import VFCalculator

    import time
    n = 100
    list_elapsed = []
    for _ in range(n):
        tic = time.time()
        pvarray = OrderedPVArray.from_dict(params)
        pvarray.cast_shadows()  # time consuming in pvarray creation
        pvarray.cuts_for_pvrow_view()
        pvarray.index_all_surfaces()
        # sr = pvarray.surface_registry
        # vm = pvarray.view_matrix
        vm, om = pvarray._build_view_matrix()
        geom_dict = pvarray.dict_surfaces

        calculator = VFCalculator()
        # number 1 time consuming, triples run time
        vf_matrix = calculator.get_vf_matrix(geom_dict, vm, om, pvarray.pvrows)
        toc = time.time()
        list_elapsed.append(toc - tic)

    print("\nAvg time elapsed: {} s".format(np.mean(list_elapsed)))
Ejemplo n.º 7
0
def test_discretization_ordered_pvarray(discr_params):
    pvarray = OrderedPVArray.from_dict(discr_params)
    pvrows = pvarray.pvrows

    assert len(pvrows[0].front.list_segments) == 5
    assert len(pvrows[0].back.list_segments) == 1
    assert len(pvrows[1].back.list_segments) == 3
    assert len(pvrows[1].front.list_segments) == 2
Ejemplo n.º 8
0
def test_plot_ordered_pvarray():
    """Test that ordered pv array plotting works correctly"""
    is_ci = os.environ.get('CI', False)
    if not is_ci:
        import matplotlib.pyplot as plt

        # Create base params
        params = {
            'n_pvrows': 3,
            'pvrow_height': 2.5,
            'pvrow_width': 2.,
            'surface_azimuth': 90.,  # east oriented modules / point right
            'axis_azimuth': 0.,  # axis of rotation towards North
            'surface_tilt': 20.,
            'gcr': 0.4,
            'solar_zenith': 20.,
            'solar_azimuth': 90.,  # sun located in the east
            'rho_ground': 0.2,
            'rho_front_pvrow': 0.01,
            'rho_back_pvrow': 0.03
        }

        # Plot simple ordered pv array
        ordered_pvarray = OrderedPVArray.from_dict(params)
        f, ax = plt.subplots()
        ordered_pvarray.plot(ax)
        plt.show()

        # Plot discretized ordered pv array
        params.update({
            'cut': {
                0: {
                    'front': 5
                },
                1: {
                    'back': 3
                }
            },
            'surface_azimuth': 270.
        })  # point left
        ordered_pvarray = OrderedPVArray.from_dict(params)
        f, ax = plt.subplots()
        ordered_pvarray.plot(ax)
        plt.show()
Ejemplo n.º 9
0
def test_ordered_pvarray_gnd_pvrow_shadow_casting_back_n_seg(
        params_direct_shading):

    params_direct_shading.update({
        'cut': {
            1: {
                'back': 7
            }
        },
        'solar_azimuth': 270,
        'surface_tilt': 120
    })
    # Test front shading on right
    ordered_pvarray = OrderedPVArray.from_dict(params_direct_shading)
    ordered_pvarray.cast_shadows()
    # Check shadow casting on ground
    assert len(ordered_pvarray.ground.list_segments[0].shaded_collection.
               list_surfaces) == 1
    assert len(ordered_pvarray.ground.list_segments[0].illum_collection.
               list_surfaces) == 2
    assert ordered_pvarray.ground.length == MAX_X_GROUND - MIN_X_GROUND

    assert ordered_pvarray.illum_side == 'back'
    # Shading length should be identical as in previous test for front surface,
    # but now with back surface
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[2].back.shaded_length, 0.33333333333333254)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[1].back.shaded_length, 0.33333333333333254)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[0].back.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[2].front.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[1].front.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[0].front.shaded_length, 0.)

    # Test individual segments
    center_row = ordered_pvarray.pvrows[1]
    list_pvsegments = center_row.back.list_segments
    fully_shaded_segment = list_pvsegments[-1]
    partial_shaded_segment = list_pvsegments[-2]
    assert fully_shaded_segment.illum_collection.is_empty
    np.testing.assert_almost_equal(
        fully_shaded_segment.shaded_collection.length,
        list_pvsegments[0].length)
    assert partial_shaded_segment.shaded_collection.length > 0
    assert partial_shaded_segment.illum_collection.length > 0
    sum_lengths = (partial_shaded_segment.illum_collection.length +
                   partial_shaded_segment.shaded_collection.length)
    np.testing.assert_almost_equal(sum_lengths, list_pvsegments[0].length)
Ejemplo n.º 10
0
def test_ordered_pvarray_gnd_shadow_casting(params):
    """Test shadow casting on ground, no inter-row shading"""

    # Test front shading on right
    ordered_pvarray = OrderedPVArray.from_dict(params)
    ordered_pvarray.cast_shadows()
    # Check shadow casting on ground
    assert len(ordered_pvarray.ground.list_segments[0].shaded_collection.
               list_surfaces) == 3
    assert len(ordered_pvarray.ground.list_segments[0].illum_collection.
               list_surfaces) == 4
    assert ordered_pvarray.ground.shaded_length == 6.385066634855475
    assert ordered_pvarray.illum_side == 'front'
Ejemplo n.º 11
0
def test_view_matrix_flat(params):

    # Make flat
    params.update({'surface_tilt': 0})

    # Create pvarray
    pvarray = OrderedPVArray.from_dict(params)

    # Create shadows and pvrow cuts
    pvarray.cast_shadows()
    pvarray.cuts_for_pvrow_view()

    # Build view matrix
    vm = pvarray.view_matrix

    assert vm.shape[0] == pvarray.n_surfaces + 1
    np.testing.assert_array_equal(vm, vm_flat_orderedpvarray)
Ejemplo n.º 12
0
def test_vfcalculator(params):

    # Prepare pv array
    params.update({'cut': {0: {'front': 3}, 1: {'back': 2}}})
    pvarray = OrderedPVArray.from_dict(params)
    pvarray.cast_shadows()
    pvarray.cuts_for_pvrow_view()
    vm, om = pvarray._build_view_matrix()
    geom_dict = pvarray.dict_surfaces

    # Calculate view factors
    calculator = VFCalculator()
    vf_matrix = calculator.get_vf_matrix(geom_dict, vm, om, pvarray.pvrows)

    # The values where checked visually by looking at plot of pvarray
    np.testing.assert_array_equal(np.around(vf_matrix, decimals=3),
                                  vf_matrix_left_cut)
Ejemplo n.º 13
0
def test_orderedpvarray_almost_flat():
    """Making sure that things are correct when the pvarray is almost flat
    and the sun is very low, which means that the shadows on the ground, and
    the edge points will be outside of ground range (since not infinite)"""

    params = {
        'n_pvrows': 3,
        'pvrow_height': 2.5,
        'pvrow_width': 2.,
        'surface_azimuth': 90.,  # east oriented modules
        'axis_azimuth': 0.,  # axis of rotation towards North
        'surface_tilt': 0.01,  # almost flat
        'gcr': 0.4,
        'solar_zenith': 89.9,  # sun super low
        'solar_azimuth': 90.,  # sun located in the east
    }

    pvarray = OrderedPVArray.from_dict(params)
    pvarray.cast_shadows()
    pvarray.cuts_for_pvrow_view()
    view_matrix = pvarray.view_matrix

    ground_seg = pvarray.ground.list_segments[0]
    # there should be no visible shadow on the ground
    assert len(ground_seg.shaded_collection.list_surfaces) == 0
    # all of the edge points should be outside of range of ground geometry
    for edge_pt in pvarray.edge_points:
        assert not contains(pvarray.ground.original_linestring, edge_pt)

    # Check values of view matrix mask, to make sure that front does not
    # see the ground
    vm_mask = np.where(view_matrix > 0, 1, 0)
    expected_vm_mask = [
        [0, 0, 1, 0, 1, 0, 1, 1],  # ground
        [0, 0, 0, 0, 1, 0, 0, 1],  # front
        [1, 0, 0, 0, 0, 0, 0, 1],  # back
        [0, 0, 0, 0, 0, 0, 1, 1],  # front
        [1, 1, 0, 0, 0, 0, 0, 1],  # back
        [0, 0, 0, 0, 0, 0, 0, 1],  # front
        [1, 0, 0, 1, 0, 0, 0, 1],  # back
        [0, 0, 0, 0, 0, 0, 0, 0]
    ]
    np.testing.assert_array_equal(vm_mask, expected_vm_mask)
Ejemplo n.º 14
0
def test_ordered_pvarray_gnd_pvrow_shadow_casting_right_n_seg(
        params_direct_shading):

    params_direct_shading.update({'cut': {1: {'front': 7}}})
    # Test front shading on right
    ordered_pvarray = OrderedPVArray.from_dict(params_direct_shading)
    ordered_pvarray.cast_shadows()
    # Check shadow casting on ground
    assert len(ordered_pvarray.ground.list_segments[0].shaded_collection.
               list_surfaces) == 1
    assert len(ordered_pvarray.ground.list_segments[0].illum_collection.
               list_surfaces) == 2
    assert ordered_pvarray.ground.length == MAX_X_GROUND - MIN_X_GROUND

    assert ordered_pvarray.illum_side == 'front'
    # Test pvrow sides: should be the same as without segments
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[0].front.shaded_length, 0.33333333333333254)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[1].front.shaded_length, 0.33333333333333254)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[2].front.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[0].back.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[1].back.shaded_length, 0.)
    np.testing.assert_almost_equal(
        ordered_pvarray.pvrows[2].back.shaded_length, 0.)

    # Test individual segments
    center_row = ordered_pvarray.pvrows[1]
    list_pvsegments = center_row.front.list_segments
    fully_shaded_segment = list_pvsegments[-1]
    partial_shaded_segment = list_pvsegments[-2]
    assert fully_shaded_segment.illum_collection.is_empty
    np.testing.assert_almost_equal(
        fully_shaded_segment.shaded_collection.length,
        list_pvsegments[0].length)
    assert partial_shaded_segment.shaded_collection.length > 0
    assert partial_shaded_segment.illum_collection.length > 0
    sum_lengths = (partial_shaded_segment.illum_collection.length +
                   partial_shaded_segment.shaded_collection.length)
    np.testing.assert_almost_equal(sum_lengths, list_pvsegments[0].length)
Ejemplo n.º 15
0
def test_view_matrix(params):

    params.update({'surface_azimuth': 270})

    # Create pvarray
    pvarray = OrderedPVArray.from_dict(params)

    # Create shadows and pvrow cuts
    pvarray.cast_shadows()
    pvarray.cuts_for_pvrow_view()

    # Build view matrix and obstruction matrix
    vm, om = pvarray._build_view_matrix()

    assert vm.shape[0] == pvarray.n_surfaces + 1
    np.testing.assert_array_equal(vm, vm_right_orderedpvarray)
    # The view matrix mask should be symmetric
    mask_vm = np.where(vm != 0, 1, 0)
    np.testing.assert_array_equal(mask_vm[:-1, :-1], mask_vm.T[:-1, :-1])
    # Removing sky row and column because didn't fill the last row

    # The obstruction matrix should be symmetric
    np.testing.assert_array_equal(om, om.T)
Ejemplo n.º 16
0
def test_ordered_pvarray_gnd_shadow_casting_tolerance():
    """It seems that there are roundoff errors when running shadow casting
    on some computers, test that this case works."""

    params = {
        'axis_azimuth': 0,
        'gcr': 0.3,
        'n_pvrows': 3,
        'pvrow_height': 1.8,
        'pvrow_width': 1.98,
        'solar_azimuth': 263.99310644558074,
        'solar_zenith': 73.91658668648401,
        'surface_azimuth': 270.0,
        'surface_tilt': 51.98206680806641
    }
    pvarray_w_direct_shading = OrderedPVArray.from_dict(params)
    pvarray_w_direct_shading.cast_shadows()

    # Check that 3 shadows on ground
    assert (pvarray_w_direct_shading.ground.list_segments[0].shaded_collection.
            n_surfaces) == 3
    # Check that there is no shading on the center pv row
    pvrow = pvarray_w_direct_shading.pvrows[1]
    assert (pvrow.front.list_segments[0].shaded_collection.n_surfaces) == 0
Ejemplo n.º 17
0
def test_isotropic_model_front(params_irr):
    """Direct shading on front surface"""

    # pvarray
    pvarray = OrderedPVArray.from_dict(params_irr,
                                       surface_params=IsotropicOrdered.params)
    pvarray.cast_shadows()
    pvarray.cuts_for_pvrow_view()
    # there should be some direct shading
    assert pvarray.pvrows[0].front.shaded_length

    # Apply irradiance model
    DNI = 1000.
    DHI = 100.
    irr_model = IsotropicOrdered()
    irr_model.fit(None, DNI, DHI, params_irr['solar_zenith'],
                  params_irr['solar_azimuth'], params_irr['surface_tilt'],
                  params_irr['surface_azimuth'], params_irr['rho_front_pvrow'],
                  params_irr['rho_back_pvrow'], params_irr['rho_ground'])

    # Expected values
    expected_dni_pvrow = DNI * cosd(45)
    expected_dni_ground = DNI * cosd(65)

    # Check fitting
    np.testing.assert_almost_equal(irr_model.direct['ground'][0],
                                   expected_dni_ground)
    np.testing.assert_almost_equal(irr_model.direct['front_pvrow'][0],
                                   expected_dni_pvrow)
    assert irr_model.direct['back_pvrow'][0] == 0.

    # Transform
    irradiance_vec, rho_vec, invrho_vec, total_perez_vec = \
        irr_model.transform(pvarray)

    # Check transform
    expected_irradiance_vec = [
        422.61826174069944, 422.61826174069944, 422.61826174069944,
        422.61826174069944, 422.61826174069944, 0.0, 707.10678118654744, 0.0,
        0.0, 707.10678118654744, 0.0, 0.0, 707.10678118654744, 0.0, 100.
    ]
    # pvrow
    np.testing.assert_almost_equal(
        pvarray.pvrows[2].front.get_param_weighted('direct'),
        expected_dni_pvrow)
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].front.list_segments[0].illum_collection.
        get_param_weighted('direct'), expected_dni_pvrow)
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].front.list_segments[0].shaded_collection.
        get_param_weighted('direct'), 0.)
    np.testing.assert_almost_equal(
        pvarray.pvrows[0].back.get_param_weighted('direct'), 0.)
    # ground
    np.testing.assert_almost_equal(
        pvarray.ground.list_segments[0].illum_collection.get_param_weighted(
            'direct'), expected_dni_ground)
    np.testing.assert_almost_equal(
        pvarray.ground.list_segments[0].shaded_collection.get_param_weighted(
            'direct'), 0.)
    np.testing.assert_array_almost_equal(expected_irradiance_vec,
                                         irradiance_vec)
    # Check invrho_vec
    expected_invrho_vec = np.array([
        5., 5., 5., 5., 5., 5., 100., 100., 33.333333, 100., 100., 33.333333,
        100., 33.333333, 1.
    ])
    np.testing.assert_array_almost_equal(invrho_vec, expected_invrho_vec)
    np.testing.assert_almost_equal(
        pvarray.pvrows[0].front.get_param_weighted('rho'),
        params_irr['rho_front_pvrow'])
    np.testing.assert_almost_equal(
        pvarray.pvrows[0].back.get_param_weighted('rho'),
        params_irr['rho_back_pvrow'])
    np.testing.assert_almost_equal(pvarray.ground.get_param_weighted('rho'),
                                   params_irr['rho_ground'])

    # Check total perez vec
    expected_total_perez_vec = [
        522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174,
        100., 807.243186, 100.13640481, 0., 807.243186, 100.13640481, 0.,
        807.243186, 0., 100.
    ]
    np.testing.assert_array_almost_equal(total_perez_vec,
                                         expected_total_perez_vec)
Ejemplo n.º 18
0
def ordered_pvarray(params):
    pvarray = OrderedPVArray.from_dict(params)
    yield pvarray
Ejemplo n.º 19
0
def test_hybridperez_ordered_back(params_irr):

    params_irr.update({'surface_azimuth': 270, 'surface_tilt': 160})

    # pvarray
    pvarray = OrderedPVArray.from_dict(
        params_irr, surface_params=HybridPerezOrdered.params)
    pvarray.cast_shadows()
    pvarray.cuts_for_pvrow_view()
    # there should be some direct shading
    assert pvarray.pvrows[0].back.shaded_length

    # Apply irradiance model
    DNI = 1000.
    DHI = 100.
    ts = dt.datetime(2019, 6, 14, 11)
    irr_model = HybridPerezOrdered(horizon_band_angle=50)
    irr_model.fit(ts, DNI, DHI, params_irr['solar_zenith'],
                  params_irr['solar_azimuth'], params_irr['surface_tilt'],
                  params_irr['surface_azimuth'], params_irr['rho_front_pvrow'],
                  params_irr['rho_back_pvrow'], params_irr['rho_ground'])

    # Expected values
    expected_dni_pvrow = DNI * cosd(45)
    expected_dni_ground = DNI * cosd(65)
    expected_circ_pvrow = 61.542748619313045
    # FIXME: it doesn't seem right that circumsolar stronger on ground
    expected_circ_ground = 36.782407037017585
    expected_hor_pvrow_no_shad = 7.2486377533042452
    expected_hor_pvrow_w_shad_1 = 6.0760257690033654
    expected_hor_pvrow_w_shad_2 = 3.6101632102156898
    horizon_shading_pct_1 = 16.176997998918541
    horizon_shading_pct_2 = 50.195287265251757

    # Check fitting
    np.testing.assert_almost_equal(irr_model.direct['ground'][0],
                                   expected_dni_ground)
    np.testing.assert_almost_equal(irr_model.direct['back_pvrow'][0],
                                   expected_dni_pvrow)
    assert irr_model.direct['front_pvrow'][0] == 0.

    # Transform
    irradiance_vec, rho_vec, invrho_vec, total_perez_vec = \
        irr_model.transform(pvarray)

    # Test isotropic_luminance
    np.testing.assert_almost_equal(irr_model.isotropic_luminance, 63.21759296)
    # Check transform
    expected_irradiance_vec = [
        459.400669, 459.400669, 459.400669, 459.400669, 459.400669, 0.,
        7.248638, 774.725556, 3.610163, 7.248638, 774.725556, 3.610163,
        7.248638, 775.898168, 63.217593
    ]
    # pvrow direct
    np.testing.assert_almost_equal(
        pvarray.pvrows[2].back.get_param_weighted('direct'),
        expected_dni_pvrow)
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].back.list_segments[0].illum_collection.
        get_param_weighted('direct'), expected_dni_pvrow)
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].back.list_segments[0].shaded_collection.
        get_param_weighted('direct'), 0.)
    np.testing.assert_almost_equal(
        pvarray.pvrows[0].front.get_param_weighted('direct'), 0.)
    # pvrow circumsolar
    np.testing.assert_almost_equal(
        pvarray.pvrows[2].back.get_param_weighted('circumsolar'),
        expected_circ_pvrow)
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].back.list_segments[0].illum_collection.
        get_param_weighted('circumsolar'), expected_circ_pvrow)
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].back.list_segments[0].shaded_collection.
        get_param_weighted('circumsolar'), 0.)
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].front.list_segments[0].illum_collection.
        get_param_weighted('circumsolar'), 0.)
    # pvrow horizon
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].front.get_param_weighted('horizon'),
        expected_hor_pvrow_no_shad)
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].back.list_segments[0].illum_collection.
        get_param_weighted('horizon'), expected_hor_pvrow_w_shad_1)
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].back.list_segments[0].shaded_collection.
        get_param_weighted('horizon'), expected_hor_pvrow_w_shad_2)
    np.testing.assert_almost_equal(
        pvarray.pvrows[0].back.list_segments[0].illum_collection.
        get_param_weighted('horizon'), expected_hor_pvrow_w_shad_1)
    np.testing.assert_almost_equal(
        pvarray.pvrows[0].back.list_segments[0].shaded_collection.
        get_param_weighted('horizon'), expected_hor_pvrow_w_shad_2)
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].back.list_segments[0].illum_collection.
        get_param_weighted('horizon_shd_pct'), horizon_shading_pct_1)
    np.testing.assert_almost_equal(
        pvarray.pvrows[1].back.list_segments[0].shaded_collection.
        get_param_weighted('horizon_shd_pct'), horizon_shading_pct_2)
    # ground
    np.testing.assert_almost_equal(
        pvarray.ground.get_param_weighted('horizon'), 0.)
    np.testing.assert_almost_equal(
        pvarray.ground.list_segments[0].illum_collection.get_param_weighted(
            'direct'), expected_dni_ground)
    np.testing.assert_almost_equal(
        pvarray.ground.list_segments[0].illum_collection.get_param_weighted(
            'circumsolar'), expected_circ_ground)
    np.testing.assert_almost_equal(
        pvarray.ground.list_segments[0].shaded_collection.get_param_weighted(
            'direct'), 0.)
    np.testing.assert_array_almost_equal(expected_irradiance_vec,
                                         irradiance_vec)
    # Check invrho_vec
    expected_invrho_vec = np.array([
        5., 5., 5., 5., 5., 5., 100., 33.333333, 33.333333, 100., 33.333333,
        33.333333, 100., 33.333333, 1.
    ])
    np.testing.assert_array_almost_equal(invrho_vec, expected_invrho_vec)
    np.testing.assert_almost_equal(
        pvarray.pvrows[0].front.get_param_weighted('rho'),
        params_irr['rho_front_pvrow'])
    np.testing.assert_almost_equal(
        pvarray.pvrows[0].back.get_param_weighted('rho'),
        params_irr['rho_back_pvrow'])
    np.testing.assert_almost_equal(pvarray.ground.get_param_weighted('rho'),
                                   params_irr['rho_ground'])

    # Check total perez vec
    expected_total_perez_vec = [
        522.618262, 522.618262, 522.618262, 522.618262, 522.618262, 100.,
        104.387248, 0., 0., 104.387248, 0., 0., 104.387248, 0., 63.217593
    ]
    np.testing.assert_array_almost_equal(total_perez_vec,
                                         expected_total_perez_vec)