NREL/rex

Need an error message when missing a required sam variable

Closed this issue · 3 comments

Bug Description
See NREL/reV#369

Expected behavior
Error message that says "missing pressure from file: {}"

Are you thinking the error message would be thrown right before this?

return self._heights

Just a simple check to see if any of the heights are empty? Seems super easy if so, and I'd be happy to add it

Yeah that seems like a good place, probably also in the preload_SAM methods (there might be a few more):

if not downscale:
for var in SAM_res.var_list:
if var in self.datasets:
SAM_res[var] = self[var, time_slice, sites]

rex/rex/renewable_resource.py

Lines 1057 to 1060 in 1739240

if isinstance(h, (int, float)):
for var in var_list:
ds_name = "{}_{}m".format(var, h)
SAM_res[var] = self[ds_name, time_slice, sites]

So the preload_SAM methods should be covered with a message already:

rex/rex/resource.py

Lines 1247 to 1249 in 1739240

if ds_name not in self.datasets:
raise ResourceKeyError('{} not in {}'
.format(ds_name, self.datasets))

That should get raised when it tries self[var, time_slice, sites] with a var name that doesn't exists (i.e. pressure).

I will add a WindResource test to verify this behavior