-
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
Saving model output to NetCDF #176
Comments
@stijnvanhoey No attributes that I know of. You can store each of the parameters as a separate key/value pair, np. |
Hi @stijnvanhoey , thanks for the elaborate explanation! I think I'll follow your 2-step advice, I agree that losing the "parameters" name (i.e. going "up one level") seems OK, and grouping together results is also useful. Introducing a new dimension is probably overkill. Question: is it easy to browse through the various groups when they are saved, or should I 'remember' the names I gave to these groups? Can an attribute of a group be a description (long string)? |
As zarr is actually a folder structure on itself, you can still navigate to the folder in your file explorer and the groups will be the main level, e.g.
That should be ok. |
@mrollier as discussed in the meeting, we had a check on the saving of the model outputs to disk. In the current model setup, there is only one attribute, which is the dictionary of parameters:
So instead of a nested dictionary (parameter dict inside the attributes which is also a dict), we could use each of the parameters as a a separate attribute. When doing so:
there is still an error. So, the N-D arrays should all be flattened to support saving them as h5/netcdf files. This is something you could do in a one-liner using dict-comprehension:
I would maybe also add an additional attribute with the original shape (dimension size)
stratification_dimension_...
to support re-creation of the original ndarray.zarr
zarr, https://zarr.readthedocs.io/en/stable/, actually supports the usage of N-D arrays in the attributes.
will also work.
usage of groups
When saving scenario's (both zarr and h5/netxdf) you can use the concepts of
groups
to save all the data in a 'single' file (which is still a directory for zarr):And each group can contain it's own set of attributes.
If you would work with a new 'scenario' dimension, you would loose the attributes, i.e. parameter values, when concatenating along the 'scenario' dimension limiting the reproducibility of it, e.g. :
@mrollier have a check if this helps you. I would propose to:
out_1.attrs = out_1.attrs["parameters"]
not required anymore@twallema, @JennaVergeynst and @jorisvandenbossche are there other elements stored in the attributes apart from the parameters? Would it be an option to have each of the parameter stored as a separate key/value pair in the attributes instead of using a 'parameters' dict?
The text was updated successfully, but these errors were encountered: