Accessing WISeREP Spectra from OTTER#

Since OTTER currently does not store spectra, we have setup a nice utility in the Python API for scraping WISeREP for spectra.

[1]:
from otter import Otter
from otter.io.data_finder import DataFinder
import matplotlib.pyplot as plt
from astropy.time import Time

db = Otter()
Attempting to login to https://otter.idies.jhu.edu/api with the following credentials:
username: user-guest
password: test

For an existing transient in OTTER#

For an existing transient in OTTER, we can use the Transient.get_wiserep_spec method. Here is an example for the TDE 2022cmc. The key is that the get_wiserep_spec method returns a metadata dataframe and a dictionary of dataframes, where the keys of the dictionary correspond to the indices of the metadata dataframe.

[2]:
t = db.get_meta(names="2022cmc")[0]
spec_meta, spec = t.get_wiserep_spec()

spec_meta
www.wiserep.org/system/files/uploaded/general/2022cmc_2022-02-15_NOT_ALFOSC_None.fits
[2]:
Spec. ID Obj. ID Obj. IAU Name Obj. Alt. Name/s Obj Family Type Obj Type Redshift Obs-date (UT) Phase/s Tel / Inst ... Public End Prop. Period Reporter/s Publish Contrib Remarks Created by Creation date (UT) Modified by Last modified date (UT)
0 68078 21988 TDE 2022cmc ZTF22aaajecp Nuclear TDE 1.19325 2022-02-15 00:00:00.00 NaN NOT / ALFOSC ... Y NaN 0.0 NaN NaN NaN Igor Andreoni 2022-11-08 21:57:59 Igor Andreoni 2022-11-08 21:57:59
1 68113 21988 TDE 2022cmc ZTF22aaajecp Nuclear TDE 1.19325 2022-02-15 00:00:00.00 NaN Gemini-N / GMOS ... Y NaN NaN NaN NaN NaN Igor Andreoni 2022-11-12 23:46:32 Igor Andreoni 2022-11-12 23:46:32
2 68114 21988 TDE 2022cmc ZTF22aaajecp Nuclear TDE 1.19325 2022-02-17 00:00:00.00 NaN VLT-UT2 / X-Shooter ... Y NaN NaN NaN NaN NaN Igor Andreoni 2022-11-12 23:46:32 Igor Andreoni 2022-11-12 23:46:32
3 68115 21988 TDE 2022cmc ZTF22aaajecp Nuclear TDE 1.19325 2022-02-17 00:00:00.00 NaN Keck2 / DEIMOS ... Y NaN NaN NaN NaN NaN Igor Andreoni 2022-11-12 23:46:32 Igor Andreoni 2022-11-12 23:46:32
4 68116 21988 TDE 2022cmc ZTF22aaajecp Nuclear TDE 1.19325 2022-02-25 00:00:00.00 NaN Keck1 / LRIS ... Y NaN NaN NaN NaN NaN Igor Andreoni 2022-11-12 23:46:32 Igor Andreoni 2022-11-12 23:46:32
5 68117 21988 TDE 2022cmc ZTF22aaajecp Nuclear TDE 1.19325 2022-03-03 00:00:00.00 NaN Keck1 / LRIS ... Y NaN NaN NaN NaN NaN Igor Andreoni 2022-11-12 23:46:32 Igor Andreoni 2022-11-12 23:46:32

6 rows × 33 columns

[3]:
spec
[3]:
{0:              wave          flux
 0     3801.161658  3.959880e-17
 1     3804.115984  2.544269e-17
 2     3807.072119  2.043800e-17
 3     3810.029589  2.072174e-17
 4     3812.988989  1.325344e-17
 ...           ...           ...
 1662  9699.843745  1.255609e-17
 1663  9703.774357  4.597480e-18
 1664  9707.707839  1.413910e-17
 1665  9711.637756 -4.758937e-19
 1666  9715.573435  7.614728e-18

 [1667 rows x 2 columns],
 1:         wave          flux
 0     3780.9 -9.542200e-15
 1     3782.0 -1.088000e-14
 2     3783.0 -3.540400e-15
 3     3784.0  1.319200e-14
 4     3785.0 -2.100300e-14
 ...      ...           ...
 4645  9592.8           NaN
 4646  9594.3           NaN
 4647  9595.9           NaN
 4648  9597.4           NaN
 4649  9598.9           NaN

 [4650 rows x 2 columns],
 2:           wave          flux
 0       322.92  2.719830e-17
 1       322.94  1.179679e-17
 2       322.96  2.934156e-17
 3       322.98 -1.145425e-17
 4       323.00  1.024262e-17
 ...        ...           ...
 34763  1019.92  6.300985e-18
 34764  1019.94  5.903712e-18
 34765  1019.96  1.943250e-18
 34766  1019.98  4.499430e-18
 34767  1020.00  7.878644e-18

 [34768 rows x 2 columns],
 3:              wave      flux
 0     5249.344001  0.746064
 1     5249.889949  1.554495
 2     5250.423940  0.559941
 3     5250.904266  0.260234
 4     5251.322104  0.444431
 ...           ...       ...
 8165  8775.021807  0.388649
 8166  8775.440147  0.447369
 8167  8775.863725  0.743812
 8168  8776.284496  1.129127
 8169  8776.704016  0.293823

 [8170 rows x 2 columns],
 4:             wave          flux
 0      3137.8279 -2.374370e-17
 1      3138.9409  1.227490e-16
 2      3140.0540 -4.633770e-17
 3      3141.1675  8.103950e-17
 4      3142.2810  1.314770e-16
 ...          ...           ...
 5968  10291.2710 -3.391160e-18
 5969  10292.4520  1.051670e-17
 5970  10293.6340  1.424370e-17
 5971  10294.8160 -1.011810e-18
 5972  10295.9970 -4.419770e-18

 [5973 rows x 2 columns],
 5:             wave          flux
 0      3061.2788  3.774020e-17
 1      3063.2290  4.144230e-17
 2      3065.1797 -1.860350e-17
 3      3067.1311  5.295430e-17
 4      3069.0830 -8.135830e-18
 ...          ...           ...
 5121  10291.4500 -1.628210e-19
 5122  10292.6330 -3.443930e-18
 5123  10293.8160  1.292440e-18
 5124  10295.0000  3.699810e-18
 5125  10296.1830  1.343260e-18

 [5126 rows x 2 columns]}

