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 urllib.request
import numpy as np
import matplotlib.pyplot as plt
import species

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

Initiating species v0.3.1... [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
Creating species_database.hdf5... [DONE]
Creating data folder... [DONE]
<species.core.setup.SpeciesInit at 0x10c8f9588>

Jupiter spectrum

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

('data/plnt_Jupiter.txt', <http.client.HTTPMessage at 0x12b817b00>)

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 loadtxt from numpy.

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=(-1e-9, 1.7e-8),
                      offset=(-0.1, -0.05),
                      figsize=(8., 4.),
Adding filter: MKO/NSFCam.J... [DONE]
Plotting spectrum: spectrum.png... [DONE]
from IPython.display import Image

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')

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 +/- 9.37e-14

Similarly, we calculate the synthetic magnitude with the spectrum_to_flux 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.22e-05