firefly library

This library contains a variety of small functions needed by the FIREFLY engine.

firefly_library.airtovac(wave_air)[source]
__author__ = ‘Kyle B. Westfall’

Wavelengths are corrected for the index of refraction of air under standard conditions. Wavelength values below 2000 A will not be altered. Uses formula from Ciddor 1996, Applied Optics 62, 958.

Args:
wave_air (int or float): Wavelength in Angstroms, scalar or
vector. If this is the only parameter supplied, it will be updated on output to contain double precision vacuum wavelength(s).
Returns:
numpy.float64 : The wavelength of the line in vacuum.
Example:
If the air wavelength is W = 6056.125 (a Krypton line), then airtovac() returns vacuum wavelength of W = 6057.8019.
Revision history:
Written W. Landsman November 1991
Use Ciddor (1996) formula for better accuracy in the infrared
Added optional output vector, W Landsman Mar 2011
Iterate for better precision W.L./D. Schlegel Mar 2011
Transcribed to python, K.B. Westfall Apr 2015

Note

Take care within 1 A of 2000 A. Wavelengths below 2000 A in air are not altered.

firefly_library.averages_and_errors(probs, prop, sampling)[source]

determines the average and error of a property for a given sampling

returns : an array with the best fit value, +/- 1, 2, 3 sigma values.

Parameters:
  • probs – probabilities
  • property – property
  • sampling – sampling of the property
firefly_library.bisect_array(array)[source]

It takes an array as input and returns the bisected array : bisected array[i] = (array[i] + array[i+1] )/2. Its lenght is one less than the array.

Parameters:array – input array
firefly_library.calculate_averages_pdf(probs, light_weights, mass_weights, unnorm_mass, age, metal, sampling, dist_lum)[source]

Calculates light- and mass-averaged age and metallicities. Also outputs stellar mass and mass-to-light ratios. And errors on all of these properties.

It works by taking the complete set of probs-properties and maximising over the parameter range (such that solutions with equivalent values but poorer probabilities are excluded). Then, we calculate the median and 1/2 sigma confidence intervals from the derived ‘max-pdf’.

NB: Solutions with identical SSP component contributions are re-scaled such that the sum of probabilities with that component = the maximum of the probabilities with that component. i.e. prob_age_ssp1 = max(all prob_age_ssp1) / sum(all prob_age_ssp1) This is so multiple similar solutions do not count multiple times.

Outputs a dictionary of: - light_[property], light_[property]_[1/2/3]_sigerror - mass_[property], mass_[property]_[1/2/3]_sigerror - stellar_mass, stellar_mass_[1/2/3]_sigerror - mass_to_light, mass_to_light_[1/2/3]_sigerror - maxpdf_[property] - maxpdf_stellar_mass where [property] = [age] or [metal]

Parameters:
  • probs – probabilities
  • light_weights – light (luminosity) weights obtained when model fitting
  • mass_weights – mass weights obtained when normalizing models to data
  • unnorm_mass – mass weights obtained from the mass to light ratio
  • age – age
  • metal – metallicity
  • sampling – sampling of the property
  • dist_lum – luminosity distance in cm
firefly_library.convert_chis_to_probs(chis, dof)[source]

Converts chi squares to probabilities.

Parameters:
  • chis – array containing the chi squares.
  • dof – array of degrees of freedom.
firefly_library.find_closest(A, target)[source]

returns the id of the target in the array A. :param A: Array, must be sorted :param target: target value to be located in the array.

firefly_library.light_weights_to_mass(light_weights, mass_factors)[source]

Uses the data/model mass-to-light ratio to convert SSP contribution (weights) by light into SSP contributions by mass.

Parameters:
  • light_weights – light (luminosity) weights obtained when model fitting
  • mass_factors – mass factors obtained when normalizing the spectrum
firefly_library.match_data_models(data_wave_int, data_flux_int, data_flags, error_flux_int, model_wave_int, model_flux_int, min_wave_in, max_wave_in, saveDowngradedModel=True, downgradedModelFile='DGmodel.txt')[source]
  • 0.Take data and models as inputs
    1. interpolate data and model to the lowest sampled array.
      • 1.1. Defines the wavelength range on the model and on the data
      • 1.2. Downgrades the array, model or data, that has most sampling
      • 1.3. integrate between them to output a matched resolution array for data and model
    1. Returns the matched wavelength array, the corresponding data, error and model arrays : matched_wave,matched_data,matched_error,matched_model
Parameters:
  • data_wave_int – data wavelength array in the restframe
  • data_flux_int – data flux array
  • data_flags – data quality flag array : 1 for good data
  • error_flux_int – data flux error array
  • model_wave_int – model wavelength array (in the rest frame)
  • model_flux_int – model flux array
  • min_wave_in – minimum wavelength to be considered
  • max_wave_in – maximum wavelength to be considered
  • saveDowngradedModel – if True it will save the downgraded models
  • downgradedModelFile – location where downgreaded models will be saved
firefly_library.max_pdf(probs, property, sampling)[source]

determines the maximum of a pdf of a property for a given sampling

Parameters:
  • probs – probabilities
  • property – property
  • sampling – sampling of the property
firefly_library.normalise_spec(data_flux, model_flux)[source]

Normalises all models to the median value of the spectrum. Saves the factors for later use.

Outputs : normed models and translation factors.

Parameters:
  • data_flux – observed flux in the data
  • model_flux – flux from the models