class documentation

class ScanData(BaseModel): (source)

View In Hierarchy

Data about a scan to be saved to a JSON file in the directory.

This serialises into a human readable format where possible with

timestamps in %Y-%m-%d_%H:%M:%S format timedeltas in %H:%M:%S format

Properties that are not known until the end have None serialised as "Unknown"

Class Method parse_timedelta Validate a timedelta that may be a string in Hrs:Min:Sec format or "Unknown".
Class Method parse_timestamp Validate a timestamp that may be a string in Year-Month-Day_Hrs:Min:Sec format.
Class Method parse_unknown_as_none Validate the string "Unknown" as None.
Method serialize_none_as_unknown Serialise None as "Unknown" for a more human readable result.
Method serialize_timedelta Serialise timedelta to Hrs:Min:Sec (or "Unknown" if None).
Method serialize_timestamp Serialise timestamp to Year-Month-Day_Hrs:Min:Sec format.
Method set_final_data Set the final data for the scan, scan duration is automatically calculated.
Class Variable autofocus_dz The z range used for autofocus (in steps).
Class Variable autofocus_on Whether autofocus is on.
Class Variable correlation_resize The resize factor applied to images when the stitching program is correlating.
Class Variable dx The number of steps between adjacent images in x.
Class Variable dy The number of steps between adjacent images in y.
Class Variable image_count The number of images taken.
Class Variable max_dist The maximum distance the scan could move (in steps) from the starting position.
Class Variable model_config Undocumented
Class Variable overlap The overlap between adjacent images as a fraction of the image size.
Class Variable save_resolution The resolution that scan images are saved at.
Class Variable scan_name The name of the scan i.e. scan_0001
Class Variable skip_background Whether automatic background detection is on, skipping locations with no sample.
Class Variable start_time The time the scan started.
Class Variable starting_position The starting position in dictionary format.
Class Variable stitch_automatically Whether the scan is set to automatically stitch when complete.
Instance Variable duration The duration of the scan.
Instance Variable scan_result The result of the scan.
@field_validator('duration', mode='before')
@classmethod
def parse_timedelta(cls, value: str | timedelta | None) -> timedelta | None: (source)

Validate a timedelta that may be a string in Hrs:Min:Sec format or "Unknown".

@field_validator('start_time', mode='before')
@classmethod
def parse_timestamp(cls, value: str | datetime) -> datetime: (source)

Validate a timestamp that may be a string in Year-Month-Day_Hrs:Min:Sec format.

@field_validator('scan_result', mode='before')
@classmethod
def parse_unknown_as_none(cls, value: str | int | None) -> str | int | None: (source)

Validate the string "Unknown" as None.

@field_serializer('scan_result')
def serialize_none_as_unknown(self, value: str | int | None) -> str | int: (source)

Serialise None as "Unknown" for a more human readable result.

@field_serializer('duration')
def serialize_timedelta(self, value: timedelta | None) -> str: (source)

Serialise timedelta to Hrs:Min:Sec (or "Unknown" if None).

@field_serializer('start_time')
def serialize_timestamp(self, value: datetime) -> str: (source)

Serialise timestamp to Year-Month-Day_Hrs:Min:Sec format.

def set_final_data(self, result: str): (source)

Set the final data for the scan, scan duration is automatically calculated.

Parameters
result:strA string describing the result.
autofocus_dz: int = (source)

The z range used for autofocus (in steps).

autofocus_on: bool = (source)

Whether autofocus is on.

correlation_resize: float = (source)

The resize factor applied to images when the stitching program is correlating.

The number of steps between adjacent images in x.

The number of steps between adjacent images in y.

image_count: int = (source)

The number of images taken.

max_dist: int = (source)

The maximum distance the scan could move (in steps) from the starting position.

model_config: dict[str, str] = (source)

Undocumented

overlap: float = (source)

The overlap between adjacent images as a fraction of the image size.

save_resolution: tuple[int, int] = (source)

The resolution that scan images are saved at.

scan_name: str = (source)

The name of the scan i.e. scan_0001

skip_background: bool = (source)

Whether automatic background detection is on, skipping locations with no sample.

start_time: datetime = (source)

The time the scan started.

starting_position: Mapping[str, int] = (source)

The starting position in dictionary format.

stitch_automatically: bool = (source)

Whether the scan is set to automatically stitch when complete.

duration: timedelta | None = (source)

The duration of the scan.

This is automatically set when set_final_data() is run.

scan_result: str | None = (source)

The result of the scan.

This should be set with set_final_data() to ensure duration is set.