Skip to content

In situ X-ray Diffraction (XRD)

XRD module for in situ data.

XRDInsituBlock

Bases: GenericInSituBlock

This datablock processes in-situ XRD data from an input .zip file containing two or three specific directories:

  • XRD data directory: Contains multiple XRD patterns (.xy, or otherwise based on datalab XRDBlock) measured at different times,
  • Time series directory: Contains the log data (.csv) with temperature or other time of measurement metadata,
  • (Optional) Electrochemical data directory: Contains electrochemical data with voltage vs time data.

Attributes:

Name Type Description
accepted_file_extensions
available_folders List[str]
block_db_model
blocktype
defaults
description
echem_folder_name
folder_name
name
plot_functions
plotting_label_dict
time_series_folder_name
version str
xrd_folder_name

accepted_file_extensions

accepted_file_extensions = ('.zip',)

available_folders

available_folders: List[str] = []

block_db_model

block_db_model = InsituBlockResponse

blocktype

blocktype = 'insitu-xrd'

defaults

defaults = {'start_exp': 1, 'exclude_exp': None, 'metadata': None, 'target_sample_number': 1000, 'target_data_number': 1000, 'data_granularity': None, 'sample_granularity': None}

description

description = __doc__

echem_folder_name

echem_folder_name = None

folder_name

folder_name = None

name

name = 'XRD insitu'

plot_functions

plot_functions

plotting_label_dict

plotting_label_dict

time_series_folder_name

time_series_folder_name = None

version

version: str = __version__

xrd_folder_name

xrd_folder_name = None

generate_insitu_xrd_plot

generate_insitu_xrd_plot(file_path: Path | None = None, link_plots: bool = False)

Generate combined XRD and electrochemical or Temperature plots using the operando-style layout.

This method coordinates the creation of various plot components and combines them into a unified visualization.

Parameters:

Name Type Description Default
file_path Path | None

Path to the zip file containing XRD and electrochemical data, rather than looking up in the database for attached files.

None
link_plots bool

Boolean to indicate if the plots should be linked using bokeh js scripts.

False

get_available_folders

get_available_folders(file_path: Path) -> List[str]

Extract and return a list of available folders from the zip file.

This method opens the zip file identified by file_id, extracts the main folder and its subfolders, and returns a sorted list of subfolder names.

Parameters:

Name Type Description Default
file_path Path

Path to the zip file.

required

Returns:

Type Description
List[str]

Sorted list of subfolder names, or empty list if file not found or on error.

process_and_store_data

process_and_store_data(file_path: str | Path)

Process all in situ XRD, log and (optional) electrochemical data and store results. This method is a wrapper for processing both XRD and electrochemical data and the log data.

subsample_data

subsample_data(data: Union[DataFrame, ndarray], sample_granularity: int, data_granularity: int, method: str = 'linear') -> Union[DataFrame, ndarray]

Subsample data to a specified granularity in both sample and feature dimensions.

Parameters:

Name Type Description Default
data Union[DataFrame, ndarray]

The data to be subsampled.

required
sample_granularity int

Subsampling step along rows (samples).

required
data_granularity int

Subsampling step along columns (features).

required
method str

Subsampling method; currently supports only 'linear' and 'max_pooling'.

'linear'

Returns:

Type Description
Union[DataFrame, ndarray]

Subsampled data of the same type as input.