Description of Issue
With the switch GSw_EFS1_AllYearLoad set to 'historic' GAMS could not read two input files: peakload_nercr.csv and load_allyear.csv. The difficulty is that GAMS is expecting the variable 't' to be an integer, but both of these files have 't' as a float. For example, 2020.0. This led GAMS to complain about the formatting of the files and the job failing. I have a temporary fix that I show below, but the problem seems to arise from the way the 'year' variable is stored in load.h5 (just speculating here). If I make sure that these two csv files have t as an integer, the errors no longer occur.
Potential Solutions
These fixes don't address the underlying issue of how the year variable from load.py is processed, but they do get things to work.
In ldc_prep.py, in the Data write-out section I added a call to 'reset_index' and a call to 'assign' with a lambda function to change the t variable type to integer:
print('Fix type of t in peakload_nercr.csv')
_temp_peakload = peakload.loc['nercr'].stack('year').rename_axis(['*nercr','t']).rename('MW').reset_index().assign(t=lambda df: df['t'].astype(int))
_temp_peakload.to_csv(
os.path.join(inputs_case,'peakload_nercr.csv'), index=False)
In hourly_writetimeseries.py, I made a similar adjustment:
## Annual timeslice demand
'load_allyear': [
(load_h.reset_index().assign(h=load_h.reset_index().h.map(chunkmap))
.groupby(['r','h'])
.agg((sw['GSw_PRM_StressLoadAggMethod'] if 'stress' in periodtype else 'mean'))
.stack('t').rename('MW')
.round(decimals).reset_index().assign(t=lambda df: df['t'].astype(int))),
False, False],
Description of Issue
With the switch GSw_EFS1_AllYearLoad set to 'historic' GAMS could not read two input files: peakload_nercr.csv and load_allyear.csv. The difficulty is that GAMS is expecting the variable 't' to be an integer, but both of these files have 't' as a float. For example, 2020.0. This led GAMS to complain about the formatting of the files and the job failing. I have a temporary fix that I show below, but the problem seems to arise from the way the 'year' variable is stored in load.h5 (just speculating here). If I make sure that these two csv files have t as an integer, the errors no longer occur.
Potential Solutions
These fixes don't address the underlying issue of how the year variable from load.py is processed, but they do get things to work.
In ldc_prep.py, in the Data write-out section I added a call to 'reset_index' and a call to 'assign' with a lambda function to change the t variable type to integer:
In hourly_writetimeseries.py, I made a similar adjustment: