From 8da90367863fefc9da16715e00deafa5462c4326 Mon Sep 17 00:00:00 2001 From: "Adam Ginsburg (keflavich)" Date: Wed, 3 Jun 2015 07:45:44 -0400 Subject: [PATCH] update lamda docs for latest changes --- astroquery/lamda/core.py | 10 +++++----- docs/lamda/lamda.rst | 31 ++++++++++++++++++------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/astroquery/lamda/core.py b/astroquery/lamda/core.py index b685616c4c..077deb900b 100644 --- a/astroquery/lamda/core.py +++ b/astroquery/lamda/core.py @@ -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): """ @@ -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 @@ -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) diff --git a/docs/lamda/lamda.rst b/docs/lamda/lamda.rst index 2ee5f9b39b..d3098fa95f 100644 --- a/docs/lamda/lamda.rst +++ b/docs/lamda/lamda.rst @@ -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 =============