Skip to content

amptek

borealis.detector.amptek

Created on Tue Mar 23 18:54:19 2021.

@author: A. Vancraeyenest

AmptekCdTe123(alias='Amptek-CdTe 123')

Bases: Detector

Interface for CdTe X-123 detector from Amptek.

Initialise the detector.

Source code in borealis/detector/amptek.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def __init__(self, alias: str = 'Amptek-CdTe 123'):
    """Initialise the detector."""
    super().__init__(alias)
    self._device = usb.core.find(idVendor=self.vendor_id,
                                 idProduct=self.product_id)
    if self._device is None:
        raise ValueError('_device not found')

    self._device.set_configuration()
    config = self._device.get_active_configuration()
    interface = config[(0, 0)]
    self._endpoint_out = usb.util.find_descriptor(
        interface,
        custom_match=lambda e:
            usb.util.endpoint_direction(e.bEndpointAddress)
            == usb.util.ENDPOINT_OUT)

    self._endpoint_in = usb.util.find_descriptor(
        interface,
        custom_match=lambda e:
            usb.util.endpoint_direction(e.bEndpointAddress)
            == usb.util.ENDPOINT_IN)

    self.serial_number = self._get_serial_number()

    # TODO: get from detector
    self.mca_size = 2048

    LOGGER.info("Detector %s successfully initialised", self)

acquisition(acquisition_time)

Start an acquisition and return corresponding Spectrum object.

Source code in borealis/detector/amptek.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def acquisition(self, acquisition_time: float) -> MCA:
    """Start an acquisition and return corresponding Spectrum object."""
    self._clear_spectrum()
    self._set_acquisition_time(acquisition_time, save_to_mem=False)
    self._enable_mca()
    sleep(acquisition_time*1.1)
    self._disable_mca()
    raw_spe_st = self._get_spectrum_status()

    data = MCA(self.mca_size)
    data.mca = self._get_mca_counts(raw_spe_st, num_chan=self.mca_size, contain_status=True)

    status = Status.from_spectrum_status_packet(raw_spe_st, num_chan=self.mca_size)

    data.runtime = status.realtime
    data.icr = status.fast_count / status.acq_time
    data.ocr = status.slow_count / status.acq_time

    return data

stop()

Close the connection to the detector and free resources.

Source code in borealis/detector/amptek.py
87
88
89
def stop(self):
    """Close the connection to the detector and free resources."""
    usb.util.dispose_resources(self._device)

Status(raw_status)

Status object for AmptekCdTe123.

Source code in borealis/detector/amptek.py
377
378
379
380
381
382
def __init__(self, raw_status):
    self._raw = raw_status
    self.status = raw_status.tobytes()
    self.serial_number = ""
    self.realtime = 0.
    self._process_raw()