keflavich / pyradex

Python interface to RADEX
BSD 3-Clause "New" or "Revised" License
18 stars 12 forks source link

If Radex.datapath is not set explicitly, an OSError occurs #11

Open tomr-stargazer opened 7 years ago

tomr-stargazer commented 7 years ago

Hey, I just started using pyradex, and wanted to log the following unhandled error. I was following the example hosted here: http://nbviewer.jupyter.org/github/keflavich/pyradex/blob/master/examples/FittingTheGrid.ipynb

and when I ran the following line:

R = pyradex.Radex(species='oh2co-h2', abundance=1e-8, column=1e14, temperature=20)

I got this error: https://gist.github.com/tomr-stargazer/9f6448b4bfc5e93011f463bfe6980003

It looks like the code somehow mishandles the fact that self.datapath is set to None, so I wonder if there is a more elegant way to handle this (at least to throw a more sensible error).

I'd be happy to attempt to solve this myself as I get more comfortable and familiar with pyradex!

tomr-stargazer commented 7 years ago

The error doesn't come up when I have $RADEX_DATAPATH (in my shell) set to something sensible, as expected.

keflavich commented 7 years ago

Right, probably the best solution is to raise a descriptive exception earlier if the path is not set, since I think we need the path set in order to stash & retrieve collisional data files.