DustModel¶
- class dgfit.dustmodel.DustModel(componentnames=None, path='./', dustmodel=None, obsdata=None, every_nth=5)[source]¶
Bases:
object
Full dust model including arbitrary size and composition distributions. Includes the physical properties of the individual dust grains.
Dust model that has each bin as an independent variable in the grain size distribution providing a truly arbitrary specification.
- Parameters:
- componentnamesstr list, optional
if set, then read in the grain information from files
- pathstr, optional
path to grain files
- dustmodelDustModel object, optional
if set, create the grain info on the obsdata wavelengths using the input dustmodel grain information
- obsdataObsData object, optional
observed data information
- Attributes:
- originstring
origin of the dust grain physical properties allowed values are ‘files’ and ‘onobsdata’
- n_componentsint
number of dust grain components
- componentsarray of DustGrain objects
one DustGrain object per component
- sizedisttypestring
functional form of component size distributions
- n_paramsints
number of size distribution parameters per grain component
- parametersdict
Dictonary of parameters with an entry for each composition each entry is then a dictonary giving the value by parameter name. For the bins case, the dictonary is empty as the parameters is the size distribution.
Methods Summary
compute_size_dist
(x, params)Compute the size distribution for the input sizes.
eff_grain_props
(OD[, predict_all])Compute the effective grain properties of the ensemble of grain sizes and compositions.
get_percentile_vals
(chain, ndim)Compute the 50% +/- 33% values from the samples
grains_on_model
(full_dustmodel)Calculate the dust grain properties on the model grid (simple copy).
grains_on_obs
(full_dustmodel, observeddata)Calculate the dust grain properties on the observed wavelength grid.
initial_walkers
(p0, nwalkers)Setup the walkers based on the initial parameters p0 Specific to MCMC fitters (e.g., emcee).
lnprob
(params, obsdata, dustmodel)Compute the full probability function including priors Static function as it will be called form the fitter
lnprob_generic
(obsdata)Compute the ln(prob) for the dust grain size and composition distribution as defined by the dustmodel.
read_grain_files
(componentnames[, path, ...])Read in the precomputed dust grain physical properties from files for each grain component.
read_sizedist_from_file
(filename)Read in the size distribution from a file interpolating across sizes if needed
save_50percentile_results
(oname, sampler, ...)Compute the 50th percentile paramaters, set the size distribution, and save the results
save_best_results
(oname, sampler, obsdata[, ...])Compute the best fit paramaters using a sampler chain, set the size distribution, and save the results
save_results
(filename, OD[, size_dist_uncs])Save fitting results to a file.
set_size_dist
(params)Set the size distributions for each component based on the parameters of the functional form of the distributions.
set_size_dist_parameters
(params)Set the size distribution parameters in the object dictonary.
Methods Documentation
- compute_size_dist(x, params)[source]¶
Compute the size distribution for the input sizes. For the bins case, just passes the parameters back. Allows for other functional forms of the size distribution with minimal new code.
- Parameters:
- xfloats
grains sizes
- paramsfloats
Size distribution parameters For the arbitrary bins case, the parameters are the number of grains per size distribution
- Returns:
- floats
Size distribution as a function of x
- eff_grain_props(OD, predict_all=False)[source]¶
Compute the effective grain properties of the ensemble of grain sizes and compositions.
- Parameters:
- ODObsData object
Observed data object specifically used to determine which observations to compute (only those needed for speed)
- predict_alltype
Regardless of the ObsData, compute all possible observations
- Returns:
- dict
Dictonary of predicted observations E.g., keys of cext, natoms, emission, albedo, g
- static get_percentile_vals(chain, ndim)[source]¶
Compute the 50% +/- 33% values from the samples
- Parameters:
- chainsampler.chain
Chain from the EMCEE sampler
- ndimint
number of paramaters
- Returns:
- tuple of floats
(p50, p84-p50, p50-p16)
- grains_on_model(full_dustmodel)[source]¶
Calculate the dust grain properties on the model grid (simple copy). Uses an existing DustModel based on the full precomputed files and an ObsData object to get the wavelength grid. Makes the fitting faster to only do this transformation once.
- Parameters:
- full_dustmodelDustModel object
full dust model based on input files
- Returns:
- updated class variables
- grains_on_obs(full_dustmodel, observeddata)[source]¶
Calculate the dust grain properties on the observed wavelength grid. Uses an existing DustModel based on the full precomputed files and an ObsData object to get the wavelength grid. Makes the fitting faster to only do this transformation once.
- Parameters:
- full_dustmodelDustModel object
full dust model based on input files
- observeddata: ObsData object
observed data to use for transformation
- Returns:
- updated class variables
- initial_walkers(p0, nwalkers)[source]¶
Setup the walkers based on the initial parameters p0 Specific to MCMC fitters (e.g., emcee).
- Parameters:
- p0floats
Initial values of the parameters
- nwalkersint
Number of walkers to initialize
- Returns:
- array of floats
concatenated set of initial walker positions
- static lnprob(params, obsdata, dustmodel)[source]¶
Compute the full probability function including priors Static function as it will be called form the fitter
- Parameters:
- paramsfloats
Parameters of the size distribution function
- obsdataObsData object
Observed data to be fit
- dustmodelDustModel object
Dust model information
- Returns:
- float
natural log of the probability
- lnprob_generic(obsdata)[source]¶
Compute the ln(prob) for the dust grain size and composition distribution as defined by the dustmodel.
- Parameters:
- obsdataObsData object
All the observed data
- Returns:
- float
natural log of the probability
- read_grain_files(componentnames, path='./', every_nth=5)[source]¶
Read in the precomputed dust grain physical properties from files for each grain component.
- Parameters:
- componentnameslist of strings
names of dust grain materials
- pathtype
path to files
- every_nthint
Only use every nth size, faster fitting
- Returns:
- updated class variables
- read_sizedist_from_file(filename)[source]¶
Read in the size distribution from a file interpolating across sizes if needed
- Parameters:
- filenamestr
name of FITS file with size distributions one component per extension
- save_50percentile_results(oname, sampler, obsdata, nburn=0, cur_step=None)[source]¶
Compute the 50th percentile paramaters, set the size distribution, and save the results
Creates a FITS file with the results
- Parameters:
- onamestr
Name of the file to save the results
- sampleremcee.sampler
Sampler object from EMCEE run
- obsdataObsData object
All the observed data (may not be needed)
- cur_stepint
Current step number
- save_best_results(oname, sampler, obsdata, cur_step=None)[source]¶
Compute the best fit paramaters using a sampler chain, set the size distribution, and save the results
Creates a FITS file with the results
- Parameters:
- onamestr
Name of the file to save the results
- sampleremcee.sampler
Sampler object from EMCEE run
- obsdataObsData object
All the observed data (may not be needed)
- cur_stepint
Current step number
- save_results(filename, OD, size_dist_uncs=[0])[source]¶
Save fitting results to a file. Results include the size distribution and all predicted observations.
Creates a FITS file with the results
- Parameters:
- filenamestr
Name of the file to save the results
- ODObsData object
All the observed data (may not be needed)
- size_dist_uncsfloats
Uncertainties on the size distributions
- set_size_dist(params)[source]¶
Set the size distributions for each component based on the parameters of the functional form of the distributions.
- Parameters:
- new_size_diststype
Description of parameter
new_size_dists
.
- Returns:
- type
Description of returned object.
- set_size_dist_parameters(params)[source]¶
Set the size distribution parameters in the object dictonary. For the bins case, this does nothing. Allows for other functional forms of the size distribution with minimal new code.
- Parameters:
- paramsfloats
Size distribution parameters For the arbitrary bins case, the parameters are the number of grains per size distribution