csiro-coasts / emsarray

xarray extension that supports EMS model formats
BSD 3-Clause "New" or "Revised" License
13 stars 2 forks source link

support for open_mfdataset #53

Closed Lachlan00 closed 1 year ago

Lachlan00 commented 1 year ago

Hello,

I just modified the source code to support the xarray function open_mfdataset (i.e. read in a list of NetCDF files) as I needed it for a project. I tested a build on my machine and it works well. Apologies if I made an error or there was a reason the function wasn't included. I'm new to developing packages.

Example

from glob import glob
import emsarray

ds = emsarray.open_mfdataset(glob("path/to/files/*.nc"), combine='nested',
                             concat_dim="record", data_vars='minimal', 
                             compat="override", join="override",
                             coords="minimal", parallel=False)
mx-moth commented 1 year ago

Thanks for the pull request! I think this is actually a problem with the documentation. I've added issue #54 to track this. The ems accessor is available on all datasets, including those opened with xarray.open_mfdataset(), as long as emsarray has been imported at some point.

I do not want to add an alias for xarray.open_mfdataset() to emsarray. Shadowing multiple functions like this can add more maintenance overhead than expected, if the xarray interface changes or they add more open_<x>dataset functions over time. Given that emsarray functionality is already available on multifile datasets, I think better documentation would instead fix this issue.