cana.spectools.specband¶
Tool for measuring an absorptium band.
Functions
depth(spec[, wmin, wmax, cont_window, …]) |
Calculate the depth of an absorptium band. |
Classes
Continuum([lowerwindow, upperwindow]) |
Model for fitting and subtracting the continum. |
Depth([wmin, wmax, continuum]) |
Model for estimating the depth and center of a spectral absorptium band. |
DepthValue(spec, center, depth, cont[, label]) |
Representation of the a band depth and center value. |
-
class
cana.spectools.specband.Continuum(lowerwindow=0.04, upperwindow=0.04)[source]¶ Model for fitting and subtracting the continum.
Methods
fit(spec)Fit the continuum. remove(spec)Remove the continuum. plot_continuum(fax[, cont_style])Add the continuum line in a plot. plot_continuum_region(spec, fax[, cont_style])Add the continuum line in a plot. -
fit(spec)[source]¶ Fit the continuum.
Parameters: - spec_arr: numpy array
The 2D (wavelength and Normalized reflectance) array
Returns: - Continuum 2D numpy array, in the same wavelenghs as the input.
-
plot_continuum(fax, cont_style=None)[source]¶ Add the continuum line in a plot.
Parameters: - fax: matplotlib axes
The current axes for ploting the continuum
- contstyle: None or dict
Matplotlib arguments for plot function. If none, default values are:{‘c’:’k’, ‘linestyle’:’–‘}
-
-
class
cana.spectools.specband.Depth(wmin=0.54, wmax=0.88, continuum=<cana.spectools.specband.Continuum object>)[source]¶ Model for estimating the depth and center of a spectral absorptium band.
Methods
measure(spec[, error, label, resolution])Measure the absorptium band in a spectra. -
measure(spec, error=<cana.spectools.uncertainties.SpecError object>, label=None, resolution='auto')[source]¶ Measure the absorptium band in a spectra.
The error is estimated using an errormodel.
Parameters: - spec: Spectrum
The spectrum object
- error: SpecError
The model to estimate the slope uncertainty.
- label: None or str
The spectrum label (for the output)
- resolution: ‘auto’ or int
The spectrum wavelength resolution for measuring the center and depth of the band. If ‘auto’ will take the spec input resolution.
Returns: - band_min:
- band_depth: DepthValue
-
-
class
cana.spectools.specband.DepthValue(spec, center, depth, cont, label=None)[source]¶ Representation of the a band depth and center value.
Methods
is_band([min_depth, theoric_min, max_dist, …])Ask if the mesuared parameters can be considered an absorptium band. plot([fax, show, savefig, axistitles, …])Plot for the band. -
is_band(min_depth=1.0, theoric_min=0.7, max_dist=0.05, sigma=3)[source]¶ Ask if the mesuared parameters can be considered an absorptium band.
Parameters: - min_depth: float (optional)
minimum depth for the band to be considered. Default is 1 percent (for hydration analysis).
- theoric_min: float (optional)
theorical central wavelength of the band. Default is 0.7 (for hydration analysis)
- max_dist: (optional)
Maximal distance from the therorical position for the band to be considered. Default is 0.05 (for hydration analysis).
- n_sigma: integer (optional)
The minimum sigma level for the absorptium band detection. Default is 3.
Returns: - ans: boolean
-
plot(fax=None, show=True, savefig=None, axistitles=True, speckwargs=None, bandkwargs=None, contkwargs=None, dotkwargs=None, legendkwargs=None)[source]¶ Plot for the band.
Parameters: - fax (Optional): matplotlib.axes
If desired to subplot image in a figure. Default is ‘None’, which will open a new plt.figure()
- show (Optional): boolean
True if want to plt.show(). Default is True.
- savefig (Optional): str
The path to save the figure. If set to None, wont save the figure. Default is None
- **kwargs: matplotlib plot kwargs
-
-
cana.spectools.specband.depth(spec, wmin=0.54, wmax=0.88, cont_window=0.04, resolution='auto', errormethod='rms', error_param=None, montecarlo=1000, min_depth=1.0, theoric_min=0.7, max_dist=0.05, n_sigma=3, speckwargs=None)[source]¶ Calculate the depth of an absorptium band.
Parameters: - spec: Spectrum, spectrum file, spectrum file list
The input can be a Spectrum object, a spectrum file or a list of spectrum files
- wmin: float
The wavelength for the beginning of the band.
- wmax: float
The wavelength for the beginning of the band
- cont_window: float
The wavelength window size for measuring the continuum
- resolution: ‘auto’ or int
The spectrum wavelength resolution for measuring the center and depth of the band. If ‘auto’ will take the spec input resolution.
- errormethod: ‘rms’, ‘removal’ or ‘bin’
The error methodology that will be applied for estimating the depth error. Default is ‘rms’
- error_param: None or float
The error methodoly parameter if needed. If errormethod=’rms’, then no value is necessary. If it is set for removal, the percentage of points to remove. For rebin, the param represents the binsize.
- montecarlo: integer
Default is 1000
- min_depth: float (optional)
minimum depth for the band to be considered. Default is 1 percent (for hydration analysis).
- theoric_min: float (optional)
theorical central wavelength of the band. Default is 0.7 (for hydration analysis)
- max_dist: (optional)
Maximal distance from the therorical position for the band to be considered. Default is 0.05 (for hydration analysis).
- n_sigma: integer (optional)
The minimum sigma level for the absorptium band detection. Default is 3.
Returns: - depth: DepthValue or Pandas.DataFrame
For a single spectrum it will return a Depthvalue, for a list of spectra, returns a pandas.DataFrame with the results