Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another issue with the 'historic' setting #197

Open
wshobe opened this issue Dec 16, 2024 · 0 comments
Open

Another issue with the 'historic' setting #197

wshobe opened this issue Dec 16, 2024 · 0 comments

Comments

@wshobe
Copy link
Collaborator

wshobe commented Dec 16, 2024

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],


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant