AbsSpectrumBase¶
-
class
quantarhei.spectroscopy.absbase.
AbsSpectrumBase
(axis=None, data=None)[source]¶ Provides basic container for absorption spectrum
Examples
Methods
add_to_data
(spect)Performs addition on the data. apply_to_data
(func)Applies a submitted function to the data at
(x[, approx])Returns the function value at the argument x change_axis
(axis)Replaces the axis object with a compatible one, zero pads or trims the values clear_data
()Sets spectrum data to zero copy
()Returns a shallow copy of the self deepcopy
()Returns a deep copy of the self fit_exponential
([guess])Exponential fit of the function fit_gaussian
([N, guess, Nsvf])Performs a Gaussian fit of the spectrum based on an initial guess get_Fourier_transform
([window])Returns Fourier transform of the DFunction get_inverse_Fourier_transform
()Returns inverse Fourier transform of the DFunction load
(filename[, test])Loads an object from a file and returns it load_data
(filename)Loads data from file into this absorption spectrum loaddir
(dirname)Returns a directory of objects saved into a directory normalize
()Normalization to one normalize2
([norm])Normalizes spectrum to a given value plot
(**kwargs)Plotting absorption spectrum using the DFunction plot method save
(filename[, comment, test])Saves the object with all its content into a file save_data
(filename)Saves the data of this absorption spectrum savedir
(dirname[, tag, comment, test])Saves an object into directory containing a file with unique name savefig
(filename)Saves current figure into a file scopy
()Creates a copy of the object by saving and loading it set_axis
(axis)Sets axis atribute set_by_interpolation
(x, y[, xaxis])Sets the data by interpolation with splines set_data
(data)Sets data atribute set_data_protected
()Implement this method to put protections on data property set_data_writable
()Implement this method to lift existing protection of data property subtract
(val)Subtracts a value from the spectrum to shift its base line convert_2_current_u convert_2_internal_u unit_repr unit_repr_latex -
add_to_data
(spect)[source]¶ Performs addition on the data.
Expects a compatible object holding absorption spectrum and adds its data to the present absorption spectrum.
Parameters: spect (spectrum containing object) – This object should have a compatible axis and some data Examples
Standard usage
>>> from quantarhei import energy_units >>> abs = AbsSpectrumBase() >>> other = AbsSpectrumBase() >>> with energy_units("1/cm"): ... w = FrequencyAxis(10000.0, 1000, 5.0) ... y = numpy.exp(-(w.data-12500.0)**2/(200.0**2)) >>> other.set_axis(w) >>> other.set_data(y) >>> abs.add_to_data(other)
Axes have to be compatible (i.e. the same)
>>> yetanother = AbsSpectrumBase() >>> yetanother.set_axis(FrequencyAxis(8000.0, 1000, 4.0)) >>> abs.add_to_data(yetanother) Traceback (most recent call last): ... Exception: Incompatible axis
An empty AbsSpectrumBase can be filled by add_to_data() method Axis is taken from the class that we add
>>> yetanother.set_axis(w) >>> yetanother.add_to_data(abs) >>> onemore = AbsSpectrumBase() >>> onemore.add_to_data(other)
>>> numpy.testing.assert_allclose(onemore.data,abs.data)
-
set_axis
(axis)[source]¶ Sets axis atribute
Parameters: axis (FrequencyAxis object) – Frequency axis object. This object has managed energy units
-
set_by_interpolation
(x, y, xaxis='frequency')[source]¶ Sets the data by interpolation with splines
When the spectrum is defined in wavelength, it is converted to an internal representation in frequency.
Examples
>>> from quantarhei import REAL >>> from quantarhei import energy_units >>> abs = AbsSpectrumBase() >>> x = numpy.array([600.0 + 5.0*ii for ii in range(100)], dtype=REAL) >>> y = numpy.exp(-(x-800.0)**2/(50**2)) >>> abs.set_by_interpolation(x, y, xaxis="wavelength") >>> with energy_units("1/cm"): ... print("%6.3f, %6.3f" % (abs.axis.min, abs.axis.max)) 9132.420, 16591.324
-