components
A module for generating rotation curve components using parameters and theoretical models.
Includes bulge, blackhole, and disk components as well as multiple halo functions. It also includes some calculations of the total velocity for convenience as well as some constants and utility functions used by the library’s main functions. Gas contributions are imported from measured data, not calculated, as the gas component is very easily measured and well-understod.
ToC: Functions
|
Retrieve a dictionary of parameters for the associated galaxy. |
|
Utility function for saving a dataset to hdf5. |
|
Utility function for loading a dataset from hdf5. |
|
Utility function for checking data present in hdf5 without loading. |
|
Function to calculate the gravitational effect of a black hole. |
|
Function to calculate the gravitational effect of a galactic bulge using empirically derived parameters. |
|
Function to calculate the gravitational effect of a galactic disk using the traced curves of the galaxies. |
|
Function to calculate the gravitational effect of a galactic gas using the traced curves of the galaxies. |
|
Function to calculate the gravitational effect of a Dark Matter halo by integrating the enclosed mass and isothermal density profile. |
|
Function to calculate the gravitational effect of a Dark Matter halo using the isothermal density profile (Source: [Jimenez2003]). |
|
Defining the default version of halo velocity calculation. In this case, using the isothermal density profile. |
|
Function to calculate the total gravitational effect of all components of a galaxy for the tiny black hole widget. |
|
Function to calculate the total gravitational effect of all components of a galaxy. |
|
Setting parameters for tiny black hole widget. |
|
Calculate fitting. |
ToC: Attributes
If 1, the h5py library is available for saving and loading data. If 0, then all calculations must be done each time without saving or loading. |
|
The default location of files containing cached calculations. |
|
Gravitational constant (\(kpc/(M_{Sun}(km/s)^2)\)). |
|
Bulge mass-to-light ratio (\(M_{Sun}/L_{Sun}\)). [Noordermeer2008] |
|
Intrinsic axis ratio. [Noordermeer2008] |
|
Bulge eccentricity. [Noordermeer2008] |
|
Inclination angle (radians). [Noordermeer2008] |
|
Core radius (\(kpc\)). [Noordermeer2008] |
|
Central black hole mass (\(M_{Sun}\)). [Noordermeer2008] |
|
Concentration parameter. [Noordermeer2007] |
|
Radial scale length (\(kpc\)). [Noordermeer2007] |
|
Central surface density of halo (\(M_{Sun}/kpc^2\)). [Noordermeer2008] |
|
Central surface density of disk (\(M_{Sun}/kpc^2\)). [Noordermeer2008] |
|
Effective radius (\(kpc\)). [Noordermeer2007] |
|
Mass-to-light ratio of the disk. [Noordermeer2008] |
Members
- components.h5py = 1
If 1, the h5py library is available for saving and loading data. If 0, then all calculations must be done each time without saving or loading.
- Type:
int
- components.defaultpath = '../'
The default location of files containing cached calculations.
- Type:
string
- components.galdict(galaxy)
Retrieve a dictionary of parameters for the associated galaxy.
- Parameters:
- galaxy: [string]
The galaxy’s full name, including catalog. Not case-sensitive. Ignores spaces.
- Returns:
Dictionary of parameters for the associated galaxy.
Note
For information on the parameters contained in the returned dictionary, see the documentation for load_galaxies.py.
- Example:
>>> # Define a function that prints the cutoff radius of any galaxy and returns it >>> def rcut(galaxy): >>> galaxydata = galdict(galaxy) # Retrieve the whole dictionary >>> cutoff = galaxydata["rc"] >>> print(cutoff) >>> return cutoff >>> # Print and assign the cutoff for NGC 5533 >>> rcut5533 = rcut('NGC5533') 1.4 >>> print(rcut5533) 1.4
- components.G = 4.30091e-06
Gravitational constant (\(kpc/(M_{Sun}(km/s)^2)\)).
- Type:
double
- components.ups = 2.8
Bulge mass-to-light ratio (\(M_{Sun}/L_{Sun}\)). [Noordermeer2008]
- Type:
float
- components.q = 0.33
Intrinsic axis ratio. [Noordermeer2008]
- Type:
float
- components.e2
Bulge eccentricity. [Noordermeer2008]
- Type:
float
- components.i
Inclination angle (radians). [Noordermeer2008]
- Type:
float
- components.h_rc = 1.4
Core radius (\(kpc\)). [Noordermeer2008]
- Type:
float
- components.Mbh_def = 2700000000.0
Central black hole mass (\(M_{Sun}\)). [Noordermeer2008]
- Type:
float
- components.n_c = 2.7
Concentration parameter. [Noordermeer2007]
- Type:
float
- components.h_c = 8.9
Radial scale length (\(kpc\)). [Noordermeer2007]
- Type:
float
- components.hrho00_c = 310000000.0
Central surface density of halo (\(M_{Sun}/kpc^2\)). [Noordermeer2008]
- Type:
float
- components.drho00_c = 310000000.0
Central surface density of disk (\(M_{Sun}/kpc^2\)). [Noordermeer2008]
- Type:
float
- components.re_c = 2.6
Effective radius (\(kpc\)). [Noordermeer2007]
- Type:
float
- components.upsdisk = 5.0
Mass-to-light ratio of the disk. [Noordermeer2008]
- Type:
float
- components.savedata(xvalues, yvalues, group, dataset, path=defaultpath, file='Inputs.hdf5')
Utility function for saving a dataset to hdf5.
- Parameters:
- xvalues[arraylike]
An array of x-values to be saved to file. Typically, these values will represent radius.
- yvalues[arraylike]
An array of y-values to be saved to file. Typically, these values will represent velocity.
- group[string]
Name of a group within the hdf5 file. Examples: ‘disk’, ‘blackhole’, ‘halo’, ‘bulge’, ‘total’
- dataset[string]
Name of the dataset to be saved. This should be unique to the data; a good way to do this is to specify the source for experimental data or the parameters for theoretical “data”.
- path[string]
Relative or absolute filepath of the hdf5 file. Does NOT include the filename.
- default:
“../” (see
defaultpath).
- file[string]
Name of the file to be saved. May include part of the path, but keep in mind path variable will also be read.
- default:
“Inputs.hdf5”.
- Returns:
None on success, 1 if h5py was not loaded, and an [array] of y-values if saving data failed and data was loaded instead.
- Example:
>>> x = [0,1,2,3] >>> y = [0,1,2,3] >>> savedata(x,y,'test','example') >>> a = loaddata('test','example') >>> print(a) [[0 1 2 3] [0 1 2 3]]
- components.loaddata(group, dataset, path=defaultpath, file='Inputs.hdf5')
Utility function for loading a dataset from hdf5.
- Parameters:
- group[string]
Name of a group within the hdf5 file. Examples: ‘disk’, ‘blackhole’, ‘halo’, ‘bulge’, ‘total’
- dataset[string]
Name of the dataset to be saved. This should be unique to the data; a good way to do this is to specify the source for experimental data or the parameters for theoretical “data”.
- path[string]
Relative or absolute filepath of the hdf5 file. Does NOT include the filename.
- default:
“../” (see
defaultpath).
- file[string]
Name of the file to be saved. May include part of the path, but keep in mind path variable will also be read.
- default:
“Inputs.hdf5”.
- Returns:
[array] on success or 1 if h5py was not loaded.
- Example:
>>> x = [0,1,2,3] >>> y = [0,1,2,3] >>> savedata(x,y,'test','example') >>> a = loaddata('test','example') >>> print(a) [[0 1 2 3] [0 1 2 3]]
- components.checkfile(group='all', path=defaultpath, file='Inputs.hdf5')
Utility function for checking data present in hdf5 without loading.
- Parameters:
- group[string]
Name of a group within the hdf5 file. Examples: ‘disk’, ‘blackhole’, ‘halo’, ‘bulge’, ‘total’
- dataset[string]
Name of the dataset to be saved. This should be unique to the data; a good way to do this is to specify the source for experimental data or the parameters for theoretical “data”.
- path[string]
Relative or absolute filepath of the hdf5 file. Does NOT include the filename.
- default:
“../” (see defaultpath <components.defaultpath>).
- file[string]
Name of the file to be saved. May include part of the path, but keep in mind path variable will also be read.
- default:
“Inputs.hdf5”.
- Returns:
None on success; 1 if h5py was not imported.
- Example:
>>> x = [0,1,2,3] >>> y = [0,1,2,3] >>> savedata(x,y,'test','example') >>> checkfile() Groups: <HDF5 group "/test" (1 members)> ---------------- More information: <HDF5 group "/test" (1 members)> <HDF5 dataset "example": shape (2, 4), type "<i8">
- components.blackhole(r, M, load=False, save=False)
Function to calculate the gravitational effect of a black hole.
- Parameters:
- r[arraylike]
Radius values or distance from the center of the galaxy used to calculate velocities (\(kpc\)).
- M[float]
Mass of the black hole (\(M_{Sun}\)).
- load[bool]
Whether or not to load data from a file. If no data can be loaded, it will be saved for future use instead.
- default:
False.
- save[bool]
Whether or not to save data to a file. If data is already present, it will be combined with any new data to expand the dataset.
- default:
False.
- Returns:
An array of rotational velocities (\(km/s\)).
- Example:
>>> # Calculate the gravitational effect of a black hole >>> # the size of 1000 suns, 10 kpc away. >>> print(blackhole(r=10, M=1000)) [0.02073864]
- components.bulge(r, bpref, galaxy, n=n_c, re=re_c, load=True, save=False, comp='bulge', **kwargs)
Function to calculate the gravitational effect of a galactic bulge using empirically derived parameters. The calculation was implemented from Noordermeer (2008).
- Parameters:
- r[array]
Radius values or distance from the center of the galaxy used to calculate velocities (\(kpc\)).
- bpref[float]
Bulge prefactor or scaling factor (unitless).
- galaxy[string]
The galaxy’s full name, including catalog. Not case-sensitive. Ignores spaces.
- n[float]
Concentration parameter (unitless).
- default:
2.7.
- re[float]
Effective radius (\(kpc\)).
- default:
2.6.
- load[bool]
Whether or not to load data from a file. If no data can be loaded, it will be saved for future use instead.
- default:
False.
- save[bool]
Whether or not to save data to a file. If data is already present, it will be combined with any new data to expand the dataset.
- default:
False.
- comp[str]
Name of group in hdf5 file, if save or load is enabled.
- **kwargs[dict]
Additionaly key-word arguments to be passed to
loaddataorsavedataif they are used.
- Returns:
An array of splined bulge velocities (\(km/s\)).
- Example:
>>> # Calculate the gravitational effect of a galactic bulge >>> # 10 kpc away for NGC 5533. >>> print(bulge(r=10, bpref=1, galaxy='NGC5533')) [166.78929909]
- components.disk(r, dpref, galaxy)
Function to calculate the gravitational effect of a galactic disk using the traced curves of the galaxies.
- Parameters:
- r[array]
Radius values or distance from the center of the galaxy used to calculate velocities (\(kpc\)).
- dpref[float]
Disk prefactor or scaling factor (unitless).
- galaxy[string]
The galaxy’s full name, including catalog. Not case-sensitive. Ignores spaces.
- Returns:
A float or an array of splined disk velocities (\(km/s\)).
- Example:
>>> # Calculate the gravitational effect of a galactic disk >>> # 10 kpc away for NGC 5533. >>> print(disk(r=10, dpref=1, galaxy='NGC5533')) 147.62309536730015
- components.gas(r, gpref, galaxy)
Function to calculate the gravitational effect of a galactic gas using the traced curves of the galaxies.
- Parameters:
- r[array]
Radius values or distance from the center of the galaxy used to calculate velocities (\(kpc\)).
- gpref[float]
Gas prefactor or scaling factor (unitless).
- galaxy[string]
The galaxy’s full name, including catalog. Not case-sensitive. Ignores spaces.
- Returns:
A float or an array of splined gas velocities (\(km/s\)).
- Example:
>>> # Calculate the gravitational effect of a galactic gas >>> # 10 kpc away for NGC 5533. >>> print(gas(r=10, gpref=1, galaxy='NGC5533')) 22.824681427585002
- components.halo_BH(r, scale, arraysize, massMiniBH, rcut)
Function to calculate the gravitational effect of a Dark Matter halo by integrating the enclosed mass and isothermal density profile.
- Parameters:
- r[array]
Radius values or distance from the center of the galaxy used to calculate velocities (\(kpc\)).
- scale[float]
Fixed scale for the Dark Matter as tiny black holes widget (unitless).
- arraysize[float]
Variable scale for the Dark Matter as tiny black holes widget (unitless). Representing the number of tiny black holes.
- massMiniBH[float]
Variable mass of tiny black holes for the Dark Matter as tiny black holes widget (\(M_{Sun}\)).
- rcut[float]
Cutoff radius (\(kpc\)).
- Returns:
A float or an array of splined halo velocities (\(km/s\)).
Note
This function is only for the case when the dark matter halo consists of tiny black holes, as described in the 10_Bonus_Black_Holes_as_DM.ipynb notebook.
- Example:
>>> # Calculate the gravitational effect of 1000 black holes, >>> # with the mass of 100 suns, 10,25,20,25,30,35,40,45,50 >>> #and 100 kpc away, with a cutoff radius of 1.4 kpc. >>> print(halo_BH(r=np.array([10,15,20,25,30,35,40,45,50,100]), ... scale=1, arraysize=1000, massMiniBH=100, rcut=1.4)) [2.91030968 3.02194461 3.07899654 3.11360553 3.13683133 3.15349481 3.16603213 3.17580667 3.18364085 3.21905242]
- components.h_viso(r, rc=galdict('NGC5533')['rc'], rho00=galdict('NGC5533')['rho0'], load=True, save=False, comp='halo', **kwargs)
Function to calculate the gravitational effect of a Dark Matter halo using the isothermal density profile (Source: [Jimenez2003]).
- Parameters:
- r[array]
Radius values or distance from the center of the galaxy used to calculate velocities (\(kpc\)).
- rc[float]
Cutoff radius (\(kpc\)).
- default:
1.4
- rho00[float]
Central mass density (\(M_{Sun}/kpc^3\)).
- default:
0.31e9
- load[bool]
Whether or not to load data from a file. If no data can be loaded, it will be saved for future use instead. :default: True.
- save[bool]
Whether or not to save data to a file. If data is already present, it will be combined with any new data to expand the dataset.
- default:
False.
- comp[string]
Component name for saving data.
- default:
halo.
- **kwargs[dict]
Additionaly key-word arguments to be passed to
loaddataorsavedataif they are used.
- Returns:
A float or an array of splined halo velocities (\(km/s\)).
- Example:
>>> # Calculate the gravitational effect of the Dark Matter halo >>> # of NGC 5533, 10 kpc away. >>> print(h_viso(r=np.array([10,15,20,25,30,35,40,45,50,100]), rc=(co.galdict('NGC5533')['rc']), rho00=(co.galdict('NGC5533')['rho0']))) [-5.50269408e-15 1.68254755e+02 1.71431272e+02 1.73358219e+02 1.74651377e+02 1.75579160e+02 1.76277209e+02 1.76821432e+02 1.77257621e+02 1.79229253e+02]
- components.halo(r, rc, rho00)
Defining the default version of halo velocity calculation. In this case, using the isothermal density profile.
- Parameters:
- r[array]
Radius values or distance from the center of the galaxy used to calculate velocities (\(kpc\)).
- rc[float]
Cutoff radius (\(kpc\)).
- rho00[float]
Central mass density (\(M_{Sun}/kpc^3\)).
- Returns:
A float or an array of splined halo velocities (\(km/s\)).
- Example:
>>> # Calculate the gravitational effect of the Dark Matter halo >>> # of NGC 5533, 10 kpc away. >>> print(halo(r=np.array([10,15,20,25,30,35,40,45,50,100]), rc=(co.galdict('NGC5533')['rc']), rho00=(co.galdict('NGC5533')['rho0']))) [ 0. 168.2547549 171.43127236 173.35821904 174.65137711 175.57916017 176.27720854 176.82143175 177.25762058 179.22925324]
- components.totalvelocity_miniBH(r, scale, arraysize, massMiniBH, rcut, bpref, dpref, gpref, Mbh, galaxy)
Function to calculate the total gravitational effect of all components of a galaxy for the tiny black hole widget. The velocities of each component is added in quadrature to calculate the total rotational velocity.
- Parameters:
- r[array]
Radius values or distance from the center of the galaxy used to calculate velocities (\(kpc\)).
- scale[float]
Fixed scale for the Dark Matter as tiny black holes widget (unitless).
- arraysize[float]
Variable scale for the Dark Matter as tiny black holes widget (unitless). Representing the number of tiny black holes.
- massMiniBH[float]
Variable mass of tiny black holes for the Dark Matter as tiny black holes widget (\(M_{Sun}\)).
- rcut[float]
Cutoff radius (\(kpc\)).
- bpref[float]
Bulge prefactor or scaling factor (unitless).
- dpref[float]
Disk prefactor or scaling factor (unitless).
- gpref[float]
Gas prefactor or scaling factor (unitless).
- Mbh[float]
Mass of the black hole (\(M_{Sun}\)).
- galaxy[string]
The galaxy’s full name, including catalog, for loading traced curves. Not case-sensitive. Ignores spaces.
- Returns:
A float or an array of total velocities (\(km/s\)).
Note
This function is only for the case when the dark matter halo consists of tiny black holes, as described in the 10_Bonus_Black_Holes_as_DM.ipynb notebook.
- Example:
>>> # Calculate the gravitational effect of all components of a galaxy >>> # at the distance of 10,15,20,25,30,35,40,45,50, and 100 kpc. >>> print(totalvelocity_miniBH(r=np.array([10,15,20,25,30,35,40,45,50,100]), ... scale=1, arraysize=1000, massMiniBH=100, rcut=1.4, ... bpref=1, dpref=1, gpref=1, Mbh=1000, galaxy='NGC5533')) [223.92115798 216.1856443 205.36165422 197.7553731 191.2224388 182.85803424 174.3309731 165.72641622 158.01875262 114.03919935]
- components.totalvelocity_halo(r, scale, arraysize, rho00, rcut, bpref, dpref, gpref, Mbh, galaxy)
Function to calculate the total gravitational effect of all components of a galaxy. The velocities of each component is added in quadrature to calculate the total rotational velocity.
- Parameters:
- r[array]
Radius values or distance from the center of the galaxy used to calculate velocities (\(kpc\)).
- scale[float]
Fixed scale for the Dark Matter as tiny black holes widget (unitless).
- arraysize[float]
Variable scale for the Dark Matter as tiny black holes widget (unitless). Representing the number of tiny black holes.
- rho00[float]
Central mass density (\(M_{Sun}/kpc^3\)).
- rcut[float]
Cutoff radius (\(kpc\)).
- bpref[float]
Bulge prefactor or scaling factor (unitless).
- dpref[float]
Disk prefactor or scaling factor (unitless).
- gpref[float]
Gas prefactor or scaling factor (unitless).
- Mbh[float]
Mass of the black hole (\(M_{Sun}\)).
- galaxy[string]
The galaxy’s full name, including catalog, for loading traced curves. Not case-sensitive. Ignores spaces.
- Returns:
A float or an array of total velocities (\(km/s\)).
- Example:
>>> # Calculate the gravitational effect of all components of a galaxy >>> # at the distance of 10,15,20,25,30,35,40,45,50, and 100 kpc. >>> print(totalvelocity_halo(r=np.array([10,15,20,25,30,35,40,45,50,100]), ... scale=0, arraysize=0, rho00=0.31e9, rcut=1.4, ... bpref=1, dpref=1, gpref=1, Mbh=1000, galaxy='NGC5533')) [223.90224449 273.92839064 267.49319608 262.96495044 258.9580756 253.48601074 247.90102596 242.32411768 237.44484552 212.40927924]
- components.set_params(model, galaxy)
Setting parameters for tiny black hole widget.
- Parameters:
- model[string]
Function used for the fitting.
- galaxy[string]
The galaxy’s full name, including catalog, for loading traced curves. Not case-sensitive. Ignores spaces.
- Returns:
[lmfit.Parameter] An lmfit Parameters object parameters to be supplied to a fit.
- Example:
>>> model = lambda r: totalvelocity_halo(r) >>> set_params(model,galaxy='NGC5005') name value initial value min max vary scale 16930000.0 16930000.0 -inf inf False rcut 9.91700000 9.917 0.10000000 inf True bpref 1.00000000 1 0.00000000 100.000000 True dpref 1.00000000 1 0.00000000 100.000000 True gpref 1.00000000 1 -inf inf False Mbh 0.00000000 0 -inf inf False
- components.bestfit(model, galaxy)
Calculate fitting.
- Parameters:
- model[string]
Function used for the fitting.
- galaxy[string]
The galaxy’s full name, including catalog, for loading traced curves. Not case-sensitive. Ignores spaces.
- Returns:
Best fit and dictionary of fitted values.
- Example:
>>> # Examples on how to use this output: >>> best_rc = fit_dict['rc'] >>> best_rho00 = fit_dict['rho00'] >>> best_bpref = fit_dict['bpref'] >>> best_dpref = fit_dict['dpref'] >>> best_gpref = fit_dict['gpref']