Hi Glenn,
Here is the line in my linked code defining the __array__ method:
https://github.com/akleeman/xray/blob/0c1a963be0542b7303dc875278f3b163a15429c5/src/xray/conventions.py#L152
I don't know when Jeff Whitaker will be releasing the next version of
netCDF4, but I expect that might be pretty
Hi,
This looks useful. What you said about __array__ makes sense, but I didn't
see it in the code you linked.
Do you know when python netcdf4 will support the numpy array interface
directly? I searched around for a roadmap but didn't find anything. It may
be best for me to proceed with a slightly c
Hi Glenn,
Here is a full example of how we wrap a netCDF4.Variable object,
implementing all of its ndarray-like methods:
https://github.com/akleeman/xray/blob/0c1a963be0542b7303dc875278f3b163a15429c5/src/xray/conventions.py#L91
The __array__ method would be the most relevant one for you: it means
Hi Stephan,
Thanks for the reply. I was thinking of something along these lines but was
hesitant because while this provides clean access to chunks of the data,
you still have to remember to do cplx_data[:].mean() for example in the
case that you want cplx_data.mean().
I was hoping to basically ha
Hi Glenn,
My usual strategy for this sort of thing is to make a light-weight wrapper
class which reads and converts values when you access them. For example:
class WrapComplex(object):
def __init__(self, nc_var):
self.nc_var = nc_var
def __getitem__(self, item):
return se
Hi,
I am using netCDF4 to store complex data using the recommended strategy of
creating a compound data type with the real and imaginary parts. This all
works well, but reading the data into a numpy array is a bit clumsy.
Typically I do:
nc = netCDF4.Dataset('my.nc')
cplx_data = nc.groups['mygrou