You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't understand how to use masked arrays with stl.
import numpy as np
import numpy.ma as ma
from pyloess.mpyloess import stl
y = np.array([1,12,5,3,5,6])
yma = ma.masked_array(y, mask=[0,0,1,0,0,0])
stl(yma)
returns: ValueError: Masked arrays should be filled first!
In the code (mpyloess.py), I see that there is a check:
class stl:
class _inputs:
def __init__(self, y):
self.y = masked_array(y, subok=True, copy=False).ravel()
self._mask = self.y._mask
if self._mask.any():
raise ValueError("Masked arrays should be filled first!")
self.y_eff = self.y.compressed()
So any masked arrays will raise this error.
If I try with yma.filled() instead, the fit does take the filled values into account, which is not what I want for masked arrays.
Is it possible to use masked arrays, I understood that STL could deal with missing data.
Note that I am using @jcrotinger's fork for Python 3.
Thanks!
The text was updated successfully, but these errors were encountered:
@alexbovet I've never used the masked array functionality but it isn't about handling missing data - the underlying Fortran implementation is not set up for this (and I believe this is mentioned in the original paper). While the weights are passed in to the Fortran stl function, this is just because there are no dynamic arrays in Fortran 77. Internally, stl sets these weights to 1 on the initial pass and sets them directly later, instead of multiplicatively.
I'm guessing this functionality is there just to allow extracting some sort of slice from a python array to pass down to the STL, but I'm not sure.
In my Java implementation, I've considered exposing the weights externally for exactly this purpose - the implementation looks like it would be straightforward to modify to ignore missing values, assuming there are enough points available to do the sub-cycle interpolation to the missing point. But it isn't high on my list right now.
Hi,
I don't understand how to use masked arrays with stl.
returns:
ValueError: Masked arrays should be filled first!
In the code (mpyloess.py), I see that there is a check:
So any masked arrays will raise this error.
If I try with
yma.filled()
instead, the fit does take the filled values into account, which is not what I want for masked arrays.Is it possible to use masked arrays, I understood that STL could deal with missing data.
Note that I am using @jcrotinger's fork for Python 3.
Thanks!
The text was updated successfully, but these errors were encountered: