Skip to content

Commit

Permalink
Add warnings if resource len is less than 8760
Browse files Browse the repository at this point in the history
  • Loading branch information
ppinchuk committed Jun 24, 2024
1 parent e92af3a commit 53702c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions reV/SAM/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ def check_resource_data(self, resource):
logger.error(msg)
raise InputError(msg)

if len(resource) < 8760:
msg = (f"Detected resource time series of length "
f"{len(resource)}, which is less than 8760. This may "
f"yeild unexpected results or fail altogether. If this "
f"is not intentional, try setting 'time_index_step: 1' "
f"in your SAM config")
logger.warning(msg)
warn(msg)

@abstractmethod
def set_resource_data(self, resource, meta):
"""Placeholder for resource data setting (nsrdb or wtk)"""
Expand Down Expand Up @@ -851,6 +860,8 @@ def set_resource_data(self, resource, meta):
time_index, resource.pop("albedo")
)

pd.DataFrame(resource).to_csv("/scratch/ppinchuk/test_pvwatts.csv", index=False)

self["solar_resource_data"] = resource


Expand Down
9 changes: 9 additions & 0 deletions reV/bespoke/bespoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,15 @@ def res_df(self):
ti_step = self.original_sam_sys_inputs["time_index_step"]
self._res_df = self._res_df.iloc[::ti_step]

if len(self._res_df) < 8760:
msg = (f"Detected resource time series of length "
f"{len(self._res_df)}, which is less than 8760. This may "
f"yeild unexpected results or fail altogether. If this "
f"is not intentional, try setting 'time_index_step: 1' "
f"in your SAM config")
logger.warning(msg)
warn(msg)

return self._res_df

@property
Expand Down

0 comments on commit 53702c0

Please sign in to comment.