-
Notifications
You must be signed in to change notification settings - Fork 30
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
Read of model when update in same root #460
Conversation
@savente93 pick this up |
@savente93 I put some placeholders in the code where I think you can try to add filehandling. Thanks again in advance for the help! |
Hi @savente93 , thanks for the help! I tested and seems to work like a charm for our test bench :) After that, could you do the final review? Unless @DirkEilander you prefer to also have a look? |
To give a bit more context for the |
Thanks! Then it's clear to me and I think a good idea indeed so let's keep it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few small comments, but other than that, I think she's ready to go chief!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @hboisgon and @savente93 !
I've added a few questions / comments, but nothing major.
hydromt/models/model_api.py
Outdated
@@ -1336,7 +1385,7 @@ def write_states(self, fn="states/{name}.nc", **kwargs) -> None: | |||
filename relative to model root and should contain a {name} placeholder, | |||
by default 'states/{name}.nc' | |||
**kwargs: | |||
Additional keyword arguments that are passed to the `RasterDatasetAdapter` | |||
Additional keyword arguments that are passed to the `_write_nc` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we refer to internal function _write_nc
in the docstring, which itself does not have a docstring? That's not a very helpful reference for users.
The _write_nc
method could be added to the external api (remove underscore) with a docstring. It could potentially even be moved to the io.py script. Alternately, we could mention the underlying xarray.to_netcdf
method here as those are the kwargs that users will mostly adapt no? idem in other places where this method is referenced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's a reflex, but if possible I'd prefer keeping things private as much as we can, so I would prefer refering to xarray.to_netcdf
instead. @hboisgon what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that we referenced it in a lot of places already but without an API docstring. The thing is that for the equivalent _read_nc method, the new 'load' option I implemented is actually then not passed to the open_dataset **kwargs so I have to document this better anyhow. I think these functions could easily be moved to io.py if you also agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong feelings on moving it to io.py
but if there is a way you think that the documentation could be improved, then I'm always happy with that. I'll leave it up to you though, I trust your judgement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not realize but as @savente93 implemented the nice temporary file writting and saving to defered file list, it became quite tough to move this function to io.py
. So in the end I decide to leave both read_nc
and write_nc
in model_api.py, removed the underscore and added docstrings. Should all be consistent now!
Issue addressed
Fixes #256
Explanation
See #256 for discussions
Checklist
main