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

input flexibility set_ds_time rt perioddata #124

Closed
tomvansteijn opened this issue Nov 2, 2022 · 5 comments · Fixed by #257
Closed

input flexibility set_ds_time rt perioddata #124

tomvansteijn opened this issue Nov 2, 2022 · 5 comments · Fixed by #257
Assignees
Labels
enhancement New feature or request

Comments

@tomvansteijn
Copy link

Currently the input function set_ds_time does not allow for the full flexibilty of the perioddata variable of the Flopy TDIS interface.

Usage of the input variable time forces timesteps of 1 day, which is not always necessary. Furthermore the timestamp multiplication factor tsmult can only be applied as a constant for all stress periods. It would be useful if the number of timesteps (ntsp) and the multiplication factor tsmult could be specified in conjunction with the perlen and the time variable.

In some cases it is more practical to specify a start date and the stress period data in the same format as required by Flopy TDIS. In other cases just the time variable should be sufficient, in my experience.

@rubencalje
Copy link
Collaborator

rubencalje commented Nov 2, 2022

Thanks for the suggestions. Some of the issues are allready implemented, but documentation can probably be improved. Here are some comments:

Usage of the input variable time forces timesteps of 1 day, which is not always necessary.

This is not true. For example, see the following example for yearly stress-period lengths, with one timestep per stress-period (nstp=1):

import pandas as pd
import nlmod
ds = nlmod.get_ds([0, 3000, 0, 2000])
ds = nlmod.time.set_ds_time(ds, time=pd.date_range('2010', '2020', freq='YS'))
ds.time

gives

<xarray.DataArray 'time' (time: 11)>
array(['2010-01-01T00:00:00.000000000', '2011-01-01T00:00:00.000000000',
       '2012-01-01T00:00:00.000000000', '2013-01-01T00:00:00.000000000',
       '2014-01-01T00:00:00.000000000', '2015-01-01T00:00:00.000000000',
       '2016-01-01T00:00:00.000000000', '2017-01-01T00:00:00.000000000',
       '2018-01-01T00:00:00.000000000', '2019-01-01T00:00:00.000000000',
       '2020-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
Coordinates:
  * time     (time) datetime64[ns] 2010-01-01 2011-01-01 ... 2020-01-01
Attributes:
    time_units:    DAYS
    start:         2000-01-02 00:00:00
    nstp:          1
    tsmult:        1.0
    steady_start:  1
    steady_state:  0

Furthermore the timestamp multiplication factor tsmult can only be applied as a constant for all stress periods. It would be useful if the number of timesteps (ntsp) and the multiplication factor tsmult could be specified in conjunction with the perlen and the time variable.

You are right. It would be nice to choose nstp and tsmult per stress-period.

In some cases it is more practical to specify a start date and the stress period data in the same format as required by Flopy TDIS. In other cases just the time variable should be sufficient, in my experience.

nlmod.time.set_ds_time can also handle period lengths. I do not know if this is what you mean, but set_ds_time is quite flexible. For example, the next peace of code generates the exact same time-dimension as above:

import nlmod
ds = nlmod.get_ds([0, 3000, 0, 2000])
perlen = [365, 365, 366, 365, 365, 365, 366, 365, 365, 365, 366]
ds = nlmod.time.set_ds_time(ds, start_time='2010', perlen=perlen)
ds.time

gives

<xarray.DataArray 'time' (time: 11)>
array(['2010-01-01T00:00:00.000000000', '2011-01-01T00:00:00.000000000',
       '2012-01-01T00:00:00.000000000', '2013-01-01T00:00:00.000000000',
       '2014-01-01T00:00:00.000000000', '2015-01-01T00:00:00.000000000',
       '2016-01-01T00:00:00.000000000', '2017-01-01T00:00:00.000000000',
       '2018-01-01T00:00:00.000000000', '2019-01-01T00:00:00.000000000',
       '2020-01-01T00:00:00.000000000'], dtype='datetime64[ns]')
Coordinates:
  * time     (time) datetime64[ns] 2010-01-01 2011-01-01 ... 2020-01-01
Attributes:
    time_units:    DAYS
    start:         2000-01-02 00:00:00
    nstp:          1
    tsmult:        1.0
    steady_start:  1
    steady_state:  0

@tomvansteijn
Copy link
Author

Thanks @rubencalje for the clarification. Indeed I was mistaken about the timestep of 1 day when using the time variable. I guess my input reduces to the wish for a nstp and tsmult per stress period, as can be specified in flopy using the perioddata argument. Specifying perioddata as tuples (perlen, nstp, tsmult) might be more practical than having different iterables as arguments which should then have the same length.

@rubencalje rubencalje added the enhancement New feature or request label Nov 4, 2022
@dbrakenhoff
Copy link
Collaborator

dbrakenhoff commented Aug 24, 2023

  • add nstp and tsmult as options

@dbrakenhoff dbrakenhoff self-assigned this Aug 24, 2023
@dbrakenhoff
Copy link
Collaborator

@tomvansteijn, we've created a PR (#257) to both simplify and improve time discretization settings.

The new function for setting the time index accepts nstp and tsmult:

# basic call signature
ds = nlmod.time.set_ds_time(ds, time, start, steady=True, nstp=1, tsmult=1.0) 

# using perlen (note that steady, nstp and tsmult also accept array-likes)
perlen = [365] * 10
ds = nlmod.time.set_ds_time(ds, time=np.cumsum(perlen), start="2010", steady=False, nstp=1, tsmult=1.0)

@dbrakenhoff dbrakenhoff linked a pull request Aug 28, 2023 that will close this issue
@dbrakenhoff
Copy link
Collaborator

dbrakenhoff commented Oct 30, 2023

Fixed by #257, and available in release v0.7.0

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

Successfully merging a pull request may close this issue.

3 participants