Then we can plot all of the spectra, normalized to the median.

[4]:
# get the 22cmc discovery date
disc_date = t.get_discovery_date().mjd

# sort the metadata dataframe by the date
spec_meta["phase"] = [Time(d).mjd-disc_date for d in spec_meta["Obs-date (UT)"]]
spec_meta = spec_meta.sort_values("phase")

# then plot
fig, ax = plt.subplots(figsize=(14, 6))
for offset, (idx,row) in enumerate(spec_meta.iterrows()):
    spec_df = spec[idx]
    norm = spec_df.flux.median()
    ax.plot(spec_df.wave, (spec_df.flux/norm)+5*offset, marker="none", label=f"{row.phase:.2f} days\n({row['Tel / Inst']})")

ax.set_ylim(-3, 40)
ax.legend(title="Phase", bbox_to_anchor=(1,1), loc="upper left")
ax.set_ylabel("Flux + Offset")
ax.set_xlabel("Wavelength [A]")
[4]:
Text(0.5, 0, 'Wavelength [A]')
../_images/examples_accessing_wiserep_spec_6_1.png

Querying WISeREP for transients not in OTTER#

The Transient.get_wiserep_spec method is just a wrapper on the DataFinder.query_wiserep method, so we can use that for a transient not currently in OTTER. As an example, consider the Type IIb supernova SN 2025ulz.

[5]:
datafinder = DataFinder(
    ra = 237.9758159,
    dec = +30.9023752,
    ra_units = "deg",
    dec_units = "deg",
    name = "2025ulz" # this should be the IAU Name! Otherwise you'll get an error
)

datafinder.query_wiserep()
[5]:
(   Spec. ID  Obj. ID Obj. IAU Name         Obj. Alt. Name/s Obj Family Type  \
 0     87945    28864    SN 2025ulz  ZTF25abjmnps, SN2025ulz              SN
 1     88934    28864    SN 2025ulz  ZTF25abjmnps, SN2025ulz              SN

   Obj Type  Redshift           Obs-date (UT)  Phase/s      Tel / Inst  ...  \
 0    SN II    0.0848  2025-08-24 00:03:40.00      NaN  VLT-UT4 / MUSE  ...
 1    SN II    0.0848  2025-08-30 02:32:55.00      NaN  MMT / BINOSPEC  ...

    Public End Prop. Period Reporter/s Publish Contrib  \
 0       Y              NaN        NaN     NaN     NaN
 1       Y              NaN        0.0     NaN     NaN

                                  Remarks  Created by   Creation date (UT)  \
 0  [TNS reporting group: 120 - ENGRAVE ]    TNS_Bot1  2025-08-25 08:30:06
 1                                    NaN  Noah Franz  2025-10-26 18:51:24

    Modified by Last modified date (UT)
 0     TNS_Bot1     2025-11-06 11:25:14
 1   Noah Franz     2025-10-26 18:51:24

 [2 rows x 33 columns],
 {0:              wave        flux
  0     4749.707031  581.415169
  1     4750.957031  318.839276
  2     4752.207031  193.009335
  3     4753.457031  265.674106
  4     4754.707031  217.658655
  ...           ...         ...
  3676  9344.707031  271.874223
  3677  9345.957031  220.513021
  3678  9347.207031  260.432850
  3679  9348.457031  342.568351
  3680  9349.707031  185.953972

  [3681 rows x 2 columns],
  1:              wave          flux
  0     4132.941538  4.235324e-18
  1     4134.228611  4.460402e-18
  2     4138.089866  4.030505e-18
  3     4139.376997  4.041083e-18
  4     4144.525670  4.095643e-18
  ...           ...           ...
  3777  9229.219681  4.047658e-18
  3778  9230.565896  4.214537e-18
  3779  9231.911943  4.655273e-18
  3780  9234.604301  4.232006e-18
  3781  9238.642963  4.024085e-18

  [3782 rows x 2 columns]})
[ ]: