Synthetic photometry#

In this tutorial, we will compute the synthetic MKO J band flux from an IRTF spectrum of Jupiter.

Getting started#

We start by importing the required Python packages.

import matplotlib.pyplot as plt
import numpy as np
import species

The species HDF5 database is initiated by creating an instance of the SpeciesInit class.

Initiating species v0.5.2... [DONE]
Creating species_config.ini... [DONE]
Database: /Users/tomasstolker/applications/species/docs/tutorials/species_database.hdf5
Data folder: /Users/tomasstolker/applications/species/docs/tutorials/data
Working folder: /Users/tomasstolker/applications/species/docs/tutorials
Grid interpolation method: linear
Creating species_database.hdf5... [DONE]
Creating data folder... [DONE]
<species.core.init.SpeciesInit at 0x14bb51990>

Jupiter spectrum#

The spectrum of Jupiter that is used as an example is now downloaded from the IRTF website.

import urllib.request
('data/plnt_Jupiter.txt', <http.client.HTTPMessage at 0x10c50e7a0>)

The file contains the wavelength in \(\mu\)m, and the flux and uncertainty in W m\(^{-2}\) \(\mu\)m\(^-1\), which are also the units that are required by species. We can read the data with numpy.loadtxt.

wavelength, flux, error = np.loadtxt('data/plnt_Jupiter.txt', unpack=True)

Let’s create a SpectrumBox with the data.

spec_box = species.create_box('spectrum',

And pass the Box to the plot_spectrum function together with the filter name.

species.plot_spectrum(boxes=[spec_box, ],
                      xlim=(0.75, 1.8),
                      ylim=(-2e-9, 1.8e-8),
                      offset=(-0.12, -0.05),
                      figsize=(7., 3.),
Adding filter: MKO/NSFCam.J... [DONE]
Plotting spectrum... [DONE]

Synthetic flux and magnitude#

Next, we use the SyntheticPhotometry class to calculate the flux and magnitude for the MKO/NSFCam.J filter. We first create and instance of SyntheticPhotometry with the filter name from the SVO website.

synphot = species.SyntheticPhotometry('MKO/NSFCam.J')
Adding filter: MKO/NSFCam.J... [DONE]

The average \(J\)-band flux is calculated with the spectrum_to_flux method. The error on the synthetic flux is estimated with Monte Carlo sampling of the input spectrum.

j_flux = synphot.spectrum_to_flux(wavelength, flux, error=error)
print(f'Flux (W m-2 um-1) = {j_flux[0]:.2e} +/- {j_flux[1]:.2e}')
Flux (W m-2 um-1) = 1.80e-09 +/- 8.58e-14

Similarly, we calculate the synthetic magnitude with the spectrum_to_magnitude method. Also the absolute magnitude can be calculated by providing the distance and uncertainty (set to None in the example). In species, the magnitude is defined relative to Vega, which is assumed to have a magnitude of 0.03 in all filters. For the selected \(J\)-band filter, Jupiter has a magnitude of 0.59 so the planet is comparable in brightness to Vega.

j_mag, _ = synphot.spectrum_to_magnitude(wavelength, flux, error=error, distance=None)
print(f'Apparent magnitude = {j_mag[0]:.2f} +/- {j_mag[1]:.2e}')
Downloading Vega spectrum (270 kB)... [DONE]
Adding Vega spectrum... [DONE]
Apparent magnitude = 0.59 +/- 5.03e-05