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

HDF5 Dimension Scales #1313

Open
axelboc opened this issue Dec 6, 2022 · 1 comment
Open

HDF5 Dimension Scales #1313

axelboc opened this issue Dec 6, 2022 · 1 comment
Labels
epic Issue that will need to be split up later on

Comments

@axelboc
Copy link
Contributor

axelboc commented Dec 6, 2022

It would be nice to support HDF5's dimension scales. We've received multiple feature requests relating to those, including in a couple of recent emails. Dimension scales are apparently used quite extensively in NetCDF4 files, to describe how to plot datasets (axes, units, etc.).

In his email, Jean-Christophe describes, for instance, how to create a time-based dimension scale (which could then be "attached" to a dataset - e.g. values.dims[0].attach_scale(time)).

df_modified = pd.to_datetime(df.index.values) - time # Difference of time from a given date
df_modified_str = df_modified.total_seconds().to_numpy()
time_dset = group.create_dataset ('time', data=df_modified_str)
time_dset.attrs["long_name"] = "UTC Time"
time_dset.attrs["description"] = ModelHDFLevel4Lumina.TIME.__doc__    
time_dset.attrs["calendar"] = "standard"
time_dset.attrs["units"] = f"seconds since {time.strftime('%Y-%m-%d %H:%M:%S')}"
time_dset.make_scale('time')

More reading:

@axelboc
Copy link
Contributor Author

axelboc commented Nov 7, 2023

h5wasm@0.6.9 brings support for reading dimension scales.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Issue that will need to be split up later on
Projects
None yet
Development

No branches or pull requests

1 participant