slugpy – The Python Helper Library¶
Installing slugpy¶
SLUG comes with the python module slugpy, which contains an extensive set of routines for reading, writing, and manipulating SLUG outputs. You can install slugpy one of two ways.
Using
Make
. If you compile the main slug code by doingMake
in the main slug directory, the c slugpy extensions will be build automatically. Once that is done, you will be able to use slugpy just by importing it, provided that the slugpy directory is in your python import path.Using
setup.py
. The slug distribution comes with asetup.py
script that follows the standard python package convensions. Just do:python setup.py build
to build the c extensions in place, which will let you import slugpy from the directory where it is located. Alternately, do:
python setup.py install
to install as a site package. Installing as a site package often requires root permissions, in which case you should do:
sudo python setup.py install
or:
python setup.py install --user
instead.
A note on compiling slugpy with setup.py: the slugpy c extensions require the GNU Scientific Library; to build or install slugpy, the appropriate headers must be in your default include path, and the appropriate libraries in your default link path. If they are not, you can tell setup where they are located by creating a file named setup.cfg
in the slug2 directory, which contains the lines:
[build_ext]
include_dirs=/PATH/TO/GSL/HEADER
library_dirs=/PATH/TO/GSL/LIBRARIES
Then you should be able to build and install slugpy with setup.py
.
Basic Usage¶
The most common task is to read a set of SLUG outputs into memory so that they can be processed. To read the data from a SLUG run using slugpy, one can simply do the following:
from slugpy import *
idata = read_integrated('SLUG_MODEL_NAME')
cdata = read_cluster('SLUG_MODEL_NAME')
The read_integrated
function reads all the integrated-light data (i.e., the data stored in the _integrated_*
files – see Output Files and Format) for a SLUG output whose name is given as the argument. This is the base name specified by the model_name
keyword (see Basic Keywords), without any extensions; the slugpy library will automatically determine which outputs are available and in what format, and read the appropriate files. It returns a namedtuple
containing all the output data available for that simulation. Note that some of these fields will only be present if the cloudy-slug interface (see cloudy_slug: An Automated Interface to cloudy) was used to process the SLUG output through cloudy to predict nebular emission, and some will be present only if extinction was enabled when SLUG was run. The fields returned are as follows:
- time: output times
- target_mass: target stellar mass at each time
- actual_mass: actual stellar mass at each time
- live_mass: mass of currently-alive stars
- cluster_mass: mass of living stars in non-disrupted clusters
- num_clusters: number of non-disrupted clusters
- num_dis_clusters: number of disrupted clusters
- num_fld_stars: number of still-living stars that formed in the field
- wl: wavelengths of output stellar spectra (in Angstrom)
- spec: integrated spectrum of all stars, expressed as a specific luminosity (erg/s/Angstrom)
- filter_names: list of photometric filter names
- filter_units: list of units for photometric outputs
- filter_wl_eff: effective wavelength for each photometric filter
- filter_wl: list of wavelengths for each filter at which the response function is given (in Angstrom)
- filter_response: photon response function for each filter at each wavelength (dimensionless)
- filter_beta: index \(\beta\) used to set the normalization for each filter – see Spectra and Photometry
- filter_wl_c: pivot wavelength used to set the normalization for each filter for which \(\beta \neq 0\) – see Spectra and Photometry
- phot: photometry of the stars in each filter
- isotope_name: element symbols for the isotopes whose yields are reported
- isotope_Z: atomic numbers for the isotopes whose yields are reported
- isotope_A: atomic numbers for the isotopes whose yields are reported
- yld: yield of each isotope at each time
The following fields are present only if SLUG was run with nebular processing enabled:
- wl_neb: same as wl, but for the spectrum that emerges after the starlight has passed through the nebulae around the emitting clusters and field stars. The nebular grid is finer than the stellar grid, because it contains wavelength extra entries around prominent lines so that the lines are resolved on the grid
- spec_neb: same as spec, but for the nebular-processed spectrum
- phot_neb: same as phot, but for the nebular-processed spectrum
The following fields are present only if SLUG was run with extinction enabled:
- wl_ex: wavelengths of output stellar spectra after extinction has been applied(in Angstrom). Note that wl_ex will generally cover a smaller wavelength range than wl, because the extinction curve used may not cover the full wavelength range of the stellar spectra. Extincted spectra are computed only over the range covered by the extinction curve.
- spec_ex: same as spec, but for the extincted spectrum
- phot_ex: same as phot, but for the extincted spectrum. Note that some values may be
NaN
. This indicates that photometry of the extincted spectrum could not be computed for that filter, because the filter response curve extends to wavelengths outside the range covered by the extinction curve.
The following fields are present only if SLUG was run with both nebular processing and extinction enabled:
- wl_neb_ex: same as wl_neb, but for the extincted, nebular-processed spectrum. Will be limited to the same wavelength range as wl_ex.
- spec_neb_ex: same as spec_neb, but with extinction applied
- phot_neb_ex: same as phot_neb, but wtih extinction applied. Note that some values may be
NaN
. This indicates that photometry of the extincted spectrum could not be computed for that filter, because the filter response curve extends to wavelengths outside the range covered by the extinction curve.
The following fields are present only for runs that have been processed through the cloudy_slug interface (see cloudy_slug: An Automated Interface to cloudy):
- cloudy_wl: wavelengths of the output nebular spectra (in Angstrom)
- cloudy_inc: incident stellar radiation field, expressed as a specific luminosity (erg/s/Angstrom) – should be the same as spec, but binned onto cloudy’s wavelength grid; provided mainly as a bug-checking diagnostic
- cloudy_trans: the transmitted stellar radiation field computed by cloudy, expressed as a specific luminosity (erg/s/Angstrom) – this is the radiation field of the stars after it has passed through the HII region, and is what one would see in an observational aperture centered on the stars with negligible contribution from the nebula
- cloudy_emit: the emitted nebular radiation field computed by cloudy, expressed as a specific luminosity (erg/s/Angstrom) – this is the radiation emitted by the nebula excluding the stars, and is what one would see in an observational aperture that included the nebula but masked out the stars
- cloudy_trans_emit: the sum of the transmitted stellar and emitted nebular radiation, expressed as a specific luminosity (erg/s/Angstrom) – this is what one would see in an observational aperture covering the both the stars and the nebula
- cloudy_linelabel: list of emitting species for the line luminosities computed by cloudy, following cloudy’s 4-letter notation
- cloudy_linewl: wavelengths of all the lines computed by cloudy (in Angstrom)
- cloudy_linelum: luminosities of the lines computed by cloudy (in erg/s)
- cloudy_filter_names, cloudy_filter_units, cloudy_filter_wl_eff, cloudy_filter_wl, cloudy_filter_response, cloudy_filter_beta, cloudy_filter_wl_c: exactly the same as the corresponding fields without the cloudy prefix, but for the photometric filters applied to the cloudy output
- cloudy_phot_trans, cloudy_phot_emit, and cloudy_phot_trans_emit: photometry of the transmitted, emitted, and transmitted+emitted radiation field provided by cloudy_trans, cloudy_emit, and cloudy_trans_emit
For the above fields, quantities that are different for each trial and each time are stored as numpy arrays with a shape (N_times, N_trials) for scalar quantities (e.g., actual_mass), or a shape (N, N_times, N_trials) for quantities that are vectors of length N (e.g., the spectrum).
The read_cluster
function is analogous, except that instead of reading the whole-galaxy data, it reads data on the individual star clusters, as stored in the _cluster_*
output files. It returns the following fields:
- id: a unique identifier number for each cluster; this is guaranteed to be unique across both times and trials, so that if two clusters in the list have the same id number, that means that the data given are for the same cluster at two different times in its evolution
- trial: the trial number in which that cluster appeared
- time: the time at which the data for that cluster are computed
- form_time: the time at which that cluster formed
- lifetime: the between when the cluster formed and when it will disrupt
- target_mass: the target stellar mass of the cluster
- actual_mass: the actual stellar mass of the cluter
- live_mass: the mass of all still-living stars in the cluster
- num_star: the number of stars in the cluster
- max_star_mass: the mass of the single most massive still-living star in the cluster
- A_V: the visual extinction for this cluster, in mag; present only if SLUG was run with extinction enabled
- All the remaining fields are identical to those listed above for integrated quantities, starting with wl
For all these fields, scalar quantities that are different for each cluster (e.g., actual_mass) will be stored as arrays of shape (N_cluster); vector quantities that are different for each cluster (e.g., spec) will be stored as arrays of shape (N_cluster, N).
The following fields are present only if SLUG was run with a Variable Mode IMF:
- VPx: The value drawn for variable parameter x (0,1,2…) in each trial. The parameters are numbered in the order they are defined in the IMF definition file.
These fields are present in both the cluster and integrated outputs if a simulation has been run using the variable mode IMF.
Full Documentation of slugpy¶
-
slugpy.
combine_cluster
(data)[source]¶ Function to combine cluster data from multiple SLUG2 runs, treating each input run as a separate set of trials. Trial and cluster unique ID numbers are altered as necessary to avoid duplication between the merged data sets.
- Parameters:
- data : list_like
- A list containing the cluster data for each run, as returned by read_cluster
- Returns:
- combined_data : namedtuple
- The combined data, in the same format as each object in data
-
slugpy.
combine_integrated
(data)[source]¶ Function to combine integrated data from multiple SLUG2 runs, treating each input run as a separate set of trials.
- Parameters
- data : list_like
- A list containing the integrated data for each run, as returned by read_integrated
- Returns
- combined_data : namedtuple
- The combined data, in the same format as each object in data
-
slugpy.
compute_photometry
(wl, spec, filtername, photsystem='L_nu', filter_wl=None, filter_response=None, filter_beta=None, filter_wl_c=None, filter_dir=None)[source]¶ This function takes an input spectrum and a set of response functions for photometric filters, and returns the photometry through those filters.
- Parameters
- wl : array
- Wavelength of input spectrum in Angstrom
- spec : array
- Specific luminosity per unit wavelength for input spectrum, in erg/s/A
- filtername : string or iterable of strings
- Name or list of names of the filters to be used. Filter names can also include the special filters Lbol, QH0, QHe0, and QHe1; the values returned for these will be the bolometric luminosity (in erg/s) and the photon luminosities (in photons/s) in the H, He, and He+ ionizing-continua, respectively.
- photsystem : string
- The photometric system to use for the output. Allowable values are ‘L_nu’, ‘L_lambda’, ‘AB’, ‘STMAG’, and ‘Vega’, corresponding to the options defined in the SLUG code.
- filter_wl : array or iterable of arrays
- Array giving the wavelengths in Angstrom at which the filter is response function is given. If this object is an iterable of arrays rather than a single array, it is assumed to represent the wavelengths for a set of filters. If this is set, no data is read from disk. Default behavior is to read the filter information from disk.
- filter_response : array or iterable of arrays
- Array giving the filter response function at each wavelenght and for each filter in filter_wl. Must be set if filter_wl is set, ignored otherwise.
- filter_beta : iterable
- Array-like object containing the index beta for each filter. Must be set if filter_wl is set, ignored otherwise.
- filter_wl_c : iterable
- Array-like object containing the pivot wavelength for each filter. Must be set if filter_wl is set, ignored otherwise.
- filter_dir : string
- Directory where the filter data files can be found. If left as None, filters will be looked for in the $SLUG_DIR/lib/filters directory. This parameter is used only if filtername is not None.
- Returns
- phot : array
- Photometric values in the requested filters. Units depend on the choice of photometric system: L_nu –> erg/s/Hz; L_lambda –> erg/s/A; AB –> absolute AB magnitude; STMAG –> absolute ST magnitude; Vega –> absolute Vega magnitude;
-
slugpy.
photometry_convert
(photsystem, phot, units, wl_cen=None, filter_last=False, filter_names=None, filter_dir=None)[source]¶ Function to convert photometric data between photometric systems.
- Parameters
- photsystem : string
- The photometric system to which to convert. Allowable values are ‘L_nu’, ‘L_lambda’, ‘AB’, ‘STMAG’, and ‘Vega’, corresponding to the options defined in the SLUG code. If this is set and the conversion requested involves a conversion from a wavelength-based system to a frequency-based one, wl_cen must not be None.
- phot : array
- array of photometric data; if the array has more than one dimension, the first dimension is assumed to represent the different photometric filters (unless filter_last is True, in which case the last dimension is represents the array of filters)
- units : iterable of strings
- iterable listing the units of the input photometric data. On return, strings will be changed to the units of the new system.
- wl_cen : array
- central wavelengths of the filters, in Angstrom; can be left as None if the requested conversion doesn’t require going between wavelength- and frequency-based systems.
- filter_last : bool
- If the input data have more than one dimension, by default it is assumed that the first dimension contains values for the different photometric filters. If this keyword is set to True, it will instead be assumed that the last dimension contains the values for the different filters.
- filter_names : iterable of strings
- Names of all filters, used to read the filter response functions from disk; only needed for conversions to and from Vega magnitudes, and ignored otherwise
- filter_dir : string
- Directory where the filter data files can be found. If left as None, filters will be looked for in the $SLUG_DIR/lib/filters directory. This parameter is used only for conversions to and from Vega magnitudes.
- Returns
- Nothing
- Raises
- ValueError, if wl_cen is None but the requested conversion requires going between wavelength- and frequency-based systems
-
slugpy.
read_cluster
(model_name, output_dir=None, fmt=None, nofilterdata=False, photsystem=None, verbose=False, read_filters=None, read_nebular=None, read_extinct=None, read_info=None, read_lines=None, no_stellar_mass=False)[source]¶ Function to read all cluster data for a SLUG2 run.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : string
- Format for the file to be read. Allowed values are ‘ascii’, ‘bin’ or ‘binary, and ‘fits’. If one of these is set, the code will only attempt to open ASCII-, binary-, or FITS-formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- nofilterdata : bool
- If True, the routine does not attempt to read the filter response data from the standard location
- photsystem : None or string
- If photsystem is None, the data will be returned in the same photometric system in which they were read. Alternately, if it is a string, the data will be converted to the specified photometric system. Allowable values are ‘L_nu’, ‘L_lambda’, ‘AB’, ‘STMAG’, and ‘Vega’, corresponding to the options defined in the SLUG code. If this is set and the conversion requested involves a conversion from a wavelength-based system to a frequency-based one, nofilterdata must be False so that the central wavelength of the photometric filters is available.
- verbose : bool
- If True, verbose output is printed as code runs
- read_filters : None | string | listlike containing strings
- If this is None, photometric data on all filters is read. Otherwise only filters whose name(s) match the input filter names ar read.
- read_nebular : None | bool
- If True, only photometric data with the nebular contribution is read; if False, only data without it is read. Default behavior is to read all data.
- read_extinct : None | bool
- If True, only photometric data with extinction applied is read; if False, only data without it is read. Default behavior is to read all data.
- read_info : dict
- On return, this dict will contain the keys ‘prop_name’, ‘phot_name’, ‘spec_name’, ‘cloudyspec_name’, ‘cloudylines_name’ and ‘format’, giving the names of the files read and the format they were in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’. If one of the files is not present, the corresponding _name key will be omitted from the dict.
- no_stellar_mass : bool
- Prior to 7/15, output files did not contain the stellar_mass field; this can be detected automatically for ASCII and FITS formats, but not for binary format; if True, this specifies that the binary file being read does not contain a stellar_mass field; it has no effect for ASCII or FITS files
- no_neb_extinct : bool
- Prior to 2/17, SLUG did not support differential nebular extinction, and thus there was no output field for it; this is detected and handled automatically for ASCII and FITS files; for binary outputs, this flag must be set for pre 2/17 output files to be read correctly
- read_lines : None | string | listlike containing strings
- If this is None, data for all the available lines will be read. Default is to read all data.
- Returns
A namedtuple containing the following fields:
(Always present)
- id : array, dtype uint
- unique ID of cluster
- trial: array, dtype uint
- which trial was this cluster part of
- time : array
- time at which cluster’s properties are being evaluated
- A_V : array
- A_V value for each cluster, in mag (present only if SLUG was run with extinction enabled)
- A_Vneb : array
- value of A_V applied to the nebular light for each cluster (present only if SLUG was run with both nebular emission and extinction enabled)
(Present if the run being read contains a cluster_prop file)
- form_time : array
- time when cluster formed
- lifetime : array
- time at which cluster will disrupt
- target_mass : array
- target cluster mass
- actual_mass : array
- actual mass at formation
- live_mass : array
- mass of currently living stars
- stellar_mass : array
- mass of all stars, living and stellar remnants
- num_star : array, dtype ulonglong
- number of living stars in cluster being treated stochastically
- max_star_mass : array
- mass of most massive living star in cluster
- vpn_tuple : tuple
- tuple containing arrays for any variable parameters we have (eg: VP0, VP1,VP2…) in the IMF. Each element of the tuple is an array. Present only if variable parameters were enables when SLUG was run.
(Present if the run being read contains a cluster_spec file)
- wl : array
- wavelength, in Angstrom
- spec : array, shape (N_cluster, N_wavelength)
- specific luminosity of each cluster at each wavelength, in erg/s/A
- wl_neb : array
- wavelength for the nebular spectrum, in Angstrom (present only if SLUG was run with nebular emission enabled)
- spec_neb : array, shape (N_cluster, N_wavelength)
- specific luminosity at each wavelength and each time for each trial, including emission and absorption by the HII region, in erg/s/A (present only if SLUG was run with nebular emission enabled)
- wl_ex : array
- wavelength for the extincted spectrum, in Angstrom (present only if SLUG was run with extinction enabled)
- spec_ex : array, shape (N_cluster, N_wavelength)
- specific luminosity at each wavelength in wl_ex and each time for each trial after extinction has been applied, in erg/s/A (present only if SLUG was run with extinction enabled)
- wl_neb_ex : array
- wavelength for the extincted spectrum with nebular emission, in Angstrom (present only if SLUG was run with both nebular emission and extinction enabled)
- spec_neb_ex : array, shape (N_cluster, N_wavelength)
- specific luminosity at each wavelength in wl_ex and each time for each trial including emission and absorption by the HII region, after extinction has been applied, in erg/s/A (present only if SLUG was run with nebular emission and extinction both enabled)
(Present if the run being read contains a cluster_phot file)
- filter_names : list of string
- a list giving the name for each filter
- filter_units : list of string
- a list giving the units for each filter
- filter_wl_cen : list
- central wavelength of each filter; this is set to None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- filter_wl : list of arrays
- a list giving the wavelength table for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- filter_response : list of arrays
- a list giving the photon response function for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- phot : array, shape (N_cluster, N_filter)
- photometric value in each filter for each cluster; units are as indicated in the units field; this is the true photometric output of the stars alone
- phot_ex : array, shape (N_cluster, N_filter)
- photometry of the stars after extinction is applied (only present if SLUG was run with extinction enabled)
- phot_neb : array, shape (N_cluster, N_filter)
- photometry of the stars plus nebular emission (only present if SLUG was run with nebular emission enabled)
- phot_neb_ex : array, shape (N_cluster, N_filter)
- photometry of the stars plus nebular emission after extinction is applied (only present if SLUG was run with both nebular emission and extinction enabled)
(Present is the run being read contains a cluster_sn file)
- tot_sn : array, shape (N_cluster)
- cumulative number of type II supernovae that have occurred in that cluster up to the present time
- stoch_sn : array of int, shape (N_cluster)
- cumulative number of stochastically-treated supernovae that have occurred in that cluster up to the present time; this differs from tot_sn only if SLUG was run with min_stoch_mass > 0
(Present if the run being read contains a cluster_yield file)
- isotope_name : array of strings
- Atomic symbols of the isotopes included in the yield table
- isotope_Z : array of int
- Atomic numbers of the isotopes included in the yield table
- isotope_A : array of int
- Atomic mass number of the isotopes included in the yield table
- yld : array
- Yield of each isotope, defined as the instantaneous amount produced up to that time; for unstable isotopes, this includes the effects of decay since production
(Present if the run being read contains a cluster_cloudyspec file)
- cloudy_wl : array
- wavelength, in Angstrom
- cloudy_inc : array, shape (N_cluster, N_wavelength)
- specific luminosity of the cluster’s stellar radiation field at each wavelength, in erg/s/A
- cloudy_trans : array, shape (N_cluster, N_wavelength)
- specific luminosity of the stellar radiation field after it has passed through the HII region, at each wavelength, in erg/s/A
- cloudy_emit : array, shape (N_cluster, N_wavelength)
- specific luminosity of the radiation field emitted by the HII region, at each wavelength, in erg/s/A
- cloudy_trans_emit : array, shape (N_cluster, N_wavelength)
- the sum of the emitted and transmitted fields; this is what would be seen by an observer looking at both the star cluster and its nebula
(Present if the run being read contains a cluster_cloudylines file)
- cloudy_linelabel : array, dtype=’S4’, shape (N_lines)
- labels for the lines, following cloudy’s 4 character line label notation
- cloudy_linewl : array, shape (N_lines)
- rest wavelength for each line, in Angstrom
- cloudy_linelum : array, shape (N_cluster, N_lines)
- luminosity of each line at each time for each trial, in erg/s
(Present if the run being read contains a cluster_cloudyphot file)
- cloudy_filter_names : list of string
- a list giving the name for each filter
- cloudy_filter_units : list of string
- a list giving the units for each filter
- cloudy_filter_wl_eff : list
- effective wavelength of each filter; this is set to None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- cloudy_filter_wl : list of arrays
- a list giving the wavelength table for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- cloudy_filter_response : list of arrays
- a list giving the photon response function for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- cloudy_filter_beta : list
- powerlaw index beta for each filter; used to normalize the photometry
- cloudy_filter_wl_c : list
- pivot wavelength for each filter; used to normalize the photometry
- cloudy_phot_trans : array, shape (N_cluster, N_filter)
- photometric value for each cluster in each filter for the transmitted light (i.e., the starlight remaining after it has passed through the HII region); units are as indicated in the units field
- cloudy_phot_emit : array, shape (N_cluster, N_filter)
- photometric value for each cluster in each filter for the emitted light (i.e., the diffuse light emitted by the HII region); units are as indicated in the units field
- cloudy_phot_trans_emit : array, shape (N_cluster, N_filter)
- photometric value in each filter for each cluster for the transmitted plus emitted light (i.e., the light coming directly from the stars after absorption by the HII region, plus the diffuse light emitted by the HII region); units are as indicated in the units field
(Present if the run being read contains a cluster_cloudyparams file)
- cloudy_hden : array
- number density of H nuclei at the inner edge of the ionized region simulated by cloudy
- cloudy_r0 : array
- inner radius of the ionized region simulated by cloudy
- cloudy_rS : array
- outer radius of the ionized region simulated by cloudy (approximate!)
- cloudy_QH0 : array
- ionizing luminosity used in the cloudy computation
- cloudy_covFac : array
- covering factor assumed in the cloudy computation; only a fraction covFac of the ionizing photons are assumed to produce emission within the HII region, while the remainder are assumed to escape
- cloudy_U : array
- volume-averaged ionization parameter of the HII region simulated by cloudy; note that this value is approximate, not exact, and the approximation can be very poor if radiation pressure effects are significant
- cloudy_Omega : array
- Yeh & Matzner (2012) wind parameter for the HII region simulated by cloudy; as with U, this value is approximate, and the approximation is valid only if radiation pressure effects are small
(Present if the run being read contains a cluster_ew file)
- line_names : list of string
- a list giving the name for each line
- line_units : list of string
- a list giving the units for the equivalent width of each line
- ew : array, shape (N_cluster, N_lines)
- equivalent width value of each line for each cluster; units are as indicated in the units field
- Raises
- IOError, if no photometry file can be opened ValueError, if photsystem is set to an unknown values
-
slugpy.
read_cluster_phot
(model_name, output_dir=None, fmt=None, nofilterdata=False, photsystem=None, verbose=False, read_info=None, filters_only=False, read_filters=None, read_nebular=None, read_extinct=None, phot_only=False)[source]¶ Function to read a SLUG2 cluster_phot file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- nofilterdata : bool
- If True, the routine does not attempt to read the filter response data from the standard location
- photsystem : None or string
- If photsystem is None, the data will be returned in the same photometric system in which they were read. Alternately, if it is a string, the data will be converted to the specified photometric system. Allowable values are ‘L_nu’, ‘L_lambda’, ‘AB’, ‘STMAG’, and ‘Vega’, corresponding to the options defined in the SLUG code. If this is set and the conversion requested involves a conversion from a wavelength-based system to a frequency-based one, nofilterdata must be False so that the central wavelength of the photometric filters is available.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- filters_only : bool
- If True, the code only reads the data on the filters, not any of the actual photometry. If combined with nofilterdata, this can be used to return the list of available filters and nothing else.
- read_filters : None | string | listlike containing strings
- If this is None, data on all filters is read. Otherwise only filters whose name(s) match the input filter names ar read.
- read_nebular : None | bool
- If True, only data with the nebular contribution is read; if False, only data without it is read. Default behavior is to read all data.
- read_extinct : None | bool
- If True, only data with extinction applied is read; if False, only data without it is read. Default behavior is to read all data.
- phot_only : bool
- If true, id, trial, time, and filter information are not read, only photometry
- Returns
A namedtuple, which can contain the following fields depending on the input options, and depending on which fields are present in the file being read:
- id : array, dtype uint
- unique ID of cluster
- trial: array, dtype uint
- which trial was this cluster part of
- time : array
- times at which cluster spectra are output, in yr
- filter_names : list of string
- a list giving the name for each filter
- filter_units : list of string
- a list giving the units for each filter
- filter_wl_eff : list
- effective wavelength of each filter; this is set to None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- filter_wl : list of arrays
- a list giving the wavelength table for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1
- filter_response : list of arrays
- a list giving the photon response function for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1
- filter_beta : list
- powerlaw index beta for each filter; used to normalize the photometry
- filter_wl_c : list
- pivot wavelength for each filter; used to normalize the photometry
- phot : array, shape (N_cluster, N_filter)
- photometric value in each filter for each cluster; units are as indicated in the units field
- phot_neb : array, shape (N_filter, N_times, N_trials)
- same as phot, but for the light after it has passed through the HII region
- phot_ex : array, shape (N_filter, N_times, N_trials)
- same as phot, but after extinction has been applied
- phot_neb_ex : array, shape (N_filter, N_times, N_trials)
- same as phot, but for the light after it has passed through the HII region and then had extinction applied
- Raises
- IOError, if no photometry file can be opened ValueError, if photsystem is set to an unknown value
-
slugpy.
read_cluster_prop
(model_name, output_dir=None, fmt=None, verbose=False, read_info=None, no_stellar_mass=False, no_neb_extinct=False)[source]¶ Function to read a SLUG2 cluster_prop file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- no_stellar_mass : bool
- Prior to 7/15, output files did not contain the stellar_mass field; this can be detected automatically for ASCII and FITS formats, but not for binary format; if True, this specifies that the binary file being read does not contain a stellar_mass field; it has no effect for ASCII or FITS files
- no_neb_extinct : bool
- Prior to 2/17, SLUG did not support differential nebular extinction, and thus there was no output field for it; this is detected and handled automatically for ASCII and FITS files; for binary outputs, this flag must be set for pre 2/17 output files to be read correctly
- Returns
A namedtuple containing the following fields:
- id : array, dtype uint
- unique ID of cluster
- trial: array, dtype uint
- which trial was this cluster part of
- time : array
- time at which cluster’s properties are being evaluated
- form_time : array
- time when cluster formed
- lifetime : array
- time at which cluster will disrupt
- target_mass : array
- target cluster mass
- actual_mass : array
- actual mass at formation
- live_mass : array
- mass of currently living stars
- stellar_mass : array
- mass of all stars, living and stellar remnants
- num_star : array, dtype ulonglong
- number of living stars in cluster being treated stochastically
- max_star_mass : array
- mass of most massive living star in cluster
- A_V : array
- A_V value for each cluster, in mag (present only if SLUG was run with extinction enabled)
- A_Vneb : array
- value of A_V applied to the nebular light for each cluster (present only if SLUG was run with both nebular emission and extinction enabled)
- vpn_tuple : tuple
- tuple containing arrays for any variable parameters we have (eg: VP0, VP1,VP2…) in the IMF. Each element of the tuple is an array. Present only if variable parameters were enables when SLUG was run.
-
slugpy.
read_cluster_spec
(model_name, output_dir=None, fmt=None, verbose=False, read_info=None)[source]¶ Function to read a SLUG2 cluster_spec file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- Returns
A namedtuple containing the following fields:
- id : array, dtype uint
- unique ID of cluster
- trial: array, dtype uint
- which trial was this cluster part of
- time : array
- times at which cluster spectra are output, in yr
- wl : array
- wavelength, in Angstrom
- spec : array, shape (N_cluster, N_wavelength)
- specific luminosity of each cluster at each wavelength, in erg/s/A
- wl_neb : array
- wavelength for the nebular spectrum, in Angstrom (present only if SLUG was run with nebular emission enabled)
- spec_neb : array, shape (N_cluster, N_wavelength)
- specific luminosity at each wavelength and each time for each trial, including emission and absorption by the HII region, in erg/s/A (present only if SLUG was run with nebular emission enabled)
- wl_ex : array
- wavelength for the extincted spectrum, in Angstrom (present only if SLUG was run with extinction enabled)
- spec_ex : array, shape (N_cluster, N_wavelength)
- specific luminosity at each wavelength in wl_ex and each time for each trial after extinction has been applied, in erg/s/A (present only if SLUG was run with extinction enabled)
- wl_neb_ex : array
- wavelength for the extincted spectrum with nebular emission, in Angstrom (present only if SLUG was run with both nebular emission and extinction enabled)
- spec_neb_ex : array, shape (N_cluster, N_wavelength)
- specific luminosity at each wavelength in wl_ex and each time for each trial including emission and absorption by the HII region, after extinction has been applied, in erg/s/A (present only if SLUG was run with nebular emission and extinction both enabled)
- Raises
- IOError, if no spectrum file can be opened
-
slugpy.
read_cluster_yield
(model_name, output_dir=None, fmt=None, verbose=False, read_info=None)[source]¶ Function to read a SLUG2 cluster_spec file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- Returns
A namedtuple containing the following fields:
- isotope_name : array of strings, shape (N_iso)
- Atomic symbols of the isotopes included in the yield table
- isotope_Z : array of int, shape (N_iso)
- Atomic numbers of the isotopes included in the yield table
- isotope_A : array of int, shape (N_iso)
- Atomic mass number of the isotopes included in the yield table
- id : array, dtype uint
- unique ID of cluster
- trial: array, dtype uint
- which trial was this cluster part of
- time : array
- times at which cluster spectra are output, in yr
- yld : array, shape (N_cluster, N_iso)
- Yield of each isotope, defined as the instantaneous amount produced up to that time; for unstable isotopes, this includes the effects of decay since production
-
slugpy.
read_cluster_sn
(model_name, output_dir=None, fmt=None, verbose=False, read_info=None)[source]¶ Function to read a SLUG2 cluster_sn file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- Returns
A namedtuple containing the following fields:
- id : array, dtype uint
- unique ID of cluster
- trial: array, dtype uint
- which trial was this cluster part of
- time : array
- times at which cluster spectra are output, in yr
- tot_sn : array, shape (N_cluster)
- total number of supernovae produced by each cluster up to the indicated time
- stoch_sn : array, shape (N_cluster)
- total number of supernovae produced by stars being treated stochastically in each cluster up to the indicated time
- Raises
- IOError, if no sn file can be opened
-
slugpy.
read_cluster_ew
(model_name, output_dir=None, fmt=None, verbose=False, read_info=None, lines_only=False, read_lines=None, ew_only=False)[source]¶ Function to read a SLUG2 cluster_ew file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files. Only FITS files are supported for the Equivalent Width data file.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- lines_only : bool
- If True, the code only reads the data on the lines, not any of the equivalent widths.
- read_lines : None | string | listlike containing strings
- If this is None, data on all lines is read. Otherwise only liness whose name(s) match the input line names are read.
- ew_only : bool
- If true, id, trial, time, and line information are not read, only the equivalent widths
- Returns
A namedtuple, which can contain the following fields depending on the input options, and depending on which fields are present in the file being read:
- id : array, dtype uint
- unique ID of cluster
- trial: array, dtype uint
- which trial was this cluster part of
- time : array
- times at which cluster spectra are output, in yr
- line_names : list of string
- a list giving the name for each line
- line_units : list of string
- a list giving the units for the equivalent width of each line
- ew : array, shape (N_cluster, N_lines)
- equivalent width value of each line for each cluster; units are as indicated in the units field
- Raises
- IOError, if no photometry file can be opened ValueError, if photsystem is set to an unknown value
-
slugpy.
read_cluster_winds
(model_name, output_dir=None, fmt=None, verbose=False, read_info=None)[source]¶ Function to read a SLUG cluster_winds file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- Returns
A namedtuple containing the following fields:
- id : array, dtype uint
- unique ID of cluster
- trial: array, dtype uint
- which trial was this cluster part of
- time : array
- time at which cluster’s properties are being evaluated
- mdot : array
- wind mass flux, in Msun / yr
- pdot : array
- wind momentum flux, in (Msun/yr) * (km/s)
- Lmech : array
- wind mechanical luminosity, in Lsun
- Raises
- IOError, if no wind file can be opened
-
slugpy.
read_filter
(filtername, filter_dir=None)[source]¶ Function to read a filter or set of filters for SLUG2. By default this function searches the SLUG_DIR/lib/filter directory, followed by the current working directory. This can be overridden by the filter_dir keyword.
- Parameters
- filtername : string or iterable containing strings
- Name or names of filters to be read; for the special filters Lbol, QH0, QHe0, and QHe1, the return value will be None
- filter_dir : string
- Directory where the filter data files can be found
- Returns
A namedtuple containing the following fields:
- wl_eff : float or array
- Central wavelength of the filter, defined by wl_eff = exp(int R ln lambda dln lambda / int R dln lambda)
- wl : array or list of arrays
- Wavelength table for each filter, in Ang
- response : array or list of arrays
- Response function per photon for each filter
- beta : float or array
- Index beta for the filter
- wl_c : float or array
- Pivot wavelength for the filter; used when beta != 0 to normalize the photometry
- Raises
- IOError, if the filter data files cannot be opened, or if the requested filter cannot be found
-
slugpy.
read_integrated
(model_name, output_dir=None, fmt=None, nofilterdata=False, photsystem=None, verbose=False, read_info=None, no_stellar_mass=False)[source]¶ Function to read all integrated light data for a SLUG2 run.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : string
- Format for the file to be read. Allowed values are ‘ascii’, ‘bin’ or ‘binary, and ‘fits’. If one of these is set, the code will only attempt to open ASCII-, binary-, or FITS-formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- nofilterdata : bool
- If True, the routine does not attempt to read the filter response data from the standard location
- photsystem : None or string
- If photsystem is None, the data will be returned in the same photometric system in which they were read. Alternately, if it is a string, the data will be converted to the specified photometric system. Allowable values are ‘L_nu’, ‘L_lambda’, ‘AB’, ‘STMAG’, and ‘Vega’, corresponding to the options defined in the SLUG code. If this is set and the conversion requested involves a conversion from a wavelength-based system to a frequency-based one, nofilterdata must be False so that the central wavelength of the photometric filters is available.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘prop_name’, ‘phot_name’, ‘spec_name’, ‘cloudyspec_name’, ‘cloudylines_name’ and ‘format’, giving the names of the files read and the format they were in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’. If one of the files is not present, the corresponding _name key will be omitted from the dict.
- no_stellar_mass : bool
- Prior to 7/15, output files did not contain the stellar_mass field; this can be detected automatically for ASCII and FITS formats, but not for binary format; if True, this specifies that the binary file being read does not contain a stellar_mass field; it has no effect for ASCII or FITS files
- Returns
A namedtuple containing the following fields:
(Always present)
- time: array
- Times at which data are output
(Only present if an integrated_prop file is found)
- target_mass : array, shape (N_times, N_trials)
- Target stellar mass at each time in each trial
- actual_mass : array, shape (N_times, N_trials)
- Actual mass of stars created up to each time in each trial
- live_mass : array, shape (N_times, N_trials)
- Mass of currently-alive stars at each time in each trial
- stellar_mass : array
- mass of all stars, living and stellar remnants
- cluster_mass : array, shape (N_times, N_trials)
- Mass of living stars in non-disrupted clusters at each time in each trial
- num_clusters : array, shape (N_times, N_trials), dtype ulonglong
- Number of non-disrupted clusters present at each time in each trial
- num_dis_clusters : array, shape (N_times, N_trials), dtype ulonglong
- Number of disrupted clusters present at each time in each trial
- num_fld_stars : array, shape (N_times, N_trials), dtype ulonglong
- Number of living field stars (excluding those in disrupted clusters and those being treated non-stochastically) present at each time in each trial
(Only present if an integrated_spec file is found)
- wl : array
- wavelengths, in Angstrom
- spec : array, shape (N_wavelength, N_times, N_trials)
- specific luminosity at each wavelength and each time for each trial, in erg/s/A
- wl_neb : array
- wavelength for the nebular spectrum, in Angstrom (present only if SLUG was run with nebular emission enabled)
- spec_neb : array, shape (N_wavelength, N_times, N_trials)
- specific luminosity at each wavelength and each time for each trial, including emission and absorption by the HII region, in erg/s/A (present only if SLUG was run with nebular emission enabled)
- wl_ex : array
- wavelength for the extincted spectrum, in Angstrom (present only if SLUG was run with extinction enabled)
- spec_ex : array, shape (N_wavelength, N_times, N_trials)
- specific luminosity at each wavelength in wl_ex and each time for each trial after extinction has been applied, in erg/s/A (present only if SLUG was run with extinction enabled)
- wl_neb_ex : array
- wavelength for the extincted spectrum with nebular emission, in Angstrom (present only if SLUG was run with both nebular emission and extinction enabled)
- spec_neb_ex : array, shape (N_wavelength, N_times, N_trials)
- specific luminosity at each wavelength in wl_ex and each time for each trial including emission and absorption by the HII region, after extinction has been applied, in erg/s/A (present only if SLUG was run with nebular emission and extinction both enabled)
(Only present if an integrated_phot file is found)
- filter_names : list of string
- a list giving the name for each filter
- filter_units : list of string
- a list giving the units for each filter
- filter_wl_cen : list
- central wavelength of each filter; this is set to None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- filter_wl : list of arrays
- a list giving the wavelength table for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- filter_response : list of arrays
- a list giving the photon response function for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- phot : array, shape (N_filter, N_times, N_trials)
- photometric value in each filter at each time in each trial; units are as indicated in the units field
- phot_ex : array, shape (N_filter, N_times, N_trials)
- photometry of the stars after extinction is applied (only present if SLUG was run with extinction enabled)
- phot_neb : array, shape (N_filter, N_times, N_trials)
- photometry of the stars plus nebular emission (only present if SLUG was run with nebular emission enabled)
- phot_neb_ex : array, shape (N_filter, N_times, N_trials)
- photometry of the stars plus nebular emission after extinction is applied (only present if SLUG was run with both nebular emission and extinction enabled)
(Only present if an integrated_sn file is found)
- tot_sn : array, shape (N_times, N_trials)
- total number of type II supernovae that have occurred up to the given time
- stoch_sn : array of int, shape (N_times, N_trials)
- total number of type II supernovae that have occurred up to the given time among stars being treated stochastically; only differs from tot_sn if SLUG was run with min_stoch_mass > 0
(Only present if an integrated_yield file is found)
- isotope_name : array of strings
- Atomic symbols of the isotopes included in the yield table
- isotope_Z : array of int
- Atomic numbers of the isotopes included in the yield table
- isotope_A : array of int
- Atomic mass number of the isotopes included in the yield table
- yld : array
- Yield of each isotope, defined as the instantaneous amount produced up to that time; for unstable isotopes, this includes the effects of decay since production
(Only present if an integrated_cloudyspec file is found)
- cloudy_wl : array
- wavelength, in Angstrom
- cloudy_inc : array, shape (N_wavelength, N_times, N_trials)
- specific luminosity of the stellar radiation field at each wavelength and each time for each trial, in erg/s/A
- cloudy_trans : array, shape (N_wavelength, N_times, N_trials)
- specific luminosity of the stellar radiation field after it has passed through the HII region, at each wavelength and each time for each trial, in erg/s/A
- cloudy_emit : array, shape (N_wavelength, N_times, N_trials)
- specific luminosity of the radiation field emitted by the HII region, at each wavelength and each time for each trial, in erg/s/A
- cloudy_trans_emit : array, shape (N_wavelength, N_times, N_trials)
- the sum of emitted and transmitted; this is what would be seen by an observer looking at both the star cluster and its nebula
(Only present if an integrated_cloudylines file is found)
- cloudy_linelabel : array, dtype=’S4’, shape (N_lines)
- labels for the lines, following cloudy’s 4 character line label notation
- cloudy_linewl : array, shape (N_lines)
- rest wavelength for each line, in Angstrom
- cloudy_linelum : array, shape (N_lines, N_times, N_trials)
- luminosity of each line at each time for each trial, in erg/s
(Only present if an integrated_cloudyphot file is found)
- cloudy_filter_names : list of string
- a list giving the name for each filter
- cloudy_filter_units : list of string
- a list giving the units for each filter
- cloudy_filter_wl_eff : list
- effective wavelength of each filter; this is set to None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- cloudy_filter_wl : list of arrays
- a list giving the wavelength table for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- cloudy_filter_response : list of arrays
- a list giving the photon response function for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- cloudy_filter_beta : list
- powerlaw index beta for each filter; used to normalize the photometry
- cloudy_filter_wl_c : list
- pivot wavelength for each filter; used to normalize the photometry
- cloudy_phot_trans : array, shape (N_filter, N_times, N_trials)
- photometric value in each filter at each time in each trial for the transmitted light (i.e., the starlight remaining after it has passed through the HII region); units are as indicated in the units field
- cloudy_phot_emit : array, shape (N_filter, N_times, N_trials)
- photometric value in each filter at each time in each trial for the emitted light (i.e., the diffuse light emitted by the HII region); units are as indicated in the units field
- cloudy_phot_trans_emit : array, shape (N_filter, N_times, N_trials)
- photometric value in each filter at each time in each trial for the transmitted plus emitted light (i.e., the light coming directly from the stars after absorption by the HII region, plus the diffuse light emitted by the HII region); units are as indicated in the units field
(Only present if an integrated_cloudyparams file is found)
- cloudy_hden : array
- number density of H nuclei at the inner edge of the ionized region simulated by cloudy
- cloudy_r0 : array
- inner radius of the ionized region simulated by cloudy
- cloudy_rS : array
- outer radius of the ionized region simulated by cloudy (approximate!)
- cloudy_QH0 : array
- ionizing luminosity used in the cloudy computation
- cloudy_covFac : array
- covering factor assumed in the cloudy computation; only a fraction covFac of the ionizing photons are assumed to produce emission within the HII region, while the remainder are assumed to escape
- cloudy_U : array
- volume-averaged ionization parameter of the HII region simulated by cloudy; note that this value is approximate, not exact, and the approximation can be very poor if radiation pressure effects are significant
- cloudy_Omega : array
- Yeh & Matzner (2012) wind parameter for the HII region simulated by cloudy; as with U, this value is approximate, and the approximation is valid only if radiation pressure effects are small
-
slugpy.
read_integrated_phot
(model_name, output_dir=None, fmt=None, nofilterdata=False, photsystem=None, verbose=False, read_info=None, filters_only=False, read_filters=None, read_nebular=None, read_extinct=None)[source]¶ Function to read a SLUG2 integrated_phot file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- nofilterdata : bool
- If True, the routine does not attempt to read the filter response data from the standard location
- photsystem : None or string
- If photsystem is None, the data will be returned in the same photometric system in which they were read. Alternately, if it is a string, the data will be converted to the specified photometric system. Allowable values are ‘L_nu’, ‘L_lambda’, ‘AB’, ‘STMAG’, and ‘Vega’, corresponding to the options defined in the SLUG code. If this is set and the conversion requested involves a conversion from a wavelength-based system to a frequency-based one, nofilterdata must be False so that the central wavelength of the photometric filters is available.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- filters_only : bool
- If True, the code only reads the data on the filters, not any of the actual photometry. If combined with nofilterdata, this can be used to return the list of available filters and nothing else.
- read_filters : None | string | listlike containing strings
- If this is None, data on all filters is read. Otherwise only filters whose name(s) match the input filter names ar read.
- read_nebular : None | bool
- If True, only data with the nebular contribution is read; if False, only data without it is read. Default behavior is to read all data.
- read_extinct : None | bool
- If True, only data with extinction applied is read; if False, only data without it is read. Default behavior is to read all data.
- Returns
A namedtuple , which can contain the following fields depending on the input options, and depending on which fields are present in the file being read:
- time : array, shape (N_times) or shape (N_trials)
- Times at which data are output; shape is either N_times (if the run was done with fixed output times) or N_trials (if the run was done with random output times)
- filter_names : list of string
- a list giving the name for each filter
- filter_units : list of string
- a list giving the units for each filter
- filter_wl_eff : list
- effective wavelength of each filter; this is set to None for the filters Lbol, QH0, QHe0, and QHe1; omitted if nofilterdata is True
- filter_wl : list of arrays
- a list giving the wavelength table for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1
- filter_response : list of arrays
- a list giving the photon response function for each filter; this is None for the filters Lbol, QH0, QHe0, and QHe1
- filter_beta : list
- powerlaw index beta for each filter; used to normalize the photometry
- filter_wl_c : list
- pivot wavelength for each filter; used to normalize the photometry
- phot : array, shape (N_filter, N_times, N_trials)
- photometric value in each filter at each time in each trial; units are as indicated in the units field
- phot_neb : array, shape (N_filter, N_times, N_trials)
- same as phot, but for the light after it has passed through the HII region
- phot_ex : array, shape (N_filter, N_times, N_trials)
- same as phot, but after extinction has been applied
- phot_neb_ex : array, shape (N_filter, N_times, N_trials)
- same as phot, but for the light after it has passed through the HII region and then had extinction applied
- Raises
- IOError, if no photometry file can be opened ValueError, if photsystem is set to an unknown value
-
slugpy.
read_integrated_prop
(model_name, output_dir=None, fmt=None, verbose=False, read_info=None, no_stellar_mass=False)[source]¶ Function to read a SLUG2 integrated_prop file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- no_stellar_mass : bool
- Prior to 7/15, output files did not contain the stellar_mass field; this can be detected automatically for ASCII and FITS formats, but not for binary format; if True, this specifies that the binary file being read does not contain a stellar_mass field; it has no effect for ASCII or FITS files
- Returns
A namedtuple containing the following fields:
- time : array, shape (N_times) or shape (N_trials)
- Times at which data are output; shape is either N_times (if the run was done with fixed output times) or N_trials (if the run was done with random output times)
- target_mass : array, shape (N_times, N_trials)
- Target stellar mass at each time
- actual_mass : array, shape (N_times, N_trials)
- Actual mass of stars created up to each time in each trial
- live_mass : array, shape (N_times, N_trials)
- Mass of currently-alive stars at each time in each trial
- stellar_mass : array
- mass of all stars, living and stellar remnants
- cluster_mass : array, shape (N_times, N_trials)
- Stellar mass in non-disrupted clusters at each time in each trial
- num_clusters : array, shape (N_times, N_trials), dtype ulonglong
- Number of non-disrupted clusters present at each time in each trial
- num_dis_clusters : array, shape (N_times, N_trials), dtype ulonglong
- Number of disrupted clusters present at each time in each trial
- num_fld_stars : array, shape (N_times, N_trials), dtype ulonglong
- Number of living field stars (excluding those in disrupted clusters and those being treated non-stochastically) present at each time in each trial
-
slugpy.
read_integrated_spec
(model_name, output_dir=None, fmt=None, verbose=False, read_info=None)[source]¶ Function to read a SLUG2 integrated_spec file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- Returns
A namedtuple containing the following fields:
- time : array, shape (N_times) or shape (N_trials)
- Times at which data are output; shape is either N_times (if the run was done with fixed output times) or N_trials (if the run was done with random output times)
- wl : array
- wavelength, in Angstrom
- spec : array, shape (N_wavelength, N_times, N_trials)
- specific luminosity at each wavelength and each time for each trial, in erg/s/A
- wl_neb : array
- wavelength for the nebular spectrum, in Angstrom (present only if SLUG was run with nebular emission enabled)
- spec_neb : array, shape (N_wavelength, N_times, N_trials)
- specific luminosity at each wavelength and each time for each trial, including emission and absorption by the HII region, in erg/s/A (present only if SLUG was run with nebular emission enabled)
- wl_ex : array
- wavelength for the extincted spectrum, in Angstrom (present only if SLUG was run with extinction enabled)
- spec_ex : array, shape (N_wavelength, N_times, N_trials)
- specific luminosity at each wavelength in wl_ex and each time for each trial after extinction has been applied, in erg/s/A (present only if SLUG was run with extinction enabled)
- wl_neb_ex : array
- wavelength for the extincted spectrum with nebular emission, in Angstrom (present only if SLUG was run with both nebular emission and extinction enabled)
- spec_neb_ex : array, shape (N_wavelength, N_times, N_trials)
- specific luminosity at each wavelength in wl_ex and each time for each trial including emission and absorption by the HII region, after extinction has been applied, in erg/s/A (present only if SLUG was run with nebular emission and extinction both enabled)
-
slugpy.
read_integrated_yield
(model_name, output_dir=None, fmt=None, read_info=None, verbose=False)[source]¶ Function to read a SLUG2 integrated_yield file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- Returns
A namedtuple containing the following fields:
- time : array, shape (N_times) or shape (N_trials)
- Times at which data are output; shape is either N_times (if the run was done with fixed output times) or N_trials (if the run was done with random output times)
- isotope_name : array of strings, shape (N_iso)
- Atomic symbols of the isotopes included in the yield table
- isotope_Z : array of int, shape (N_iso)
- Atomic numbers of the isotopes included in the yield table
- isotope_A : array of int, shape (N_iso)
- Atomic mass number of the isotopes included in the yield table
- yld : array, shape (N_iso, N_times) or (N_iso, N_trials)
- Yield of each isotope, defined as the instantaneous amount produced up to that time; for unstable isotopes, this includes the effects of decay since production
-
slugpy.
read_integrated_sn
(model_name, output_dir=None, fmt=None, verbose=False, read_info=None)[source]¶ Function to read a SLUG2 integrated_sn file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- verbose : bool
- If True, verbose output is printed as code runs
- read_info : dict
- On return, this dict will contain the keys ‘fname’ and ‘format’, giving the name of the file read and the format it was in; ‘format’ will be one of ‘ascii’, ‘binary’, or ‘fits’
- Returns
A namedtuple containing the following fields:
- time : array, shape (N_times) or shape (N_trials)
- Times at which data are output; shape is either N_times (if the run was done with fixed output times) or N_trials (if the run was done with random output times)
- tot_sn : array, shape (N_cluster)
- total number of supernovae produced by each cluster up to the indicated time
- stoch_sn : array, shape (N_cluster)
- total number of supernovae produced by stars being treated stochastically in each cluster up to the indicated time
- Raises
- IOError, if no sn file can be opened
-
slugpy.
read_summary
(model_name, output_dir=None)[source]¶ Function to open a SLUG output summary file.
- Parameters
- model_name : string
- The name of the model to be read
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR directory if that environment variable is set
- Returns
- summary : dict
- A dict containing all the keywords stored in the output file
- Raises
- IOError, if a summary file for the specified model cannot be found
-
slugpy.
slug_open
(filename, output_dir=None, fmt=None)[source]¶ Function to open a SLUG2 output file.
- Parameters
- filename : string
- Name of the file to open, without any extension. The following extensions are tried, in order: .txt, .bin, .fits
- output_dir : string
- The directory where the SLUG2 output is located; if set to None, the current directory is searched, followed by the SLUG_DIR/output directory if the SLUG_DIR environment variable is set
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the file to be read. If one of these is set, the function will only attempt to open ASCII-(‘txt’ or ‘ascii’), binary (‘bin’ or ‘binary’), or FITS (‘fits’ or ‘fits2’) formatted output, ending in .txt., .bin, or .fits, respectively. If set to None, the code will try to open ASCII files first, then if it fails try binary files, and if it fails again try FITS files.
- Returns
- fp : file or astropy.io.fits.hdu.hdulist.HDUList
- A file object pointing the file that has been opened
- fname : string
- Name of the file that was opened
- Raises
- IOError, if a file of the specified name cannot be found
-
class
slugpy.
slug_pdf
(pdffile=None)[source]¶ A class that implements the SLUG PDF drawing method. This class contains a method to parse slug-formatted PDF files and then draw values from the PDFs they specify. This class is thread-safe, in the sense that if multiple slug_pdf instances are instantiated in different threads, the random streams they generate will not be identical.
-
slugpy.
write_cluster
(data, model_name, fmt)[source]¶ Function to write a set of output cluster files in SLUG2 format, starting from a cluster data set as returned by read_cluster.
- Parameters
- data : namedtuple
- Cluster data to be written, in the namedtuple format returned by read_cluster
- model_name : string
- Base file name to give the model to be written. Can include a directory specification if desired.
- fmt : ‘txt’ | ‘ascii’ | ‘bin’ | ‘binary’ | ‘fits’ | ‘fits2’
- Format for the output file; ‘txt’ and ‘ascii’ produce ASCII text files, ‘bin’ or ‘binary’ produce binary files, and ‘fits’ or ‘fits2’ product FITS files; ‘fits2’ uses an ordering that allows for more efficient querying of outputs too large to fit in memory
- Returns
- Nothing
-
slugpy.
write_integrated
(data, model_name, fmt)[source]¶ Function to write a set of output integrated files in SLUG2 format, starting from an integrated data set as returned by read_integrated.
- Parameters
- data : namedtuple
- Integrated data to be written, in the namedtuple format returned by read_integrated
- model_name : string
- Base file name to give the model to be written. Can include a directory specification if desired.
- fmt : string
- Format for the output file. Allowed values are ‘ascii’, ‘bin’ or ‘binary, and ‘fits’.
- Returns
- Nothing