home about contact

QuasarNET

architecture

Computer vision meets astrophysics! QuasarNET uses computer vision techniques to identify and locate emission lines in astrophysical spectra. Find out more: arXiv:1808.09955

QuasarNET online server

No installation required! Get your predictions directly from the QuasarNET server.

From the command line:

Send your spectra via a POST request to the QuasarNET server and save the response to predictions.json.

curl -o predictions.json -X POST -H "Content-Type: application/json" --data @spectra.json https://thequasar.net:5000/predict

The file spectra.json that contains your spectra should look like this:

{
  "wave":["l1","l2","l3",...],
  "flux":[["f1_1","f2_1","f3_1",...], ["f1_2","f2_2","f3_2", ...], ...] ,
  "ivar":[["iv1_1","iv2_1","iv3_1",...], ["iv1_2","iv2_2","iv3_2",...], ... ]
}

where the "wave" array contains the wavelenghts in Angstrom, "flux" is an array of arrays, each array containing the flux values (any units), and ivar is an array of arrays containing the inverse variances. The double quotes around the values are required. Note that all spectra are assumed to have a common wavelength grid.

The returned json contains the following fields:

"lines": list of line-names searched for
"lines_BAL": list of lines where BAL were searched for
"p_<line name>": array of probabilities for the line given by <line name> (one probability per spectrum per line-name)
"pBAL_<line name>": same but for BAL
"z_<line name>": array of redshifts for the given line (one redshift per spectrum per line)
"zBAL_<line name>": same but for BAL
"zbest": array of redshift, chosen as that of the line with highest probability
It is up to you to decide on a threshold probability and a threshold number of lines to determine when a spectrum is classified as a quasar. Please refer to the paper for recommendations on these values.

From a python session:

## Organize your spectra in a dictionary:
spectra = {}

## wave is an array containing the wavelength values
## (doesn't need to be sorted). E.g. for three wavelength bands:
wave = numpy.hstack(wave_b, wave_r, wave_z)
spectra['wave'] = [str(lam) for lam in wave]

## fluxes is a list of arrays, each containing the flux of a spectrum
## e.g. for three bands (r, b, z):
fluxes = [numpy.hstack(flux1_b, flux1_r, flux1_z), numpy.hstack(flux2_b, flux2_r, flux2_z), ...]
spectra['flux'] = [[str(fl) for fl in flux] for flux in fluxes]

## ivar is a list of arrays, each containing the inverse variance of a spectrum
ivars = [numpy.hstack(ivar0_b, ivar0_r, ivar0_z), numpy.hstack(ivar1_b, ivar1_r, ivar1_z), ...]
spectra['ivar'] = [[str(iv) for iv in ivar] for ivar in ivars]

## now send the post request
## you might need to
## pip install requests
## if you don't have the requests library installed

import requests
url = "http://thequasar.net:5000/predict"
r = requests.post(url = url, json = spectra)

## store the results on the 'out' dictionary:
out = r.json()

Installation instructions

QuasarNET runs on python3

## clone the project 
git clone https://github.com/ngbusca/QuasarNET.git
cd QuasarNET
## install external packages
pip install -r requirements.txt --user
## install QuasarNET
python setup.py install --user

Download the pre-trained weights

Download the weights to the QuasarNET/weights/ directory, unzip the file and fix read/write permissions.

The pre-trained weights are available for direct download at https://www.kaggle.com/ngbusca/qnet_trained_models

or use the kaggel API:

cd weights
kaggle datasets download ngbusca/qnet_trained_models
unzip qnet_trained_models.zip
chmod 600 *

Download the data

These data are a reprocessing of data release 12 (DR12) of the Sloan Digital Sky Survey (https://www.sdss.org/dr12/)

They are available on Kaggle: https://www.kaggle.com/ngbusca/qnet_data

A practical way to download the data is to use the kaggle-api, which will allow you to do it from the command line. Otherwise you can simply click the download link on the website.

Download the data to the QuasarNET/data/ directory, unzip the file and set read/write permissions (skip the kaggle datasets... line if you've downloaded the data through the website).

cd data
kaggle datasets download ngbusca/qnet_data
unzip qnet_data.zip
chmod 600 *

Contact

Questions? Suggestions? contact@thequasar.net