[SciPy-user] fill a timeseries with masked data by correlation from another series
Thu Apr 3 19:21:10 CDT 2008
On Thursday 03 April 2008 18:52:26 Marco Tuckner wrote:
> I would like to correlate two (or more timeseries) to estimate invalid and
> masked values in one series based on the values of another complete series
> using the correlation coefficient.
> How can I to that?
Thinking about it, there's a simple solution if you're in a hurry: don't use
masked data. Of course, you have to make sure to be consistent...
- Make sure that your two series are aligned (that they start at the same date
and have the same frequency and length).
- Create a common mask with something like
commonmask = ma.mask_or(ma.getmask(series_1), ma.getmask(series_2))
- Apply the mask to your two series:
series_1.mask = series_2.mask = commonmask
- Compress them to get rid of any missing values with the 'compressed'
- Perform the computation you want on the compressed data.
You may have to copy some data when needed, but you have the gist of it.
let me know how it goes.
More information about the SciPy-user