uiucsn / astro_ghost

Galaxies HOsting Supernovae and other Transients (GHOST): A database of supernovae and the photometric and spectroscopic properties of their host galaxies.
2 stars 6 forks source link

errors in getTransientHost function #4

Closed djones1040 closed 3 years ago

djones1040 commented 3 years ago

Hi Alex! Was just trying out GHOST, and was wondering if you could help me figure out this error I get after trying to run a few Foundation SNe through GHOST:

In [28]: snCoord = [SkyCoord(75.933292*u.deg, 3.412472*u.deg, frame='icrs'),
    ...:            SkyCoord(317.282846667*u.deg,-18.1039466667*u.deg,frame='icrs'),
    ...:            SkyCoord(159.935667*u.deg,+15.034661*u.deg,frame='icrs')]

In [29]: hosts = getTransientHosts(['PS16n','ATLAS16dqf','2016ixf'], snCoord, verbose=1, starcut='normal')
2 transients not found in GHOST by name, trying a coordinate search...
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-29-804969a05f1c> in <module>
----> 1 hosts = getTransientHosts(['PS16n','ATLAS16dqf','2016ixf'], snCoord, verbose=1, starcut='normal')

//anaconda3/envs/yse_pz/lib/python3.8/site-packages/astro_ghost/ghostHelperFunctions.py in getTransientHosts(snName, snCoord, snClass, verbose, starcut)
    495             tempHost3 = findNewHosts(snName_remaining, snCoord_remaining, snClass_remaining, verbose, starcut)
    496             found_by_manual = len(tempHost3)
--> 497     hostDB = pd.concat([tempHost1, tempHost2, tempHost3], ignore_index=True)
    498     hostDB.replace(-999.0, np.nan, inplace=True)
    499     if verbose:

UnboundLocalError: local variable 'tempHost3' referenced before assignment
alexandergagliano commented 3 years ago

Added a line to initialize these values to 0 and None on the offchance that it finds all the hosts in the database and doesn't need to run a new host association for anything.