Open lcoandrade opened 1 month ago
Not sure what is happening here. Since a TypeError
is reported, I first thought your input data might have a weird, type, but the first line in lyap_r
is data = np.asarray(data, dtype=np.float64)
, so everything should be a float after that anyway. :thinking:
A few things you might want to try:
mf
is (content + type) at the last reported line.min_tsep
(e.g. just use a value of min_tsep=1
for testing) and see if the algorithm works or if you get a different error.Using min_tsep=1
it works....
But I would need a good approach for min_tsep, that would be the mean period, but how to make it work?
Can you just manually execute the following code from lyap_r
in a script or notebook and tell me what mf
is? (Both print(mf)
and print(type(mf))
.)
data = np.asarray(data, dtype=np.float64)
n = len(data)
max_tsep_factor = 0.25
f = np.fft.rfft(data, n * 2 - 1)
mf = np.fft.rfftfreq(n * 2 - 1) * f**2
mf = np.sum(mf[1:]) / np.sum(f[1:]**2)
Alternatively, you can also just send me a sample dataset and the code that you use to load it and I can try to debug this on my end. This week, I actually have a bit of time to work on nolds, so I would be interested to investigate this. If this happens with sane input data, it might be an actual bug in the code for calculating min_tsep
.
Thanks for your help! Let me give one of the datasets, the respective yaml and the code I'm using.
This is one of the datasets: el_carmen.csv
This is the yaml file for the data: el_carmen.yaml.zip
This is the code: el_carmen.yaml.zip
The prints you asked me are these:
MF: (0.0001414471551393651+1.1866513857669307e-05j)
MF Type: <class 'numpy.complex128'>
Nice, thanks. Now it all makes a lot more sense. mf
somehow ends up as a complex number (albeit not very complex given the e-5) and the ceiling of a complex number is not defined. I was under the impression that you couldn't get complex numbers if all your inputs are real numbers, but it seems I made a mistake there. :thinking: For now, you can take np.ceil(1/mf.real)
as an estimate for min_tsep
. That would end up at 7070, which is quite high. Nolds would reduce that down to about half to ensure that min_tsep
is at maximum 25% of the number of datapoints in your input, but you might want to experiment with different values and see how the debug plot responds to that. I don't think it has to be that high.
Would you agree with this?
mtsep = np.ceil(1/mf.real)
mtsep = min(mtsep, int(0.25 * n))
We are observing something similar in our code with pandas dataframe of floats. Before upgrade from 0.5.2 to 0.6.x this was not a problem.
Can we hope for a proper fix in 0.6.2 soon?
I have a time series of meteorological data. I'm trying to compute lyap_r with this code:
But I get this error:
This is the series I'm using:
I'm using numpy==1.26.4 and nolds==0.6.
How can I solve this problem?