Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install pyradex on latest (and any) anaconda #24

Open
SmirnGreg opened this issue Jun 4, 2019 · 7 comments
Open

Can't install pyradex on latest (and any) anaconda #24

SmirnGreg opened this issue Jun 4, 2019 · 7 comments

Comments

@SmirnGreg
Copy link
Contributor

Dear Adam,

I can't install pyradex and make it to go through tests. I am installing it into conda environment since I don't have root access on most machines.

Steps to reproduce:

conda create -n pyradex_demo anaconda python=3.7
conda activate pyradex_demo      
git clone --recursive https://github.com/keflavich/pyradex.git
cd pyradex
pip install astroquery
pip install https://github.com/astropy/specutils/archive/master.zip
python setup.py install_radex install_myradex install

python runtests.py  # raises   File "_pytest.config", line 187, in addini AssertionError
pytest # raises Failed: [pytest] section in setup.cfg files is no longer supported, change to [tool:pytest] instead.

rm setup.cfg        
pytest   
# ==================================== test session starts ====================================
#platform linux -- Python 3.7.3, pytest-4.3.1, py-1.8.0, pluggy-0.9.0
#rootdir: /home/smirnov/pyradex, inifile:
#plugins: remotedata-0.3.1, openfiles-0.3.2, doctestplus-0.3.0, arraydiff-0.3
#collected 22 items                                                                          

#pyradex/tests/test_fjdu.py FF                                                         [  9%]
#pyradex/tests/test_radex.py .FF......F..F..F                                          [ 81%]
#pyradex/tests/test_radex_install.py F                                                 [ 86%]
#pyradex/tests/test_radex_myradex_consistency.py FF                                    [ 95%]
#pyradex/tests/test_synthspec.py

ipython
Python 3.7.3 (default, Mar 27 2019, 22:11:17) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import pyradex 
   ...: import numpy as np 
   ...: R = pyradex.Radex(collider_densities={'oH2':900,'pH2':100}, column=1e16, species='co'
   ...: , temperature=20) 
   ...: Tlvg = R(escapeProbGeom='lvg') 
   ...: Tslab = R(escapeProbGeom='slab') 
   ...: Tsphere = R(escapeProbGeom='sphere') 
   ...: Tlvg[:3].pprint() 
   ...: Tslab[:3].pprint() 
   ...: Tsphere[:3].pprint()                                                                 
/home/smirnov/pyradex/pyradex/core.py:910: RuntimeWarning: invalid value encountered in true_divide
  frac_level_diff = level_diff/self.level_population
         Tex                    tau            frequency  ...      brightness     T_B
          K                                       GHz     ... erg / (cm2 Hz s sr)  K 
---------------------- ---------------------- ----------- ... ------------------- ---
 3.433046369148207e-15  9.472345744143519e-20 115.2712018 ...                 0.0 0.0
3.2016068866791967e-15  3.786530681495501e-20     230.538 ...                 0.0 0.0
1.4043485108295587e-15 2.4326869586205468e-20 345.7959899 ...                 0.0 0.0
         Tex                    tau            frequency  ...      brightness     T_B
          K                                       GHz     ... erg / (cm2 Hz s sr)  K 
---------------------- ---------------------- ----------- ... ------------------- ---
 3.433046369148207e-15  9.472345744143519e-20 115.2712018 ...                 0.0 0.0
3.2016068866791967e-15  3.786530681495501e-20     230.538 ...                 0.0 0.0
1.4043485108295587e-15 2.4326869586205468e-20 345.7959899 ...                 0.0 0.0
         Tex                    tau            frequency  ...      brightness     T_B
          K                                       GHz     ... erg / (cm2 Hz s sr)  K 
---------------------- ---------------------- ----------- ... ------------------- ---
 3.433046369148207e-15  9.472345744143519e-20 115.2712018 ...                 0.0 0.0
3.2016068866791967e-15  3.786530681495501e-20     230.538 ...                 0.0 0.0
1.4043485108295587e-15 2.4326869586205468e-20 345.7959899 ...                 0.0 0.0

This looks very different from what is in the readme, and started to work only after I have installed RADEX from https://personal.sron.nl/~vdtak/radex/index.shtml

Before that, and on other machine without RADEX, I get the following:

Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pyradex
   ...: import numpy as np
   ...: R = pyradex.Radex(collider_densities={'oH2':900,'pH2':100}, column=1e16, species='co', temperature=20)
   ...: Tlvg = R(escapeProbGeom='lvg')
   ...: Tslab = R(escapeProbGeom='slab')
   ...: Tsphere = R(escapeProbGeom='sphere')
   ...: Tlvg[:3].pprint()
   ...: Tslab[:3].pprint()
   ...: Tsphere[:3].pprint()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-5897764a5c29> in <module>
      1 import pyradex
      2 import numpy as np
----> 3 R = pyradex.Radex(collider_densities={'oH2':900,'pH2':100}, column=1e16, species='co', temperature=20)
      4 Tlvg = R(escapeProbGeom='lvg')
      5 Tslab = R(escapeProbGeom='slab')

~/pyradex/pyradex/core.py in __init__(self, collider_densities, density, total_density, temperature, species, column, column_per_bin, tbackground, deltav, abundance, datapath, escapeProbGeom, outfile, logfile, debug, mu, source_area)
    290                 raise ValueError("Data path %s was not successfully stored;"
    291                                  " instead %s was." % (datapath,self.datapath))
--> 292         self.species = species
    293         if self.molpath == b'':
    294             raise ValueError("Must set a species name.")

~/pyradex/pyradex/base_class.py in species(self, species)
    125         self._species = species
    126         try:
