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

Maybe support hdf4 #494

Merged
merged 14 commits into from
Sep 12, 2024
7 changes: 7 additions & 0 deletions docs/source/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ File format backends
kerchunk.fits.process_file
kerchunk.tiff.tiff_to_zarr
kerchunk.netCDF3.NetCDF3ToZarr
kerchunk.hdf4.HDF4ToZarr

.. autoclass:: kerchunk.hdf.SingleHdf5ToZarr
:members:
Expand All @@ -24,6 +25,9 @@ File format backends
.. autoclass:: kerchunk.netCDF3.NetCDF3ToZarr
:members: __init__, translate

.. autoclass:: kerchunk.hdf4.HDF4ToZarr
:members: __init__, translate

Codecs
------

Expand All @@ -50,6 +54,9 @@ Codecs
.. autoclass:: kerchunk.codecs.RecordArrayMember
:members: __init__

.. autoclass:: kerchunk.codecs.ZlibCodec
:members: __init__

Combining
---------

Expand Down
17 changes: 17 additions & 0 deletions kerchunk/codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from numcodecs.abc import Codec
import numpy as np
import threading
import zlib


class FillStringsCodec(Codec):
Expand Down Expand Up @@ -238,3 +239,19 @@ def decode(self, buf, out=None):

def encode(self, buf):
raise NotImplementedError


class ZlibCodec(Codec):
codec_id = "zlib"

def __init__(self):
...

def decode(self, data, out=None):
if out:
out[:] = zlib.decompress(data)
return out
return zlib.decompress(data)

def encode(self, buf):
return zlib.compress(buf)
Loading
Loading