Giter Site home page Giter Site logo

Comments (8)

shoyer avatar shoyer commented on May 18, 2024

Unfortunately I think this means that this file is HDF5 file but not an netCDF4 file, so we can't really expect netCDF tools to work on it. netCDF4 is a specialized file format built on HDF5.

This could probably be made to work with a default dimension, but in general dimension scales are a pretty core part of the netCDF4 data model, so maybe it makes sense to use h5py here instead.

from h5netcdf.

denis-bz avatar denis-bz commented on May 18, 2024

Stephan,
Thanks. Is there any program in nc* that would tell me that ?
nccopy -k nc4 my.h5 my.nc creates a .nc that works in h5netcdf ?!
ncinfo looks ok to me --

<type 'netCDF4._netCDF4.Dataset'>
root group (NETCDF4 data model, file format HDF5):
    dimensions(sizes): 
    variables(dimensions): 
    groups: NS

Ideally I'd like a description of common differences between HDF5 and netCDF4;
is there a test suite for that
(preferably .cdl files -- diffing binary files is, um, Fortran-age.)
I realize that's a tall order, and not your job; pass it on ?

from h5netcdf.

shoyer avatar shoyer commented on May 18, 2024

If netCDF4 supports it, then ideally h5netcdf should, too. Can you share an example file so I can take a look?

I don't know a general way to check for netCDF4 API compatibility, unfortunately. Recent versions of netCDF4 do add some special attributes for checking if an HDF5 file was created via a netCDF library (e.g., the _NCProperties attribute), but other HDF5 files might also be valid netCDF fiels.

from h5netcdf.

denis-bz avatar denis-bz commented on May 18, 2024

I could put up a binary file, but don't want to waste your time
on non-reproducible stuff (it works after`nccopy).

All I really wanted to do is read an .h5 file that somebody sent me into xarray;
there's a tiny test case for that under https://gist.github.com/denis-bz
test.cdl -> test.nc -> read3.py, read with h5py h5netcdf xarray

looks like more for xarray people than for you -- if so could you pass it on ?
Thanks

from h5netcdf.

shoyer avatar shoyer commented on May 18, 2024

from h5netcdf.

kmuehlbauer avatar kmuehlbauer commented on May 18, 2024

Sorry for reviving this, but I have some similar issue reading HDF5 files.

Currently I'm using the netCDF4 based engine within xarray to load hdf5 files (without dimension-scales). The dimensions are picked up by the netcdf-c library as phony_dim_N, where N is some number of first occurrence. As h5netcdf seems to be faster (with smaller memory footprint) for my use case I tried to get it running, but the error mentioned in the OP prevents me reading the data.

If tried to fix this by just replacing
https://github.com/shoyer/h5netcdf/blob/f71e4a692bc11689a3ad7850e8ce4ac1cb536659/h5netcdf/core.py#L98-L109

with:

        for axis, dim in enumerate(self._h5ds.dims):
            if len(dim) == 0:
                name = 'phony_dim_{}'.format(axis)
            else:
                name = _name_from_dimension(dim)
            dims.append(name)

This works, but will initialize new phony_dim_0 to phony_dim_N for every subgroup. Means phony_dim_0 in subgroup X and phony_dim_0 in subgroup Y aren't neccessarily the same. To completely mimic the netCDF4 behaviour, the dimensions have to be named in some distinct order while iterating over the whole file contents.

To find my way through the code to correctly implement this I would need some help and guidance.

@shoyer Where should I start looking?

from h5netcdf.

shoyer avatar shoyer commented on May 18, 2024

Yes, it this seems like a reasonable feature to add.

from h5netcdf.

kmuehlbauer avatar kmuehlbauer commented on May 18, 2024

@denis-bz It's been a while, but this should be resolved with #64. If you encounter any problems, please reopen or create a new issue.

from h5netcdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.