From 51c12d801ad89a23d95132aeaf7f6a45e0ed2b13 Mon Sep 17 00:00:00 2001 From: "Brandon N. Benton" Date: Tue, 28 May 2024 20:20:01 -0600 Subject: [PATCH] need conditional axis selection for field renaming in tz_elev_check. single site vs dataframe --- reV/SAM/generation.py | 5 +++-- tests/test_curtailment.py | 27 +++++++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/reV/SAM/generation.py b/reV/SAM/generation.py index ee975ffed..d8eaf3f59 100644 --- a/reV/SAM/generation.py +++ b/reV/SAM/generation.py @@ -257,13 +257,14 @@ def tz_elev_check(sam_sys_inputs, site_sys_inputs, meta): Returns ------- meta : pd.DataFrame | pd.Series - Datafram or series for a single site. Will include "timezone" + Dataframe or series for a single site. Will include "timezone" and "elevation" from the sam and site system inputs if found. """ if meta is not None: + axis = 0 if isinstance(meta, pd.core.series.Series) else 1 meta = meta.rename( - SupplyCurveField.map_to(ResourceMetaField), axis=1 + SupplyCurveField.map_to(ResourceMetaField), axis=axis ) if sam_sys_inputs is not None: if ResourceMetaField.ELEVATION in sam_sys_inputs: diff --git a/tests/test_curtailment.py b/tests/test_curtailment.py index 57343fb06..51bc865ab 100644 --- a/tests/test_curtailment.py +++ b/tests/test_curtailment.py @@ -5,6 +5,7 @@ @author: gbuster """ + import os from copy import deepcopy @@ -63,10 +64,16 @@ def test_cf_curtailment(year, site): points = slice(site, site + 1) # run reV 2.0 generation - gen = Gen('windpower', points, sam_files, res_file, - output_request=('cf_profile',), - curtailment=curtailment, - sites_per_worker=50, scale_outputs=True) + gen = Gen( + "windpower", + points, + sam_files, + res_file, + output_request=("cf_profile",), + curtailment=curtailment, + sites_per_worker=50, + scale_outputs=True, + ) gen.run(max_workers=1) results, check_curtailment = test_res_curtailment(year, site=site) results["cf_profile"] = gen.out["cf_profile"].flatten() @@ -83,8 +90,6 @@ def test_cf_curtailment(year, site): ) assert np.sum(check) == 0, msg - return results - @pytest.mark.parametrize("year", ["2012", "2013"]) def test_curtailment_res_mean(year): @@ -200,8 +205,10 @@ def test_res_curtailment(year, site): sza = SolarPosition( non_curtailed_res.time_index, - non_curtailed_res.meta[[ResourceMetaField.LATITUDE, - ResourceMetaField.LONGITUDE]].values).zenith + non_curtailed_res.meta[ + [ResourceMetaField.LATITUDE, ResourceMetaField.LONGITUDE] + ].values, + ).zenith ti = non_curtailed_res.time_index @@ -285,8 +292,8 @@ def test_eqn_curtailment(plot=False): nc_res = non_curtailed_res[0] c_mask = (c_res.windspeed == 0) & (nc_res.windspeed > 0) - temperature = nc_res['temperature'].values - wind_speed = nc_res['windspeed'].values + temperature = nc_res["temperature"].values + wind_speed = nc_res["windspeed"].values eval_mask = eval(c_eqn)