petitRADTRANS.synthetic_photometry#

Module for downloading filter data from the website of the SVO Filter Profile Service. Reimplemented from species: tomasstolker/species to avoid circular dependencies between species and petitRADTRANS.

Classes#

ReadFilter

Class for reading a filter profile from the database.

SyntheticPhotometry

Class for calculating synthetic photometry from a spectrum and also

Functions#

_db_lock(→ filelock.FileLock)

add_vega(→ None)

Function for adding a flux-calibrated spectrum of Vega to the

add_filter_profile(→ None)

Function for downloading and adding a filter profile

download_filter(→ Tuple[Optional[numpy.ndarray], ...)

Function for downloading filter profile data

Module Contents#

petitRADTRANS.synthetic_photometry._db_lock(database_path: str) filelock.FileLock#
class petitRADTRANS.synthetic_photometry.ReadFilter(filter_name: str)#

Class for reading a filter profile from the database.

filter_name#
database#
data_folder#
vega_mag#
get_filter() numpy.ndarray#

Select a filter profile from the database.

Returns#

np.ndarray

Array with the wavelengths and filter transmission. The array has 2 dimensions with the shape (n_wavelengths, 2).

interpolate_filter() scipy.interpolate.interp1d#

Interpolate a filter profile with the interp1d function from scipy.interpolate and linear kind of interpolation.

Returns#

scipy.interpolate.interp1d

Linearly interpolated filter profile.

wavelength_range() Tuple[numpy.float32 | numpy.float64, numpy.float32 | numpy.float64]#

Extract the wavelength range of the filter profile.

Returns#

float

Minimum wavelength (\(\mu\mathrm{m}\)).

float

Maximum wavelength (\(\mu\mathrm{m}\)).

mean_wavelength() numpy.float32 | numpy.float64#

Calculate the weighted mean wavelength of the filter profile.

Returns#

float

Mean wavelength (\(\mu\mathrm{m}\)).

effective_wavelength() numpy.float32 | numpy.float64#

Calculate the effective wavelength of the filter profile. The effective wavelength is calculated as the weighted average based on the filter profile and the spectrum of Vega.

Returns#

float

Effective wavelength (\(\mu\mathrm{m}\)).

filter_fwhm() float | None#

Calculate the full width at half maximum (FWHM) of the filter profile.

Returns#

float, None

Full width at half maximum (\(\mu\mathrm{m}\)). Returns None if the filter has only one wavelength. with a non-zero transmission.

effective_width() numpy.float32 | numpy.float64#

Calculate the effective width of the filter profile. The effective width is equivalent to the horizontal size of a rectangle with height equal to the maximum transmission and with the same area as the one covered by the filter profile.

Returns#

float

Effective width (\(\mu\mathrm{m}\)).

detector_type() str#

Return the detector type.

Returns#

str

Detector type (‘energy’ or ‘photon’).

class petitRADTRANS.synthetic_photometry.SyntheticPhotometry(filter_name: str, zero_point: float | None = None)#

Class for calculating synthetic photometry from a spectrum and also for converting between magnitudes and fluxes. Any filter from the SVO Filter Profile Service will be automatically downloaded and added to the database. Also the detector type (energy- or photon-counting) will be fetched. For a photon-counting detector, an additional wavelength factor is included in the integral for calculating the synthetic photometry, although typically the impact of the factor on the calculated flux is negligible. It is also important to note that by default the magnitude of Vega is set to 0.03 for all filters. The value can be adjusted in the configuration file.

filter_name#
zero_point = None#
filter_interp = None#
wavel_range = None#
database#
data_folder#
vega_mag#
det_type#
calc_zero_point() float | numpy.float64#

Internal function for calculating the zero point of the provided filter_name. The zero point is here defined as the flux of Vega, which by default is set to a magnitude of 0.03 for all filters.

Returns#

float

Zero-point flux (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).

spectrum_to_flux(wavelength: numpy.ndarray, flux: numpy.ndarray, error: numpy.ndarray | None = None, threshold: float | None = 0.01) Tuple[float | numpy.float32 | numpy.float64, float | numpy.float32 | numpy.float64 | None]#

Function for calculating the average flux from a spectrum and a filter profile. The uncertainty is propagated by sampling 200 random values from the error distributions.

Parameters#

wavelengthnp.ndarray

Wavelength points (um).

fluxnp.ndarray

Flux (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).

errornp.ndarray, None

Uncertainty (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)). Not used if set to None.

thresholdfloat, None

Transmission threshold (value between 0 and 1). If the minimum transmission value is larger than the threshold, a NaN is returned. This will happen if the input spectrum does not cover the full wavelength range of the filter profile. The parameter is not used if set to None (default: 0.01).

Returns#

float

Average flux (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).

float, None

Uncertainty (\(\mathrm{W}\) \(\mathrm{m}^{-2}\) \(\mu\mathrm{m}^{-1}\)).

petitRADTRANS.synthetic_photometry.add_vega(input_path: str, database: h5py._hl.files.File) None#

Function for adding a flux-calibrated spectrum of Vega to the database. The latest spectrum (alpha_lyr_stis_011.fits) is downloaded from the STScI archive (see CALSPEC page for details).

Parameters#

input_pathstr

Path of the data folder.

databaseh5py._hl.files.File

Database.

Returns#

NoneType

None

petitRADTRANS.synthetic_photometry.add_filter_profile(input_path: str, database: h5py._hl.files.File, filter_name: str) None#

Function for downloading and adding a filter profile to the HDF5 database.

Parameters#

input_pathstr

Folder where the data is located.

databaseh5py._hl.files.File

Database.

filter_namestr

Filter name from the SVO Filter Profile Service (e.g., ‘Paranal/NACO.Lp’) or a user-defined name if a filename is specified.

Returns#

None

NoneType

petitRADTRANS.synthetic_photometry.download_filter(filter_id: str, input_path: str) Tuple[numpy.ndarray | None, numpy.ndarray | None, str | None]#

Function for downloading filter profile data from the SVO Filter Profile Service.

Parameters#

filter_idstr

Filter name as listed on the website of the SVO Filter Profile Service.

input_pathstr

Folder where the data is located.

Returns#

np.ndarray

Wavelength (um).

np.ndarray

Fractional transmission.

str

Detector type (‘energy’ or ‘photon’).