Skip to content

Commit

Permalink
some enum class methods for mapping between sc fields, res fields, an…
Browse files Browse the repository at this point in the history
…d site fields. Dictionary of "old" names used to rename test data to match current sc names. bespoke tests mostly passing.
  • Loading branch information
bnb32 committed May 28, 2024
1 parent 4866bca commit 49da781
Show file tree
Hide file tree
Showing 7 changed files with 669 additions and 388 deletions.
17 changes: 10 additions & 7 deletions reV/SAM/SAM.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
)
from rex.utilities.utilities import check_res_file

from reV.utilities import ResourceMetaField
from reV.utilities.exceptions import (
ResourceError,
SAMExecutionError,
Expand Down Expand Up @@ -713,7 +714,7 @@ def ensure_res_len(arr, time_index):

freq = pd.infer_freq(time_index[:s])
msg = "frequencies do not match before and after 2/29"
assert freq == pd.infer_freq(time_index[s + 1:]), msg
assert freq == pd.infer_freq(time_index[s + 1 :]), msg
else:
freq = pd.infer_freq(time_index)
else:
Expand Down Expand Up @@ -796,11 +797,10 @@ def _parse_meta(meta):
location. Should include values for latitude, longitude, elevation,
and timezone. Can be None for econ runs.
"""

if isinstance(meta, pd.DataFrame):
msg = (
"Meta data must only be for a single site but received: {}"
.format(meta)
"Meta data must only be for a single site but received: "
f"{meta}"
)
assert len(meta) == 1, msg
meta = meta.iloc[0]
Expand Down Expand Up @@ -861,7 +861,9 @@ def outputs_to_utc_arr(self):

if self._is_hourly(output):
n_roll = int(
-1 * self.meta["timezone"] * self.time_interval
-1
* self.meta[ResourceMetaField.TIMEZONE]
* self.time_interval
)
output = np.roll(output, n_roll)

Expand Down Expand Up @@ -889,8 +891,9 @@ def collect_outputs(self, output_lookup):
bad_requests.append(req)

if any(bad_requests):
msg = ('Could not retrieve outputs "{}" from PySAM object "{}".'
.format(bad_requests, self.pysam))
msg = 'Could not retrieve outputs "{}" from PySAM object "{}".'.format(
bad_requests, self.pysam
)
logger.error(msg)
raise SAMExecutionError(msg)

Expand Down
Loading

0 comments on commit 49da781

Please sign in to comment.