nespinoza / juliet

A versatile modelling tool for transiting and non-transiting (single and multiple) exoplanetary systems
MIT License
53 stars 31 forks source link

Problem loading my file from local path #70

Closed GeoLek closed 2 years ago

GeoLek commented 2 years ago

Dear Nestor,

Congratulations for this package. This is the first time I use it and it seems to be a powerhouse. I want to incorporate Gaussian Processes into the code and played around with the sample notebook but also with data set downloaded via URL successfully. Now I want to load files from my local path but I have a problem loading them with Juliet. I follow the instructions here: https://juliet.readthedocs.io/en/latest/user/priorsnparameters.html with "juliet.load" but with no successful outcome.

Below I write some ways I tried to load my file following the documentation:

A)

import juliet import numpy as np import matplotlib.pyplot as plt

priors = {} dataset = juliet.load(priors=priors, t_lc = times, y_lc = fluxes, yerr_lc = fluxes_error, lc_test.fits = /home/orion/Geo/lc_test.fits)

Plot the data:

plt.errorbar(dataset, fmt='.') plt.xlim([np.min(t),np.max(t)]) plt.xlabel('Time (BJD - 2457000)') plt.ylabel('Relative flux')

Which gives a syntax error at "/home", so I put it in " ' ' " ('/home/orion/Geo/lc_test.fits') but it also gives an expression error.

B)

Tried to simplify it: import juliet import numpy as np import matplotlib.pyplot as plt

dataset = juliet.load(lc_test = '/home/orion/Geo/lc_test.fits')

Plot the data:

plt.errorbar(dataset, fmt='.') plt.xlim([np.min(t),np.max(t)]) plt.xlabel('Time (BJD - 2457000)') plt.ylabel('Relative flux')

But I get a unexpected argument error as well.

C) import juliet import numpy as np import matplotlib.pyplot as plt

dataset = juliet.load('lc_test.fits == /home/orion/Geo/lc_test.fits')

Plot the data:

plt.errorbar(dataset, fmt='.') plt.xlim([np.min(t),np.max(t)]) plt.xlabel('Time (BJD - 2457000)') plt.ylabel('Relative flux')

Error: No such file or directory but the directory is correct.

Can you please provide me with some solutions/directions? Thank you very much!!

icweaver commented 2 years ago

Hey @GeoLek, hope you are enjoying the package! I happened to notice your issue, so I hope you don't mind me chiming in!

It looks like you are trying to load a fits file on your computer using a keyword argument that does not exist. Could you describe a little bit about what are in the contents of this file and/or where it came from? Typically, we either pass a times and fluxes array to juliet directly, or have a helper function like get_TESS_data read in a particularly formatted fits file and compute those arrays for us.

In the example you posted above:

dataset = juliet.load(priors=priors, t_lc = times, y_lc = fluxes, yerr_lc = fluxes_error, lc_test.fits = /home/orion/Geo/lc_test.fits)

it looks like you are passing:

Regarding that last point, paths in Python are typically strings, while something like foo/bar/baz is parsed as those individual vars divided by each other, which would then throw a NameError because they were never defined in the first place. This is what gives the syntax error you mentioned before you tried wrapping your path in quotes.

So, it looks like you are probably trying to mix two things together, passing time and flux arrays directly to juliet.load vs. computing them through a helper function which can accept a path to a fits file. To know which path (hah) you would like to go, could you provide a MWE? It would be really helpful for us! You can also wrap your code snippets in triple backticks like this to get nice formatting and syntax highlighting 🌈

```python
<your awesome code here>
nespinoza commented 2 years ago

Closing this as I think @icweaver had this covered with his answer (thanks Ian!).