widget_SPARC
A module for handling the SPARC widget, notebook 09_Widget_SPARC_Galaxies.ipynb.
ToC: Functions
|
Interpolating the bulge velocity. |
|
Interpolating the disk velocity. |
|
Interpolating the gas velocity. |
|
Function to calculate the gravitational effect of a Dark Matter halo using the isothermal density profile (Source: [Jimenez2003]). |
|
Function to calculate the total gravitational effect of all components of a galaxy. |
|
Generate a plot for use with interactive rotation curve plot of SPARC data with sliders for parameters. |
|
Generate an interactive plot widget, allowing the user to interact with the SPARC data and the galaxy's components. |
A function to reset values when the 'Best Fit' button is clicked. |
|
|
Fetch and display an image of the selected galaxy. |
ToC: Attributes
A local text file, opened in read-only mode, indicating a chosen galaxy. |
|
The name of the chosen galaxy. |
|
The filename (including relative path) containing data for the |
|
A numpy array of data loaded from the |
|
If the bulge component is missing, a message indicating that it is. Otherwise, an empty string. |
|
If the disk component is missing, a message indicating that it is. Otherwise, an empty string. |
|
If the gas component is missing, a message indicating that it is. Otherwise, an empty string. |
|
Distance to galaxy, in Mpc. |
|
An lmfit Model object for the |
|
An lmfit Parameters object for the |
|
An lmfit fitting result for the |
|
Best fit results of |
|
Dictionary of best parameter results from |
|
Slider for controlling the bulge prefactor. |
|
Slider for controlling the disk prefactor. |
|
Slider for controlling the cutoff radius. |
|
Slider for controlling the halo density variable rho0. |
|
A button that returns all settings to the best fit. |
|
A handler for widget output. |
Members
- widget_SPARC.textfile
A local text file, opened in read-only mode, indicating a chosen galaxy.
- Type
file
The purpose of this file is to: 1. Allow this chosen galaxy variable to be passed flexibly between programs. 2. Allow this chosen galaxy to be retained between sessions.
See also
The data in this text file is stored in the
galaxyvariable.
- widget_SPARC.galaxy
The name of the chosen galaxy.
- Type
string
See also
This string is retrieved from
textfile.
- widget_SPARC.SPARC_file_path
The filename (including relative path) containing data for the
chosen galaxy.- Type
string
- widget_SPARC.data
A numpy array of data loaded from the
SPARC file path.- Type
array
- widget_SPARC.warning_bulge = There is no bulge component.
If the bulge component is missing, a message indicating that it is. Otherwise, an empty string.
- Type
string
- widget_SPARC.warning_disk = There is no disk component.
If the disk component is missing, a message indicating that it is. Otherwise, an empty string.
- Type
string
- widget_SPARC.warning_gas = There is no gas component.
If the gas component is missing, a message indicating that it is. Otherwise, an empty string.
- Type
string
- widget_SPARC.distance
Distance to galaxy, in Mpc.
- Type
float
- widget_SPARC.bulge(r, bpref)
Interpolating the bulge velocity.
- Parameters
- r[array]
Sampling radius values or distance from the center of the galaxy (in kpc).
- bpref[float]
Bulge prefactor or scaling factor (unitless).
- Returns
Splined bulge velocity as a [function] of sampling radii.
- Example
>>> # Define measured radius and velocity and interpolate them >>> import numpy as np >>> Rad = np.array([0, 0.5, 1.2, 2.6, 5.3, 6.7, 7.1, 9.5]) >>> Vbul = np.array([100, 200, 280, 200, 130, 120, 110, 100]) >>> r = np.linspace(0, 20, 50) >>> bulgespline = bulge(r, bpref=1) >>> plt.plot(Rad, Vbul, 'ro') >>> plt.plot(r, bulgespline) >>> plt.show()
- widget_SPARC.disk(r, dpref)
Interpolating the disk velocity.
- Parameters
- r[array]
Sampling radius values or distance from the center of the galaxy (in kpc).
- dpref[float]
Disk prefactor or scaling factor (unitless).
- Returns
Splined disk velocity as a [function] of sampling radii.
- Example
>>> # Define measured radius and velocity and interpolate them >>> #Rad = #Plotting Rad and Vdisk as imported from this library >>> #Vdisk = #^ >>> r = np.linspace(0, 20, 50) >>> diskspline = disk(r, dpref=1) >>> plt.plot(Rad, Vdisk, 'ro') >>> plt.plot(r, diskspline) >>> plt.show()
- widget_SPARC.gas(r)
Interpolating the gas velocity.
- Parameters
- r[array]
Sampling radius values or distance from the center of the galaxy (in kpc).
- Returns
Splined gas velocity as a [function] of sampling radii.
- Example
>>> # Define measured radius and velocity and interpolate them >>> #Rad = # We plot the radius and velocities as imported from this library. >>> #Vgas = #^ >>> r = np.linspace(0, 20, 50) >>> gasspline = gas(r) >>> plt.plot(Rad, Vgas, 'ro') >>> plt.plot(r, gasspline) >>> plt.show()
- widget_SPARC.halo(r, rc, rho0)
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 (in kpc).
- rc[float]
Cutoff radius (in kpc). Default: 1.4
- rho0[float]
Central mass density (in solar mass/kpc^3). Default: 0.31e9
- Returns
A [float] or an [array] of halo velocities (in 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=1.4, rho0=0.31e9))) [162.0220417 168.23695403 171.41313542 173.33987823 174.63289949 175.5605844 176.25855891 176.80272454 177.23886723 179.21029129]
- widget_SPARC.totalcurve(r, bpref, dpref, rc, rho0)
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 (in kpc).
- bpref[float]
Bulge prefactor or scaling factor (unitless).
- dpref[float]
Disk prefactor or scaling factor (unitless).
- rc[float]
Cutoff radius (in kpc).
- rho0[float]
Central mass density (in solar mass/kpc^3).
- Returns
A [float] or an [array] of total velocities (in km/s).
Note
If the galaxy contains a supermassive black hole at the center, it is incorporated in the bulge velocity.
- 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(totalcurve(r=np.array([10,15,20,25,30,35,40,45,50,100]), ... bpref=1, dpref=1, rc=1.4, rho0=0.31e9))) [3.34371479e+02 3.22215072e+02 7.25902496e+02 2.16917607e+03 5.21519130e+03 1.04268198e+04 1.83732304e+04 2.96250118e+04 4.47531137e+04 5.34875631e+05]
- widget_SPARC.fit_mod
An lmfit Model object for the
totalcurvefunction.- Type
lmfit.Model
- widget_SPARC.fit_params
An lmfit Parameters object for the
fit_modModel.- Type
lmfit.Parameters
Parameter
Starting Value
Minimum
Maximum
rc
1.4
0.1
(None)
rho0
3.10e8
0
(None)
bpref
1
0.5
100
dpref
1
0.5
100
- widget_SPARC.fit
An lmfit fitting result for the
fit_modModel against thedata imported for the chosen galaxy.- Type
lmfit.ModelResult
- widget_SPARC.bestfit
Best fit results of
the fit of the total curve against the galaxy's data.- Type
ndarray
- widget_SPARC.fit_dict
Dictionary of best parameter results from
the fit of the total curve against the galaxy's data.- Type
dict
- Keys
bpref, dpref, rc, rho0.
- widget_SPARC.widgetfunction(bpref, dpref, rc, rho0)
Generate a plot for use with interactive rotation curve plot of SPARC data with sliders for parameters. Can also be used to generate a static plot of individual components and their total.
- Parameters
- bpref: [float]
Prefactor scaling the bulge component.
- dpref: [float]
Prefactor scaling the disk component.
- rcut: [float]
Cutoff radius of the halo.
- rho0: [float]
Density parameter for the halo.
- Returns
None
See also
For information on how the curves displayed are calculated, see:
totalcurve,bulge,disk,halo,gas.See the
interactive_plotfunction as an example usecase of this function.
- widget_SPARC.bpref
Slider for controlling the bulge prefactor.
- Type
ipywidgets.widgets.widget_float.FloatSlider
- widget_SPARC.dpref
Slider for controlling the disk prefactor.
- Type
ipywidgets.widgets.widget_float.FloatSlider
- widget_SPARC.rc
Slider for controlling the cutoff radius.
- Type
ipywidgets.widgets.widget_float.FloatSlider
- widget_SPARC.rho0
Slider for controlling the halo density variable rho0.
- Type
ipywidgets.widgets.widget_float.FloatSlider
- widget_SPARC.interactive_plot(widgetfunction)
Generate an interactive plot widget, allowing the user to interact with the SPARC data and the galaxy’s components.
- Parameters
- widgetfunction: [function]
A function that generates the base plot for the widget to alter. This should, in all likelihood, be
widgetfunction.
- Returns
[ipywidgets.widgets.interaction.interactive] – creates sliders to make the plot interactive.
See also
For an example usage of this function, see the notebook 09_Widget_SPARC_Galaxies.ipynb on Binder.
- widget_SPARC.button
A button that returns all settings to the best fit.
- Type
ipywidgets.widgets.widget_button.Button
- widget_SPARC.out
A handler for widget output.
- Type
ipywidgets.widgets.widget_output.Output
- widget_SPARC.on_button_clicked(_)
A function to reset values when the ‘Best Fit’ button is clicked.
- Parameters
None
- Returns
None
- Example
>>> button.on_click(on_button_clicked)
This renders the button click behavior seen in 09_Widget_SPARC_Galaxies.ipynb on Binder.
- widget_SPARC.GalaxyImage(position=galaxy, survey=['DSS'])
Fetch and display an image of the selected galaxy.
- Parameters
- Position: [string]
The name of the galaxy whose image is to be fetched.
- Survey: [list]
The name(s) of surveys, as strings, containing the galaxy whose image is to be fetched.
- Returns
None
See also
For an example usage of this function, see the notebook 09_Widget_SPARC_Galaxies.ipynb on Binder.