Working with the Host Class

Working with the Host Class#

Similar to the transient_objects.ipynb notebook, this will go through useful methods of the Host class. The general thing to keep in mind here is that we want to minimize the amount of data that OTTER stores locally for Hosts. This is because much of the data is already available in an easy format online. So, instead, we provide code to query those services for data on the hosts and just store host metadata.

We will start by setting up the OTTER dataset connection and pulling the Host information from the ASASSN-14li Transient object. If you are unsure what this means, we recommend you return to the transient_objects.ipynb notebook.

[1]:
# imports
import os
import otter
import matplotlib.pyplot as plt
[2]:
# connect to the dataset
db = otter.Otter()

# grab the host information for ASASSN-14li
t = db.query(names='ASASSN-14li')[0]
host = t.get_host()[0] # we can just take the last one

host
Attempting to login to https://otter.idies.jhu.edu/api with the following credentials:
username: user-guest
password: test
[2]:
SDSS J124815.23+174626.4 @ (RA, Dec)=(192.06249999999997 deg,17.77401111111111 deg)

Before we do anything else, you should take a look at the host attributes and methods with the documentation. The notable attributes are:

  • name: The name of the host

  • coord: The astropy SkyCoord for this host

  • z or redshift: The redshift of this host

  • transient_name: The default name from OTTER for the associated transient

  • bibcodes: The references that say this is the host galaxy of transient_name

So, as you can see, this has many methods to pull data from a wide variety of sources for this host galaxy! I will go through three here; querying simbad, ZTF forced photometry, and sparcl (for spectra).

Simbad#

Querying simbad will give you more meta information on the host, in case we are missing any in OTTER.

[3]:
host.query_simbad()
[3]:
Table length=1
main_idradeccoo_err_majcoo_err_mincoo_err_anglecoo_wavelengthcoo_bibcode
degdegmasmasdeg
objectfloat64float64float32float32int16str1object
ZW VIII 211192.0634387608217.774020951730.17120.107990O2020yCat.1350....0G

ZTF Forced Photometry#

The query_ztf method will pull all of the ZTF forced photometry for this Host. There are other services that will give you forced photometry like the query_asassn, query_ptf, and query_atlas methods. Most of these are easy and do not require authentication. But, please note, you need to set some special environment variables for querying ATLAS forced photometry.

