Skip to content

Commit

Permalink
uses tns if not found on opensne
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Ridden authored and Ryan Ridden committed Apr 24, 2024
1 parent 057f4cf commit 24113a5
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tessreduce/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,17 +420,22 @@ def sn_lookup(name,time='disc',buffer=0,print_table=True):
json_acceptable_string = response.content.decode("utf-8").replace("'", "").split('\n')[0]
d = json.loads(json_acceptable_string)
if list(d.keys())[0] == 'message':
print(d['message'])
return None
#print(d['message'])

#return None
tns = True
else:
disc_t = d[name]['discoverdate'][0]['value']
disc_t = Time(disc_t.replace('/','-'))


max_t = d[name]['maxdate'][0]['value']
max_t = Time(max_t.replace('/','-'))
max_t = d[name]['maxdate'][0]['value']
max_t = Time(max_t.replace('/','-'))
ra = d[name]['ra'][-1]['value']
dec = d[name]['dec'][-1]['value']
tns = False
except:
print('!! Open SNe Catalog down, using TNS !!')
tns = True
if tns:
#print('!! Open SNe Catalog down, using TNS !!')
name = name[name.index('2'):]
url = f'https://www.wis-tns.org/object/{name}' # hard coding in that the event is in the 2000s
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
Expand All @@ -445,9 +450,6 @@ def sn_lookup(name,time='disc',buffer=0,print_table=True):
ra = c.ra.deg
dec = c.dec.deg


ra = d[name]['ra'][-1]['value']
dec = d[name]['dec'][-1]['value']
c = SkyCoord(ra,dec, unit=(u.hourangle, u.deg))
ra = c.ra.deg
dec = c.dec.deg
Expand Down

0 comments on commit 24113a5

Please sign in to comment.