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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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()

    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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def acquisition(self, acquisition_time: float):
    """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()
    mca_counts = self._get_mca_counts(raw_spe_st, num_chan=2048, contain_status=True)
    status = Status.from_spectrum_status_packet(raw_spe_st, num_chan=2048)

    mca_metadata = MCAMetadata(status.realtime,
                               status.fast_count / status.acq_time,
                               status.slow_count / status.acq_time,
                               self.get_det_info())
    mca_obj = MCA(mca_counts, mca_metadata)

    return mca_obj

stop()

Close the connection to the detector and free resources.

Source code in borealis/detector/amptek.py
76
77
78
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
366
367
368
369
370
371
def __init__(self, raw_status):
    self._raw = raw_status
    self.status = raw_status.tobytes()
    self.serial_number = ""
    self.realtime = 0.
    self._process_raw()