# yt.analysis_modules.star_analysis.sfr_spectrum module¶

StarAnalysis - Functions to analyze stars.

yt.analysis_modules.star_analysis.sfr_spectrum.MtoD = array(['Z0001', 'Z0004', 'Z004', 'Z008', 'Z02', 'Z05'], dtype='<U5')

This spectrum code is based on code from Ken Nagamine, converted from C to Python. I’ve also reversed the order of elements in the flux arrays to be in C-ordering, for faster memory access.

class yt.analysis_modules.star_analysis.sfr_spectrum.SpectrumBuilder(ds, bcdir='', model='chabrier', time_now=None, star_filter=None)[source]

Bases: object

Initialize the data to build a summed flux spectrum for a collection of stars using the models of Bruzual & Charlot (2003). This function loads the necessary data tables into memory and must be called before analyzing any star particles.

Parameters: ds (EnzoDataset object) – bcdir (String) – Path to directory containing Bruzual & Charlot h5 fit files. model (String) – Choice of Initial Metalicity Function model, ‘chabrier’ or ‘salpeter’. Default = ‘chabrier’.

Examples

>>> import yt
>>> from yt.analysis_modules.star_analysis.api import SpectrumBuilder
>>> spec = SpectrumBuilder(ds, "bc", model="salpeter")

calculate_spectrum(data_source=None, star_mass=None, star_creation_time=None, star_metallicity_fraction=None, star_metallicity_constant=None, min_age=0.0 yr)[source]

For the set of stars, calculate the collective spectrum. Attached to the output are several useful objects:

final_spec

array – The collective spectrum in units of flux binned in wavelength.

wavelength

array – The wavelength for the spectrum bins, in Angstroms.

total_mass

float – Total mass of all the stars.

avg_mass

float – Average mass of all the stars.

avg_metal

float – Average metallicity of all the stars.

Parameters: data_source (AMRRegion object, optional) – The region from which stars are extracted for analysis. If this is not specified, the next three parameters must be supplied. star_mass (Array or list of floats) – An array of star masses in Msun units. star_creation_time (Array or list of floats) – An array of star creation times in code units. star_metallicity_fraction (Array or list of floats) – An array of star metallicity fractions, in code units (which is not Z/Zsun, rather just Z). star_metallicity_constant (Float) – If desired, override the star metallicity fraction of all the stars to the given value. min_age (Float) – Removes young stars younger than this number (in years) from the spectrum. Default: 0 (all stars).

Examples

>>> import yt
>>> from yt.analysis_modules.star_analysis.api import SpectrumBuilder
>>> spec = SpectrumBuilder(ds, "bc", model="salpeter")
>>> sp = ds.sphere([0.5, 0.5, 0.5], 0.1)
>>> spec.calculate_spectrum(data_source=sp, min_age=1.e6)

read_bclib()[source]

Read in the age and wavelength bins, and the flux bins for each metallicity.

write_out(name='sum_flux.out')[source]

Write out the summed flux to a file.

The output file from this function has two columns: Wavelength (Angstrom) and Flux (Luminosity per unit wavelength, L_sun Ang^-1, L_sun = 3.826 * 10^33 ergs s^-1.).

Parameters: name (String) – Name of file to write to. Default = “sum_flux.out”

Examples

>>> import yt
>>> from yt.analysis_modules.star_analysis.api import SpectrumBuilder
>>> sp = ds.sphere([0.5, 0.5, 0.5], 0.1)
>>> spec = SpectrumBuilder(ds, "bc", model="salpeter")
>>> spec.calculate_spectrum(data_source=sp, min_age = 1.e6)
>>> spec.write_out("spec.out")

write_out_SED(name='sum_SED.out', flux_norm=5200.0)[source]

Write out the summed SED to a file. The file has two columns: 1) Wavelength (Angstrom) 2) Relative flux normalized to the flux at flux_norm. It also will attach to the SpectrumBuilder object an array f_nu which is the normalized flux, identical to the disk output.

Parameters: name (String) – Name of file to write to. Default = “sum_SED.out” flux_norm (Float) – Wavelength of the flux to normalize the distribution against. Default = 5200 Ang.

Examples

>>> import yt
>>> from yt.analysis_modules.star_analysis.api import SpectrumBuilder
>>> spec = SpectrumBuilder(ds, "bc", model="salpeter")
>>> sp = ds.sphere([0.5, 0.5, 0.5], 0.1)
>>> spec.calculate_spectrum(data_source=sp, min_age = 1.e6)
>>> spec.write_out_SED(name = "SED.out", flux_norm = 6000.)

class yt.analysis_modules.star_analysis.sfr_spectrum.StarFormationRate(ds, data_source=None, star_mass=None, star_creation_time=None, bins=300, volume=None, star_filter=None)[source]

Bases: object

Calculates the star formation rate for a given population of star particles.

Parameters: ds (EnzoDataset object) – data_source (AMRRegion object, optional) – The region from which stars are extracted for analysis. If this is not supplied, the next three must be, otherwise the next three do not need to be specified. star_mass (Ordered array or list of floats) – The mass of the stars to be analyzed in units of Msun. star_creation_time (Ordered array or list of floats) – The creation time for the stars in code units. volume (Float) – The comoving volume of the region for the specified list of stars. bins (Integer) – The number of time bins used for binning the stars. Default = 300. star_filter (A user-defined filtering rule for stars.) – See: http://yt-project.org/docs/dev/analyzing/filtering.html Default: ct>0

Examples

>>> import yt
>>> from yt.analysis_modules.star_analysis.api import StarFormationRate
>>> sp = ds.sphere([0.5, 0.5, 0.5], 0.1)
>>> sfr = StarFormationRate(ds, sp)

attach_arrays()[source]

Attach convenience arrays to the class for easy access.

build_dist()[source]

Build the data for plotting.

write_out(name='StarFormationRate.out')[source]

Write out the star analysis to a text file name. The columns are in order.

The columns in the output file are:
1. Time (yrs)
2. Look-back time (yrs)
3. Redshift
4. Star formation rate in this bin per year (Msol/yr)
5. Star formation rate in this bin per year per Mpc**3 (Msol/yr/Mpc**3)
6. Stars formed in this time bin (Msol)
7. Cumulative stars formed up to this time bin (Msol)
Parameters: name (String) – The name of the file to write to. Default = StarFormationRate.out.

Examples

>>> import yt
>>> from yt.analysis_modules.star_analysis.api import StarFormationRate