How to use the h5netcdf.core.BaseVariable 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 / legacyapi.py View on Github external
def __getattr__(self, name):
        try:
            return self.attrs[name]
        except KeyError:
            raise AttributeError('NetCDF: attribute {} not found'
                                 .format(type(self).__name__, name))

    def __setattr__(self, name, value):
        if self._initialized and name not in self.__dict__:
            self.attrs[name] = value
        else:
            object.__setattr__(self, name, value)


class Variable(core.BaseVariable, HasAttributesMixin):
    _cls_name = 'h5netcdf.legacyapi.Variable'

    def chunking(self):
        chunks = self._h5ds.chunks
        if chunks is None:
            return 'contiguous'
        else:
            return chunks

    def filters(self):
        complevel = self._h5ds.compression_opts
        return {'complevel': 0 if complevel is None else complevel,
                'fletcher32': self._h5ds.fletcher32,
                'shuffle': self._h5ds.shuffle,
                'zlib': self._h5ds.compression == 'gzip'}
github shoyer / h5netcdf / h5netcdf / core.py View on Github external
_cls_name = 'h5netcdf.Variable'

    def __repr__(self):
        if self._parent._root._closed:
            return '' % self._cls_name
        header = ('<%s %r: dimensions %s, shape %s, dtype %s>' %
                  (self._cls_name, self.name, self.dimensions, self.shape,
                   self.dtype))
        return '\n'.join([header] +
                         ['Attributes:'] +
                         ['    %s: %r' % (k, v)
                          for k, v in self.attrs.items()])


class Variable(BaseVariable):

    @property
    def chunks(self):
        return self._h5ds.chunks

    @property
    def compression(self):
        return self._h5ds.compression

    @property
    def compression_opts(self):
        return self._h5ds.compression_opts

    @property
    def fletcher32(self):
        return self._h5ds.fletcher32