Closed benjaminleighton closed 1 year ago
@benjaminleighton this looks good, we could merge it - but perhaps another option is to use xr.open_mfdataset
in the existing SourceFile class instead of xr.open_dataset
. There is one limitation with using xr.open_mfdataset
that I am aware of which is it does not handle file-like objects, so if for example we want to open a remote file using fsspec
it will throw an exception. We could capture this exception though and attempt to use xr.open_dataset
in that case. I'd be happy doing it that way but I'm also happy to have an extra SourceFiles
class as you have implemented. What do you think?
I thought a bit about puting the logic into the SourceFile instead. I'm not sure if there is an issue. https://docs.xarray.dev/en/stable/generated/xarray.open_mfdataset.html and https://docs.xarray.dev/en/stable/generated/xarray.open_dataset.html are different in what kwargs they accept as well. I'm not sure if that matters. Easiest for me is this change as it's what I have 😃 but I don't know if that's a good enough reason really!
As discussed @rafa-guedes I will abandon this pull request as the new SourceFile functionlity you suggested is being implemented.
New SourceFiles similar to SourceFile but please reject and let me know if there is a better alternative.