Skip to content

Commit

Permalink
Merge pull request #123 from zjzhang42/main
Browse files Browse the repository at this point in the history
update utils
  • Loading branch information
dr-rodriguez authored Apr 20, 2021
2 parents 4c372e2 + 8d885e2 commit 7434626
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions scripts/ingests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


# Make sure all source names are Simbad resolvable:
def check_names_simbad(ingest_names, ingest_ra, ingest_dec, verbose=False):
def check_names_simbad(ingest_names, ingest_ra, ingest_dec, radius='2s', verbose=False):
verboseprint = print if verbose else lambda *a, **k: None

resolved_names = []
Expand All @@ -32,13 +32,20 @@ def check_names_simbad(ingest_names, ingest_ra, ingest_dec, verbose=False):
verboseprint(resolved_names[i], "Found name match in Simbad")
n_name_matches = n_name_matches + 1

# If no identifier match found, search within 2 arcseconds of coords for a Simbad object
# If no identifier match found, search within "radius" of coords for a Simbad object
else:
verboseprint("searching around ", ingest_name)
coord_result_table = Simbad.query_region(
SkyCoord(ingest_ra[i], ingest_dec[i], unit=(u.deg, u.deg), frame='icrs'), radius='2s', verbose=verbose)

# If more than one match found within 2 arcseconds, query user for selection and append to resolved_name
if len(coord_result_table) > 1:
SkyCoord(ingest_ra[i], ingest_dec[i], unit=(u.deg, u.deg), frame='icrs'), radius=radius, verbose=verbose)

# If no match is found in Simbad, use the name in the ingest table
if coord_result_table is None:
resolved_names.append(ingest_name)
verboseprint("coord search failed")
n_notfound = n_notfound + 1

# If more than one match found within "radius", query user for selection and append to resolved_name
elif len(coord_result_table) > 1:
for j, name in enumerate(coord_result_table['MAIN_ID']):
print(f'{j}: {name}')
selection = int(input('Choose \n'))
Expand All @@ -58,12 +65,6 @@ def check_names_simbad(ingest_names, ingest_ra, ingest_dec, verbose=False):
verboseprint(resolved_names[i], "only result nearby in Simbad")
n_nearby = n_nearby + 1

# If no match is found in Simbad, use the name in the ingest table
else:
resolved_names.append(ingest_name)
verboseprint("coord search failed")
n_notfound = n_notfound + 1

# Report how many find via which methods
print("Names Found:", n_name_matches)
print("Names Selected", n_selections)
Expand Down

0 comments on commit 7434626

Please sign in to comment.