Skip to content

Commit

Permalink
Merge pull request #494 from martindurant/hdf4
Browse files Browse the repository at this point in the history
Maybe support hdf4
  • Loading branch information
martindurant authored Sep 12, 2024
2 parents 4a55497 + 3d84877 commit 10a9248
Show file tree
Hide file tree
Showing 4 changed files with 534 additions and 0 deletions.
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

0 comments on commit 10a9248

Please sign in to comment.