ModelSet
- class dysmalpy.models.ModelSet[source]
Bases:
object
Object that contains all model components, parameters, and settings
ModelSet
does not take any arguments. Instead, it first should be initialized and thenModelSet.add_component()
can be used to include specific model components. All included components can then be accessed throughModelSet.components
which is a dictionary that has keys equal to the names of each component. The primary method ofModelSet
isModelSet.simulate_cube()
which produces a model data cube of line emission that follows the full kinematics of given model.Methods Summary
add_component
(model[, name, light, ...])Add a model component to the set
circular_velocity
(r[, compute_baryon, ...])Calculate the total circular velocity as a function of radius
enclosed_mass
(r[, compute_baryon, ...])Calculate the total enclosed mass
Calculate the composite derivative dln(rho,gas) / dlnr
get_dm_aper
(r)Calculate the enclosed dark matter fraction
Calculate the dark matter fraction within an aperture radius
Calculate the total enclosed mass within an aperture radius
Return the index within an array of each free parameter
Return the current values of the free parameters
Return the alpha parameter value for a
TwoPowerHalo
Return the Burkert radius parameter value for a
Burkert
dark matter haloReturn the total log prior based on current values
Return the virial mass of the dark matter halo component
get_vmax
([r, tracer])Calculate the peak velocity of the rotation curve
set_parameter_fixed
(model_name, param_name, fix)Change whether a specific parameter is fixed or not
set_parameter_value
(model_name, param_name, ...)Change the value of a specific parameter
simulate_cube
([obs, dscale])Simulate a line emission cube of this model set
update_parameters
(theta)Update all of the free and tied parameters of the model
vcirc_sq
(r[, compute_baryon, compute_dm, step1d])Calculate the square of the total circular velocity as a function of radius
velocity_profile
(r[, tracer, compute_dm])Calculate the rotational velocity as a function of radius
write_profile_file
([r, filename, cols, ...])Output various radial profiles of the
ModelSet
write_vrot_vcirc_file
([r, filename, tracer, ...])Output the rotational and circular velocities to a file
Methods Documentation
- add_component(model, name=None, light=False, geom_type='galaxy', disp_type='galaxy')[source]
Add a model component to the set
- Parameters:
model (
_DysmalModel
) – Model component to be added to the model setname (str) – Name of the model component
light (bool) – If True, use the mass profile of the model component in the calculation of the flux of the line, i.e. setting the mass-to-light ratio equal to 1.
geom_type ({'galaxy', component name}) – Specify which model components the geometry applies to. Only used if
model
is aGeometry
. If ‘galaxy’, then all included components except named components with other geometries will follow this geometry (i.e., those with a separate geometry included that has ‘geom_type’=the component name). Default is ‘galaxy’.disp_type ({'galaxy', component name}) – Specify which model components the dispersion applies to (by name, with the exception of the default profiles). Only used if
model
is aDispersionProfile
. Default is ‘galaxy’.
- circular_velocity(r, compute_baryon=False, compute_dm=False, step1d=0.2)[source]
Calculate the total circular velocity as a function of radius
- Parameters:
r (float or array) – Radius or radii at which to calculate the circular velocity in kpc
compute_baryon (bool) – If True, also return the circular velocity due to the baryons
compute_dm (bool) – If True, also return the circular velocity due to the halo
step1d (float, optional) – Step size in kpc to use during adiabatic contraction calculation
- Returns:
vel (float or array) – Total circular velocity in km/s
vbaryon (float or array, only if
compute_baryon
= True) – Circular velocity due to the baryonsvdm (float or array, only if
compute_dm
= True) – Circular velocity due to the halo
- enclosed_mass(r, compute_baryon=False, compute_dm=False, step1d=0.2)[source]
Calculate the total enclosed mass
- Parameters:
r (float or array) – Radius or radii at which to calculate the enclosed mass in kpc
compute_baryon (bool) – If True, also return the enclosed mass of the baryons
compute_dm (bool) – If True, also return the enclosed mass of the halo
step1d (float, optional) – Step size in kpc to use during adiabatic contraction calculation
- Returns:
enc_mass (float or array) – Total enclosed mass in Msun
enc_bary (float or array, only if
compute_baryon
= True) – Enclosed mass of the baryons, in Msunenc_dm (float or array, only if
compute_dm
= True) – Enclosed mass of the halo, in Msun
- get_dlnrhogas_dlnr(r)[source]
Calculate the composite derivative dln(rho,gas) / dlnr
- ** Assumes gas follows same distribution as total baryons.
Based on slope, so do not need to rescale for fgas/Mgas under this assumption.**
- get_dm_frac_r_ap()[source]
Calculate the dark matter fraction within an aperture radius
Uses the method self._model_aperture_r to get the defined apeture radius. By default this function seturns the disk effective radius (i.e., self.components[‘disk+bulge’].__getattribute__[‘r_eff_disk’].value )
- Returns:
dm_frac – Dark matter fraction within the specified effective radius
- Return type:
- get_encl_mass_r_ap()[source]
Calculate the total enclosed mass within an aperture radius
Uses the method self._model_aperture_r to get the defined apeture radius. By default this function seturns the disk effective radius (i.e., self.components[‘disk+bulge’].__getattribute__[‘r_eff_disk’].value )
- Returns:
menc – Total enclosed mass within the specified effective radius
- Return type:
Notes
(OLD: This method uses the total circular velocity to determine the enclosed mass based on v^2 = GM/r.)
- get_free_parameter_keys()[source]
Return the index within an array of each free parameter
- Returns:
pfree_keys – Dictionary of all model components with their parameters. If a model parameter is free, then it lists its index within
p
. Otherwise, -99.- Return type:
dictionary
- get_free_parameters_values()[source]
Return the current values of the free parameters
- Returns:
pfree – Values of the free parameters
- Return type:
array
- get_halo_alpha()[source]
Return the alpha parameter value for a
TwoPowerHalo
- Returns:
alpha – Value of the alpha parameter. Returns None if the correct component does not exist.
- Return type:
float or None
- get_log_prior()[source]
Return the total log prior based on current values
- Returns:
log_prior_model – Summed log prior
- Return type:
- get_mvirial()[source]
Return the virial mass of the dark matter halo component
- Returns:
mvir – Virial mass of the dark matter halo in log(Msun)
- Return type:
- get_vmax(r=None, tracer=None)[source]
Calculate the peak velocity of the rotation curve
- Parameters:
r (array, optional) – Radii to sample to find the peak. If None, then a linearly spaced array from 0 to 25 kpc with 251 points will be used
tracer (string) – Name of the dynamical tracer (used to determine which is the appropriate dispersion profile).
- Returns:
vmax – Peak velocity of the rotation curve in km/s
- Return type:
Notes
This simply finds the maximum of the rotation curve which is calculated at discrete radii,
r
.
- set_parameter_fixed(model_name, param_name, fix)[source]
Change whether a specific parameter is fixed or not
- set_parameter_value(model_name, param_name, value, skip_updated_tied=False)[source]
Change the value of a specific parameter
- simulate_cube(obs=None, dscale=None)[source]
Simulate a line emission cube of this model set
- Parameters:
obs (Observation class) – Instance holding the observation information
dscale (float) – Conversion from sky to physical coordinates in arcsec/kpc
- Returns:
cube_final (3D array) – Line emission cube that incorporates all of the kinematics due to the components of the current
ModelSet
spec (1D array) – Values of the spectral channels as determined by
spec_type
,spec_start
,spec_step
,nspec
, andspec_unit
- update_parameters(theta)[source]
Update all of the free and tied parameters of the model
- Parameters:
theta (array with length =
ModelSet.nparams_free
) – New values for the free parameters
Notes
The order of the values in
theta
is important. UseModelSet.get_free_parameter_keys()
to determine the correct order.
- vcirc_sq(r, compute_baryon=False, compute_dm=False, step1d=0.2)[source]
Calculate the square of the total circular velocity as a function of radius
- Parameters:
r (float or array) – Radius or radii at which to calculate the circular velocity in kpc
compute_baryon (bool) – If True, also return the circular velocity due to the baryons
compute_dm (bool) – If True, also return the circular velocity due to the halo
step1d (float, optional) – Step size in kpc to use during adiabatic contraction calculation
- Returns:
vel (float or array) – Total circular velocity in km/s
vbaryon (float or array, only if
compute_baryon
= True) – Circular velocity due to the baryonsvdm (float or array, only if
compute_dm
= True) – Circular velocity due to the halo
- velocity_profile(r, tracer=None, compute_dm=False)[source]
Calculate the rotational velocity as a function of radius
- Parameters:
- Returns:
vel (float or array) – Rotational velocity as a function of radius in km/s
vdm (float or array) – Circular velocity due to the dark matter halo in km/s Only returned if
compute_dm
= True
- write_profile_file(r=None, filename=None, cols=None, prettycolnames=None, colunits=None, tracer=None, overwrite=False)[source]
Output various radial profiles of the
ModelSet
- Parameters:
r (array, optional) – Radii to sample to find the peak. If None, then a linearly spaced array from 0 to 10 kpc with a stepsize of 0.1 will be used
filename (str, optional) – Output filename to write to. Will be written as ascii, w/ space delimiter. Default is ‘rprofiles.txt’
cols (list, optional) – Names of ModelSet methods that will be called as function of r, and to be saved as a column in the output file. Default is [‘velocity_profile’, ‘circular_velocity’, ‘get_dm_aper’].
prettycolnames (list, optional) – Alternate column names for output in file header (eg, ‘vrot’ not ‘velocity_profile’) Default is
cols
.colunits (list, optional) – Units of each column. r is added by hand, and will always be in kpc.
tracer (string) – Name of the dynamical tracer (used to determine which is the appropriate dispersion profile).
- write_vrot_vcirc_file(r=None, filename=None, tracer=None, overwrite=False)[source]
Output the rotational and circular velocities to a file
- Parameters:
r (array, optional) – Radii to sample to find the peak. If None, then a linearly spaced array from 0 to 25 kpc with 251 points will be used
filename (str, optional) – Name of file to output velocities to. Default is ‘vout.txt’
tracer (string) – Name of the dynamical tracer (used to determine which is the appropriate dispersion profile).