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

Add dimension info to hdf5 output #27

Open
logan-nc opened this issue Mar 12, 2019 · 2 comments
Open

Add dimension info to hdf5 output #27

logan-nc opened this issue Mar 12, 2019 · 2 comments
Assignees

Comments

@logan-nc
Copy link
Collaborator

I am trying to read in the hdf5 file more intelligently for a nice interactive experience in OMFIT.

We use xarray Datasets a lot (http://xarray.pydata.org/en/stable/index.html) for interacting with netcdfs (and doing almost anything - it is awesome!). Luckily the modern netCDF4 is based on HDF5. This means I can successfully read the FOCUS output using our OMFITncDataset, browse, and print / plot the FOCUS output data just by clicking on it

image

Notice how the (double-click in the tree) plot knew the ylabel? Smart. But see how it doesn't know the xlabel? Thats because FOCUS isn't storing the dimensions along with any of its data. This sort of meta-data is a major strength of HDF5/netCDF over dumb binary formats. Can we utilize it better in FOCUS? It shouldn't be hard, for example, to tell the HDF5 that intial_Bmns is m by n (yes, I see technically it is just 1D by "mode_index" as are Bmnin and Bmnim... but even recording that would be helpful).

While we are at it, all the 0D (i.e. length 1) outputs should probably just be stored as global attributes. I think HDF5/netCDF standard practices are right to use these, as they increase efficiency and clarity of the file.

This is not pressing, but worth having in the to do list.

@zhucaoxiang
Copy link
Collaborator

@logan-nc Great suggestion. I was aware of that FOCUS is writing HDF5 file not in the Standard way. I copy the format from somewhere. I will add this in to-do list and keep you informed if there is an update on this topic.

@logan-nc
Copy link
Collaborator Author

👍
I like netcdf if you are open to switching to that (you'll love xarray if you do). There is a fairly clean self contained example at https://github.com/PrincetonUniversity/GPEC/blob/develop/dcon/dcon_netcdf.f.

Or just google examples of best practices for HDF5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants