Skip to content

Commit 095dc7b

Browse files
authored
Merge pull request #248 from NREL/gb/qa_fix
Gb/qa fix
2 parents e38597a + 1368951 commit 095dc7b

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

sup3r/qa/qa.py

+31-5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def __init__(
4949
t_enhance,
5050
temporal_coarsening_method,
5151
features=None,
52+
source_features=None,
5253
output_names=None,
5354
input_handler_name=None,
5455
input_handler_kwargs=None,
@@ -85,6 +86,17 @@ def __init__(
8586
Explicit list of features to validate. Can be a single feature str,
8687
list of string feature names, or None for all features found in the
8788
out_file_path.
89+
source_features : str | list | None
90+
Optional feature names to retrieve from the source dataset if the
91+
source feature names are not the same as the sup3r output feature
92+
names. These will be used to derive the features to be validated.
93+
e.g. If model output is temperature_2m, and these were derived from
94+
temperature_min_2m (and max), then source features should be
95+
temperature_min_2m and temperature_max_2m while the model output
96+
temperature_2m is aggregated using min/max in the
97+
temporal_coarsening_method. Another example is features="ghi",
98+
source_features="rsds", where this is a simple alternative name
99+
lookup.
88100
output_names : str | list
89101
Optional output file dataset names corresponding to the features
90102
list input
@@ -125,6 +137,11 @@ class for argument details.
125137
self._features = (
126138
features if isinstance(features, (list, tuple)) else [features]
127139
)
140+
self._source_features = (
141+
source_features
142+
if isinstance(source_features, (list, tuple))
143+
else [source_features]
144+
)
128145
self._out_names = (
129146
output_names
130147
if isinstance(output_names, (list, tuple))
@@ -198,6 +215,14 @@ def output_names(self):
198215
return self.features
199216
return self._out_names
200217

218+
@property
219+
def source_features(self):
220+
"""Get a list of source dataset names corresponding to the input source
221+
data """
222+
if self._source_features is None or self._source_features == [None]:
223+
return self.features
224+
return self._source_features
225+
201226
@property
202227
def output_type(self):
203228
"""Get output data type
@@ -451,16 +476,17 @@ def run(self):
451476
"""
452477

453478
errors = {}
454-
ziter = zip(self.features, self.output_names)
455-
for idf, (feature, dset_out) in enumerate(ziter):
479+
ziter = zip(self.features, self.source_features, self.output_names)
480+
for idf, (feature, source_feature, dset_out) in enumerate(ziter):
456481
logger.info(
457-
'Running QA on dataset {} of {} for "{}"'.format(
458-
idf + 1, len(self.features), feature
482+
'Running QA on dataset {} of {} for feature "{}" '
483+
'with source feature name "{}"'.format(
484+
idf + 1, len(self.features), feature, source_feature,
459485
)
460486
)
461487
data_syn = self.get_dset_out(feature)
462488
data_syn = self.coarsen_data(idf, feature, data_syn)
463-
data_true = self.input_handler[feature][...]
489+
data_true = self.input_handler[source_feature][...]
464490

465491
if data_syn.shape != data_true.shape:
466492
msg = (

sup3r/solar/solar.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ def preflight(self):
138138
assert 'surface_pressure' in self.nsrdb.dsets
139139
assert isinstance(self.nsrdb_tslice, slice)
140140

141-
ti_gan = self.gan_data.time_index
142-
delta = pd.Series(ti_gan[1:] - ti_gan[:-1]).mean().total_seconds()
141+
delta = pd.Series(self.time_index[1:] - self.time_index[:-1])
142+
delta = delta.mean().total_seconds()
143143
msg = (
144144
'Its assumed that the sup3r GAN output solar data will be '
145-
'hourly but received time index: {}'.format(ti_gan)
145+
'hourly but received time index: {}'.format(self.time_index)
146146
)
147147
assert delta == 3600, msg
148148

@@ -305,9 +305,8 @@ def ghi(self):
305305
"""
306306
if self._ghi is None:
307307
logger.debug('Calculating GHI.')
308-
self._ghi = (
309-
self.get_nsrdb_data('clearsky_ghi') * self.clearsky_ratio
310-
)
308+
nsrdb_cs_ghi = self.get_nsrdb_data('clearsky_ghi')
309+
self._ghi = nsrdb_cs_ghi * self.clearsky_ratio
311310
self._ghi[:, self.out_of_bounds] = 0
312311
return self._ghi
313312

sup3r/utilities/cli.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ def from_config(cls, module_name, module_class, ctx, config_file, verbose,
7373
cmd = module_class.get_node_cmd(config)
7474

7575
if hardware_option.lower() in AVAILABLE_HARDWARE_OPTIONS:
76-
cls.kickoff_slurm_job(module_name, ctx, pipeline_step, cmd,
76+
cls.kickoff_slurm_job(module_name, ctx, cmd,
77+
pipeline_step=pipeline_step,
7778
**exec_kwargs)
7879
else:
79-
cls.kickoff_local_job(module_name, ctx, cmd, pipeline_step)
80+
cls.kickoff_local_job(module_name, ctx, cmd,
81+
pipeline_step=pipeline_step)
8082

8183
@classmethod
8284
def from_config_preflight(cls, module_name, ctx, config_file, verbose):

0 commit comments

Comments
 (0)