def test_isotropic_model_front(params_irr): """Direct shading on front surface""" # Create and fit 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_ground']) # Expected values expected_dni_pvrow = DNI * cosd(45) expected_dni_ground = DNI * cosd(65) # Check irradiance fitting np.testing.assert_almost_equal(irr_model.direct['ground_illum'][0], expected_dni_ground) np.testing.assert_almost_equal(irr_model.direct['front_illum_pvrow'][0], expected_dni_pvrow) assert irr_model.direct['back_illum_pvrow'][0] == 0. # Create, fit, and transform pv array pvarray = OrderedPVArray.fit_from_dict_of_scalars( params_irr, param_names=IsotropicOrdered.params) irr_model.transform(pvarray) # there should be some direct shading assert pvarray.ts_pvrows[0].front.shaded_length # Get modeling vectors irradiance_mat, rho_mat, invrho_mat, total_perez_mat = \ irr_model.get_ts_modeling_vectors(pvarray) # Check transform expected_irradiance_vec = [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 707.10678119, 0., 0., 0., 707.10678119, 0., 0., 0., 707.10678119, 0., 0., 0. ] # pvrow np.testing.assert_almost_equal( pvarray.ts_pvrows[2].front.get_param_weighted('direct'), expected_dni_pvrow) np.testing.assert_almost_equal( pvarray.ts_pvrows[1].front.list_segments[0].illum.get_param_weighted( 'direct'), expected_dni_pvrow) np.testing.assert_almost_equal( pvarray.ts_pvrows[1].front.list_segments[0].shaded.get_param_weighted( 'direct'), 0.) np.testing.assert_almost_equal( pvarray.ts_pvrows[0].back.get_param_weighted('direct'), 0.) # ground np.testing.assert_almost_equal( pvarray.ts_ground.illum.get_param_weighted('direct'), expected_dni_ground) np.testing.assert_almost_equal( pvarray.ts_ground.shaded.get_param_weighted('direct'), 0.) np.testing.assert_array_almost_equal(expected_irradiance_vec, np.squeeze(irradiance_mat)) # Check invrho_vec expected_invrho_vec = [ 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 100., 100., 33.33333333, 33.33333333, 100., 100., 33.33333333, 33.33333333, 100., 100., 33.33333333, 33.33333333 ] np.testing.assert_array_almost_equal(np.squeeze(invrho_mat), expected_invrho_vec) np.testing.assert_almost_equal( pvarray.ts_pvrows[0].front.get_param_weighted('rho'), params_irr['rho_front_pvrow']) np.testing.assert_almost_equal( pvarray.ts_pvrows[0].back.get_param_weighted('rho'), params_irr['rho_back_pvrow']) np.testing.assert_almost_equal(pvarray.ts_ground.get_param_weighted('rho'), params_irr['rho_ground']) # Check total perez vec expected_total_perez_vec = [ 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 807.243186, 100.13640481, 0., 0., 807.243186, 100.13640481, 0., 0., 807.243186, 100.13640481, 0., 0. ] np.testing.assert_array_almost_equal(np.squeeze(total_perez_mat), expected_total_perez_vec) # check that 2 dimensional assert np.shape(irradiance_mat) == (40, 1) # check faoi modifiers assert irr_model.faoi_back['direct'] == 0.97 assert irr_model.faoi_front['direct'] == 0.99 assert irr_model.faoi_ground == 0.8 # get absorbed sum of sky components irr_comp_absorbed = irr_model.get_summed_components(pvarray, absorbed=True) assert np.shape(irr_comp_absorbed) == (40, 1) # Check a ground surface value np.testing.assert_allclose( np.array(irr_comp_absorbed)[12, 0], (1. - params_irr['rho_ground']) * np.array(irradiance_mat)[12, 0])
def test_isotropic_model_back(params_irr): """Direct shading on back surface""" params_irr.update({'surface_azimuth': 270, 'surface_tilt': 160}) # 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_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_illum'][0], expected_dni_ground) np.testing.assert_almost_equal(irr_model.direct['back_illum_pvrow'][0], expected_dni_pvrow) assert irr_model.direct['front_illum_pvrow'][0] == 0. # Create, fit, and transform pv array pvarray = OrderedPVArray.fit_from_dict_of_scalars( params_irr, param_names=IsotropicOrdered.params) irr_model.transform(pvarray) # there should be some direct shading assert pvarray.ts_pvrows[0].back.shaded_length # Get modeling vectors irradiance_mat, rho_mat, invrho_mat, total_perez_mat = \ irr_model.get_ts_modeling_vectors(pvarray) # Check expected_irradiance_mat = [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 422.61826174, 0., 0., 707.10678119, 0., 0., 0., 707.10678119, 0., 0., 0., 707.10678119, 0. ] # pvrow np.testing.assert_almost_equal( pvarray.ts_pvrows[2].back.get_param_weighted('direct'), expected_dni_pvrow) np.testing.assert_almost_equal( pvarray.ts_pvrows[1].back.list_segments[0].illum.get_param_weighted( 'direct'), expected_dni_pvrow) np.testing.assert_almost_equal( pvarray.ts_pvrows[1].back.list_segments[0].shaded.get_param_weighted( 'direct'), 0.) np.testing.assert_almost_equal( pvarray.ts_pvrows[0].front.get_param_weighted('direct'), 0.) # ground np.testing.assert_almost_equal( pvarray.ts_ground.illum.get_param_weighted('direct'), expected_dni_ground) np.testing.assert_almost_equal( pvarray.ts_ground.shaded.get_param_weighted('direct'), 0.) np.testing.assert_array_almost_equal(expected_irradiance_mat, np.squeeze(irradiance_mat)) # Check invrho_mat expected_invrho_mat = [ 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 5., 100., 100., 33.33333333, 33.33333333, 100., 100., 33.33333333, 33.33333333, 100., 100., 33.33333333, 33.33333333 ] np.testing.assert_array_almost_equal(np.squeeze(invrho_mat), expected_invrho_mat) np.testing.assert_almost_equal( pvarray.ts_pvrows[0].front.get_param_weighted('rho'), params_irr['rho_front_pvrow']) np.testing.assert_almost_equal( pvarray.ts_pvrows[0].back.get_param_weighted('rho'), params_irr['rho_back_pvrow']) np.testing.assert_almost_equal(pvarray.ts_ground.get_param_weighted('rho'), params_irr['rho_ground']) # Check total perez vec expected_total_perez_mat = [ 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., 100., 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 522.61826174, 104.38724754, 104.38724754, 0., 0., 104.38724754, 104.38724754, 0., 0., 104.38724754, 104.38724754, 0., 0. ] np.testing.assert_array_almost_equal(np.squeeze(total_perez_mat), expected_total_perez_mat) # Get ts modeling matrices irradiance_mat, rho_mat, invrho_mat, total_perez_mat = \ irr_model.get_full_ts_modeling_vectors(pvarray) # check that 2 dimensional assert irradiance_mat.shape == (41, 1)