diff --git a/reV/supply_curve/sc_aggregation.py b/reV/supply_curve/sc_aggregation.py index 59b297ba8..ef6274a02 100644 --- a/reV/supply_curve/sc_aggregation.py +++ b/reV/supply_curve/sc_aggregation.py @@ -784,7 +784,7 @@ def _check_data_layers( @staticmethod def _get_res_gen_lcoe_data( - gen, res_class_dset, res_class_bins, cf_dset, lcoe_dset + gen, res_class_dset, res_class_bins, lcoe_dset ): """Extract the basic resource / generation / lcoe data to be used in the aggregation process. @@ -800,8 +800,6 @@ def _get_res_gen_lcoe_data( res_class_bins : list | None List of two-entry lists dictating the resource class bins. None if no resource classes. - cf_dset : str - Dataset name from f_gen containing capacity factor mean values. lcoe_dset : str Dataset name from f_gen containing LCOE mean values. @@ -811,16 +809,14 @@ def _get_res_gen_lcoe_data( Extracted resource data from res_class_dset res_class_bins : list List of resouce class bin ranges. - cf_data : np.ndarray | None - Capacity factor data extracted from cf_dset in gen lcoe_data : np.ndarray | None LCOE data extracted from lcoe_dset in gen """ - dset_list = (res_class_dset, cf_dset, lcoe_dset) + dset_list = (res_class_dset, lcoe_dset) gen_dsets = [] if gen is None else gen.datasets - labels = ("res_class_dset", "cf_dset", "lcoe_dset") - temp = [None, None, None] + labels = ("res_class_dset", "lcoe_dset") + temp = [None, None] if isinstance(gen, Resource): source_fps = [gen.h5_file] @@ -847,12 +843,12 @@ def _get_res_gen_lcoe_data( logger.warning(w) warn(w, OutputWarning) - res_data, cf_data, lcoe_data = temp + res_data, lcoe_data = temp if res_class_dset is None or res_class_bins is None: res_class_bins = [None] - return res_data, res_class_bins, cf_data, lcoe_data + return res_data, res_class_bins, lcoe_data @staticmethod def _get_extra_dsets(gen, h5_dsets): @@ -1110,9 +1106,9 @@ def run_serial( excl_fpath, gen_fpath, **file_kwargs ) as fh: temp = cls._get_res_gen_lcoe_data( - fh.gen, res_class_dset, res_class_bins, cf_dset, lcoe_dset + fh.gen, res_class_dset, res_class_bins, lcoe_dset ) - res_data, res_class_bins, cf_data, lcoe_data = temp + res_data, res_class_bins, lcoe_data = temp h5_dsets_data = cls._get_extra_dsets(fh.gen, h5_dsets) n_finished = 0 @@ -1131,7 +1127,7 @@ def run_serial( gen_index, res_class_dset=res_data, res_class_bin=res_bin, - cf_dset=cf_data, + cf_dset=cf_dset, lcoe_dset=lcoe_data, h5_dsets=h5_dsets_data, data_layers=fh.data_layers, diff --git a/tests/test_supply_curve_sc_aggregation.py b/tests/test_supply_curve_sc_aggregation.py index 5d75ff769..78052a433 100644 --- a/tests/test_supply_curve_sc_aggregation.py +++ b/tests/test_supply_curve_sc_aggregation.py @@ -151,15 +151,22 @@ def test_agg_summary(): def test_agg_summary_solar_ac(pd): """Test the aggregation summary method for solar ac outputs.""" + with Outputs(GEN, "r") as out: + cf_means_dc = out["cf_mean-means"] + with tempfile.TemporaryDirectory() as td: gen = os.path.join(td, "gen.h5") shutil.copy(GEN, gen) Outputs.add_dataset( gen, "dc_ac_ratio", np.array([1.3] * 188), np.float32 ) + Outputs.add_dataset( + gen, "cf_mean_ac-means", cf_means_dc * 1.3, np.float32 + ) with Outputs(gen, "r") as out: assert "dc_ac_ratio" in out.datasets + assert "cf_mean_ac-means" in out.datasets sca = SupplyCurveAggregation( EXCL, @@ -173,8 +180,21 @@ def test_agg_summary_solar_ac(pd): summary = sca.summarize(gen, max_workers=1) assert SupplyCurveField.CAPACITY_AC_MW in summary + assert SupplyCurveField.CAPACITY_DC_MW in summary + assert SupplyCurveField.MEAN_CF_AC in summary + assert SupplyCurveField.MEAN_CF_DC in summary + + assert not summary[SupplyCurveField.CAPACITY_AC_MW].isna().any() + assert not summary[SupplyCurveField.CAPACITY_DC_MW].isna().any() + assert not summary[SupplyCurveField.MEAN_CF_AC].isna().any() + assert not summary[SupplyCurveField.MEAN_CF_DC].isna().any() + assert np.allclose(summary[SupplyCurveField.CAPACITY_DC_MW] / 1.3, summary[SupplyCurveField.CAPACITY_AC_MW]) + assert np.allclose(summary[SupplyCurveField.CAPACITY_DC_MW] + * summary[SupplyCurveField.MEAN_CF_DC], + summary[SupplyCurveField.CAPACITY_AC_MW] + * summary[SupplyCurveField.MEAN_CF_AC]) def test_multi_file_excl():