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

Refactor NIST #152

Merged
merged 16 commits into from Aug 9, 2013
Merged

Refactor NIST #152

merged 16 commits into from Aug 9, 2013

Conversation

jdnc
Copy link
Contributor

@jdnc jdnc commented Aug 5, 2013

This refactors the NIST module. Still need to update nist.rst, add remote tests

@jdnc
Copy link
Contributor Author

jdnc commented Aug 5, 2013

I just realized the table doesn't read the last two columns well because of them being url links. Working on this.

 Observed     Ritz     Rel.    Aki    ... Type    TP       Line   
-------- ----------- ----- --------- ... ---- -------- ----------
  --    4020.871 (200)    5526.5 ... over "showBal oon('[',ev
  --  4052.18664    -- 1238100.0 ...   --   <a cla s='bib' ON
  --  4052.19376    --  737160.0 ...   --   <a cla s='bib' ON
  --  4052.22121    --  215030.0 ... over "showBal oon('[',ev
  --  4052.23222    --  737210.0 ...   --   <a cla s='bib' ON
  -- 4052.248747    -- 2412100.0 ... over "showBal oon('T',ev
  --  4052.24892    -- 1485800.0 ... over "showBal oon('[',ev
  --  4052.26147    --   18846.0 ...   --   <a cla s='bib' ON
 ...         ...   ...       ... ...  ...      ...        ...
  --     5525.19 (150)    2470.9 ... over "showBal oon('[',ev
  --    5711.464 (180)    3515.8 ... over "showBal oon('[',ev
  --     5908.22 (540)   70652.0 ...   --   <a cla s='bib' ON
  --    5956.845 (210)    5156.2 ... over "showBal oon('[',ev
  --    6291.918 (250)    7845.7 ... over "showBal oon('[',ev
  --    6771.993 (300)   12503.0 ...   --   <a cla s='bib' ON
  --    6946.756    --    688.58 ... over "showBal oon('[',ev

@keflavich
Copy link
Contributor

Note that yesterday's version of process_asyncs had some errors in it; you should grab the latest. I'll merge the asyncs branch into master tomorrow, though, if you want to wait on that (we can discuss on hangout)

@jdnc
Copy link
Contributor Author

jdnc commented Aug 6, 2013

There seems to be a slight issue in the rendering of the generated functions API via sphinx

@keflavich
Copy link
Contributor

I've already used this successfully a few times:

>>> from astroquery import nist
>>> import astropy.units as u
>>> nist.Nist.query(minwav=1.63*u.um, maxwav=1.65*u.um, linename="Fe II")
<Table rows=1 names=('Observed','Ritz','Rel.','Aki','Acc.','Ei           Ek','Lower level','Upper level','Type','TP','Line')>
masked_array(data = [ (--, 1.643998, --, 0.006, 'C', '0.2321687    -    0.9863313', '3p6.3d7 | a 4F | 9/2', '3d6.(5D).4s | a 4D | 7/2', 'E2', 'T6677', --)],
             mask = [(True, False, True, False, False, False, False, False, False, False, True)],
       fill_value = (999999, 1e+20, 999999, 1e+20, 'N', 'N/A', 'N/A', 'N/A', 'N/', 'N/A', 999999),
            dtype = [('Observed', '<i8'), ('Ritz', '<f8'), ('Rel.', '<i8'), ('Aki', '<f8'), ('Acc.', 'S1'), ('Ei           Ek', 'S27'), ('Lower level', 'S20'), ('Upper level', 'S24'), ('Type', 'S2'), ('TP', 'S5'), ('Line', '<i8')])

