Skip to content

Commit

Permalink
Add open_dataset_options parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrjones committed Oct 11, 2023
1 parent 8bd3f06 commit 430e2e8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions kerchunk/xarray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ def open_dataset(
*,
drop_variables=None,
storage_options=None,
open_dataset_options=None
):

ref_ds = open_reference_dataset(
filename_or_obj,
storage_options=storage_options,
open_dataset_options=open_dataset_options,
)
if drop_variables is not None:
ref_ds = ref_ds.drop_vars(drop_variables)
Expand All @@ -24,6 +26,7 @@ def open_dataset(
open_dataset_parameters = [
"filename_or_obj",
"storage_options",
"open_dataset_options",
]

def guess_can_open(self, filename_or_obj):
Expand All @@ -37,7 +40,14 @@ def guess_can_open(self, filename_or_obj):
url = "https://fsspec.github.io/kerchunk/"


def open_reference_dataset(filename_or_obj, *, storage_options=None):
def open_reference_dataset(
filename_or_obj, *, storage_options=None, open_dataset_options=None
):
if storage_options is None:
storage_options = {}
if open_dataset_options is None:
open_dataset_options = {}
fs = ReferenceFileSystem(fo=filename_or_obj, **storage_options)
m = fs.get_mapper()
return xr.open_dataset(m, engine="zarr", consolidated=False)

return xr.open_dataset(m, engine="zarr", consolidated=False, **open_dataset_options)

0 comments on commit 430e2e8

Please sign in to comment.