Re: [Numpy-discussion] Transparently reading complex arrays from netcdf4

2014-03-29 Thread Stephan Hoyer
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

Re: [Numpy-discussion] Transparently reading complex arrays from netcdf4

2014-03-29 Thread G Jones
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

Re: [Numpy-discussion] Transparently reading complex arrays from netcdf4

2014-03-29 Thread Stephan Hoyer
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

[Numpy-discussion] Transparently reading complex arrays from netcdf4

2014-03-29 Thread G Jones
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

Re: [Numpy-discussion] Changes to np.vander

2014-03-29 Thread Jaime Fernández del Río
On Sat, Mar 29, 2014 at 8:55 AM, wrote: > On Sat, Mar 29, 2014 at 7:31 AM, wrote: > > On Sat, Mar 29, 2014 at 12:12 AM, Jaime Fernández del Río > > wrote: > >> Hi, > >> > >> I have submitted a PR (https://github.com/numpy/numpy/pull/4568) that > speeds > >> up `np.vander` by using accumulated

Re: [Numpy-discussion] Dates and times and Datetime64 (again)

2014-03-29 Thread Nathaniel Smith
On 29 Mar 2014 20:57, "Chris Barker" wrote: > I think this is somewhat open for discussion -- yes, it's odd, but in the spirit of practicality beats purity, it seems OK. We could allow any TZ specifier for that matter -- that's kind of how "naive" or "local" timezone (non) handling works -- it's u

Re: [Numpy-discussion] Dates and times and Datetime64 (again)

2014-03-29 Thread Chris Barker
On Sat, Mar 29, 2014 at 1:04 PM, Nathaniel Smith wrote: > > 1- You give as an example of "naive" datetime handling: > > > np.datetime64('2005-02-25T03:00Z') > > np.datetime64('2005-02-25T03:00') > > > > This IIUC is incorrect. The Z modifier is a timezone offset, and for > normal > > "naive"

Re: [Numpy-discussion] Dates and times and Datetime64 (again)

2014-03-29 Thread Nathaniel Smith
On Fri, Mar 28, 2014 at 9:30 PM, Sankarshan Mudkavi wrote: > > Hi Nathaniel, > > 1- You give as an example of "naive" datetime handling: > np.datetime64('2005-02-25T03:00Z') > np.datetime64('2005-02-25T03:00') > > This IIUC is incorrect. The Z modifier is a timezone offset, and for normal > "

Re: [Numpy-discussion] Changes to np.vander

2014-03-29 Thread josef . pktd
On Sat, Mar 29, 2014 at 7:31 AM, wrote: > On Sat, Mar 29, 2014 at 12:12 AM, Jaime Fernández del Río > wrote: >> Hi, >> >> I have submitted a PR (https://github.com/numpy/numpy/pull/4568) that speeds >> up `np.vander` by using accumulated multiplication instead of exponentiation >> to compute the

Re: [Numpy-discussion] Changes to np.vander

2014-03-29 Thread josef . pktd
On Sat, Mar 29, 2014 at 12:12 AM, Jaime Fernández del Río wrote: > Hi, > > I have submitted a PR (https://github.com/numpy/numpy/pull/4568) that speeds > up `np.vander` by using accumulated multiplication instead of exponentiation > to compute the Vandermonde matrix. For largish matrices the speed