rabrahm / ceres

A set of pipelines and routines for echelle spectrographs
MIT License
39 stars 27 forks source link

Fatal Python error: PyThreadState_Get: no current thread - missing jplephem #3

Closed jmccormac01 closed 8 years ago

jmccormac01 commented 8 years ago

Hi again, Sorry for all the messages, I've just tried firing up CERES on some CAFE data we got recently and I immediately run into trouble. I get a ThreadState_Get error and the script crashes. It doesn't leave me in interactive mode to dig around.

As a first try, I just went with a simple, no options, all the data in a folder run (at least that's what I think it should do). It seems to print my path then immediately goes to a Fatal Python error.

▶ python -i cafepipe.py /Users/James/Dropbox/CAFE-OBS/data/testset/ 
['/Users/James/Documents/ceres/cafe', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/site-packages/donuts-0.1.0-py2.7.egg', '/Users/James/.pyenv/versions/miniconda-latest/lib/python27.zip', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/plat-darwin', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/plat-mac', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/lib-tk', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/lib-old', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/lib-dynload', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/site-packages', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/site-packages/setuptools-20.7.0-py2.7.egg', '../utils/Continuum', '../utils/Correlation', '../utils/OptExtract', '../utils/GLOBALutils', '../utils/SSEphem/']
Fatal Python error: PyThreadState_Get: no current thread
[1]    63946 abort      python -i cafepipe.py /Users/James/Dropbox/CAFE-OBS/data/testset/ 

I tried running it on a folder with some calibration frames and a few spectra. By adding print statements to the file I traced the error to

import jplephem

I did not have jplephem installed. I installed it with pip and the error went away. I'm now onto a new error about datatypes in the calibrations creating. I will try to get through this and update this issue or submit a pull request if I succeed :)

Thanks James

rabrahm commented 8 years ago

Hi James,

Thanks for the notification. However that won't work because the jplephem package that is supposed to be used is the one installed in the SSephem directory. The problem arises due to conflicts between the differen python versions on your system. What you can try to do for now is to comment out all the lines that deal with the barycentric correction. I will work on this issue during the week.

All the best, Rafael

El sept. 10, 2016 13:08, "James McCormac" notifications@github.com escribió:

Hi again, Sorry for all the messages, I've just tried firing up CERES on some CAFE data we got recently and I immediately run into trouble. I get a ThreadState_Get error and the script crashes. It doesn't leave me in interactive mode to dig around.

As a first try, I just went with a simple, no options, all the data in a folder run (at least that's what I think it should do). It seems to print my path then immediately goes to a Fatal Python error.

▶ python -i cafepipe.py /Users/James/Dropbox/CAFE-OBS/data/testset/ ['/Users/James/Documents/ceres/cafe', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/site-packages/donuts-0.1.0-py2.7.egg', '/Users/James/.pyenv/versions/miniconda-latest/lib/python27.zip', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/plat-darwin', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/plat-mac', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/lib-tk', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/lib-old', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/lib-dynload', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/site-packages', '/Users/James/.pyenv/versions/miniconda-latest/lib/python2.7/site-packages/setuptools-20.7.0-py2.7.egg', '../utils/Continuum', '../utils/Correlation', '../utils/OptExtract', '../utils/GLOBALutils', '../utils/SSEphem/'] Fatal Python error: PyThreadState_Get: no current thread [1] 63946 abort python -i cafepipe.py /Users/James/Dropbox/CAFE-OBS/data/testset/

I tried running it on a folder with some calibration frames and a few spectra. By adding print statements to the file I traced the error to

import jplephem

I did not have jplephem installed. I installed it with pip and the error went away. I'm now onto a new error about datatypes in the calibrations creating. I will try to get through this and update this issue or submit a pull request if I succeed :)

Thanks James

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rabrahm/ceres/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/APktrOIL79TbgU9gWLn46XdsXM5-EA-gks5qotWQgaJpZM4J5wUr .

jmccormac01 commented 8 years ago

Thanks for the reply on the weekend. Ah, I see. I thought Pyenv should quarantine all the Python versions from each other. I have many versions for testing etc and it is normally ok.

The other issue I mentioned about the datatypes mismatching was when trying to bias subtract. I got the following error which was coming from pyfits (I found the same issue in the astrometry.net issues list):

        No previous pre-processing files or found
        Generating Master calibration frames...
                -> Masterbias: done!
Traceback (most recent call last):
  File "cafepipe.py", line 179, in <module>
    Flat, RO_fl, GA_fl = cafeutils.MedianCombine(flats, zero=dirout+'MasterBias.fits')
  File "/Users/James/Documents/ceres/cafe/cafeutils.py", line 261, in MedianCombine
    d1 -= z.data
TypeError: Cannot cast ufunc subtract output from dtype('float64') to dtype('uint16') with casting rule 'same_kind'

I was using pyfits v3.4 and rolling back to v3.3 fixed this error. Maybe it is worth adding that to the README? I can work around the barycentric correction with the new astropy light travel time calculations for now.

I'm midway through my first run with CERES, it is doing the wavelength solution. This is great! :)

Cheers James

jmccormac01 commented 8 years ago

Ok, as you predicted the reduction fell over around the barycentric correction. I've had a look and I might be able to comment out those lines with the barycenter correction.

During the installation I did edit the Makefile in SSEphem folder to point it at where I think it should be pointing on my machine. See below. Hopefully there is an easy fix :)

PY  = /Users/James/.pyenv/versions/miniconda-latest/include/python2.7/                                                                                                                             
SWIG = /usr/local/bin/swig                                                                                                                                                                         
INUM = /Users/James/.pyenv/versions/miniconda-latest/pkgs/numpy-1.11.0-py27_0/lib/python2.7/site-packages/numpy/core/include/numpy/                                                                
ISOFA = ./SOFA                                                                                                                                                                                     
LSOFA = ./SOFA/lib                                                                                                                                                                                 
CPP = g++ -fPIC 
jmccormac01 commented 8 years ago

Hi again, Just to let you know (in case you are working on this now). My colleagues @mindriot101 and @pchote found a solution to the issue with jplephem compilation. I am running the pipeline now to check that it runs from end to end then I can submit a pull request with the changes.

rabrahm commented 8 years ago

Hi James, I was fixing another problem regarding with the BaryCor module (which doesn't exist anymore) and I was moving now to the jplephem problem, so I will be very interested in the solution that your colleagues found.

rabrahm commented 8 years ago

Thanks James, @mindriot101 and @pchote. I have just made a slight modification in the position of the paths in the Makefile.

jmccormac01 commented 8 years ago

Great, thank you. Hopefully SSEphem is ok under Linux with the small changes. Thanks for the quick merge! Are you continuing to develop CERES on the master branch?

jmccormac01 commented 8 years ago

I will close this now. If this problem comes back we can reopen it. Cheers.