PyJEM.femtus.acquisition

Acquisition service API .

Todo

Prerequisites:

The Scan Area is configured in the UI.

>>> from PyJEM.femtus import acquisition
>>> acquisition.get_detectors()
{'Detectors': ['EDS', 'EELS', 'Image']}
>>> acquisition.get_status()
{
    'Status': {
        'AcquisitionID': '00000000-0000-0000-0000-000000000000',
        'AcquisitionRunning': True,
        'SweepCount': 2,
        'ElapsedSeconds': 61293.0765006
        },
    Version': '1.0.0'
}
>>> result = acquisition.get_settings()
>>> setting = result["Settings"][0]
>>> setting["Detectors"] = ["Image"]
>>> setting["Region"]["Width"] = 128
>>> setting["Region"]["Height"] = 128
>>> setting["Conditions"]["DwellTime"] = 100
>>> start(setting)
{
    'AcquisitionID': '00000000-0000-0000-0000-000000000000',
    'WorksheetID': '00000000-0000-0000-0000-000000000000',
    'ReferenceDetector': '',
    'Version': '1.0.0'
}
>>> stop()
{'Result': 'OK', 'Version': '1.0.0'}
PyJEM.femtus.acquisition.get_detectors()

Retrieve the list of detectors.

Returns:

The returned value is a dictionary. A description of each item is provided below.

key

type

value

Detectors

list[str]

List of available detector names.

Example:

["EDS", "EELS", "Image"]

Version

str

API version string.

Return type:

dict

Examples

>>> get_detectors()
{
    "Detectors": [
        "EDS",
        "EELS",
        "Image"
    ],
    "Version": "1.0.0"
}
PyJEM.femtus.acquisition.get_status()

Retrieve the current acquisition status and version information.

Returns:

The returned value is a dictionary. A description of each item is provided below.

key

type

value

Version

str

API version string.

Status

dict

Acquisition status object with the following fields

⇒ See Status items.

Status items

key

type

value

AcquisitionRunning

bool

True if acquisition is currently running.

AcquisitionID

str

Unique identifier of the current or last acquisition.

SweepCount

int | float

Number of completed sweeps.

ElapsedSeconds

float

Elapsed time since acquisition start, in seconds.

Return type:

dict

Examples

>>> get_status()
{
    "Version": "1.0.0",
    "Status": {
        "AcquisitionRunning": False,
        "AcquisitionID": "00000000-0000-0000-0000-000000000000",
        "SweepCount": 1,
        "ElapsedSeconds": 100
    }
}
PyJEM.femtus.acquisition.get_settings()

Retrieve acquisition settings as json object. You cannot retrieve the conditions unless they are configured in the FEMTUS UI.

Returns:

The returned value is a dictionary. A description of each item is provided below

key

type

value

Version

str

API version string.

Settings

list[dict]

List of Settings items.

Settings items

key

type

value

Id

str

Data acquisition settings identifier.

Detectors

list[str]

A list of detectors that can perform data acquisition; configurable detectors can be obtained using GetAvailableDetectors.

Region

dict

The area information indicating the data acquisition range will cause an error if it specifies an area outside the image size range. The image size follows the Scan settings at runtime.

⇒ See Region items.

Conditions

dict

Data Acquisition Conditions

⇒ See Conditions items.

DriftCorrection

dict

Dictionary specifying drift correction parameters.

⇒ See DriftCorrection items.

Region items

key

type

value

Left

int

X coordinate of top-left corner in pixels.

Top

int

Y coordinate of top-left corner in pixels.

Width

int

Width of acquisition region in pixels.

Height

int

Height of acquisition region in pixels.

Shape

str

One of "Point", "Line", "Rectangle". Default is "Rectangle".

Conditions items

key

type

value

DwellTime

int

Exposure time in microseconds. If omitted, current scan setting is used.

Attention:

The minimum DwellTime value is determined by the configured detector; values below this will result in an error.

CollectionMode

dict

Data acquisition mode.

⇒ See CollectionMode items.

PixelResolution

float

One of 0.25, 0.5, 1, 2, 4. Default is 1.0.

IsPlayback

bool

If True, save data as time-series without accumulation.

CollectionMode items

key

type

value

Mode

str

Mode kind are "Sweep", "Time", "Endless".

  • Sweep

    Executes the scan a specified number of times. Requires value to be the number of sweeps.

  • Time

    Executes the scan for the specified duration. Requires value to be the acquisition time in seconds.

  • Endless

    Executes the scan continuously until Stop is called. value is ignored.

Count

int

