Skip to content

Commit

Permalink
docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
martindurant committed Sep 3, 2024
1 parent 90a353b commit 753ad16
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions kerchunk/hdf4.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ def f(func):


class HDF4ToZarr:
"""Experimental: interface to HDF4 archival files"""

def __init__(
self,
path,
storage_options=None,
inline_threshold=100,
out=None,
remote_protocol=None,
remote_options=None,
):
self.path = path
self.st = storage_options
self.thresh = inline_threshold
self.out = out or {}
self.remote_protocol = remote_protocol
self.remote_options = remote_options

def read_int(self, n):
return int.from_bytes(self.f.read(n), "big")
Expand Down Expand Up @@ -76,7 +74,8 @@ def translate(self, filename=None, storage_options=None):
import zarr
from kerchunk.codecs import ZlibCodec

self.f = fsspec.open(self.path, **(self.st or {})).open()
fo = fsspec.open(self.path, **(self.st or {}))
self.f = fo.open()

# magic header
assert self.f.read(4) == b"\x0e\x03\x13\x01"
Expand Down Expand Up @@ -134,11 +133,13 @@ def translate(self, filename=None, storage_options=None):

# hierarchical output
output = self._descend_vg(*list(roots)[0])
prot = fo.fs.protocol
prot = prot[0] if isinstance(prot, tuple) else prot
fs = fsspec.filesystem(
"reference",
fo=self.out,
remote_protocol=self.remote_protocol,
remote_options=self.remote_options,
remote_protocol=prot,
remote_options=self.st,
)
g = zarr.open_group("reference://", storage_options=dict(fs=fs))
refs = {}
Expand Down

0 comments on commit 753ad16

Please sign in to comment.