pixie16.c-library-sdk module¶
Interface to C-library function provided by XIA.
The interface to python is provided by the ctypes library.
Currently calling the XIA C-library functions is only supported on Windows. Adding Linux support should be relatively straight forward though (just changing the ctype loading of the library).
We provide access to all XIA functions and try to provide a more pythonic interface. This include providing our own names for the functions (mostly just removing the Pixie16 in front and converting from CamelCase to lower case seperated by underscores).
This file only includes the functions that are in XIA’s library and a very few helper functions. We see these as more low level functions and build our own set of python function on top of these in control.py that automate several aspects, e.g. providing information from a config file, etc. See config.py for more details. There should be no need for the user to call any of the functions in here directly.
- XIA’s code can be found here:
- Their document can be accessed here:
This is based on version 3.3a2 of XIA’s SDK.
Here is the list of supported functions and their names in our package:
SDK name |
python name |
---|---|
Pixie16AcquireADCTrace, Pixie16ReadSglChanADCTrace |
acquire_adc_trace |
Pixie16AdjustOffsets |
adjust_offsets |
Pixie16BLcutFinder |
baseline_cut_finder |
Pixie16BootModule |
boot_module |
Pixie16CheckExternalFIFOStatus |
check_external_FIFO_status |
Pixie16CheckRunStatus |
check_run_status |
Pixi16CopyDSPParameters |
copy_DSP_parameters |
Pixie16EndRun |
end_run |
Pixie16ExitSystem |
exit_system |
Pixie16InitSystem |
init_system |
Pixie16LoadDSPParametersFromFile |
load_dsp_parameters_from_file |
Pixie16ReadDataFromExternalFIFO |
read_data_from_external_FIFO |
Pixie16ReadHistogramFromModule |
read_histogram_from_module |
Pixie16ReadModuleInfo |
read_module_info |
Pixie16ReadSglChanBaselines, Pixie16AcquireBaselines |
read_baselines |
Pixie16ReadSglChanPar |
read_single_channel_parameter |
Pixie16ReadSglModPar |
read_single_module_parameter |
Pixie16ReadStatisticsFromModule, Pixie16GetStatisticsSize, Pixie16ComputeRealTime, Pixie16ComputeLiveTime, Pixie16ComputeRawInputCount, Pixie16ComputeInputCountRate, Pixie16ComputeRawOutputCount, Pixie16ComputeOutputCountRate |
read_statistics_from_module |
Pixie16SaveDSPParametersToFile |
save_dsp_parameters_as_json |
Pixie16SetDACs |
set_DACs |
Pixie16StartHistogramRun |
start_histogram_run |
Pixie16StartListModeRun |
start_list_mode_run |
Pixie16TauFinder |
tau_finder |
Pixie16WriteSglChanPar |
write_single_channel_parameter |
Pixie16WriteSglModPar |
write_single_module_parameter |
XIA’s library provides several other functions that we do not expose direclty, but use in some of our calls. For example, acquire_adc_trace include the XIA call to set up the measurement.
- pixie16.C_library_sdk.acquire_adc_trace(module: int) list[numpy.ndarray] ¶
Collects ADC traces for all 16 channels in a specific module.
- Parameters:
module – Module number to collect traces from
- Returns:
list containing 16 traces as numpy arrays
- Return type:
List[np.ndarray]
- pixie16.C_library_sdk.adjust_offsets(module: int) None ¶
Executes the adjust_offsets control task for a module.
- Parameters:
module – Module number to collect traces from
- pixie16.C_library_sdk.baseline_cut_finder(module: int, channel: int) None ¶
Find an appropriate baseline cuts for a channel in a module.
- Parameters:
module – Module number
channel – Channel number
- pixie16.C_library_sdk.boot_module(DSPParFile: Path, ComFPGAConfigFile: Path, SPFPGAConfigFile: Path, DSPCodeFile: Path, DSPVarFile: Path, ModNum: int, BootPattern: int = 127, verbose: bool = False) None ¶
Boot the module(s).
See page 13 of the programming manual.
- Parameters:
ComFPGAConfigFile – config file found under Firmware
SPFPGAConfigFile – config file found under Firmware
DSPCodeFile – config file found under DSP
DSPParFile – config file found under Configuration
DSPVarFile – config file found under DSP
ModNum – location of module you want to boot (either 0,…,k-1 for individual modules or k for all modules) if None, check global modules variable to boot all modules
BootPattern – boot pattern mask. 0x7F to boot all on-board chips.
verbose – print out what firmware we are using
- Returns:
return True on success and False on error
- Return type:
bool
- pixie16.C_library_sdk.check_external_FIFO_status(module: int) int ¶
Read how many 32bit words are available in the FIFO of a specific module.
- Parameters:
module – module number
- Returns:
number of 32 bit words available
- Return type:
int
- pixie16.C_library_sdk.check_run_status(module: int) bool ¶
Check the run status of a module.
See page 17 in the manual.
- Parameters:
module – module number
- Returns:
True if run is still ongoing, False if not and None on error.
- Return type:
bool or None
- pixie16.C_library_sdk.converter_IEEE754_to_ulong(x: float) <MagicMock id='139778606259536'> ¶
Converts a floating point number to a 32 bit integers representation.
- pixie16.C_library_sdk.converter_ulong_to_IEEE754(x: <MagicMock id='139778607253840'>) float ¶
Converts a 32bit integer into a float.
- pixie16.C_library_sdk.end_run(module: int) None ¶
End the current measurement run in a specific module.
- Parameters:
module – module number
- pixie16.C_library_sdk.exit_system(module: int) None ¶
Release resources used by the modules before exiting the application.
For k modules, the number is either 0,…,k-1 for individual modules or k for all modules.
- Parameters:
module – module number
- pixie16.C_library_sdk.init_system(modules: list[int] | None = None, offline_mode: bool = False, verbose: bool = True) None ¶
Initialize the system.
- Parameters:
modules – array containing the slot numbers of each module
offline_mode – specify to use online or offline mode
verbose – if True, print more output
- Returns:
returns True if system initialized or False otherwise
- Return type:
bool
- pixie16.C_library_sdk.load_dsp_parameters_from_file(filename: Path) None ¶
Read the DSP parameter from either an old .set file or a json file.
- Parameters:
filename – DSP parameter file (either old .set or new .json)
- pixie16.C_library_sdk.read_baselines(module: int) list[list[numpy.ndarray]] ¶
Acquire and read back baselines for all channels in a module.
- Parameters:
module – The module number
- Returns:
Baselines for each channels in the module
- Return type:
List[np.ndarray]
- pixie16.C_library_sdk.read_data_from_external_FIFO(module: int, words: int) numpy.ndarray ¶
Read data in 32bit words from module N.
- Parameters:
module – module number
words – number of words to read
- Returns:
numpy array of 32 bit words (unsigned integers 32bit)
- Return type:
np.ndarray
- pixie16.C_library_sdk.read_histogram_from_module(module: int, channel: int, N: int = 32768) numpy.ndarray ¶
Read a single channel histogram from the module.
- Parameters:
module – module number
channel – channel in module
N – number of bins in the histogram, by default 32768
- Returns:
1D-numpy array with the histogram data
- Return type:
np.ndarray
- pixie16.C_library_sdk.read_module_info(module: int) dict ¶
Read the module information.
- Parameters:
module – The module number
Results
-------
dict – dictionary with serial number, revision and other information
- pixie16.C_library_sdk.read_single_channel_parameter(channel_parameter_name: str, module: int, channel: int, convert_bit_pattern: bool = True) list[bool] | float ¶
Read a parameter in one channel in a module.
See pg. 51 of the programmers manual for a list of parameters available.
- Parameters:
channel_parameter_name – parameter name
module – module number
channel – channel number
- Returns:
Returns the value as floating number or for bitmasks as list of bools
- Return type:
float or List[bools]
- pixie16.C_library_sdk.read_single_module_parameter(module_parameter_name: str, module: int, convert_bit_pattern: bool | None = False) int | float | list[bool] ¶
Read a parameter in one module.
See pg. 53 of the programmers manual for a list of parameters available.
- Parameters:
module_parameter_name – parameter name
module – module number
- Returns:
The value of the parameter
- Return type:
int or float
- pixie16.C_library_sdk.read_statistics_from_module(module: int) dict ¶
Read statistics from a module.
- Parameters:
module – module number
- Returns:
Return stats for one module
- Return type:
dict
- pixie16.C_library_sdk.save_dsp_parameters_as_json(filename: Path) None ¶
Save the current DSP parameters to a file.
Uses the new json style.
- Parameters:
Filename – DSP parameter file name (with complete path)
- pixie16.C_library_sdk.set_DACs(module: int) None ¶
Update voltage offsets from the current setting
The new setting already needs to be set. This just activates it.
- Parameters:
module – the module that will be updated
- pixie16.C_library_sdk.start_histogram_run(module: int, resume: bool = False) None ¶
Start an MCA run in a module.
- Parameters:
module – module number 0,…, k-1 to start individual modules, k to start all modules
resume – Resume the run or clear old histograms
- pixie16.C_library_sdk.start_list_mode_run(module: int, resume: bool = False) None ¶
Start a list mode run in one channel in a module.
- Parameters:
module – module number 0,…, k-1 to start individual modules, k to start all modules
resume – If False erase histogram and statistics information
- pixie16.C_library_sdk.tau_finder(module: int) numpy.ndarray ¶
Find the decay constants.
- Parameters:
module – module number
- Returns:
The values of the decay constant for each channel, -1 if no tau has been found
- Return type:
np.ndarray
- pixie16.C_library_sdk.write_single_channel_parameter(channel_parameter_name: str, channel_parameter_data: int | float | Iterable[bool], module: int, channel: int) None ¶
Change a parameter in one channel in a module.
See pg. 67 of the programmers manual for a list of parameters available.
- Parameters:
channel_parameter_name – parameter name
channel_parameter_data – value of the parameter you wish to set
module – module number
channel – channel number
- pixie16.C_library_sdk.write_single_module_parameter(module_parameter_name: str, module_parameter_data: int | float | list[bool], module: int) None ¶
Change a parameter in one module.
See pg. 69 of the programmers manual for a list of parameters available.
- Parameters:
module_parameter_name – parameter name
module_parameter_data – value of the parameter you wish to set
module – module number