How to use the h5netcdf.core.Group function in h5netcdf

To help you get started, we’ve selected a few h5netcdf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shoyer / h5netcdf / h5netcdf / core.py View on Github external
for var in self.variables.values():
            new_shape = list(var.shape)
            for i, d in enumerate(var.dimensions):
                if d == dimension:
                    new_shape[i] = size
            new_shape = tuple(new_shape)
            if new_shape != var.shape:
                var._h5ds.resize(new_shape)

        # Recurse as dimensions are visible to this group and all child groups.
        for i in self.groups.values():
            i.resize_dimension(dimension, size)


class File(Group):

    def __init__(self, path, mode='a', invalid_netcdf=None, phony_dims=None,
                 **kwargs):
        try:
            if isinstance(path, str):
                if path.startswith(('http://', 'https://', 'hdf5://')):
                    if no_h5pyd:
                        raise ImportError(
                            "No module named 'h5pyd'. h5pyd is required for "
                            "opening urls: {}".format(path))
                    try:
                        with h5pyd.File(path, 'r') as f:  # noqa
                            pass
                        self._preexisting_file = True
                    except IOError:
                        self._preexisting_file = False