[Numpy-discussion] more recfunctions, structured array help
John [H2O]
washakie@gmail....
Tue Dec 8 16:32:52 CST 2009
Pierre GM-2 wrote:
>
>
>
> masked_where is a function that requires 2 arguments.
> If you try to mask a whole record, you can try something like
>>>> x = ma.array([('a',1),('b',2)],dtype=[('','|S1'),('',float)])
>>>> x[x['f0']=='a'] = ma.masked
> For an individual field, try something like
>>>>x['f1'][x['f1']=='b'] = ma.masked
>
>
Just some more detail, here's what I'm working on:
def mk_COarray(rD,datetimevec):
""" rD is a previous record array, but I add the datetime vector """
codata =
np.column_stack((np.array(datetime),rD.lon,rD.lat,rD.elv,rD.co))
codata = np.ma.array(codata)
codata_masked = np.ma.masked_where(codata==-9999.,codata)
codata =
np.rec.fromrecords(codata_masked,names='datetime,lon,lat,elv,co')
return codata, codata_masked
Plotting the arrays out of this:
In [128]: cd,cdm = mk_COarray(rD,datetimevec)
In [129]: plt.plot(cd.datetime,cd.co,label='raw');
plt.plot(cdm[:,0],cdm[:,4],label='masked')
I get the following image, where you can see that the codata which is
created from the codata_masked seems to not be masked????
http://old.nabble.com/file/p26702019/example.png
--
View this message in context: http://old.nabble.com/more-recfunctions%2C-structured-array-help-tp26700380p26702019.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.
More information about the NumPy-Discussion
mailing list