From b8b14e5c2f5508e16b87ebf5075ca523f9e7eb80 Mon Sep 17 00:00:00 2001 From: Darryl Melander Date: Wed, 21 Apr 2021 14:34:46 -0600 Subject: [PATCH] Fixes for rts-gmlc data sources --- prescient/data/providers/gmlc_data_provider.py | 6 +++--- prescient/engine/egret/data_extractors.py | 16 +++++++++++----- prescient/engine/forecast_helper.py | 3 ++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/prescient/data/providers/gmlc_data_provider.py b/prescient/data/providers/gmlc_data_provider.py index bea12304..a45dcc67 100644 --- a/prescient/data/providers/gmlc_data_provider.py +++ b/prescient/data/providers/gmlc_data_provider.py @@ -192,13 +192,13 @@ def _populate_with_forecastable_data(self, self._cache.populate_skeleton_with_data(model.data, sim_type, start_time, end_time) else: copy_from = self._cache.generate_model(sim_type, start_time, end_time) - self._recurse_copy_at_ratio(copy_from.data, model.data, step_ratio) + _recurse_copy_at_ratio(copy_from.data, model.data, step_ratio) # Fill in the times time_labels = model.data['system']['time_keys'] delta = timedelta(minutes=time_period_length_minutes) for i in range(len(time_labels)): - dt = start_date + i*delta - time_labels[t] = dt.strftime('%Y-%m-%d %H:%M') + dt = start_time + i*delta + time_labels[i] = dt.strftime('%Y-%m-%d %H:%M') def _recurse_copy_at_ratio(src:dict[str, Any], target:dict[str, Any], ratio:int) -> None: ''' Copy every Nth value from a src dict's time_series values into corresponding arrays in a target dict. diff --git a/prescient/engine/egret/data_extractors.py b/prescient/engine/egret/data_extractors.py index 1385be35..f59ced01 100644 --- a/prescient/engine/egret/data_extractors.py +++ b/prescient/engine/egret/data_extractors.py @@ -113,13 +113,19 @@ def get_max_power_output(self, sced: OperationsModel, g: G) -> float: return p_max def get_max_power_available(self, sced: OperationsModel, g: G) -> float: - return sced.data['elements']['generator'][g]['headroom']['values'][0] \ - + self.get_power_generated(sced, g)*int(self.is_generator_on(sced,g)) \ - + sced.data['elements']['generator'][g]['rg']['values'][0] + gdata = sced.data['elements']['generator'][g] + val = gdata['headroom']['values'][0] \ + + self.get_power_generated(sced, g)*int(self.is_generator_on(sced,g)) + if 'rg' in gdata: + val += sced.data['elements']['generator'][g]['rg']['values'][0] + return val def get_thermal_headroom(self, sced: OperationsModel, g: G) -> float: - return sced.data['elements']['generator'][g]['headroom']['values'][0] \ - + sced.data['elements']['generator'][g]['rg']['values'][0] + gdata = sced.data['elements']['generator'][g] + val = gdata['headroom']['values'][0] + if 'rg' in gdata: + val += gdata['rg']['values'][0] + return val def get_min_downtime(self, sced: OperationsModel, g: G) -> float: return sced.data['elements']['generator'][g]['min_up_time'] diff --git a/prescient/engine/forecast_helper.py b/prescient/engine/forecast_helper.py index 86c77c77..9f932194 100644 --- a/prescient/engine/forecast_helper.py +++ b/prescient/engine/forecast_helper.py @@ -49,7 +49,8 @@ def get_forecastables(*models: EgretModel) -> Iterable[ Tuple[MutableSequence[fl yield tuple(m.data['elements']['load'][bus]['p_load']['values'] for m in models) # Reserve requirement - yield tuple(m.data['system']['reserve_requirement']['values'] for m in models) + if 'reserve_requirement' in model1.data['system']: + yield tuple(m.data['system']['reserve_requirement']['values'] for m in models) return