PAHdb / pyPAHdb

A Python tool to decompose astronomical PAH emission into contributing PAH subclasses.

Home Page:https://www.astrochemistry.org/pahdb/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

More convenient way to access/import sample data

mattjshannon opened this issue · comments

There is a way to specify certain files within the repo as "data" or special files, such that when we want access them, we would not have to know their absolute paths at all times. Instead we basically import them a la Python modules if I recall correctly. I know I've seen this done before though I don't remember the code. I'll try to look up how to do this.

It will be useful because otherwise in the tutorial files I'll have to specify the relative paths of the example data I wish to use (or hard-code their absolute paths, which could change in the future). Being able to simply import the data makes the tutorials agnostic to the repo structure, which would be a nice property long-term.

Not high priority, but I think it's something we should incorporate. I believe it's rather straight-forward (once I find it online again!).

I found a decent way to do this. Basically you can find the absolute system path to the pyPAHdb module like so...
package_dir = os.path.dirname(os.path.abspath(pypahdb.__file__))

And then you can identify the directory containing our test data, e.g.,
data_dir = package_dir + '/tests/data/'

In this case I point to 'NGC7023-NW-PAHs.txt' within this directory. I think it's a good enough solution. Only thing is I had to copy that .txt file into the tests/data directory (from the examples folder).

This was solved by #8.