[SciPy-user] creating timeseries for non convertional custom frequencies

Pierre GM pgmdevlist@gmail....
Mon Apr 14 17:12:58 CDT 2008


Marco,

> (1) One mask that I created when importing the data or creating the masked
> array. This is used to mask all data values are physically inplausible or
> invalid.
> (2) Another mask that I just created with fill_missing_dates to get the
> missing dates filled.

Just count the number of unmasked data with series.count(), and store it into 
a count_ini variable. 
Then, keep on applying your filters, counting the number of unmasked data each 
time. You can then compare this new counts to count_ini (the original one).

> BTW, Is there a more efficient way to get properties of the masked array
> like number of masked and not masked values?

If you look at the source code for the count method (in numpy.ma), you'll see 
that the result of count is only the difference between the size along the 
given axis and the sum of the mask along the same axis:
ma.count(s, axis) = numpy.size(s._data, axis) - numpy.sum(s._mask, axis)

So, the nb of "valid" values is given by series.count(axis), the nb 
of "invalid" values by series._mask.sum(axis), the total nb of data by 
numpy.size(s,axis) or simply series.shape[axis].

If you only have 1D data, that's even faster:
nb of valid: series.count()
nb of invalid: series._mask.sum()
nb of data: series.size



More information about the SciPy-user mailing list