Module bhreader
¶
This module contains functions to load and decode files from Becker & Hickl hardware.
The high-level function in this module are:
load_spc()
which loads and decoded the photon data from SPC files.load_set()
which returns a dictionary of metadata from SET files.
Becker & Hickl SPC Format¶
The structure of the SPC format is here described.
SPC-600/630¶
SPC-600/630 files have a record of 48-bit (6 bytes) in little endian (<) format. The first 6 bytes of the file are an header containing the timestamps_unit (in 0.1ns units) in the two central bytes (i.e. bytes 2 and 3). In the following drawing each char represents 2 bits:
bit: 64 48 0
0000 0000 XXXX XXXX XXXX XXXX XXXX XXXX
'-------' '--' '--' '-----'
field names: a c b d
0000 0000 XXXX XXXX XXXX XXXX XXXX XXXX
'-------' '--' '--' '-------'
numpy dtype: a c b field0
macrotime = [ b ] [ a ] (24 bit)
detector = [ c ] (8 bit)
nanotime = [ d ] (12 bit)
overflow bit: 13, bit_mask = 2^(13-1) = 4096
SPC-134/144/154/830¶
SPC-134/144/154/830 files have a record of 32-bits (4 bytes) in little endian (<) format. The first 4 bytes of the file are an header containing the timestamps_unit (in 0.1ns units) in first two bytes. In the following drawing each char represents 2 bits:
bit: 32 0
XXXX XXXX XXXX XXXX
'''-----' '''-----'
field names: a b c d
XXXX XXXX XXXX XXXX
'-------' '-------'
numpy dtype: field1 field0
macrotime = [ d ] (12 bit)
detector = [ c ] (4 bit)
nanotime = [ b ] (12 bit)
aux = [ a ] (4 bit)
aux = [invalid, overflow, gap, mark]
If overflow == 1 and invalid == 1 --> number of overflows = [ b ][ c ][ d ]
List of functions¶
High-level functions to load and decode Becker & Hickl SPC/SET pair of files:
-
phconvert.bhreader.
load_spc
(fname, spc_model='SPC-630')¶ Load data from Becker & Hickl SPC files.
Parameters: spc_model (string) – name of the board model. Valid values are ‘SPC-630’, ‘SPC-134’, ‘SPC-144’, ‘SPC-154’ and ‘SPC-830’. Returns: 3 numpy arrays (timestamps, detector, nanotime) and a float (timestamps_unit).
-
phconvert.bhreader.
load_set
(fname_set)¶ Return a dict with data from the Becker & Hickl .SET file.
Low-level functions¶
These functions are the building blocks for decoding Becker & Hickl files:
-
phconvert.bhreader.
bh_set_identification
(fname_set)¶ Return a dict containing the IDENTIFICATION section of .SET files.
The both keys and values are native strings (binary strings on py2 and unicode strings on py3).
-
phconvert.bhreader.
bh_set_sys_params
(fname_set)¶ Return a dict containing the SYS_PARAMS section of .SET files.
The keys are native strings (traditional strings on py2 and unicode strings on py3) while values are numerical type or byte strings.
-
phconvert.bhreader.
bh_decode
(s)¶ Replace code strings from .SET files with human readable label strings.
-
phconvert.bhreader.
bh_print_sys_params
(sys_params)¶ Print a summary of the Becker & Hickl system parameters (.SET file).