-
Notifications
You must be signed in to change notification settings - Fork 20
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
Fix Spitzer logic #362
Fix Spitzer logic #362
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
def SpitzerIRS_get_spec(sample_table, search_radius_arcsec, COMBINESPEC): | ||
""" | ||
Retrieve HST spectra for a list of sources. | ||
Retrieve Spitzer spectra for a list of sources. | ||
|
||
Parameters | ||
---------- | ||
|
@@ -47,14 +47,14 @@ def SpitzerIRS_get_spec(sample_table, search_radius_arcsec, COMBINESPEC): | |
|
||
# If multiple entries are found, pick the closest. | ||
# Or should we take the average instead?? | ||
if len(tab) > 0: | ||
if len(tab) > 1: | ||
print("More than 1 entry found", end="") | ||
if not COMBINESPEC: | ||
print(" - pick the closest") | ||
sep = [search_coords.separation(SkyCoord(tt["ra"], tt["dec"], unit=u.deg, frame='icrs')).to( | ||
u.arcsecond).value for tt in tab] | ||
id_min = np.where(sep == np.nanmin(sep))[0] | ||
tab_final = tab[id_min] | ||
id_min = np.nanargmin(sep) | ||
tab_final = tab[[id_min]] # double brackets to return a Table instead of a Row | ||
else: | ||
print(" - Combine spectra") | ||
tab_final = tab.copy() | ||
|
@@ -63,7 +63,7 @@ def SpitzerIRS_get_spec(sample_table, search_radius_arcsec, COMBINESPEC): | |
|
||
# Now extract spectra and put all in one array | ||
specs = [] | ||
for tt in tab: | ||
for tt in tab_final: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code change does change the results, and appears to be what the author intended. The code block above this produces There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I agree that the original intent of the code is to use COMBINESPEC to determine if the spectra should be combined or chosen based on the nearest, and I agree that is not happening (good catch!). I agree this change you suggest makes sense. |
||
url = "https://irsa.ipac.caltech.edu{}".format(tt["xtable"].split("\"")[1]) | ||
spec = Table.read(url, format="ipac") # flux_density in Jy | ||
specs.append(spec) | ||
|
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 code change:
print("More than 1 entry found"
)len(tab) == 1
.)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 makes sense to me that this is a typo and not intentional. I agree with the change.
Along the same lines, do we need the 'else' statement for this 'if' statment? since we have already covered the case where it is 0, it should never get to that else. Which may mean that we can get rid of the whole 'if len(tab)> 1 ...else' and reduce the indentation??? Somehow I can't leave this comment on the appropriate line, sorry.
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.
That code block wasn't getting hit originally but it will now when
len(tab) == 1
. And/but I agree that this could be made simpler (== easier to follow).