API Reference#
This page lists the various classes and functions that demcmc
provides.
Contents
Input#
- class demcmc.TempBins(edges: Quantity)#
A set of temperature bins.
The bins are defined through the bin edges.
- Parameters:
- edges
astropy.units.Quantity
Bin edges.
- edges
- iter_bins() Iterator[Tuple[Quantity, Quantity]] #
Iterate through lower/upper bounds of temperature bins.
- Yields:
- lower_edge
astropy.units.Quantity
Lower edge of bin.
- upper_edge
astropy.units.Quantity
Upper edge of bin.
- lower_edge
- demcmc.load_cont_funcs(path: Path) Dict[str, ContFuncDiscrete] #
Load a set of contribution functions from a netCDF file.
The file should contain a 2D array of data, with coordinates named “Temperature” for the temperatures and “Line” for the line names.
- Parameters:
- path
os.PathLike
Path of the netCDF file.
- path
- Returns:
dict
[str
,ContFuncDiscrete
]Mapping of line name to the loaded contribution function.
- class demcmc.ContFuncDiscrete(temps: Quantity, values: Quantity, *, name: str | None = None)#
A pre-computed contribution function defined at temperature values.
- Parameters:
- temps
u.Quantity
Temperature values of samples.
- values
u.Quantity
Contribution function values.
- name
str
Name for the contribution function.
- temps
- binned(temp_bins: TempBins) Quantity #
Get contribution function.
- Parameters:
- temp_bins
TempBins
Temperature bins to get contribution function at.
- temp_bins
- Returns:
astropy.units.Quantity
Contribution function at given temperature bins.
- class demcmc.EmissionLine(cont_func: ContFunc, intensity_obs: float | None = None, sigma_intensity_obs: float | None = None, name: str | None = None)#
A single emission line.
- Parameters:
- I_pred(dem: BinnedDEM) Quantity #
Calculate predicted intensity of a given line.
- Parameters:
- dem
BinnedDEM
DEM.
- dem
- Returns:
astropy.units.Quantity
Predicted intensity.
Running#
- demcmc.predict_dem_emcee(lines: Sequence[EmissionLine], temp_bins: TempBins, *, nsteps: int, nwalkers: int, progress: bool = True) DEMOutput #
Estimate DEM from a number of emission lines.
- Parameters:
- lines
Sequence
[EmissionLine
] Emission lines.
- temp_bins
TempBins
Temperature bins to predict DEM in.
- nsteps
int
Total number of steps for the MCMC walkers to take.
- nwalkers
int
Number of MCMC walkers to use.
- progressbool
Whether to show a progress bar for the MCMC walking.
- lines
- Returns:
DEMOutput
Output container.
Output#
- class demcmc.DEMOutput#
Output from running DEM calculation.
This is not intended to be created by users.
- iter_binned_dems() Iterator[BinnedDEM] #
Iterate across each final sample, returning a
BinnedDEM
.- Yields:
BinnedDEM
- classmethod load(path: Path) DEMOutput #
Load a computed DEM from a netCDF file.
This will load files saved by the
.save()
method.- Parameters:
- path
pathlib.Path
Path to netCDF file.
- path
- Returns:
- plot_final_samples(ax: Axes, **kwargs: Any) None #
Plot the final samples of the MCMC walker.
- Parameters:
- ax
matplotlib.axes.Axes
Axes to plot the samples on.
- **kwargs
dict
Keyword arguments are passed to
stairs()
.
- ax
- property sampler: EnsembleSampler#
Sampler used by emcee to calculated the DEM.
- save(path: Path) None #
Save a computed DEM to a netCDF file.
- Parameters:
- path
pathlib.Path
Path to save to. Should end in
".nc"
.
- path
- class demcmc.emission.BinnedDEM(temp_bins: TempBins, values: Quantity)#
A DEM binned over a range of temperature values.
- Parameters:
- temp_bins
TempBins
Temperature bins.
- values
astropy.units.Quantity
DEM values.
- temp_bins
- demcmc.plot_emission_loci(lines: List[EmissionLine], ax: Axes, **kwargs: Any) None #
Plot emission loci for a set of observed emission lines.
- Parameters:
- lines
list
[EmissionLine
] Lines to plot.
- ax
matplotlib.axes.Axes
Axes to plot on.
- **kwargs
dict
Keyword arguments are passed to
stairs()
.
- lines
Notes
Currently only works with lines that have a
ContFuncDiscrete
contribution function.