Skip to main content

A package to associate transients with host galaxies, and a database of 16k SNe-host galaxies in PS1.

Project description

GHOST

"At the last dim horizon, we search among ghostly errors of observations for landmarks that are scarcely more substantial. The search will continue. The urge is older than history. It is not satisfied and it will not be oppressed." --Edwin Hubble

Welcome to GHOST, the database for supernovae and their host galaxies. This database contains ~16k sources in PS1, which were used to predict supernova classes in Gagliano et al. (2020). Installation instructions for the analysis tools are below.

Installation

  1. Create a clean conda environment.

  2. Run the following code:

pip install astro_ghost

Or, download this repo and run

python setup.py install

from the main directory.

Example Usage

import os
import sys
from astro_ghost.PS1QueryFunctions import getAllPostageStamps
from astro_ghost.TNSQueryFunctions import getTNSSpectra
from astro_ghost.NEDQueryFunctions import getNEDSpectra
from astro_ghost.ghostHelperFunctions import *
from astro_ghost.classifier import classify
from astropy.coordinates import SkyCoord
from astropy import units as u
import pandas as pd
from datetime import datetime

#we want to include print statements so we know what the algorithm is doing
verbose = 1

#download the database from ghost.ncsa.illinois.edu
#note: real=False creates an empty database, which
#allows you to use the association methods without
#needing to download the full database first

#create a list of the supernova names and their skycoords (these three are from TNS)
snName = ['SN 2021os', 'SN 2020aerc']

snCoord = [SkyCoord(180.7253405*u.deg, +5.6147629*u.deg, frame='icrs'),\
SkyCoord(358.64857935*u.deg, +34.8807245*u.deg, frame='icrs')]

# run the association algorithm!
# this first checks the GHOST database for a SN by name, then by coordinates, and
# if we have no match then it manually associates them.
# The starcut parameter can be 'normal', 'gentle', or 'aggressive'
hosts = getTransientHosts(snName, snCoord, verbose=verbose, starcut='normal')

# classify transients
predictions = classify(hosts, verbose=verbose)

#create directories to store the host spectra, the transient spectra, and the postage stamps
hSpecPath = "./hostSpectra/"
tSpecPath = "./SNspectra/"
psPath = "./hostPostageStamps/"
paths = [hSpecPath, tSpecPath, psPath]
for tempPath in paths:
    if not os.path.exists(tempPath):
        os.makedirs(tempPath)

transients = pd.DataFrame({'Name':snName, 'RA':[x.ra.deg for x in snCoord], 'DEC':[x.dec.deg for x in snCoord]})

#get postage stamps and spectra
getAllPostageStamps(hosts, 120, psPath, verbose) #get postage stamps of hosts
getNEDSpectra(hosts, hSpecPath, verbose) #get spectra of hosts
getTNSSpectra(transients, tSpecPath, verbose) #get spectra of transients (if on TNS)

# Helper functions for querying the database
supernovaCoord = [SkyCoord(344.5011708333333*u.deg, 6.0634388888888875*u.deg, frame='icrs')]
galaxyCoord = [SkyCoord(344.50184181*u.deg, 6.06983149*u.deg, frame='icrs')]
snName = ["PTF10llv"]
table = fullData()

# 1. Get the entry corresponding to a specific transient by its name (or coordinates)
#    note: The coordinate/name is passed as a list, so multiple entries can be
#          queried simultaneously
#    This function returns the matches as a pandas dataframe (df) along with
#    a list of the sources not found (by name or coordinate)
df, notFound = getDBHostFromTransientCoords(supernovaCoord)
df, notFound = getDBHostFromTransientName(snName)

# 2. Print summary statistics about a particular host galaxy system or set of systems from a supernova
getHostStatsFromTransientName(snName)
getHostStatsFromTransientCoords(supernovaCoord)

# 3. Get stats about the supernovae associated with a host galaxy
galaxyName = ['UGC 12266']
getTransientStatsFromHostName(galaxyName)
getTransientStatsFromHostCoords(galaxyCoord)

# 4. get an image of the field by coordinates
tempSize = 400 #size in pixels
band = ['grizy']
getcolorim(galaxyCoord[0].ra.deg, galaxyCoord[0].dec.deg, size=tempSize, filters=band, format="png")

# 5. get an image of the host galaxy system associated with a supernova (by supernova name)
getHostImage(snName, save=0)

# 6. Find all supernova-host galaxy matches within a certain search radius (in arcseconds)
coneSearchPairs(supernovaCoord[0], 1.e3)

# 7. Classify supernovae as core-collapse or SN Ia based on host galaxy information
feature_list, dataML_preprocessed, labels_df2, names = preprocess_dataframe(hosts, nclass=2, PCA=False)
dataML_matrix_scaled = preprocessing.scale(dataML_preprocessed)
rf = load_classifier()
names = hosts['TransientName'].values
class_predictions = rf.predict(dataML_matrix_scaled, labels_df2.values)
for i in np.arange(len(class_predictions)):
    print("%s is predicted to be a %s." % (names[i], class_predictions[i]))

The database of supernova-host galaxy matches can be found at http://ghost.ncsa.illinois.edu/static/GHOST.csv, and retrieved using the getGHOST() function. This database will need to be created before running the association pipeline. Helper functions can be found in ghostHelperFunctions.py for querying and getting quick stats about SNe within the database, and tutorial_databaseSearch.py provides example usages. The software to associate these supernovae with host galaxies is also provided, and tutorial.py provides examples for using this code.

GHOST Viewer

In addition to these software tools, a website has been constructed for rapid viewing of many objects in this database. It is located at ghost.ncsa.illinois.edu. Json files containing supernova and host information can be found at http://ghost.ncsa.illinois.edu/static/json.tar.gz. host spectra, SN spectra, and SN photometry are found at http://ghost.ncsa.illinois.edu/static/hostSpectra.tar.gz, http://ghost.ncsa.illinois.edu/static/SNspectra.tar.gz, and http://ghost.ncsa.illinois.edu/static/SNphotometry.tar.gz.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

astro_ghost-0.0.78.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

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

astro_ghost-0.0.78-py3-none-any.whl (71.8 MB view details)

Uploaded Python 3

File details

Details for the file astro_ghost-0.0.78.tar.gz.

File metadata

  • Download URL: astro_ghost-0.0.78.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.6

File hashes

Hashes for astro_ghost-0.0.78.tar.gz
Algorithm Hash digest
SHA256 dc04ee6c2a753d22becce73d1d520de9d30dee53697accdb9516e11ff40d9b82
MD5 ab337049cda03f4eee85cfda295bcd57
BLAKE2b-256 ae12210f30f61623164e2017097549450bf9239ee5695f60c6095f7bd5aa2b2a

See more details on using hashes here.

File details

Details for the file astro_ghost-0.0.78-py3-none-any.whl.

File metadata

  • Download URL: astro_ghost-0.0.78-py3-none-any.whl
  • Upload date:
  • Size: 71.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.6

File hashes

Hashes for astro_ghost-0.0.78-py3-none-any.whl
Algorithm Hash digest
SHA256 2b1f6f3a3aecab0ef8705f1542127448f4e2826e452856c1084186d818e5122b
MD5 e9a776b2fa8134967f44359eaf2d156d
BLAKE2b-256 5dc6ddac62862cb242cf42eca3a7f4939422f0448bae3da7dba3e5d56392938e

See more details on using hashes here.

Supported by

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