2.3. utils.specutils_hasp package
2.3.1. haspspectrum
- class utils.specutils_hasp.haspspectrum.HASPSpectrum(nelem=None, wavelengths=None, fluxes=None, fluxerrs=None, dqs=None, plot_info=None, orig_file=None)[source]
Bases:
objectDefines a HASP 1D spectrum, including wavelegnth, flux, and flux errors.
- Raises:
ValueError
Create a HASPSpectrum object, default to empty values. Allows user to preallocate space if they desire by setting “nelem” but not providing lists/arrays on input right away.
- Parameters:
nelem (int) – Number of elements for this segment’s spectrum.
wavelengths (list) – List of wavelengths in this segment’s spectrum.
fluxes (list) – List of fluxes in this segment’s spectrum.
fluxerrs (list) – List of flux uncertainties in this segment’s spectrum.
dqs (list) – List of data quality flags.
plot_info (dict) – dictionary with information for the preview plot.
orig_file (str) – Original FITS file read to create the spectrum (includes full path).
2.3.2. plotspec
- utils.specutils_hasp.plotspec(hasp_spectrum, output_type, output_file, flux_scale_factor, fluxerr_scale_factor, plot_metrics, dpi_val=96.0, output_size=1024, debug=False, full_ylabels=False, optimize=True)[source]
Accepts a HASPSpectrum object from the READSPEC function and produces preview plots.
- Parameters:
hasp_spectrum (HASPSpectrum) – HASP spectrum as returned by READSPEC.
output_type (str) – What kind of output to make?
output_file (str) – Name of output file (including full path).
flux_scale_factor (float) – Max. allowed ratio between the flux and a median flux value, used in edge trimming. Default = 10.
fluxerr_scale_factor (float) – Max. allowed ratio between the flux uncertainty and a median flux uncertainty value, used in edge trimming. Default = 5.
plot_metrics (list) – Collection of plot metrics (flux statistics, axis ranges, etc.) to use when making the plots. These are computed using
utils.specutils.calc_plot_metrics().dpi_val (float) – The DPI value of your device’s monitor. Affects the size of the output plots. Default = 96. (applicable to most modern monitors).
output_size – Size of plot in pixels (plots are square in dimensions). Defaults to 1024.
output_size – int
debug (bool) – Should the output plots include debugging information (color-coded data points based on rejection criteria, shaded exclude regions)? Default = False.
full_ylabels (bool) – Should the y-labels contain the full values (including the power of 10 in scientific notation)? Default = False.
optimize (bool) – If set to True, will use a slightly optimized version of determining the plot covering fraction.
- Raises:
OSError, utils.specutils.SpecUtilsError
Note
This function assumes a screen resolution of 96 DPI in order to generate plots of the desired sizes. This is because matplotlib works in units of inches and DPI rather than pixels.
2.3.3. readspec
- utils.specutils_hasp.readspec(input_file)[source]
Reads in a HASP spectrum FITS file (_cspec.fits) and returns the wavelengths, fluxes, and flux uncertainties.
- Parameters:
input_file (str) – Name of input FITS file.
- Returns:
HASPSpectrum – The spectroscopic data (wavelength, flux, flux error, etc):