--> 127             self.molpath = os.path.join(self.datapath,species+'.dat')
    128         except IOError:
    129             log.warn("Did not find data file for species {0} "

~/pyradex/pyradex/core.py in molpath(self, molfile)
    613         else:
    614             self.radex.impex.molfile[:] = ""
--> 615         utils.verify_collisionratefile(molfile)
    616         try:
    617             self.radex.impex.molfile[:len(molfile)] = molfile

~/pyradex/pyradex/utils.py in verify_collisionratefile(fn)
     69     from astroquery import lamda
     70
---> 71     if not os.path.exists(fn):
     72         raise IOError("File {0} does not exist.".format(fn))
     73

/anaconda3/envs/pyradex_demo/lib/python3.7/genericpath.py in exists(path)
     17     """Test whether a path exists.  Returns False for broken symbolic links"""
     18     try:
---> 19         os.stat(path)
     20     except OSError:
     21         return False

ValueError: embedded null byte

Is it expected? Does pyradex depend on pre-installed RADEX? Is it fine that tests don't run out of the box, and many of them fail if I run them manually?

I am sorry if I do something weird.

@keflavich
Copy link
Owner

the 'embedded null byte' issue is one I've seen but I thought I had fixed. I'll investigate; maybe there are py3.7 issues as I haven't tested against 3.7 yet

@keflavich
Copy link
Owner

it does look like some of the tests are broken. However, I'm pretty sure the code is working in most cases... I won't be able to fix the bugs for at least a day though

@SmirnGreg
Copy link
Contributor Author

SmirnGreg commented Jun 4, 2019 via email

@keflavich
Copy link
Owner

I fixed a few of the bugs. I'm a little worried about the numerical differences in the README example, though - Jeff Mangum reported a similar issue, and I don't know what caused it. I want to validate against a clean RADEX run. That has to happen later, unfortunately. If you want to help with that, it would be welcome, though =)

@gianninapr
Copy link

I'm having the same issue listed by @SmirnGreg of the embedded null byte despite having installed RADEX and updated my data path within the MAKEFILE in RADEX. I used homebrew gcc to install my gfortran compiler. I'm running python version 3.6 , I can't get any of the simpler examples listed in the README file to run since they all give the same error

@keflavich
Copy link
Owner

Regarding the original issue, I just did a fresh install & run of the example using python 3.7:

import pyradex
import numpy as np
R = pyradex.Radex(collider_densities={'oH2':900,'pH2':100}, column=1e16, species='co', temperature=20)
Tlvg = R(escapeProbGeom='lvg')
Tslab = R(escapeProbGeom='slab')
Tsphere = R(escapeProbGeom='sphere')
Tlvg[:3].pprint()
Tslab[:3].pprint()
Tsphere[:3].pprint()

## -- End pasted text --
/Users/adam/miniconda3/lib/python3.7/site-packages/pyradex/core.py:910: RuntimeWarning: invalid value encountered in true_divide
  frac_level_diff = level_diff/self.level_population
       Tex                tau          frequency  upperstateenergy upperlevel lowerlevel    upperlevelpop       lowerlevelpop          brightness              T_B
        K                                 GHz            K                                                                        erg / (cm2 Hz s sr)           K
------------------ ------------------ ----------- ---------------- ---------- ---------- ------------------- ------------------- ---------------------- -----------------
13.290883580311629 1.1468849744920648 115.2712018             5.53     1          0       0.4690681835772442 0.23707418568311267 2.7509509930774456e-14 6.738597089663219
 9.818841145513437  3.001401907034107     230.538             16.6     2          1        0.253345500331731  0.4690681835772442   7.92657371926513e-14 4.854323769676796
 7.463146983160675  1.923670595076573 345.7959899            33.19     3          2      0.03837985573671704   0.253345500331731  6.197465478870997e-14  1.68695108408779
       Tex                tau          frequency  upperstateenergy upperlevel lowerlevel    upperlevelpop      lowerlevelpop          brightness              T_B
        K                                 GHz            K                                                                       erg / (cm2 Hz s sr)           K
------------------ ------------------ ----------- ---------------- ---------- ---------- ------------------- ------------------ ---------------------- ------------------
15.033255537705188 0.8822636119487622 115.2712018             5.53     1          0       0.4187667856349173 0.2016829184801295 2.7746969242628808e-14 6.7967639792879995
 12.96726846017353 2.2752960483725784     230.538             16.6     2          1       0.2973499665319058 0.4187667856349173  1.174470050344317e-13  7.192587975689052
 9.881878806224918 2.0596268711954067 345.7959899            33.19     3          2      0.07763119330763295 0.2973499665319058   1.20717013122686e-13 3.2859190075271423
       Tex                tau          frequency  upperstateenergy upperlevel lowerlevel    upperlevelpop       lowerlevelpop          brightness              T_B
        K                                 GHz            K                                                                        erg / (cm2 Hz s sr)           K
------------------ ------------------ ----------- ---------------- ---------- ---------- ------------------- ------------------- ---------------------- ------------------
12.643328614869603 1.2818237512839787 115.2712018             5.53     1          0       0.4930538787795504  0.2545664508826119 2.7244700714182203e-14  6.673730699068296
 8.479008281968543  3.401580205974277     230.538             16.6     2          1      0.22286520293005335  0.4930538787795504  6.189487914094684e-14 3.7905126940903053
  6.85804192779582 1.7288125158470458 345.7959899            33.19     3          2      0.02774741534234436 0.22286520293005335  4.779526844016607e-14   1.30098796329388

@keflavich
Copy link
Owner

When you say you installed RADEX, could you give more details? On my machine, I have not installed radex (at least, radex is not anywhere on my path).

If you're still having trouble, try running python setup.py install_radex install_myradex build install and put the full results in a gist. Mine looks like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants