Skip to content

In situ NMR Spectroscopy

NMR module for in situ data.

InsituBlock

Bases: DataBlock

This datablock processes in situ NMR data from an input .zip file containing two specific directories:

  • NMR Data Directory: Contains multiple Bruker in-situ NMR experiment datasets.
  • Echem Data Directory: Contains echem data files in .mpr format.

If multiple echem experiments are present, their filenames must include GCPL.

Attributes:

Name Type Description
accepted_file_extensions
blocktype
defaults
description
name
plot_functions
version str

accepted_file_extensions

accepted_file_extensions = ('.zip',)

blocktype

blocktype = 'insitu-nmr'

defaults

defaults = {'ppm1': 0.0, 'ppm2': 0.0, 'start_exp': 1, 'end_exp': None, 'step_exp': None, 'exclude_exp': None}

description

description = __doc__

name

name = 'NMR insitu'

plot_functions

plot_functions

version

version: str = __version__

count_experiments_in_nmr_folder

count_experiments_in_nmr_folder(file_path: Path, nmr_folder_name: str) -> int

Count the number of experiments in the selected NMR folder.

generate_insitu_nmr_plot

generate_insitu_nmr_plot(file_path: str | Path | None = None, link_plots: bool = True)

Generate combined NMR and electrochemical 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 str | Path | None

Optional path to the zip file containing NMR and echem data, removing the need to lookup in a database.

None
link_plots bool

If True, links the plots for synchronized interaction, otherwise time can be saved by leaving them unlinked.

True

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 from which to extract folder names.

required

Returns:

Type Description
List[str]

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) -> tuple[DataFrame, DataFrame]

Process insitu NMR and electrochemical data and store results.

This method validates input parameters, extracts data from the specified folders, and stores the processed data in the block's data attribute.

Returns:

Type Description
tuple[DataFrame, DataFrame]

A tuple containing NMR and electrochemical data as dataframes.

process_datalab_data

process_datalab_data(api_url: str, item_id: str, folder_name: str, nmr_folder_name: str, echem_folder_name: str, start_at: int = 1, end_at: Optional[int] = None, step: Optional[int] = None, exclude_exp: Optional[List[int]] = None) -> Dict

Process NMR spectroscopy data from Datalab API.

Parameters:

Name Type Description Default
api_url str

URL of the Datalab API

required
item_id str

ID of the item to process

required
folder_name str

Base folder name

required
nmr_folder_name str

Folder containing NMR experiments

required
echem_folder_name str

Folder containing Echem data

required
start_at int

Starting experiment number (default: 1)

1
exclude_exp Optional[List[int]]

List of experiment numbers to exclude (default: None)

None

Returns:

Type Description
Dict

Dictionary containing processed NMR and electrochemical data

process_local_data

process_local_data(folder_name: str, nmr_folder_name: str, echem_folder_name: str, start_at: int = 1, end_at: Optional[int] = None, step: Optional[int] = None, exclude_exp: Optional[List[int]] = None) -> Dict

Process NMR spectroscopy data from local zip files.

Parameters:

Name Type Description Default
folder_name str

Path to the ZIP file or folder containing the NMR data.

required
nmr_folder_name str

Name of the folder inside folder_name containing NMR experiments.

required
echem_folder_name str

Name of the folder inside folder_name containing electrochemical data.

required
start_at int

Starting experiment number (default: 1).

1
exclude_exp Optional[List[int]]

List of experiment numbers to exclude (default: None).

None

Returns:

Name Type Description
Dict Dict

Dictionary containing processed NMR and electrochemical data.