MNGuenther / allesfitter

allesfitter is a convenient wrapper around the packages ellc (light curve and RV models), dynesty (static and dynamic nested sampling) emcee (Markov Chain Monte Carlo sampling) and celerite (Gaussian Process models).
MIT License
60 stars 36 forks source link

[Bug?] allesfitter.allesclass(object_dir) fails #57

Closed martindevora closed 1 year ago

martindevora commented 1 year ago

Hello, I'm finding the next error:

Traceback (most recent call last):
  File "/home/martin/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/201.7846.77/plugins/python/helpers/pydev/pydevd.py", line 1438, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/martin/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/201.7846.77/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/martin/git_repositories/sherlockpipe/sherlockpipe/plan.py", line 340, in <module>
    alles = allesfitter.allesclass(object_dir)
  File "/home/martin/.local/lib/python3.8/site-packages/allesfitter/__init__.py", line 132, in __init__
    self.posterior_derived_params = pickle.load(open(os.path.join(datadir,'ns_derived_samples.pickle'),'rb'))
FileNotFoundError: [Errno 2] No such file or directory: '/home/martin/git_repositories/sherlockpipe/TIC305048087_all_short/fit_0/ns_derived_samples.pickle'

Process finished with exit code 1

after running this:

allesfitter.allesclass(object_dir)

I believe this code token from allesclass is not well written:

  if os.path.exists( os.path.join(config.BASEMENT.outdir,'ns_derived_samples.pickle') ):
      self.posterior_derived_params = pickle.load(open(os.path.join(datadir,'ns_derived_samples.pickle'),'rb'))

  #::: mcmc derived results?
  elif os.path.exists( os.path.join(config.BASEMENT.outdir,'mcmc_derived_samples.pickle') ):
      self.posterior_derived_params = pickle.load(open(os.path.join(datadir,'mcmc_derived_samples.pickle'),'rb'))

I belive that the pickle loading lines should do: pickle.load(open(os.path.join(config.BASEMENT.outdir,'mcmc_derived_samples.pickle'),'rb')) instead, because datadir is the root allesfitter directory meanwhile config.BASEMENT.outdir is the results directory containing the bayesian fit results.

Please would you confirm the extent? Because this is blocking our pipeline bayesian fit procedure as it is mainly based on allesfitter.

Kind regards. Martín.

martindevora commented 1 year ago

Hi, any updates about this? It is still a blocking issue. If you confirm that we can change datadir by config.BASEMENT.outdir I could send you a Pull Request. Regards.

MNGuenther commented 1 year ago

Thanks @martindevora

I am quite confused as to where this bug came from, and why no user (including myself) ever encounter this before. It must have slipped in with one of the latest pushs. Else, all past allesclass calls should have always failed.

Fix merged.