Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions astroquery/lamda/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class LamdaClass(BaseQuery):

def __init__(self, **kwargs):
super(LamdaClass, self).__init__(**kwargs)
self._moldict_path = os.path.join(self.cache_location,
"molecules.json")
self.moldict_path = os.path.join(self.cache_location,
"molecules.json")

def _get_molfile(self, mol, cache=True, timeout=None):
"""
Expand Down Expand Up @@ -112,8 +112,8 @@ def get_molecules(self, cache=True):
"""
if cache and hasattr(self, '_molecule_dict'):
return self._molecule_dict
elif cache and os.path.isfile(self._moldict_path):
with open(self._moldict_path, 'r') as f:
elif cache and os.path.isfile(self.moldict_path):
with open(self.moldict_path, 'r') as f:
md = json.load(f)
return md

Expand All @@ -133,7 +133,7 @@ def get_molecules(self, cache=True):
url
for url in datfile_urls}

with open(self._moldict_path, 'w') as f:
with open(self.moldict_path, 'w') as f:
s = json.dumps(molecule_dict)
f.write(s)

Expand Down
31 changes: 18 additions & 13 deletions docs/lamda/lamda.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,32 @@ query, use:

.. code-block:: python

>>> from astroquery import lamda
>>> lamda.print_mols()
>>> from astroquery.lamda import Lamda
>>> lamda.molecule_dict

A query type must be specified among ``'erg_levels'`` for energy levels,
``'rad_trans'`` for radiative transitions, or ``'coll_rates'`` for collisional
rates. Example queries are show below:
The dictionary is created dynamically from the LAMDA website the first time it
is called, then cached for future use. If there has been an update and you
want to reload the cache, you can find the cache file `molecules.json` and
remove it:

.. code-block:: python

>>> erg_t = lamda.query(mol='co', query_type='erg_levels')
>>> rdt_t = lamda.query(mol='co', query_type='rad_trans')
>>> clr_t = lamda.query(mol='co', query_type='coll_rates')
>>> Lamda.cache_location
u'/Users/your_username/.astropy/cache/astroquery/Lamda'
>>> Lamda.moldict_path
u'/Users/your_username/.astropy/cache/astroquery/Lamda/molecules.json'
>>> os.remove(Lamda.moldict_path)

Catalogs are returned as `~astropy.table.Table` instances. Often molecules have
collisional rates calculate for more than one collisional partner, specify the
order of the partner in the datafile using the ``coll_partner_index`` parameter:

You can query for any molecule in that dictionary.

.. code-block:: python

>>> clr_t0 = lamda.query(mol='co', query_type='coll_rates', coll_partner_index=0)
>>> clr_t1 = lamda.query(mol='co', query_type='coll_rates', coll_partner_index=1)
>>> collrates,radtransitions,enlevels = Lamda.query(mol='co')

Catalogs are returned as `~astropy.table.Table` instances, except for
`collrates`, which is a dictionary of tables, with one table for each
collisional partner.

Reference/API
=============
Expand Down