[4]:
ztf_phot = host.query_ztf()
ztf_phot
[4]:
Table length=1380
oidexpidhjdmjdmagmagerrcatflagsfiltercoderadecchisharpfilefracdayfieldccdidqidlimitmagmagzpmagzprmsclrcoeffclrcouncexptimeairmassprogramid
int64int32float64float64float32float32int32str2float64float64float32float32int64int32uint8uint8float32float32float32float32float32float32float32int32
577108400005378448310632458202.816185215558202.310636616.377230.0154390020zg192.06343817.77407152.7160.277201803253106255778420.8526.2415050.0337535-0.0242719954.0729796e-0530.01.0721
577108400005378448335592458202.84113893558202.335590316.4198190.01557906250zg192.063404717.77403392.8770.218201803253355795778420.926.237380.03151846-0.0212197173.6010155e-0530.01.0421
577108400005378451305542458205.81108702958205.30554416.4228340.0155892810zg192.063431717.77403952.2720.102201803283055215778420.2126.2586380.040733323-0.0198166678.143837e-0530.01.0671
577108400005378451318542458205.82408467658205.318541716.426170.0156006410zg192.063432317.77406732.8190.159201803283185305778420.326.2640670.041553747-0.017580118.442703e-0530.01.051
577108400005378456299622458210.80513163558210.299629616.4418220.0156545940zg192.063453717.77407891.9810.149201804022994685778419.7526.1697620.04299412-0.0084749420.0001563728130.01.0561
577108400005378456321162458210.82667077858210.32116916.4680020.0157473732768zg192.063452117.77404571.6350.101201804023211575778419.2726.049080.049283765-0.0208422880.000310862330.01.0371
577108400005378460282172458214.787617135358214.282175916.3900340.0154802720zg192.063393917.77413092.5090.032201804062821645778420.3725.737190.04760029-0.0116361640.0001088625430.01.0651
577108400005378473295082458227.800154081558227.29508116.3730160.01542558150zg192.063397817.77407652.4090.065201804192950695778421.026.2263950.032994743-0.019940363.9443865e-0530.01.0341
577108400005378476334602458230.83955763858230.334606516.4408440.0156511870zg192.063417817.77408033.1180.266201804223345955778421.6926.2101570.025991382-0.048994062.3768815e-0530.01.0821
........................................................................
15722154000267091558307892459312.813289339759312.307893515.9263170.0133430820zr192.063487817.77403143.8060.40420210408307882157215421.5926.3101520.0276592630.1055522042.350647e-0530.01.0513
15722154000267091570237462459324.742492642759324.237465315.95095350.0133940920zr192.063465217.77406073.0480.12920210420237465157215420.7726.2698650.0291912520.105332562.7050333e-0530.01.0832
15722154000267091570237922459324.74295552559324.237928215.9090860.0133083260zr192.063426217.77402454.3640.33120210420237928157215421.0926.2568720.028953460.112065032.616994e-0530.01.0833
15722154000267091589223922459343.727960731459343.223923615.8320290.0131618310zr192.063481717.77406423.3450.21120210509223924157215421.6726.2204950.029719970.104887212.7938207e-0530.01.0512
15722154000267091589224392459343.728435199259343.224398115.8408470.01317787450zr192.063449717.77406633.9740.38520210509224398157215421.7126.2203350.0274561890.116742912.385869e-0530.01.0513
15722154000267091953201902459707.706026772559707.201909715.9111150.0133123790zr192.063486517.77407963.2670.08120220508201910157215420.626.2848050.0312240550.114652853.0734343e-0530.01.0672
15722154000267092263405402460017.910846625560017.405405115.9251540.01334071132768zr192.063487917.77409552.2790.33120230314405394157215419.525.120990.0492228870.121204849.146372e-0530.01.0612
15722154000267092288332692460042.83810263760042.332696815.9563230.0134054170zr192.06345917.77410673.1610.32220230408332697157215419.4625.7692450.048680740.1118899969.221749e-0530.01.0572
15722154000267092301305182460055.810190341460055.305185215.9040690.0132983450zr192.063486317.77410792.8440.46220230421305174157215421.1126.2697930.029438270.12032382.7261045e-0530.01.0642
15722154000267092305236372460059.741212825860059.236377315.9099040.0133099580zr192.063485717.77409723.7040.42420230425236366157215421.0626.2135980.0276704970.120037172.4489718e-0530.01.0692

Which gives us a lot of time-series photometry for this host! Let’s plot the light curve, color coded by the filter. And, we can easily add a line for the discovery date of ASASSN-14li.

[5]:
fig, ax = plt.subplots()
for label, grp in ztf_phot.to_pandas().groupby('filtercode'):
    ax.errorbar(grp.mjd, grp.mag, yerr=grp.magerr, fmt='o', label=label)

ax.axvline(t.get_discovery_date().mjd, linestyle='--', label='ASASSN-14li Discovery')

ax.set_ylabel('Magnitude')
ax.set_xlabel('MJD')
fig.gca().invert_yaxis()
ax.legend();
../_images/examples_host_objects_10_0.png

Get Host Spectra#

To get host spectra, we use the query_sparcl method which queries the SPARCL database. This will give an astropy table with columns for the wavelength and flux.

For a description of the columns see https://astrosparcl.datalab.noirlab.edu/sparc/sfc/

[6]:
spec = host.query_sparcl()
spec
[6]:
Table length=1
sparcl_iddecraspecidfluxwavelength_dr
str36float64float64int64objectobjectstr9
8aa3ea9d-a072-11ee-870c-525400ad133617.774016192.063462928594919838738432[75.78482819 75.77787018 78.90979004 ... 78.68370819 81.32446289\n 81.32581329][3803.64520329 3804.5211258 3805.39725003 ... 9215.09888735 9217.22098659\n 9219.34357452]SDSS-DR16
[7]:
fig, ax = plt.subplots()

for row in spec:
    ax.plot(row['wavelength'], row['flux'], label=row['_dr'])

ax.set_ylabel(r'Flux [$10^{-17}~erg~cm^{-2}~s^{-1}~AA^{-1}$]')
ax.set_xlabel(r'Wavelength [$\AA$]')
ax.legend();
../_images/examples_host_objects_13_0.png
[ ]: