io#
Load, save, import, and export scan data and projects.
beep
#
beep(
mode: Literal[
"success", "warning", "error", "info"
] = "info",
theme: Literal[
"big-sur",
"chime",
"mario",
"material",
"pokemon",
"sonic",
"zelda",
] = "material",
) -> None
Plays an audio signal ("beep").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
Literal['success', 'warning', 'error', 'info']
|
The tone of the signal. Default: "info". |
'info'
|
theme
|
Literal['big-sur', 'chime', 'mario', 'material', 'pokemon', 'sonic', 'zelda']
|
Variation of the signal. Default: "material". |
'material'
|
export_signal
#
export_signal(
path: str | Path,
format_id: str | None = None,
signal: Signal1D | Signal2D | None = None,
) -> bool
Export signal data to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Output file path. |
required |
format_id
|
str | None
|
Export format ID (e.g., 'csv'). Auto-detected from extension if None. |
None
|
signal
|
Signal1D | Signal2D | None
|
Signal to export. Uses current state signal if None. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if export succeeded, False otherwise. |
export_spectrum
#
export_spectrum(
path: str | Path,
format_id: str | None = None,
spectrum: Spectrum1D | Spectrum2D | None = None,
) -> bool
Export spectrum data to file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Output file path. |
required |
format_id
|
str | None
|
Export format ID (e.g., 'csv'). Auto-detected from extension if None. |
None
|
spectrum
|
Spectrum1D | Spectrum2D | None
|
Spectrum to export. Uses current state spectrum if None. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if export succeeded, False otherwise. |
get_save_group
#
Get the current save group path.
Returns:
| Type | Description |
|---|---|
str | None
|
Current group path, or None if saving to project root. |
import_scan
#
Import a scan from file.
The imported data is loaded into State.signal and State.spectrum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Input file path. |
required |
format_id
|
str | None
|
Import format ID. Auto-detected if None. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if import succeeded, False otherwise. |
list_export_formats
#
list_export_formats() -> list[str]
List available export format IDs.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of format IDs (e.g., ['csv', 'jcamp_dx', 'nmrpipe']). |
list_import_formats
#
list_import_formats() -> list[str]
List available import format IDs.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of format IDs (e.g., ['jcamp_dx', 'bruker', 'varian']). |
list_samples
#
list_scans
#
list_scans(project_name: str | None = None) -> list[str]
List all scan IDs in a project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name
|
str | None
|
Project to list scans from. Uses current project if None. |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of scan IDs. |
load_project
#
load_project(
name: str, update_state: bool = True
) -> Project | None
Load a project from the repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Project name to load. |
required |
update_state
|
bool
|
If True, sets as current project in State. Default: True. |
True
|
Returns:
| Type | Description |
|---|---|
Project | None
|
The loaded Project, or None if not found. |
load_sample
#
load_sample(
sample_id: str, update_state: bool = True
) -> Sample | None
Load a sample from the library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_id
|
str
|
|
required |
update_state
|
bool
|
If True, sets as current sample in State.project. Default: True. |
True
|
Returns:
| Type | Description |
|---|---|
Sample | None
|
The loaded Sample, or None if not found. |
load_scan
#
load_scan(
scan_id: str,
project_name: str | None = None,
update_state: bool = True,
) -> tuple[
Signal1D | Signal2D | None,
Spectrum1D | Spectrum2D | None,
]
Load a scan from the repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scan_id
|
str
|
Scan ID to load. |
required |
project_name
|
str | None
|
Project containing the scan. Uses current project if None. |
None
|
update_state
|
bool
|
If True, updates State.signal/spectrum/current_scan. Default: True. |
True
|
Returns:
| Type | Description |
|---|---|
tuple[Signal1D | Signal2D | None, Spectrum1D | Spectrum2D | None]
|
Tuple of (signal, spectrum), either may be None. |
save_as_scan
#
save_as_scan(
signal: Signal1D | Signal2D | None = None,
spectrum: Spectrum1D | Spectrum2D | None = None,
name: str = "user_saved",
project_name: str | None = None,
group: str | None = None,
) -> str | None
Save provided signal/spectrum as a new scan in the repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
signal
|
Signal1D | Signal2D | None
|
Signal data to save (optional). |
None
|
spectrum
|
Spectrum1D | Spectrum2D | None
|
Spectrum data to save (optional). |
None
|
name
|
str
|
Name/label for the scan. Default: "user_saved". |
'user_saved'
|
project_name
|
str | None
|
Project to save to. Uses current project if None. |
None
|
group
|
str | None
|
Optional group/folder within the project. |
None
|
Returns:
| Type | Description |
|---|---|
str | None
|
The scan ID if successful, None otherwise. |
save_group
#
Context manager that routes scans saved within it to group_path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_path
|
str
|
Group path relative to project (e.g., "January/SampleA"); "" for project root. |
required |
save_project
#
save_project(
project: Project | None = None, name: str | None = None
) -> bool
Save a project to the repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
Project | None
|
Project to save. Uses State.project if None. |
None
|
name
|
str | None
|
Override name for the project. Uses project.name if None. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise. |
save_sample
#
save_sample(
sample: Sample | None = None, name: str | None = None
) -> bool
Save a sample to the library, under its Sample.id (a new sample gets one).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Sample | None
|
Sample to save. Uses State.project.sample if None. |
None
|
name
|
str | None
|
New name for the sample. Keeps sample.name if None. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise. |
save_state_as_scan
#
save_state_as_scan(
name: str = "user_saved",
project_name: str | None = None,
group: str | None = None,
) -> str | None
Save current State.signal and State.spectrum as a new scan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name/label for the scan. Default: "user_saved". |
'user_saved'
|
project_name
|
str | None
|
Project to save to. Uses current project if None. |
None
|
group
|
str | None
|
Optional group/folder within the project. |
None
|
Returns:
| Type | Description |
|---|---|
str | None
|
The scan ID if successful, None otherwise. |
set_save_group
#
Set the save group for subsequent scans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_path
|
str | None
|
Group path, or None to reset to project root. |
required |