Discrepancy between NetCDF and HDF5

Hello,

I am finding a discrepancy in reading the files obtained from channelflow simulations by matlab with respect to the two formats (Matlab : ncread & h5read). I was finding a discrepancy in the two data sets, so I created a random field using the randomfield tool in NetCDF format and then converted the same using fieldconvert tool into HDF5. Further, I also tried to compare the data by reading the files directly in Python. Since the random filed contained the padded modes, I used the interpolate function with the python wrapper and interpolated the field onto a flowfield with 2/3Nx,2/3Nz.

The coordinate data from the HDF5 file matches with the one from Python but not when the NetCDF file is directly read by matlab using “ncread”. The attached file contains the properties of the two file formats generated using the “ncdisp” and “h5disp” commands from matlab. The difference is clearly shown.

Can you please clarify what is wrong here ?

Regards,

Pavan

Hello,

A further note:

with regards to the confusion of reading and reshaping required for the HDF5 files (comments on GitHub and matlab scripts from version 1.5x), i am finding that the velocity data set in the version 2.0 is along the size [Nx,Ny,Nz,Nd](see attached figure) . Is the reshaping and re-ordering still required ?

Regards,

Pavan

Hi Pavan,

you are right that there is a discrepancy in the I/O:
NetCDF files have a grid of size 2(N/3) for padded fields.
HDF5 files have a grid of size (2N)/3 for padded fields.

Since these are integer operations they may differ. Although this changes the physical representation of the FlowField, the spectral data is the same for both of them because it affects a mode which is zero. Thus, it is not really a bug but I agree that it is confusing if you look at the interpolated data in physical representation.

I created a PR to adjust the HDF5 output:

Best regards,
Florian

Hello Florian,

Thank you for the response.

Regards,

Pavan