Skip to content

Commit

Permalink
need conditional axis selection for field renaming in tz_elev_check. …
Browse files Browse the repository at this point in the history
…single site vs dataframe
  • Loading branch information
bnb32 committed May 29, 2024
1 parent a8ab4c8 commit 51c12d8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
5 changes: 3 additions & 2 deletions reV/SAM/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
27 changes: 17 additions & 10 deletions tests/test_curtailment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@author: gbuster
"""

import os
from copy import deepcopy

Expand Down Expand Up @@ -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()
Expand All @@ -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):
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 51c12d8

Please sign in to comment.