4.1. twinkle.py Documentation

4.1.1. Star class

class twinkle.twinkle.Star(fuel, starname=None)[source]

Bases: object

Instantiating StarObject does a number of things, foremost of which is to create a StarObject for ONE particular star. The initialization process loads the input script file, uploads and saves the data in the input star file, empirical color file, photospheric grid models.

In addition, it cleans up the photometry, converts photometry to flux, fits photometric flux to the best photospheric model, and possibly scales the new photosphere to a subset of the input photometry.

FYI: I get bored and some of the print statements may be… odd.

W2Adopt(specs, pmaglist=None, simple=True)[source]

Determines whether the WISE W2 photometry should be included in the list of photometric points to be used to pin down the photosphere. v1 uses the previously determined W1-W2 cuts as well as the excess SNRs (Sigma_{E[W1-W2]}) to determine whether the photometry is photospheric. This is from Patel et al., 2014

Parameters:
  • specs (dict) – dictionary created using json file.

  • pmaglist (list) – includes the string list of photometry used to pin down photosphere.

  • simple (bool) – if simple is set, it uses the saturation limit to determine whether W3 should be used.

Returns:

new list of photospheric string values

Return type:

plist (list)

W3Adopt(specs, pmaglist=None, simple=True)[source]

Determines whether the WISE W3 photometry should be included in the list of photometric points to be used to pin down the photosphere. v1 uses the previously determined W1-W3 and W2-W3 cuts as well as the excess SNRs (Sigma_{E[Wi-W3]}) to determine whether the photometry is photospheric for a given star. This is from Patel et al., 2014. Or whether the photometry is saturated or not.

Parameters:
  • specs (dict) – dictionary created using json file.

  • pmaglist (list) – includes the string list of photometry used to pin down photosphere.

  • simple (bool) – if simple is set, it uses the saturation limit to determine whether W3 should be used.

Returns:

new list of photospheric string values

Return type:

plist (list)

calc_excessflux()[source]

Calculates the excess flux at the passbands listed in mags4Dust using the photospheric fit.

flux and uncertainty for excesses are stored in Star.fluxEx and Star.efluxEx.

Wavelengths are in Star.WaveEx in angstroms.

cleanphotometry(specs)[source]

The purpose of this module is to remove any photometry that is null and supplement any null error measurements with 5% of the photometric value. It also removes saturated bands for that particular star.

arrays created:

  • Star.mags2use - all the bands that are used.

  • Star.mags4Phot - bands that are used to fit to model photosphere.

  • Star.mags4scale - bands used to scale raw model to input flux.

  • Star.mags4Dust - band used to calculate excess.

Also it removes optical bands if they’re late type stars.

Parameters:

specs (dict) – dictionary created using json parameterfile.

fitPhotosphere(sconst, T0, model, grav, met, MegaGridModels)[source]

Fit a stellar photosphere model to bands in the Star.mags4Phot list/array. This uses twinkle.utils.mosaic_tools.mpfit() Levenberg-Marquadt algorithm

Results are saved in the following internal variables: - Star.StarRadius: Stellar radius in Solar Radius units. - Star.StarTemp: Temperature of the fitted star in Kelvin.

Parameters:
  • sconst (float) – Scaling factor for raw fluxes. It equals: (Solar Radius [cm] / 1 pc [cm])^2 * (1/Stellar Distance [pc]^2)

  • T0 (float) – Initial guess for the temperature, in units of Kelvin/1000.

  • model (str) – Name of the model to use. Options are “Atlas9” or “NextGen”.

  • grav (float) – Surface gravity, expressed as \(10\log(g)\ [\mbox{cm}/s^2]\).

  • met (float) – Logarithmic metallicity. A value of 0 represents solar metallicity.

  • MegaGridModels (dict) – all atmospheric grid models with metallicity, grav, and temperature keys.

keep_unsatmags(vegaDict, magsCheck)[source]

This will remove any saturated photometry from the photometry string lists:

  • Star.mags2use - all the bands that are used.

  • Star.mags4Phot - bands that are used to fit to model photosphere.

  • Star.mags4scale - bands used to scale raw model to input flux.

  • Star.mags4Dust - band used to calculate excess.

Parameters:
  • vegaDict (dict) – Photometry of bands for a particular star.

  • magsCheck (list/arr) – subset of bands to check.

Returns:

(list/arr) subset of magsCheck that don’t have saturated photometry.

Return type:

magsCheck1

plot_observedData(ax, ms=4, lcolor='k', pcolor='g', markerp='o', markernp='*', capsize=0, linestyle='-', lw=1, **kwargs)[source]

Plot empirical SED data.

Parameters:
  • ax (obj) – matplotlib axis object

  • pointsize (float) – marker size

  • lcolor (str) – line color

  • pcolor (str) – point color

  • markerp (str) – marker type

  • markernp (str) – don’t remember what this does

  • capsize (float)

  • linestyle (string) – linestyle

  • lw (float) – linewidth

plot_photosphere(ax, pointsize=4, lcolor='orange', pcolor='orange', marker='o', linestyle='--', lw=2, **kwargs)[source]

Plot photospheric data.

Parameters:
  • ax (obj) – matplotlib axis object

  • pointsize (float) – marker size

  • color (string) – marker color

  • marker (string) – marker type

  • linestyle (string) – linesytle

  • lw (float) – linewidth

  • kwargs (dict) – additional matplotlib keyworded arguments

plot_photrange(ax, color='orange', **kwargs)[source]

Plot photosphere limits based on uncertainties in fit parameters.

Parameters:
  • ax (obj) – matplotlib axis object

  • color (str) – matplotlib color identifier.

  • kwargs (dict) – additional matplotlib kwargs.

resetFullSpectrum()[source]

Resets the spectrum to original photospheric guess emission… I think.

writeSED(filename='sed.txt', comment='# lambda: Angstroms, f_lambda: erg/s/cm^2/Angstrom, Teff={:.1f}K,rad={:.3f}Rsol.\n')[source]

Function to write out fitted SED to file.

Parameters:
  • filename – (str) file of where SED will be saved.

  • comment – (str) comment starting with ‘#’ of any comment to go on first line of the saved SED file.

4.1.2. Fuel class

class twinkle.twinkle.Fuel(jfile)[source]

Bases: object

This should be called before all others. Initialization process loads the input script file, uploads and saves the data of the input star file, empirical color file, photospheric grid models and is accessible through sed.DataLogistics