Skip to content

Commit

Permalink
filter feature data for cloud flag if model isnt trained on this - in…
Browse files Browse the repository at this point in the history
… the case of cloud type prediction model
  • Loading branch information
bnb32 committed Aug 26, 2024
1 parent d856fb4 commit 21c5b6e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion nsrdb/gap_fill/mlclouds_fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,10 @@ def predict_cld_properties(
col_slice
)
)
predict_feats = feature_df[self.phygnn_model.feature_names]
predict_feats = set(feature_df.columns).intersection(
self.phygnn_model.input_feature_names
)
predict_feats = feature_df[list(predict_feats)]
if not low_mem:
labels = self.phygnn_model.predict(predict_feats, table=False)
else:
Expand Down
8 changes: 4 additions & 4 deletions nsrdb/nsrdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,10 +762,10 @@ def collect_data_model(
@classmethod
def collect_final(
cls,
collect_dir,
out_dir,
year,
grid,
collect_dir=None,
freq='5min',
var_meta=None,
i_fname=None,
Expand All @@ -777,15 +777,15 @@ def collect_final(
Parameters
----------
collect_dir : str
Directory with chunked files to be collected.
out_dir : str
Project directory.
year : int | str
Year of analysis
grid : str
Final/full NSRDB grid file. The first column must be the NSRDB
site gid's.
collect_dir : str
Directory with chunked files to be collected.
freq : str
Final desired NSRDB temporal frequency.
var_meta : str | pd.DataFrame | None
Expand All @@ -804,7 +804,7 @@ def collect_final(
Logging level (DEBUG, INFO). If None, no logging will be
initialized.
"""

collect_dir = collect_dir or os.path.join(out_dir, 'collect')
nsrdb = cls(out_dir, year, grid, freq=freq, var_meta=var_meta)
nsrdb._init_loggers(log_file=log_file, log_level=log_level)
ti = nsrdb._parse_data_model_output_ti(nsrdb._daily_dir, freq)
Expand Down
5 changes: 4 additions & 1 deletion nsrdb/utilities/sky_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ def add_validation_data(self, df):
"""Add NSRDB and SURFRAD ghi and dni data to a DataFrame."""
df = df.reindex(self.nsrdb_time_index)
assert len(df) == len(self.nsrdb_time_index)
ti_deltas = self.nsrdb_time_index - np.roll(self.nsrdb_time_index, 1)
ti_deltas = (
self.nsrdb_time_index.values[1:]
- self.nsrdb_time_index.values[:-1]
)
ti_deltas_minutes = pd.Series(ti_deltas).dt.seconds / 60
ti_delta_minutes = int(mode(ti_deltas_minutes)[0])
freq = '{}T'.format(ti_delta_minutes)
Expand Down

0 comments on commit 21c5b6e

Please sign in to comment.