You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, me like many WRF users are starting to use xarray and wrf-python for a lot of our work, which still requires the native netCDF4.Dataset object to access most of the routines.
Although it would be great if wrf-python simply operated on xarray.Dataset objects (there are plans to do so), but there are still several use cases where accessing the underlying datastore would be useful.
I've looked through the source code with a fine-tooth comb and I cannot for the life of me figure out where the native data store goes in the flow of logic in the load, likely it just disappears once loaded through xarray. Access to the encoding object reveals only a path to the source file, not the original source file object itself.
Describe the solution you'd like
It would be really great if there were the ability to access the underlying datastore object.
Or something similar, maybe a method if that is required.
Alternatively, if the encoding attribute still pointed at the original object (rather than a path) then that would work too.
I know this goes against the xarray goal of protecting the original source file, but I genuinely think it would increase the utility of the library to allow users more freedom in this respect. Surely there is a mode of opening the file that is truly read-only so that we can access the native object?
Describe alternatives you've considered
I've dug into the source code to find the source object, no success.
Working with wrf-python I load with netCDF4.Dataset then assemble my xarray.Dataset after extracting diagnostics, it is important to remember to close the original nc.Dataset if you're doing anything else down the line!
Other options include creating an in-memory Dataset object from the xarray.Dataset but it feels wrong to load through xarray only to create a netCDF4.Dataset from its contents.
Additional context
I am happy to implement this change if someone can point me at the underlying datastore in the code.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem?
Prior to #4809 it was possible to access the underlying netcdf dataset behind the xarray.Dataset object, albeit by accessing private members.
As per https://stackoverflow.com/questions/42699765/access-to-a-datasets-netcdf4-dataset, this functionality was expected to disappear, and then did.
However, me like many WRF users are starting to use xarray and wrf-python for a lot of our work, which still requires the native netCDF4.Dataset object to access most of the routines.
Although it would be great if wrf-python simply operated on xarray.Dataset objects (there are plans to do so), but there are still several use cases where accessing the underlying datastore would be useful.
I've looked through the source code with a fine-tooth comb and I cannot for the life of me figure out where the native data store goes in the flow of logic in the load, likely it just disappears once loaded through xarray. Access to the encoding object reveals only a path to the source file, not the original source file object itself.
Describe the solution you'd like
It would be really great if there were the ability to access the underlying datastore object.
For example:
Or something similar, maybe a method if that is required.
Alternatively, if the encoding attribute still pointed at the original object (rather than a path) then that would work too.
I know this goes against the xarray goal of protecting the original source file, but I genuinely think it would increase the utility of the library to allow users more freedom in this respect. Surely there is a mode of opening the file that is truly read-only so that we can access the native object?
Describe alternatives you've considered
I've dug into the source code to find the source object, no success.
Working with wrf-python I load with netCDF4.Dataset then assemble my xarray.Dataset after extracting diagnostics, it is important to remember to close the original nc.Dataset if you're doing anything else down the line!
Other options include creating an in-memory Dataset object from the xarray.Dataset but it feels wrong to load through xarray only to create a netCDF4.Dataset from its contents.
Additional context
I am happy to implement this change if someone can point me at the underlying datastore in the code.
The text was updated successfully, but these errors were encountered: