-
Notifications
You must be signed in to change notification settings - Fork 35
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 of LineList tables #409
Conversation
…tools/linetools into fk5_refactor # Conflicts: # linetools/scripts/lt_xabssys.py and a few more fk5 purges
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There appear to be some recurring bugs dealing with calls to LineList._data, and I suspect these are symptomatic of a data table error that will rear its ugly head in several applications (e.g., instantiating AbsLines, AbsComponents, etc.)
linetools/abund/ions.py
Outdated
@@ -37,6 +37,7 @@ def ion_name(ion, flg=0, nspace=None): | |||
------- | |||
|
|||
""" | |||
import pdb; pdb.set_trace() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why drop into the debugger here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is now deprecated. I could just remove it I guess.
Just did.
@@ -103,7 +103,7 @@ def gaussian_ew(spec, ltype, initial_guesses=None): | |||
# Use only good values (i.e. with meaningful errors) | |||
cond = (sig > 0.) & (np.isfinite(sig)) | |||
# Actual fit | |||
g = fit_g(g_init, wv[cond], fx[cond], weights=1./sig[cond]) | |||
g = fit_g(g_init, wv[cond].value, fx[cond].value, weights=1./sig[cond].value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 65: I think this function is actually tested through test_gaussew_absline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't passing astropy 2.0.1 without this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my comment should have been inserted much higher and has nothing to do with your committed change. I was referring to your comment just below the docstring: "Note: Tested in test_absline_anly"
linetools/lists/linelist.py
Outdated
@@ -593,48 +621,46 @@ def all_transitions(self, line): | |||
if line == 'unknown': | |||
return self.unknown_line() | |||
if self.list in ['H2']: | |||
|
|||
cond = self._data['ion_name'] == line.split('(')[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the self._data['ion_name'] does not exist. Should be self._data['name'].
linetools/lists/linelist.py
Outdated
else: # this should be always len(tbl)==1 because Z is not None | ||
return self.from_table_to_dict(tbl) | ||
else: | ||
indices = np.where(self._data['ion_name'] == line)[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above also: self._data['ion_name'] does not exist; should be self._data['name']. Calling, e.g., LineList.all_transitions('HI') fails currently. However, it appears that self._data['ion_name'] is set in LineList. set_extra_columns_to_datatable()? Either way, all_transitions() doesn't work with or without 'extras'.
|
||
def strongest_transitions(self, line, wvlims, n_max=3, verbose=False): | ||
""" Find the strongest transition for an ion | ||
def strongest_transitions(self, line, wvlims, n_max=3, verbose=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method doesn't work either, also due to _data['ion_name'] KeyError.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as expected now.
Several of the methods in LineList(), e.g. all_transitions Previously, this was the default but I've turned that off. This will |
Changes Unknown when pulling 7a77e02 on fk5_refactor into ** on master**. |
Changes Unknown when pulling e7d3c9d on fk5_refactor into ** on master**. |
This guy ready to look at again? |
yes, please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good news: available_transitions, all_transitions, etc., seem to be working well now that the table keys are straightened out.
I spot checked a few VP fits with joebvp, which accesses atomic data through linetools, and all seems to be well there.
Bad news: I tested igmguesses and some odd behavior is now occurring. For one, when I start up igmguesses, the gui shows an odd assortment of lines in the various panels (beginning with MgI and PbII). When I switch to the 'strong' linelist with the 'T' key, I then get the normal suite of lines I usually see starting with Ly-alpha. Things get weirder when I try to add a component, as the list of added components shows the wrong ion!
I suspect that @ntejos will be able to track down the source of the problem fairly easily. Lines 240-262 of pyigm.guis.igmguesses initialize the linelists to be used by igmguesses and 311 and 326-355 set the list for use.
|
||
def strongest_transitions(self, line, wvlims, n_max=3, verbose=False): | ||
""" Find the strongest transition for an ion | ||
def strongest_transitions(self, line, wvlims, n_max=3, verbose=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as expected now.
@@ -103,7 +103,7 @@ def gaussian_ew(spec, ltype, initial_guesses=None): | |||
# Use only good values (i.e. with meaningful errors) | |||
cond = (sig > 0.) & (np.isfinite(sig)) | |||
# Actual fit | |||
g = fit_g(g_init, wv[cond], fx[cond], weights=1./sig[cond]) | |||
g = fit_g(g_init, wv[cond].value, fx[cond].value, weights=1./sig[cond].value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my comment should have been inserted much higher and has nothing to do with your committed change. I was referring to your comment just below the docstring: "Note: Tested in test_absline_anly"
I am pretty sure the changes to igmguesses will be straightforward enough. |
I'm aware of this, but I may need some extra time before I can start looking closer (still traveling). Regarding igmguesses, we can leave that for the very end and I agree changes there will be relatively easy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, specially the handling of available transitions
and (hopefully) strongest transitions
, if my "head compilation" was done right the later may need extra work to ensure the original sortening. Left some comments for your consideration...
linetools/isgm/abscomponent.py
Outdated
@@ -359,12 +359,15 @@ def add_abslines_from_linelist(self, llist='ISM', init_name=None, wvlim=None, mi | |||
|
|||
# unify output to be always QTable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update inline comment QTable
-> Table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@@ -65,7 +67,7 @@ class LineList(object): | |||
sort_by : str or list of str, optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove use_ISM_table
from docstring as it is removed below from code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked that the docs (linelist.rst) is up to date too
data_file = resource_filename('linetools', 'data/lines/linelist.ascii') | ||
# Read | ||
self._fulltable = Table.read(data_file, format='ascii.ecsv') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thus, we are not making the table from scratch anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct.
linetools/lists/linelist.py
Outdated
@@ -247,21 +260,25 @@ def set_lines(self, verbose=True, use_cache=True, use_ISM_table=True): | |||
use_ISM_table : bool, optional | |||
For speed, use a saved ISM table instead of reading from original source files. | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove use_ISM_table
as it seems is not used anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
return | ||
|
||
if self.list not in ['HI', 'ISM', 'EUV', 'Strong', 'H2']: | ||
warnings.warn('Not implemented: will not set relative strength for LineList: {}.'.format(self.list)) | ||
return | ||
|
||
# Set ion_name column | ||
ion_name = np.array([' '*20]*len(self.name)).astype(str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a good time to set up a naming convention that is valid for atoms and molecules alike? Instead of having different ones as currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, I'm not sure we have a convention at all.
Only 2 different prescriptions to generate them.
It might be good to have one method that does them.
But I think we are ok for now.
@@ -912,51 +933,123 @@ def update_wrest(table, verbose=True): | |||
table['Ek'][mt[0]] = 52330.33 / u.cm | |||
''' | |||
# | |||
def load_datasets(datasets, tol=1e-3, use_cache=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make tol lower? 1e-4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would require quite a bit of fussing.
Let's stick with 1e-3 for now.
linetools/lists/parse.py
Outdated
|
||
Parameters | ||
---------- | ||
use_ISM_table : bool, optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove use_ISM_table
from docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
|
||
Parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define datasets
in docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
def test_ism_read_source_catalogues(): | ||
ism = LineList('ISM', use_ISM_table=False) | ||
ism = LineList('ISM')#, use_ISM_table=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove for good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
#with pytest.raises(ValueError) as tmp: # This is failing Python 2.7 for reasons unbenknownst to me | ||
# ism.set_extra_columns_to_datatable(abundance_type='incorrect_one') | ||
#ism = LineList('ISM') | ||
#with pytest.raises(ValueError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we test for expected errors now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fussed with this for quite awhile. I can't
get it to work on 2.7 (it is fine on 3.6).
…tools/linetools into fk5_refactor # Conflicts: # linetools/isgm/abssystem.py # linetools/scripts/lt_xabssys.py
@ntejos , @jnburchett -- I think we are there (but let's see if this Am going to fuss with igmguesses to make sure that works. |
Changes Unknown when pulling fe60a20 on fk5_refactor into ** on master**. |
Changes Unknown when pulling fe60a20 on fk5_refactor into ** on master**. |
@jnburchett -- if you are happy and you know it, approve this PR. Thanks. |
Changes Unknown when pulling bf9d89e on fk5_refactor into ** on master**. |
Tested IGMguesses and problems seem to have been fixed. |
This started as a branch to convert fk5 coords to icrs (fk5 only
uses float32 precision!) and became a refactor of LineList tables.
I also sped up some of the methods.
Note that I've turned off the 'extra' columns as the default
when initializing LineList but I can be convinced to have
this be on by default.
I imagine there will be some issues raised in pyigm and/or GUIs.