Skip to main content

WiseRep API

API to access WiserRep data

repo license Python Version PyPI DOI

Installation

It is recommended to install wiserep_api from pip:

pip install wiserep_api

or it can be installed from source in the usual way.

Usage Example

Below are some basic examples of what the user can do with this package.

Download a list of SNe

A list of targets can be downloaded for a given spectral type. The spectral types are as defined in Wiserep, which can be printed with print_spectral_types:

from wiserep_api.search import print_spectral_types, download_sn_list
print_spectral_types()
{'Other': 0, 'SN': 1, 'SN I': 2, 'SN Ia': 3, 'SN Ib': 4, 'SN Ic': 5, 'SN Ib/c': 6, 'SN Ic-BL': 7, 'SN Ib - Ca-rich': 8, 'SN Ibn': 9, 'SN II': 10, 'SN IIP': 11, 'SN IIL': 12, 'SN IIn': 13, 'SN IIb': 14, 'SN I-faint': 15, 'SN I-rapid': 16, 'SLSN-I': 18, 'SLSN-II': 19, 'SLSN-R': 20, 'Afterglow': 23, 'LBV': 24, 'ILRT': 25, 'Nova': 26, 'CV': 27, 'Varstar': 28, 'AGN': 29, 'Galaxy': 30, 'QSO': 31, 'Std-spec': 50, 'Gap': 60, 'Gap I': 61, 'Gap II': 62, 'SN impostor': 99, 'SN Ia-pec': 100, 'SN Ia-SC': 102, 'SN Ia-91bg-like': 103, 'SN Ia-91T-like': 104, 'SN Ia-02cx-like': 105, 'SN Ia-CSM': 106, 'SN Ib-pec': 107, 'SN Ic-pec': 108, 'SN II-pec': 110, 'SN IIn-pec': 112, 'TDE': 120, 'WR': 200, 'WR-WN': 201, 'WR-WC': 202, 'WR-WO': 203, 'M dwarf': 210}

In this example, we can download 1991-T-like supernovae (SNe):

download_sn_list("SN Ia-91T-like")
390 "SN Ia-91T-like" objects found!
URL used: https://www.wiserep.org/search?&page=8&public=all&type[]=104

Download spectra

The public available spectra can also be easily downloaded for a list of targets. These will be saved under the spectra directory, in a separate directory for each target:

import numpy as np
from wiserep_api import download_target_spectra

sne_list = np.genfromtxt('SNIa-91T-like_wiserep.txt', dtype=str, delimiter='\n')

for sn in sne_list:
    try:
        download_target_spectra(sn, file_type='ascii', exclude=['SEDM'])
    except Exception as exc:
        print(f'{sn}: {exc}')

Running SNID

Assuming that SNID is already istalled, it can be run with just a few lines of code:

import os
from wiserep_api import snid

sne_list = np.genfromtxt('SNIa-91T-like_wiserep.txt', dtype=str, delimiter='\n')
snid_commmand = 'snid inter=0 plot=0 aband=0 usetype=Ia-91T'

for sn in sne_list:
    directory = os.path.join('spectra', sn)
    snid.run_snid(directory, command=snid_commmand)

Getting object's properties

The properties of a given object can be easily obtained:

from wiserep_api import get_target_property

for prop in ['type', 'redshift', 'host', 'coords', 'coords_deg']:
    value = get_target_property('2004eo', prop)
    print(f'{prop}: {value}')
type: SN Ia
redshift: 0.015718
host: NGC6928
coords: 20:32:54.190 +09:55:42.71
coords_deg: 308.22579 +9.92853

Or you can get multiple properties at once:

properties = ['type', 'redshift', 'host', 'coords', 'coords_deg']
values = get_target_property('2004eo', properties)

The spectral type of a given object can also be retrived with get_target_class, which does a more "in-depth" search of the classification in case this is not found in the main properties:

from wiserep_api import get_target_class

sn_type = get_target_class("2004eo")
print(sn_type)
'SN Ia'

Contributing

To contribute, either open an issue or send a pull request (prefered option). You can also contact me directly (check my profile: https://github.com/temuller).

Citing WiseRep API

If you make use of this code, please cite it:

@software{tomas_e_muller_bravo_2023_7896352,
  author       = {{M{\"u}ller-Bravo}, Tom{\'a}s E.},
  title        = {temuller/wiserep\_api: First Official Release!},
  month        = may,
  year         = 2023,
  publisher    = {Zenodo},
  version      = {v0.1.5},
  doi          = {10.5281/zenodo.7896352},
  url          = {https://doi.org/10.5281/zenodo.7896352}
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wiserep_api-0.1.11.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wiserep_api-0.1.11-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file wiserep_api-0.1.11.tar.gz.

File metadata

  • Download URL: wiserep_api-0.1.11.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for wiserep_api-0.1.11.tar.gz
Algorithm Hash digest
SHA256 711ccbe25d7d0007d42607d9f1aec2897e486d3e2ab423b236748a996d30c8bd
MD5 1bc2371030475d4fa0191a4b5be7bf0b
BLAKE2b-256 e4593770f15088e80b1a595a732b1bbfa81753e3cd08faf5d337676c1459f5c5

See more details on using hashes here.

File details

Details for the file wiserep_api-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: wiserep_api-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for wiserep_api-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 6da3252117d3f16afab773452756ec171f49281f900cf84f9fc261bba2442a08
MD5 bb5b9a3c84ba013db0c9b005c34c76ba
BLAKE2b-256 69c295d2d4f736da3ed30db5672e67fe1e5f877b4571a6156c62034b2c56faf9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.11 This release

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page