>>> nist.Nist.query(minwav=1.59*u.um, maxwav=1.61*u.um, linename="Fe II")
<Table rows=1 names=('Observed','Ritz','Rel.','Aki','Acc.','Ei           Ek','Lower level','Upper level','Type','TP','Line')>
masked_array(data = [ (--, 1.599909, --, 0.00418, 'C', '0.3012936    -    1.076239', '3p6.3d7 | a 4F | 7/2', '3d6.(5D).4s | a 4D | 3/2', 'E2', 'T6677', --)],
             mask = [(True, False, True, False, False, False, False, False, False, False, True)],
       fill_value = (999999, 1e+20, 999999, 1e+20, 'N', 'N/A', 'N/A', 'N/A', 'N/', 'N/A', 999999),
            dtype = [('Observed', '<i8'), ('Ritz', '<f8'), ('Rel.', '<i8'), ('Aki', '<f8'), ('Acc.', 'S1'), ('Ei           Ek', 'S26'), ('Lower level', 'S20'), ('Upper level', 'S24'), ('Type', 'S2'), ('TP', 'S5'), ('Line', '<i8')])

>>> nist.Nist.query(minwav=2.16*u.um, maxwav=2.17*u.um, linename="H I")
<Table rows=1 names=('Observed','Ritz','Rel.','Aki','Acc.','Ei           Ek','Lower level','Upper level','Type','TP','Line')>
masked_array(data = [ (2.1661178, 2.166121, 8000, 304150.0, 'AAA', '12.7485385    -     13.32091736', 4, 7, --, 'T8637', 'L7421')],
             mask = [ (False, False, False, False, False, False, False, False, True, False, False)],
       fill_value = (1e+20, 1e+20, 999999, 1e+20, 'N/A', 'N/A', 999999, 999999, 999999, 'N/A', 'N/A'),
            dtype = [('Observed', '<f8'), ('Ritz', '<f8'), ('Rel.', '<i8'), ('Aki', '<f8'), ('Acc.', 'S3'), ('Ei           Ek', 'S31'), ('Lower level', '<i8'), ('Upper level', '<i8'), ('Type', '<i8'), ('TP', 'S5'), ('Line', 'S5')])

However, there ought to be a way to catch errors from empty tables:

>>> nist.Nist.query(minwav=2.17*u.um, maxwav=2.18*u.um, linename="H I")
ERROR: IndexError: list index out of range [astroquery.nist.core]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/adam/repos/astroquery/astroquery/utils/class_or_instance.py", line 25, in <lambda>
    f = lambda *args, **kwds: self.fn(cls, *args, **kwds)
  File "/Users/adam/repos/astroquery/astroquery/nist/core.py", line 51, in newmethod
    result = self._parse_result(response)
  File "/Users/adam/repos/astroquery/astroquery/utils/class_or_instance.py", line 25, in <lambda>
    f = lambda *args, **kwds: self.fn(cls, *args, **kwds)
  File "/Users/adam/repos/astroquery/astroquery/nist/core.py", line 194, in _parse_result
    pre = pre_re.findall(response.content)[0]
IndexError: list index out of range

@jdnc
Copy link
Contributor Author

jdnc commented Aug 7, 2013

Now this seems to handle this case correctly:

In [1]: import astropy.units as u

In [2]: from astroquery.nist import Nist

In [3]: Nist.query(minwav=2.17*u.um, maxwav=2.18*u.um, linename="H I")
ERROR: Exception: Result did not contain a table [astroquery.nist.core]
---------------------------------------------------------------------------

@keflavich
Copy link
Contributor

@jdnc - rebase this whenever you have a chance (the process_asyncs code can now be imported)

@jdnc
Copy link
Contributor Author

jdnc commented Aug 8, 2013

This is now rebased. There are issues in the rendering of query docs. Maybe we require a full-stop before the Parameters section begins ? e.g.
screenshot from 2013-08-08 11 00 06

@astrofrog
Copy link
Member

@jdnc - the first line of a docstring should always end with a period - I think that is the issue here.

@jdnc
Copy link
Contributor Author

jdnc commented Aug 9, 2013

@astrofrog , since this was a minor change to process_asyncsI have pushed in the commit for a period at the end along with #158

keflavich added a commit that referenced this pull request Aug 9, 2013
@keflavich keflavich merged commit 88a4954 into astropy:master Aug 9, 2013
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

Successfully merging this pull request may close these issues.

None yet

3 participants