Open warrickball opened 3 years ago
@nielsenmb couldn't reproduce this in Python 3.7 and neither can I with Python 3.7.4. I do, however, hit this with Python 3.8.2 and
Creating the LightCurve object seems to be fine so I had a closer look at why assigning the timeseries that are downloaded via Lightkurve works but passing a custom timeseries doesn't. Mimicking the code in PBjam, I tried this
import numpy as np
import pandas as pd
import lightkurve as lk
import pbjam
n = 1000
data = np.zeros((2,n))
data[0] = np.arange(n, dtype=float)/720
data[1] = np.random.randn(n)
df = pd.DataFrame({'ID': np.array(['test']).reshape((-1,1)).flatten()})
df['timeseries'] = [lk.LightCurve(time=data[0], flux=data[1])]
which is similar to the code path followed for custom timeseries and reproduces the Datatype coercion is not allowed
error message.
If I change the last line to this, which tries to be more like the path for downloaded objects (i.e. when you pass a string identifier), it appears to work:
df.at[0, 'timeseries'] = lk.LightCurve(time=data[0], flux=data[1], targetid='test')
vardf.at[0, key] = _arr_to_lk(x, y, vardf['ID'][0], key)
returns an error for me on Python 3.7, but
vardf[key] = object()
vardf.at[0, key] = _arr_to_lk(x, y, vardf['ID'][0], key)
seems to work
Here's a script that creates a basic timeseries of Gaussian noise in a 2×1000 array.
It fails with the following traceback:
I had a brief look around. The problem isn't the conversion of the timeseries into a Lightkurve object but rather when adding this to the
vardf
dataframe.I just did a
git pull
so I'm using the top ofmaster
(commit 0c5591a). If any other versions are relevant, they are: