Skip to content

Commit

Permalink
Add flag to ignore look-ahead period counts when parsing RTS-GMLC.
Browse files Browse the repository at this point in the history
RTS-GMLC metadata has "Look_Ahead_Periods_per_Step" fields that indicate
how much data to include in each simulation step. Consumers of RTS-GMLC
data (such as Prescient) may have their own mechanisms for determining
the simulation horizon, and it may not match the values stored in the
metadata.

This commit adds a new argument to rts_gmlc.parser.parse_to_cache(), called
"honor_lookahead". If this is True (the default), it uses the lookahead
period count found in the data's metadata. If it is False, it does not
include any extra data beyond the specified end_time. When calling this
function, consumers of the parsed data are expected to adjust the end_time
to include any look-ahead periods it may need.
  • Loading branch information
darrylmelander authored and bknueven committed May 23, 2023
1 parent bbeb5b0 commit 954cc47
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions egret/parsers/rts_gmlc/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def create_model_data_dict(rts_gmlc_dir:str,
def parse_to_cache(rts_gmlc_dir:str,
begin_time:Union[datetime,str],
end_time:Union[datetime,str],
t0_state:Optional[dict]=None) -> ParsedCache:
t0_state:Optional[dict]=None,
honor_lookahead=True) -> ParsedCache:
''' Parse data in RTS-GMLC format, keeping the portions between a start and end time
rts_gmlc_dir : str
Expand All @@ -127,7 +128,7 @@ def parse_to_cache(rts_gmlc_dir:str,
model_data = _create_rtsgmlc_skeleton(rts_gmlc_dir)

# Save the data frequencies
metadata_df = _read_metadata(rts_gmlc_dir)
metadata_df = _read_metadata(rts_gmlc_dir, honor_lookahead)
minutes_per_period = {'DAY_AHEAD':int(metadata_df.loc['Period_Resolution', 'DAY_AHEAD'])//60,
'REAL_TIME':int(metadata_df.loc['Period_Resolution', 'REAL_TIME'])//60}

Expand All @@ -151,14 +152,18 @@ def parse_to_cache(rts_gmlc_dir:str,
timeseries_df, load_participation_factors, constant_reserve_data)


def _read_metadata(base_dir:str) -> pd.DataFrame:
def _read_metadata(base_dir:str, honor_lookahead:bool) -> pd.DataFrame:
metadata_path = os.path.join(base_dir, "simulation_objects.csv")
if not os.path.exists(metadata_path):
raise ValueError(f'RTS-GMLC directory "{rts_gmlc_dir}" does not contain expected CSV files.')

# Read metadata about the data
metadata_df = pd.read_csv(metadata_path, index_col=0)

if not honor_lookahead:
metadata_df.loc['Look_Ahead_Periods_per_Step']['DAY_AHEAD'] = 0
metadata_df.loc['Look_Ahead_Periods_per_Step']['REAL_TIME'] = 0

return metadata_df

def _get_data_date_range(metadata_df) -> Tuple[datetime, datetime]:
Expand Down

0 comments on commit 954cc47

Please sign in to comment.