The semantics of the output values differ depending on the selected mode.

  • Mode=="Sweep"

    Number of scans performed

  • Mode=="Time"

    Data acquisition execution time, unit: [seconds]

  • Mode=="Endless"

    Not set.

DriftCorrection items

key

type

value

Type

str

One of "None", "Line", "Seconds", "Frames", "LossLess".

  • "LossLess": only valid when the image size matches the correction region.

  • "None": disables drift correction.

Interval

int

Correction interval. Unit depends on Type.

  • "Line" : every N lines

  • "Seconds" : every N seconds

  • "Frames" : every N frames

  • "LossLess" : every N frames

CorrectionRegion

dict

Region within the image used for drift correction. If omitted, the entire image is used. All coordinates are in pixels.

⇒ See CorrectionRegion items.

CorrectionRegion items

key

type

value

Left

int

X coordinate of top-left corner (>= 0).

Top

int

Y coordinate of top-left corner (>= 0).

Width

int

Width of correction region (power of 2 recommended).

Height

int

Height of correction region (power of 2 recommended).

Return type:

dict

Examples

>>> get_settings()
{
    "Settings": [
        {
            "Conditions": {
                "CollectionMode": {
                    "Count": 1,
                    "Mode": "Sweep"
                },
                "DwellTime": 1,
                "IsPlayback": False,
                "PixelResolution": 1
            },
            "Detectors": [],
            "DriftCorrection": {
                "CorrectionRegion": None,
                "Interval": 1,
                "Type": "None"
            },
            "Id": "56896236-c55b-4354-b8a5-bf238efc4d18",
            "Region": {
                "Height": 512,
                "Left": 0,
                "Points": None,
                "Shape": "Rectangle",
                "Top": 0,
                "Width": 512
            }
        }
    ],
    "Version": "1.0.0"
}
PyJEM.femtus.acquisition.get_acquisition_result(id)

Retrieve the acquisition result for a specific detector.

Parameters:

id (str) –

Unique identifier for the acquisition result. Must be a valid GUID string.

Example:

"00000000-0000-0000-0000-000000000000".

Returns:

The returned value is a dictionary. A description of each item is provided below.

key

type

value

Version

str

API version string.

Results

list[dict]

List of Results items.

Results items

key

type

value

Id

str

Identifier of result data.

DataType

str

Data type/format identifier. See DataType(FormatID).xlsx.

Return type:

dict

Examples

>>> get_acquisition_result("detector_id")
{
    "Results": [
        {
            "DataType": "STEM_Survey",
            "Id": "03aa06db-95ba-4330-82e3-8ba940775f2f"
        },
        {
            "DataType": "STEM_HAADF_SeleArea",
            "Id": "969a5682-4614-4c2b-b9df-dbbfd11185f7"
        }
    ]
}
PyJEM.femtus.acquisition.start(param)

Start the acquisition service.

Parameters:

param (dict) –

Acquisition settings payload.

key

type

value

Detectors

list[str]

Detector names used for acquisition.

Region

dict

See Region items.

Conditions

dict

See Conditions items.

DriftCorrection

dict

See DriftCorrection items.

Returns:

JSON response for the start request.

key

type

value

Version

str

API version string.

AcquisitionID

str

Unique identifier of the acquisition result.

WorksheetID

str

Identifier of the worksheet where the result is stored.

ReferenceDetector

str

Name of the reference detector for the acquisition settings.

Return type:

dict

Examples

>>> param = {
        "Conditions": {
            "CollectionMode": {
                "Count": 1,
                "Mode": "Sweep"
            },
            "DwellTime": 1,
            "IsPlayback": False,
            "PixelResolution": 1
        },
        "Detectors": [
            "Image"
        ],
        "DriftCorrection": {
            "CorrectionRegion": None,
            "Interval": 1,
            "Type": "None"
        },
        "Region": {
            "Height": 512,
            "Left": 0,
            "Points": None,
            "Shape": "Rectangle",
            "Top": 0,
            "Width": 512
        }
    }
>>> start(param)
{
    "AcquisitionID": "40d1a2a5-4bfb-4841-8be5-b99c5395eef2",
    "ReferenceDetector": "",
    "Version": "1.0.0",
    "WorksheetID": "a4fef4e1-90d9-4334-bedf-671b575e2db4"
}
PyJEM.femtus.acquisition.stop()

Stop the currently running data acquisition. When running in EndlessMode, data acquisition will not complete until this request is sent

Returns:

JSON response for the stop request.

key

type

value

Version

str

API version string.

Result

str

Execution status. One of "OK" or "Fail".

Return type:

dict

Examples

>>> stop()
{'Result': 'OK', 'Version': '1.0.0'}