class TestLongTermGrossEnergyUQ(unittest.TestCase): def setUp(self): np.random.seed(42) # Set up data to use for testing (TurbineExampleProject) self.project = Project_Engie('./examples/data/la_haute_borne') self.project.prepare() self.analysis_uq = TurbineLongTermGrossEnergy(self.project, UQ=True, num_sim=5) self.analysis_uq.run(enable_plotting=False, reanal_subset=['era5', 'merra2']) def test_longterm_gross_energy_results(self): # Test UQ case, mean value res_uq = self.analysis_uq._plant_gross.mean() check_uq = 13.7 npt.assert_almost_equal(res_uq / 1e6, check_uq, decimal=1) # Test UQ case, stdev res_std_uq = self.analysis_uq._plant_gross.std() check_std_uq = 0.10 npt.assert_almost_equal(res_std_uq / 1e6, check_std_uq, decimal=1) def tearDown(self): pass
class TestElectricalLosses(unittest.TestCase): def setUp(self): np.random.seed(42) # Set up data to use for testing (ENGIE data) self.project = Project_Engie('./examples/data/la_haute_borne') self.project.prepare() # Create electrical loss method object and run # NO UQ case self.analysis = ElectricalLosses(self.project, UQ=False) self.analysis.run(uncertainty_correction_thresh=0.95) def test_electrical_losses_results(self): # Check that the computed electrical loss means and their std are as expected expected_losses = 0.02 expected_losses_std = 0 actual_compiled_data = self.analysis._electrical_losses.mean() actual_compiled_data_std = self.analysis._electrical_losses.std() npt.assert_array_almost_equal(expected_losses, actual_compiled_data, decimal=3) npt.assert_array_almost_equal(expected_losses_std, actual_compiled_data_std, decimal=3) def tearDown(self): pass
class TestElectricalLossesUQ(unittest.TestCase): def setUp(self): np.random.seed(42) # Set up data to use for testing (ENGIE data) self.project = Project_Engie('./examples/data/la_haute_borne') self.project.prepare() # Create electrical loss method object and run # WITH UQ self.analysis_uq = ElectricalLosses(self.project, UQ=True, num_sim=3000) self.analysis_uq.run(uncertainty_correction_thresh=(0.9, 0.995)) def test_electrical_losses_results(self): # Check that the computed electrical loss means and their std are as expected expected_losses_uq = 0.02 expected_losses_uq_std = 0.0069 actual_compiled_data_uq = self.analysis_uq._electrical_losses.mean() actual_compiled_data_uq_std = self.analysis_uq._electrical_losses.std() npt.assert_array_almost_equal(expected_losses_uq, actual_compiled_data_uq, decimal=3) npt.assert_array_almost_equal(expected_losses_uq_std, actual_compiled_data_uq_std, decimal=3) def tearDown(self): pass
def setUp(self): np.random.seed(42) # Set up data to use for testing (ENGIE data) self.project = Project_Engie('./examples/data/la_haute_borne') self.project.prepare() # Create electrical loss method object and run # NO UQ case self.analysis = ElectricalLosses(self.project, UQ=False) self.analysis.run(uncertainty_correction_thresh=0.95)
def setUp(self): np.random.seed(42) # Set up data to use for testing (TurbineExampleProject) self.project = Project_Engie('./examples/data/la_haute_borne') self.project.prepare() self.analysis_uq = TurbineLongTermGrossEnergy(self.project, UQ=True, num_sim=5) self.analysis_uq.run(enable_plotting=False, reanal_subset=['era5', 'merra2'])
def setUp(self): np.random.seed(42) # Set up data to use for testing (ENGIE data) self.project = Project_Engie('./examples/data/la_haute_borne') self.project.prepare() # Create electrical loss method object and run # WITH UQ self.analysis_uq = ElectricalLosses(self.project, UQ=True, num_sim=3000) self.analysis_uq.run(uncertainty_correction_thresh=(0.9, 0.995))
def setUp(self): np.random.seed(42) # Set up data to use for testing (ENGIE data) self.project = Project_Engie('./examples/data/la_haute_borne') self.project.prepare() self.analysis = TurbineLongTermGrossEnergy(self.project, UQ=False) self.analysis.run(reanal_subset=['era5', 'merra2'], max_power_filter=0.85, wind_bin_thresh=1., correction_threshold=0.9, enable_plotting=False)
class TestLongTermGrossEnergy(unittest.TestCase): def setUp(self): np.random.seed(42) # Set up data to use for testing (ENGIE data) self.project = Project_Engie('./examples/data/la_haute_borne') self.project.prepare() self.analysis = TurbineLongTermGrossEnergy(self.project, UQ=False) self.analysis.run(reanal_subset=['era5', 'merra2'], max_power_filter=0.85, wind_bin_thresh=1., correction_threshold=0.9, enable_plotting=False) def test_longterm_gross_energy_results(self): # Test not-UQ case res = self.analysis._plant_gross check = np.ones_like(res) * 13.7 npt.assert_almost_equal(res / 1e6, check, decimal=1) def tearDown(self): pass
def setUp(self): reset_prng() # Set up data to use for testing (ENGIE example plant) self.project = Project_Engie("./examples/data/la_haute_borne") self.project.prepare()
class TestPandasPrufPlantAnalysis(unittest.TestCase): def setUp(self): reset_prng() # Set up data to use for testing (ENGIE example plant) self.project = Project_Engie("./examples/data/la_haute_borne") self.project.prepare() # Test inputs to the regression model, at monthly time resolution def test_monthly_inputs(self): reset_prng() # ____________________________________________________________________ # Test inputs to the regression model, at monthly time resolution self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=["merra2", "era5"], time_resolution="M", reg_temperature=True, reg_winddirection=True, ) df = self.analysis._aggregate.df # Check the pre-processing functions self.check_process_revenue_meter_energy_monthly(df) self.check_process_loss_estimates_monthly(df) self.check_process_reanalysis_data_monthly(df) def test_monthly_lin(self): reset_prng() # ____________________________________________________________________ # Test linear regression model, at monthly time resolution self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=["merra2", "era5"], time_resolution="M", reg_model="lin", reg_temperature=False, reg_winddirection=False, ) # Run Monte Carlo AEP analysis, confirm the results are consistent self.analysis.run(num_sim=10) sim_results = self.analysis.results self.check_simulation_results_lin_monthly(sim_results) # Test inputs to the regression model, at daily time resolution def test_daily_inputs(self): reset_prng() # ____________________________________________________________________ # Test inputs to the regression model, at monthly time resolution self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=["merra2", "era5"], time_resolution="D", reg_temperature=True, reg_winddirection=True, ) df = self.analysis._aggregate.df # Check the pre-processing functions self.check_process_revenue_meter_energy_daily(df) self.check_process_loss_estimates_daily(df) self.check_process_reanalysis_data_daily(df) def test_daily_gam(self): reset_prng() # ____________________________________________________________________ # Test GAM regression model (can be used at daily time resolution only) self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=["merra2", "era5"], time_resolution="D", reg_model="gam", reg_temperature=True, reg_winddirection=True, ) # Run Monte Carlo AEP analysis, confirm the results are consistent self.analysis.run(num_sim=5) sim_results = self.analysis.results self.check_simulation_results_gam_daily(sim_results) def test_daily_gbm(self): reset_prng() # ____________________________________________________________________ # Test GBM regression model (can be used at daily time resolution only) self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=["era5"], time_resolution="D", reg_model="gbm", reg_temperature=True, reg_winddirection=False, ) # Run Monte Carlo AEP analysis, confirm the results are consistent self.analysis.run(num_sim=5) sim_results = self.analysis.results self.check_simulation_results_gbm_daily(sim_results) def test_daily_etr(self): reset_prng() # ____________________________________________________________________ # Test ETR regression model (can be used at daily time resolution only) self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=["merra2"], time_resolution="D", reg_model="etr", reg_temperature=False, reg_winddirection=False, ) # Run Monte Carlo AEP analysis, confirm the results are consistent self.analysis.run(num_sim=5) sim_results = self.analysis.results self.check_simulation_results_etr_daily(sim_results) def check_process_revenue_meter_energy_monthly(self, df): # Energy Nan flags are all zero nptest.assert_array_equal(df["energy_nan_perc"].values, np.repeat(0.0, df.shape[0])) # Expected number of days per month are equal to number of actual days nptest.assert_array_equal(df["num_days_expected"], df["num_days_actual"]) # Check a few energy values expected_gwh = pd.Series([0.692400, 1.471730, 0.580035]) actual_gwh = df.loc[ pd.to_datetime(["2014-06-01", "2014-12-01", "2015-10-01"]), "energy_gwh" ] nptest.assert_array_almost_equal(expected_gwh, actual_gwh) def check_process_loss_estimates_monthly(self, df): # Availablity, curtailment nan fields both 0, NaN flag is all False nptest.assert_array_equal(df["avail_nan_perc"].values, np.repeat(0.0, df.shape[0])) nptest.assert_array_equal(df["curt_nan_perc"].values, np.repeat(0.0, df.shape[0])) nptest.assert_array_equal(df["nan_flag"].values, np.repeat(False, df.shape[0])) # Check a few reported availabilty and curtailment values expected_avail_gwh = pd.Series([0.029417, 0.021005, 0.000444]) expected_curt_gwh = pd.Series([0.013250, 0.000000, 0.000000]) expected_avail_pct = pd.Series([0.040019, 0.014071, 0.000765]) expected_curt_pct = pd.Series([0.018026, 0.000000, 0.000000]) date_ind = pd.to_datetime(["2014-06-01", "2014-12-01", "2015-10-01"]) nptest.assert_array_almost_equal(expected_avail_gwh, df.loc[date_ind, "availability_gwh"]) nptest.assert_array_almost_equal(expected_curt_gwh, df.loc[date_ind, "curtailment_gwh"]) nptest.assert_array_almost_equal(expected_avail_pct, df.loc[date_ind, "availability_pct"]) nptest.assert_array_almost_equal(expected_curt_pct, df.loc[date_ind, "curtailment_pct"]) def check_process_reanalysis_data_monthly(self, df): expected = { "merra2": [5.42523278, 6.86883337, 5.02690892], "era5": [5.20508049, 6.71586744, 5.23824611], "merra2_wd": [11.74700241, 250.90081133, 123.70142025], "era5_wd": [23.4291153, 253.14150601, 121.25886916], "merra2_temperature_K": [289.87128364, 275.26493716, 281.72562887], "era5_temperature_K": [290.82110632, 276.62490053, 282.71629935], } date_ind = pd.to_datetime(["2014-06-01", "2014-12-01", "2015-10-01"]) computed = {key: df.loc[date_ind, key].to_numpy() for key in expected.keys()} print(computed) for key in expected.keys(): nptest.assert_array_almost_equal(expected[key], computed[key]) def check_process_revenue_meter_energy_daily(self, df): # Energy Nan flags are all zero nptest.assert_array_equal(df["energy_nan_perc"].values, np.repeat(0.0, df.shape[0])) # Check a few energy values expected_gwh = pd.Series([0.0848525, 0.0253657, 0.0668642]) actual_gwh = df.loc[ pd.to_datetime(["2014-01-02", "2014-10-12", "2015-12-28"]), "energy_gwh" ] nptest.assert_array_almost_equal(expected_gwh, actual_gwh) def check_process_loss_estimates_daily(self, df): # Availablity, curtailment nan fields both 0, NaN flag is all False nptest.assert_array_equal(df["avail_nan_perc"].values, np.repeat(0.0, df.shape[0])) nptest.assert_array_equal(df["curt_nan_perc"].values, np.repeat(0.0, df.shape[0])) nptest.assert_array_equal(df["nan_flag"].values, np.repeat(False, df.shape[0])) # Check a few reported availabilty and curtailment values expected_avail_gwh = pd.Series([0.0000483644, 0.000000, 0.000000]) expected_curt_gwh = pd.Series([0.000000, 0.00019581, 0.000000]) expected_avail_pct = pd.Series([0.000569658, 0.000000, 0.000000]) expected_curt_pct = pd.Series([0.000000, 0.00766034, 0.000000]) date_ind = pd.to_datetime(["2014-01-02", "2014-10-12", "2015-12-28"]) nptest.assert_array_almost_equal(expected_avail_gwh, df.loc[date_ind, "availability_gwh"]) nptest.assert_array_almost_equal(expected_curt_gwh, df.loc[date_ind, "curtailment_gwh"]) nptest.assert_array_almost_equal(expected_avail_pct, df.loc[date_ind, "availability_pct"]) nptest.assert_array_almost_equal(expected_curt_pct, df.loc[date_ind, "curtailment_pct"]) def check_process_reanalysis_data_daily(self, df): expected = { "merra2": np.array([11.02459231, 7.04306896, 8.41880152]), "era5": np.array([10.47942319, 7.71069617, 9.60864791]), "merra2_wd": np.array([213.81683361, 129.08053181, 170.39815032]), "era5_wd": np.array([212.23854097, 127.75317448, 170.33488958]), "merra2_temperature_K": np.array([279.67922333, 285.69317833, 278.15574917]), "era5_temperature_K": np.array([281.14880642, 285.81961816, 280.42017656]), } date_ind = pd.to_datetime(["2014-01-02", "2014-10-12", "2015-12-28"]) computed = {key: df.loc[date_ind, key].to_numpy() for key in expected.keys()} print(computed) for key in expected.keys(): nptest.assert_array_almost_equal(expected[key], computed[key]) def check_simulation_results_lin_monthly(self, s): # Make sure AEP results are consistent to one decimal place expected_results = [11.401602, 9.789065, 1.131574, 4.766565, 0.059858, 4.847703] calculated_results = [ s.aep_GWh.mean(), s.aep_GWh.std() / s.aep_GWh.mean() * 100, s.avail_pct.mean() * 100, s.avail_pct.std() / s.avail_pct.mean() * 100, s.curt_pct.mean() * 100, s.curt_pct.std() / s.curt_pct.mean() * 100, ] nptest.assert_array_almost_equal(expected_results, calculated_results) def check_simulation_results_gam_daily(self, s): # Make sure AEP results are consistent to one decimal place expected_results = [12.807144, 3.959101, 1.320519, 6.294529, 0.049507, 8.152235] calculated_results = [ s.aep_GWh.mean(), s.aep_GWh.std() / s.aep_GWh.mean() * 100, s.avail_pct.mean() * 100, s.avail_pct.std() / s.avail_pct.mean() * 100, s.curt_pct.mean() * 100, s.curt_pct.std() / s.curt_pct.mean() * 100, ] nptest.assert_array_almost_equal(expected_results, calculated_results) def check_simulation_results_gbm_daily(self, s): # Make sure AEP results are consistent to one decimal place expected_results = [12.794527, 10.609839, 1.298789, 4.849577, 0.050383, 8.620032] calculated_results = [ s.aep_GWh.mean(), s.aep_GWh.std() / s.aep_GWh.mean() * 100, s.avail_pct.mean() * 100, s.avail_pct.std() / s.avail_pct.mean() * 100, s.curt_pct.mean() * 100, s.curt_pct.std() / s.curt_pct.mean() * 100, ] nptest.assert_array_almost_equal(expected_results, calculated_results) def check_simulation_results_etr_daily(self, s): # Make sure AEP results are consistent to one decimal place expected_results = [12.938536, 8.561798, 1.334704, 5.336189, 0.057874, 11.339976] calculated_results = [ s.aep_GWh.mean(), s.aep_GWh.std() / s.aep_GWh.mean() * 100, s.avail_pct.mean() * 100, s.avail_pct.std() / s.avail_pct.mean() * 100, s.curt_pct.mean() * 100, s.curt_pct.std() / s.curt_pct.mean() * 100, ] nptest.assert_array_almost_equal(expected_results, calculated_results) def tearDown(self): pass
class TestPandasPrufPlantAnalysis(unittest.TestCase): def setUp(self): np.random.seed(42) # Set up data to use for testing (ENGIE example plant) self.project = Project_Engie('./examples/data/la_haute_borne') self.project.prepare() # Test inputs to the regression model, at monthly time resolution def test_plant_analysis(self): # ____________________________________________________________________ # Test inputs to the regression model, at monthly time resolution self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=['merra2', 'era5'], time_resolution='M', reg_temperature=True, reg_winddirection=True) df = self.analysis._aggregate.df # Check the pre-processing functions self.check_process_revenue_meter_energy_monthly(df) self.check_process_loss_estimates_monthly(df) self.check_process_reanalysis_data_monthly(df) # ____________________________________________________________________ # Test inputs to the regression model, at daily time resolution self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=['merra2', 'era5'], time_resolution='D', reg_temperature=True, reg_winddirection=True) df = self.analysis._aggregate.df # Check the pre-processing functions self.check_process_revenue_meter_energy_daily(df) self.check_process_loss_estimates_daily(df) self.check_process_reanalysis_data_daily(df) # ____________________________________________________________________ # Test linear regression model, at monthly time resolution self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=['merra2', 'era5'], time_resolution='M', reg_model='lin', reg_temperature=False, reg_winddirection=False) # Run Monte Carlo AEP analysis, confirm the results are consistent self.analysis.run(num_sim=30) sim_results = self.analysis.results self.check_simulation_results_lin_monthly(sim_results) # ____________________________________________________________________ # Test linear regression model, at daily time resolution self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=['merra2', 'era5'], time_resolution='D', reg_model='lin', reg_temperature=False, reg_winddirection=False) # Run Monte Carlo AEP analysis, confirm the results are consistent self.analysis.run(num_sim=30) sim_results = self.analysis.results self.check_simulation_results_lin_daily(sim_results) # ____________________________________________________________________ # Test GAM regression model (can be used at daily time resolution only) self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=['merra2', 'era5'], time_resolution='D', reg_model='gam', reg_temperature=False, reg_winddirection=True) # Run Monte Carlo AEP analysis, confirm the results are consistent self.analysis.run(num_sim=10) sim_results = self.analysis.results self.check_simulation_results_gam_daily(sim_results) # ____________________________________________________________________ # Test GBM regression model (can be used at daily time resolution only) self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=['merra2', 'era5'], time_resolution='D', reg_model='gbm', reg_temperature=True, reg_winddirection=True) # Run Monte Carlo AEP analysis, confirm the results are consistent self.analysis.run(num_sim=10) sim_results = self.analysis.results self.check_simulation_results_gbm_daily(sim_results) # ____________________________________________________________________ # Test ETR regression model (can be used at daily time resolution only) self.analysis = plant_analysis.MonteCarloAEP( self.project, reanal_products=['merra2', 'era5'], time_resolution='D', reg_model='etr', reg_temperature=False, reg_winddirection=False) # Run Monte Carlo AEP analysis, confirm the results are consistent self.analysis.run(num_sim=10) sim_results = self.analysis.results self.check_simulation_results_etr_daily(sim_results) def check_process_revenue_meter_energy_monthly(self, df): # Energy Nan flags are all zero nptest.assert_array_equal(df['energy_nan_perc'].values, np.repeat(0.0, df.shape[0])) # Expected number of days per month are equal to number of actual days nptest.assert_array_equal(df['num_days_expected'], df['num_days_actual']) # Check a few energy values expected_gwh = pd.Series([0.692400, 1.471730, 0.580035]) actual_gwh = df.loc[ pd.to_datetime(['2014-06-01', '2014-12-01', '2015-10-01']), 'energy_gwh'] nptest.assert_array_almost_equal(expected_gwh, actual_gwh) def check_process_loss_estimates_monthly(self, df): # Availablity, curtailment nan fields both 0, NaN flag is all False nptest.assert_array_equal(df['avail_nan_perc'].values, np.repeat(0.0, df.shape[0])) nptest.assert_array_equal(df['curt_nan_perc'].values, np.repeat(0.0, df.shape[0])) nptest.assert_array_equal(df['nan_flag'].values, np.repeat(False, df.shape[0])) # Check a few reported availabilty and curtailment values expected_avail_gwh = pd.Series([0.029417, 0.021005, 0.000444]) expected_curt_gwh = pd.Series([0.013250, 0.000000, 0.000000]) expected_avail_pct = pd.Series([0.040019, 0.014071, 0.000765]) expected_curt_pct = pd.Series([0.018026, 0.000000, 0.000000]) date_ind = pd.to_datetime(['2014-06-01', '2014-12-01', '2015-10-01']) nptest.assert_array_almost_equal(expected_avail_gwh, df.loc[date_ind, 'availability_gwh']) nptest.assert_array_almost_equal(expected_curt_gwh, df.loc[date_ind, 'curtailment_gwh']) nptest.assert_array_almost_equal(expected_avail_pct, df.loc[date_ind, 'availability_pct']) nptest.assert_array_almost_equal(expected_curt_pct, df.loc[date_ind, 'curtailment_pct']) def check_process_reanalysis_data_monthly(self, df): # Check a few wind speed values expected_merra2 = pd.Series([5.43, 6.87, 5.03]) expected_era5 = pd.Series([5.21, 6.72, 5.24]) date_ind = pd.to_datetime(['2014-06-01', '2014-12-01', '2015-10-01']) nptest.assert_array_almost_equal(expected_merra2, df.loc[date_ind, 'merra2'], decimal=2) nptest.assert_array_almost_equal(expected_era5, df.loc[date_ind, 'era5'], decimal=2) # Check a few wind direction values expected_merra2_wd = pd.Series([11.7, 250.9, 123.7]) expected_era5_wd = pd.Series([23.4, 253.1, 121.3]) date_ind = pd.to_datetime(['2014-06-01', '2014-12-01', '2015-10-01']) nptest.assert_array_almost_equal(expected_merra2_wd * 2 * np.pi / 360, df.loc[date_ind, 'merra2_wd'], decimal=1) nptest.assert_array_almost_equal(expected_era5_wd * 2 * np.pi / 360, df.loc[date_ind, 'era5_wd'], decimal=1) # Check a few temperature values expected_merra2_temp = pd.Series([289.9, 275.3, 281.7]) expected_era5_temp = pd.Series([290.8, 276.6, 282.7]) date_ind = pd.to_datetime(['2014-06-01', '2014-12-01', '2015-10-01']) nptest.assert_array_almost_equal(expected_merra2_temp, df.loc[date_ind, 'merra2_temperature_K'], decimal=1) nptest.assert_array_almost_equal(expected_era5_temp, df.loc[date_ind, 'era5_temperature_K'], decimal=1) def check_process_revenue_meter_energy_daily(self, df): # Energy Nan flags are all zero nptest.assert_array_equal(df['energy_nan_perc'].values, np.repeat(0.0, df.shape[0])) # Check a few energy values expected_gwh = pd.Series([0.0848525, 0.0253657, 0.0668642]) actual_gwh = df.loc[ pd.to_datetime(['2014-01-02', '2014-10-12', '2015-12-28']), 'energy_gwh'] nptest.assert_array_almost_equal(expected_gwh, actual_gwh) def check_process_loss_estimates_daily(self, df): # Availablity, curtailment nan fields both 0, NaN flag is all False nptest.assert_array_equal(df['avail_nan_perc'].values, np.repeat(0.0, df.shape[0])) nptest.assert_array_equal(df['curt_nan_perc'].values, np.repeat(0.0, df.shape[0])) nptest.assert_array_equal(df['nan_flag'].values, np.repeat(False, df.shape[0])) # Check a few reported availabilty and curtailment values expected_avail_gwh = pd.Series([0.0000483644, 0.000000, 0.000000]) expected_curt_gwh = pd.Series([0.000000, 0.00019581, 0.000000]) expected_avail_pct = pd.Series([0.000569658, 0.000000, 0.000000]) expected_curt_pct = pd.Series([0.000000, 0.00766034, 0.000000]) date_ind = pd.to_datetime(['2014-01-02', '2014-10-12', '2015-12-28']) nptest.assert_array_almost_equal(expected_avail_gwh, df.loc[date_ind, 'availability_gwh']) nptest.assert_array_almost_equal(expected_curt_gwh, df.loc[date_ind, 'curtailment_gwh']) nptest.assert_array_almost_equal(expected_avail_pct, df.loc[date_ind, 'availability_pct']) nptest.assert_array_almost_equal(expected_curt_pct, df.loc[date_ind, 'curtailment_pct']) def check_process_reanalysis_data_daily(self, df): # Check a few wind speed values expected_merra2 = pd.Series([11.02, 7.04, 8.42]) expected_era5 = pd.Series([10.48, 7.71, 9.61]) date_ind = pd.to_datetime(['2014-01-02', '2014-10-12', '2015-12-28']) nptest.assert_array_almost_equal(expected_merra2, df.loc[date_ind, 'merra2'], decimal=2) nptest.assert_array_almost_equal(expected_era5, df.loc[date_ind, 'era5'], decimal=2) # Check a few wind direction values expected_merra2_wd = pd.Series([213.8, 129.1, 170.4]) expected_era5_wd = pd.Series([212.2, 127.8, 170.3]) date_ind = pd.to_datetime(['2014-01-02', '2014-10-12', '2015-12-28']) nptest.assert_array_almost_equal(expected_merra2_wd * 2 * np.pi / 360, df.loc[date_ind, 'merra2_wd'], decimal=1) nptest.assert_array_almost_equal(expected_era5_wd * 2 * np.pi / 360, df.loc[date_ind, 'era5_wd'], decimal=1) # Check a few temperature values expected_merra2_temp = pd.Series([279.7, 285.7, 278.2]) expected_era5_temp = pd.Series([281.1, 285.8, 280.4]) date_ind = pd.to_datetime(['2014-01-02', '2014-10-12', '2015-12-28']) nptest.assert_array_almost_equal(expected_merra2_temp, df.loc[date_ind, 'merra2_temperature_K'], decimal=1) nptest.assert_array_almost_equal(expected_era5_temp, df.loc[date_ind, 'era5_temperature_K'], decimal=1) def check_simulation_results_lin_monthly(self, s): # Make sure AEP results are consistent to one decimal place expected_results = [12.41, 8.29, 1.30, 3.57, 0.09, 3.57] calculated_results = [ s.aep_GWh.mean(), s.aep_GWh.std() / s.aep_GWh.mean() * 100, s.avail_pct.mean() * 100, s.avail_pct.std() / s.avail_pct.mean() * 100, s.curt_pct.mean() * 100, s.curt_pct.std() / s.curt_pct.mean() * 100, ] nptest.assert_array_almost_equal(expected_results, calculated_results, decimal=0) def check_simulation_results_lin_daily(self, s): # Make sure AEP results are consistent to one decimal place expected_results = [12.31, 4.76, 1.36, 4.90, 0.09, 4.91] calculated_results = [ s.aep_GWh.mean(), s.aep_GWh.std() / s.aep_GWh.mean() * 100, s.avail_pct.mean() * 100, s.avail_pct.std() / s.avail_pct.mean() * 100, s.curt_pct.mean() * 100, s.curt_pct.std() / s.curt_pct.mean() * 100, ] nptest.assert_array_almost_equal(expected_results, calculated_results, decimal=0) def check_simulation_results_gam_daily(self, s): # Make sure AEP results are consistent to one decimal place expected_results = [12.68, 4.50, 1.36, 4.44, 0.087, 4.44] calculated_results = [ s.aep_GWh.mean(), s.aep_GWh.std() / s.aep_GWh.mean() * 100, s.avail_pct.mean() * 100, s.avail_pct.std() / s.avail_pct.mean() * 100, s.curt_pct.mean() * 100, s.curt_pct.std() / s.curt_pct.mean() * 100, ] nptest.assert_array_almost_equal(expected_results, calculated_results, decimal=-1) def check_simulation_results_gbm_daily(self, s): # Make sure AEP results are consistent to one decimal place expected_results = [12.82, 3.84, 1.35, 5.17, 0.09, 5.17] calculated_results = [ s.aep_GWh.mean(), s.aep_GWh.std() / s.aep_GWh.mean() * 100, s.avail_pct.mean() * 100, s.avail_pct.std() / s.avail_pct.mean() * 100, s.curt_pct.mean() * 100, s.curt_pct.std() / s.curt_pct.mean() * 100, ] nptest.assert_array_almost_equal(expected_results, calculated_results, decimal=-1) def check_simulation_results_etr_daily(self, s): # Make sure AEP results are consistent to one decimal place expected_results = [12.56, 3.99, 1.35, 5.10, 0.09, 5.10] calculated_results = [ s.aep_GWh.mean(), s.aep_GWh.std() / s.aep_GWh.mean() * 100, s.avail_pct.mean() * 100, s.avail_pct.std() / s.avail_pct.mean() * 100, s.curt_pct.mean() * 100, s.curt_pct.std() / s.curt_pct.mean() * 100, ] nptest.assert_array_almost_equal(expected_results, calculated_results, decimal=-1) def tearDown(self): pass
def setUp(self): np.random.seed(42) # Set up data to use for testing (ENGIE example plant) self.project = Project_Engie('./examples/data/la_haute_borne') self.project.prepare()