pygammaspec.spectrum module

class pygammaspec.spectrum.Calibration(calibration_data, order=1)

Simple calibration class capable of fitting a conversion function capable of converting channel index into energy values.

Parameters:
  • calibration_data (Dict[float, float]) – The dictionary containing the channels as keys and the energies (in keV) as values.

  • order (int) – The order of the fitting polynomial (default: 1)

property channels: List[float]

The list of channels used for the calibration.

Returns:

The list of channels used for the calibration.

Return type:

List[float]

property energies: List[float]

The list of energies (in keV) used for the calibration.

Returns:

The list of energies (in keV) used for the calibration.

Return type:

List[float]

classmethod from_calibration_file(path)

Classmethod capable of generating an instance of the Calibration class starting from a calibration file.

Parameters:

path (str) – The path to the calibration datafile.

Returns:

The loaded calibration object

Return type:

Calibration

get_energy(channel)

Conversion function that, from the calibration data, converts the channel index into energy value.

Parameters:

channel (float) – The index of the channel

Returns:

The energy in keV corresponding to the selected channel

Return type:

float

property order

The order of the fitting polynomial

Returns:

The order of the fitting polynomial

Return type:

int

save_calibration_file(path)

Save the calibration data in a file defined by the user specified path.

Parameters:

path (str) – The path to the calibration datafile

Return type:

None

class pygammaspec.spectrum.GammaSpectrum

The GammaSpectrum class provide a simple object allowing the manipulation and analysis of pulse height histogram data collected from gamma spectroscopy experiments. An instance of the class can be created from a PRA histogram file using the from_PRA_histogram function. The class supports various operations such as addition and subrtaction. The class supports an energy calibration capable of correlating channel indices to gamma photon energies.

calibration: Calibration

The calibration object using to correlate channel indices to energy values (in keV)

acquisition_time: Optional[float]

The acquisition time (in seconds) used for the measurement.

channels: List[float]

The list of channel indeces

energies: List[float]

The list of gamma photon energies associated to each channel (in keV)

counts: List[float]

The list of counts for each channel in counts per second (cps)

total_activity: float

The total activity in counts per second (cps) recoded by the detector

property acquisition_time: Optional[float]

The total acquisition time used in the measurement. If the object is derived from a binary operation between different spectra objects, the acquisition time will be set to None.

Returns:

The acquisition time in seconds. If None the spectrum has been obtained form operations between spectra.

Return type:

Optional[float]

average_smoothing(width)

Applies an average smoothing filter to the gamma spectrum.

width: int

The excursion of the averaging windows (the total number of points is 2*width + 1)

Returns:

The smoothed gamma spectrum.

Return type:

GammaSpectrum

Parameters:

width (int) –

property calibration: Calibration

The energy calibation object associated to the measurement.

Returns:

The calibration object.

Return type:

Calibration

property channels: List[float]

The list of acquisition channels.

Returns:

The list of channels.

Return type:

List[float]

property counts: List[float]

The activity in counts per second for each channel.

Returns:

The conting rate for each channel.

Return type:

List[float]

property energy: List[float]

The list of energy values (in keV) associated to each acquisition channel. Requires the definition of an energy calibration object.

Raises:

RuntimeError – Exception raised if an energy calibration has not been given.

Returns:

The list of energy values (in keV) associated to each datapoint.

Return type:

List[float]

classmethod from_PRA_histogram(path, acqisition_time)

Construct a GammaSpectrum object from a PRA histogram file and the total acquisition time.

Parameters:
  • path (str) – The path to the histogram file generated by PRA.

  • acquisition_time (float) – The acquisition time in seconds (positive integer or float).

  • acqisition_time (float) –

Raises:

ValueError – Exception raised if the arguments given are deemed invalid.

Returns:

A fully initialized GammaSpectrum object containing the measured data.

Return type:

GammaSpectrum

property total_activity: float

The total activity of the sample, as pulse per second, recorded over all channels.

Returns:

The total activity of the sample, as pulse per second, recorded over all channels.

Return type:

float