atomscale.results.rheed_image.RHEEDImageResult#

class atomscale.results.rheed_image.RHEEDImageResult(data_id: UUID | str, processed_data_id: UUID | str, processed_image: Image, mask: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None, pattern_graph: Graph | None, metadata: dict | None = None, collected_datetime: str | None = None)[source]

Bases: MSONable

RHEED image result

Parameters:
  • data_id (UUID | str) – Data ID for the entry in the data catalogue.

  • processed_data_id (UUID | str) – Processed data ID for the entry in the catalogue.

  • processed_image (Image) – Processed image data in a PIL Image format.

  • mask (NDArray | None) – Array containing binary segmentation mask.

  • pattern_graph (Graph | None) – NetworkX Graph object for the extracted diffraction pattern.

  • metadata (dict) – Generic metadata (e.g. timestamp, cluster_id, etc…).

  • collected_datetime (str | None) – Datetime when the data was collected.

__init__(data_id: UUID | str, processed_data_id: UUID | str, processed_image: Image, mask: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None, pattern_graph: Graph | None, metadata: dict | None = None, collected_datetime: str | None = None)[source]

RHEED image result

Parameters:
  • data_id (UUID | str) – Data ID for the entry in the data catalogue.

  • processed_data_id (UUID | str) – Processed data ID for the entry in the catalogue.

  • processed_image (Image) – Processed image data in a PIL Image format.

  • mask (NDArray | None) – Array containing binary segmentation mask.

  • pattern_graph (Graph | None) – NetworkX Graph object for the extracted diffraction pattern.

  • metadata (dict) – Generic metadata (e.g. timestamp, cluster_id, etc…).

  • collected_datetime (str | None) – Datetime when the data was collected.

Methods

__init__(data_id, processed_data_id, ...[, ...])

RHEED image result

as_dict()

A JSON serializable dict representation of an object.

from_dict(d)

Reconstruct an MSONable object from a dict.

get_laue_zero_radius()

Get the radius of the zeroth order Laue zone.

get_pattern_dataframe([extra_data, ...])

Featurize this RHEED image into a DataFrame of per-node features.

get_plot([show_mask, show_spot_nodes, ...])

Get diffraction pattern image with optional overlays

load(file_path)

Load an instance from a JSON file written by save().

save(json_path[, mkdir, json_kwargs, ...])

Serialize the instance to JSON on disk, pickling fields if needed.

to_json()

Returns a json string representation of the MSONable object.

unsafe_hash()

Return a hash of the current object.

validate_monty_v1(_MSONable__input_value)

Pydantic validator with correct signature for pydantic v1.x.

validate_monty_v2(_MSONable__input_value, _)

Pydantic validator with correct signature for pydantic v2.x.

Attributes

REDIRECT

get_plot(show_mask: bool = True, show_spot_nodes: bool = True, symmetrize: bool = False, alpha: float = 0.2) Image[source]

Get diffraction pattern image with optional overlays

Parameters:
  • show_mask (bool) – Whether to show mask overlay of identified pattern. Defaults to True.

  • show_spot_nodes (bool) – Whether to show identified diffraction node overlays. Defaults to True.

  • symmetrize (bool) – Whether to mirror the pattern across the vertical axis before drawing overlays. Defaults to False.

  • alpha (float) – Opacity of the mask overlay, from 0 (transparent) to 1 (opaque). Defaults to 0.2.

Returns:

PIL Image object with optional overlays

Return type:

(Image)

get_laue_zero_radius() tuple[float, tuple[float, float]][source]

Get the radius of the zeroth order Laue zone. Note that the data is symmetrized across the vertical axis before the Laue zone is searched for.

Returns:

Tuple containing the best fit radius and center point.

Return type:

(tuple[float, tuple[float, float]])

get_pattern_dataframe(extra_data: dict | None = None, symmetrize: bool = False, return_as_features: bool = False) DataFrame[source]

Featurize this RHEED image into a DataFrame of per-node features.

Parameters:
  • extra_data (dict | None) – Dictionary containing field names and values of extra data to be included in the DataFrame object. Defaults to None.

  • symmetrize (bool) – Whether to symmetrize the data across the vertical axis. Defaults to False.

  • return_as_features (bool) – When True, return a wide feature table with one row per image and one column per (feature, node) pair; when False, return the raw per-node rows. Defaults to False.

Returns:

Pandas DataFrame of per-node features.

Return type:

(DataFrame)

as_dict() dict

A JSON serializable dict representation of an object.

Return type:

dict

classmethod from_dict(d: dict) MSONable

Reconstruct an MSONable object from a dict.

Parameters:

d (dict) – Dict representation.

Return type:

MSONable

Returns:

MSONable class.

classmethod load(file_path: PathLike | str) MSONable

Load an instance from a JSON file written by save().

Parameters:

file_path (PathLike | str) – The JSON file to load from.

Return type:

MSONable

Returns:

An instance of the class being reloaded.

save(json_path: PathLike | str, mkdir: bool = True, json_kwargs: dict | None = None, pickle_kwargs: dict | None = None, strict: bool = True) None

Serialize the instance to JSON on disk, pickling fields if needed.

For a fully MSONable class, only {save_dir}/class.json is written. For a partially MSONable class, non-serializable attributes are pickled individually into the same directory, keeping the JSON portion readable.

Parameters:
  • json_path (PathLike | str) – The file to which to save the JSON object. A pickled companion file with the same stem but a different extension may also be written if the class is not entirely MSONable.

  • mkdir (bool) – If True, create the target directory (including parents).

  • json_kwargs (dict | None) – Keyword arguments forwarded to the JSON serializer.

  • pickle_kwargs (dict | None) – Keyword arguments forwarded to pickle.dump.

  • strict (bool) – If True, refuse to overwrite existing files.

Return type:

None

to_json() str

Returns a json string representation of the MSONable object.

Return type:

str

unsafe_hash() Any

Return a hash of the current object.

This uses a generic but low performance method of converting the object to a dictionary, flattening any nested keys, and then performing a hash on the resulting object.

Return type:

Any

classmethod validate_monty_v1(_MSONable__input_value)

Pydantic validator with correct signature for pydantic v1.x.

classmethod validate_monty_v2(_MSONable__input_value, _)

Pydantic validator with correct signature for pydantic v2.x.