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

KNMI-data assigned to stress periods wrongly #129

Closed
rubencalje opened this issue Nov 15, 2022 · 1 comment
Closed

KNMI-data assigned to stress periods wrongly #129

rubencalje opened this issue Nov 15, 2022 · 1 comment

Comments

@rubencalje
Copy link
Collaborator

rubencalje commented Nov 15, 2022

Right now we make an error, when we add recharge from the KNMI-server to a model dataset. The recharge from the next stress period is assigned to the current stress period. See the code in read\knmi.py:

model_recharge = pd.Series(index=ds.time.data, dtype=float)
for j, ts in enumerate(model_recharge.index):
    if j < (len(model_recharge) - 1):
        model_recharge.loc[ts] = (
            timeseries.loc[ts : model_recharge.index[j + 1]].iloc[:-1].mean()
        )
    else:
        model_recharge.loc[ts] = timeseries.loc[ts:end].iloc[:-1].mean()

The index of the pandas Series timeseries is equal to the end of the period that the data describes. Therefore I will change this into the following code:

model_recharge = pd.Series(index=ds.time.data, dtype=float)
for j, ts in enumerate(model_recharge.index):
    if j == 0:
        start = ds.time.start
    else:
        start = model_recharge.index[j - 1]
    mask = (timeseries.index > start) & (timeseries.index <= ts)
    model_recharge.loc[ts] = timeseries[mask].mean()

Keep in mind this will change model output in the next version.

@rubencalje rubencalje changed the title KNMI assigned to stress periods wrongly KNMI-data assigned to stress periods wrongly Nov 15, 2022
rubencalje added a commit that referenced this issue Nov 15, 2022
make sure time dimension is always first
no separate code for steady-state models anymore
rubencalje added a commit that referenced this issue Nov 15, 2022
* Fix issue #129 and some improvements

make sure time dimension is always first
no separate code for steady-state models anymore

* Fix assignment of values

* Fix assignment of values some more
@rubencalje
Copy link
Collaborator Author

Fixed

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