Core Modules
ScanPaths API
geecs_data_utils.scan_paths.ScanPaths ¶
ScanPaths(folder: Optional[SysPath] = None, tag: Optional[ScanTag] = None, base_directory: Union[Path, str, None] = None, read_mode: bool = True)
Represents a GEECS experiment scan.
Attributes:
| Name | Type | Description |
|---|---|---|
scan_info |
dict[str, str]
|
Dictionary containing scan configuration information loaded from scan info file |
paths_config |
GeecsPathsConfig
|
Class-level configuration object for managing GEECS data paths |
Initialize ScanPaths object.
Either a folder or a tag+base_directory needs to be given in order to specify the location of a scan data folder
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder
|
Union[str, bytes, PathLike]
|
Data folder containing the scan data, e.g. "Z:/data/Undulator/Y2023/05-May/23_0501/scans/Scan002". |
None
|
tag
|
Optional[ScanTag]
|
NamedTuple with the experiment name, date, and scan number |
None
|
base_directory
|
Optional[Union[Path, str]]
|
The base path for the data, e/g/ "Z:/data/" If not given, will default to the path located by GeecsPathsConfig |
None
|
read_mode
|
bool
|
If True (the default), raise if the scan folder does not exist. If False, silently create the folder (including any missing parents).
|
True
|
Methods:
| Name | Description |
|---|---|
reload_paths_config |
Use by GEECS Scanner to fix scan_data_manager in case experiment name has changed. |
get_scan_tag |
Return a ScanTag tuple given the appropriate information, formatted correctly. |
get_scan_folder_path |
Build scan folder paths for local and client directories. |
get_daily_scan_folder |
Build path to the daily scan folder. If no tag given but experiment name given, uses the current day. |
get_scan_analysis_folder_path |
Build analysis folder path using the scan folder path as a baseline. |
get_device_shot_path |
Build the full path to a device's shot file based on the scan tag, device name, and shot number. |
get_latest_scan_tag |
Locates the last generated scan for the given day or defaults to today if no date is provided. |
get_next_scan_tag |
Determine the next available scan tag for the given day or today if no date is provided. |
get_next_scan_folder |
Build the folder path for the next scan on the given day or today if no date is provided. |
build_next_scan_data |
Create the ScanData object for the next scan and builds its folder. |
is_background_scan |
Check if the given scan tag references a scan that was designated as a background. |
get_folder |
Get the scan folder path. |
get_tag |
Get the scan tag. |
get_tag_date |
Get the scan date. |
get_analysis_folder |
Get the analysis folder path, creating it if necessary. |
get_folders_and_files |
Get lists of device folders and files in the scan directory. |
load_scan_info |
Load scan configuration information from the scan info file. |
get_ecs_dump_file |
Get the ECS Live Dump file corresponding to this scan. |
build_device_file_map |
Build a mapping from shot number to file path for a given device. |
get_common_shot_dataframe |
Generate a DataFrame containing file paths for all devices with common shot number. |
list_device_folders |
Return device subfolder names from this scan folder. |
device_folder |
Resolve ' |
build_asset_filename |
Build canonical expected file naming. |
build_asset_path |
Full expected path for one asset. |
infer_device_ext |
Peek at up to |
Source code in geecs_data_utils/scan_paths.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
reload_paths_config
classmethod
¶
reload_paths_config(config_path: Optional[Path] = None, default_experiment: Optional[str] = None, set_base_path: Optional[Union[Path, str]] = None, image_analysis_configs_path: Optional[Union[Path, str]] = None)
Use by GEECS Scanner to fix scan_data_manager in case experiment name has changed.
Source code in geecs_data_utils/scan_paths.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
get_scan_tag
staticmethod
¶
get_scan_tag(year: Union[int, str], month: Union[int, str], day: Union[int, str], number: Union[int, str], experiment: Optional[str] = None, experiment_name: Optional[str] = None) -> ScanTag
Return a ScanTag tuple given the appropriate information, formatted correctly.
Ideally one should only build ScanTag objects using this function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
Union[int, str]
|
Target scan year |
required |
month
|
Union[int, str]
|
Target scan month |
required |
day
|
Union[int, str]
|
Target scan day |
required |
number
|
Union[int, str]
|
Target scan number |
required |
experiment
|
str
|
Target scan's experiment name |
None
|
experiment_name
|
str
|
Target scan's experiment name (deprecated) |
None
|
Returns:
| Type | Description |
|---|---|
ScanTag
|
properly formatted information to describe the target scan |
Source code in geecs_data_utils/scan_paths.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
get_scan_folder_path
staticmethod
¶
get_scan_folder_path(tag: ScanTag, base_directory: Optional[Union[Path, str]] = None) -> Path
Build scan folder paths for local and client directories.
Source code in geecs_data_utils/scan_paths.py
253 254 255 256 257 258 259 260 261 | |
get_daily_scan_folder
staticmethod
¶
get_daily_scan_folder(experiment: str = None, tag: ScanTag = None, base_directory: Optional[Union[Path, str]] = None) -> Path
Build path to the daily scan folder. If no tag given but experiment name given, uses the current day.
Source code in geecs_data_utils/scan_paths.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
get_scan_analysis_folder_path
staticmethod
¶
get_scan_analysis_folder_path(tag: ScanTag, base_directory: Optional[Union[Path, str]] = None) -> Path
Build analysis folder path using the scan folder path as a baseline.
Source code in geecs_data_utils/scan_paths.py
296 297 298 299 300 301 302 303 304 305 306 307 | |
get_device_shot_path
staticmethod
¶
get_device_shot_path(tag: ScanTag, device_name: str, shot_number: int, file_extension: str = 'png', base_directory: Optional[Union[Path, str]] = None) -> Path
Build the full path to a device's shot file based on the scan tag, device name, and shot number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
ScanTag
|
The scan tag containing year, month, day, and scan number. |
required |
device_name
|
str
|
The name of the device. |
required |
shot_number
|
int
|
The shot number. |
required |
file_extension
|
str
|
File extension for the shot file (default: 'png'). |
'png'
|
base_directory
|
Optional[Union[Path, str]]
|
Base directory for the scan (default: CONFIG.local_base_path). |
None
|
experiment
|
Optional[str]
|
Experiment name (default: CONFIG.experiment). |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The full path to the device's shot file. |
Source code in geecs_data_utils/scan_paths.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
get_latest_scan_tag
staticmethod
¶
get_latest_scan_tag(experiment: Optional[str] = None, year: Optional[int] = None, month: Optional[int] = None, day: Optional[int] = None, base_directory: Union[str, Path, None] = None) -> Optional[ScanTag]
Locates the last generated scan for the given day or defaults to today if no date is provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment
|
Optional[str]
|
Experiment name (default: CONFIG.experiment). |
None
|
year
|
Optional[int]
|
Year of the scan (4-digit, default: current year if not provided). |
None
|
month
|
Optional[int]
|
Month of the scan (1-12, default: current month if not provided). |
None
|
day
|
Optional[int]
|
Day of the scan (1-31, default: current day if not provided). |
None
|
Returns:
| Type | Description |
|---|---|
Optional[ScanTag]
|
The ScanTag representing the latest scan folder, or None if no scans exist for the given day. |
Source code in geecs_data_utils/scan_paths.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
get_next_scan_tag
staticmethod
¶
get_next_scan_tag(experiment: Optional[str] = None, year: Optional[int] = None, month: Optional[int] = None, day: Optional[int] = None, base_directory: Union[str, Path, None] = None) -> ScanTag
Determine the next available scan tag for the given day or today if no date is provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment
|
Optional[str]
|
Experiment name (default: CONFIG.experiment). |
None
|
year
|
Optional[int]
|
Year of the scan (4-digit, default: current year if not provided). |
None
|
month
|
Optional[int]
|
Month of the scan (1-12, default: current month if not provided). |
None
|
day
|
Optional[int]
|
Day of the scan (1-31, default: current day if not provided). |
None
|
Returns:
| Type | Description |
|---|---|
ScanTag
|
The ScanTag for the next available scan. |
Source code in geecs_data_utils/scan_paths.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | |
get_next_scan_folder
staticmethod
¶
get_next_scan_folder(experiment: Optional[str] = None, year: Optional[int] = None, month: Optional[int] = None, day: Optional[int] = None, base_directory: Union[str, Path, None] = None) -> Path
Build the folder path for the next scan on the given day or today if no date is provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment
|
Optional[str]
|
Experiment name (default: CONFIG.experiment). |
None
|
year
|
Optional[int]
|
Year of the scan (4-digit, default: current year if not provided). |
None
|
month
|
Optional[int]
|
Month of the scan (1-12, default: current month if not provided). |
None
|
day
|
Optional[int]
|
Day of the scan (1-31, default: current day if not provided). |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The Path to the folder for the next scan. |
Source code in geecs_data_utils/scan_paths.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | |
build_next_scan_data
staticmethod
¶
build_next_scan_data(experiment: Optional[str] = None, year: Optional[int] = None, month: Optional[int] = None, day: Optional[int] = None, base_directory: Union[str, Path, None] = None) -> ScanPaths
Create the ScanData object for the next scan and builds its folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment
|
Optional[str]
|
Experiment name (default: CONFIG.experiment). |
None
|
year
|
Optional[int]
|
Year of the scan (4-digit, default: current year if not provided). |
None
|
month
|
Optional[int]
|
Month of the scan (1-12, default: current month if not provided). |
None
|
day
|
Optional[int]
|
Day of the scan (1-31, default: current day if not provided). |
None
|
Returns:
| Type | Description |
|---|---|
ScanData
|
The ScanData object for the next scan. |
Source code in geecs_data_utils/scan_paths.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
is_background_scan
staticmethod
¶
is_background_scan(tag: ScanTag, base_directory: Optional[Union[Path, str]] = None) -> bool
Check if the given scan tag references a scan that was designated as a background.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
ScanTag
|
The scan tag containing year, month, day, and scan number. |
required |
base_directory
|
Optional[Union[Path, str]]
|
Base directory for the scan (default: CONFIG.local_base_path). |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if scan was explictly set as a Background scan, False otherwise |
Source code in geecs_data_utils/scan_paths.py
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
get_folder ¶
get_folder() -> Optional[Path]
Get the scan folder path.
Source code in geecs_data_utils/scan_paths.py
542 543 544 | |
get_tag ¶
get_tag() -> Optional[ScanTag]
Get the scan tag.
Source code in geecs_data_utils/scan_paths.py
546 547 548 | |
get_tag_date ¶
get_tag_date() -> Optional[date]
Get the scan date.
Source code in geecs_data_utils/scan_paths.py
550 551 552 | |
get_analysis_folder ¶
get_analysis_folder() -> Optional[Path]
Get the analysis folder path, creating it if necessary.
Source code in geecs_data_utils/scan_paths.py
554 555 556 557 558 559 560 561 562 563 | |
get_folders_and_files ¶
get_folders_and_files() -> dict[str, list[str]]
Get lists of device folders and files in the scan directory.
Source code in geecs_data_utils/scan_paths.py
565 566 567 568 | |
load_scan_info ¶
load_scan_info()
Load scan configuration information from the scan info file.
Source code in geecs_data_utils/scan_paths.py
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | |
get_ecs_dump_file ¶
get_ecs_dump_file() -> Optional[Path]
Get the ECS Live Dump file corresponding to this scan.
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Path to the ECS dump file if it exists, else None. |
Source code in geecs_data_utils/scan_paths.py
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | |
build_device_file_map ¶
build_device_file_map(device: str, file_tail: str, *, device_file_stem: Optional[str] = None) -> dict[int, Path]
Build a mapping from shot number to file path for a given device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
str
|
Device name; also the subfolder of the scan directory containing the files. |
required |
file_tail
|
str
|
Suffix and extension, e.g., '.png', '_avg.h5'. |
required |
device_file_stem
|
str
|
Token used in the filename between |
None
|
Returns:
| Type | Description |
|---|---|
dict[int, Path]
|
Mapping from shot number to file path. |
Source code in geecs_data_utils/scan_paths.py
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | |
get_common_shot_dataframe ¶
get_common_shot_dataframe(device_file_specs: Sequence[tuple[str, str]]) -> pd.DataFrame
Generate a DataFrame containing file paths for all devices with common shot number.
This method identifies shot numbers that are common (present in all specified devices' subfolders) and returns a table where each row corresponds to a shot number, and each column contains the full path to the file for that device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_file_specs
|
Sequence[tuple[str, str]]
|
A sequence of (device_name, file_tail) pairs.
- |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A DataFrame with one row per shot number that exists for all devices.
Columns:
- 'shot_number': The shot number (int).
- One column per device name, with each entry as a |
Examples:
>>> tag = ScanTag(year=2025, month=8, day=7, number=5, experiment='Undulator')
>>> sd = ScanPaths(tag=tag)
>>> dev_list = [
... ('Z_Test_Scope', '.dat'),
... ('Z_Test_Scope_2', '.dat'),
... ('UC_ALineEBeam3', '.png')
... ]
>>> common_shots = sd.get_common_shot_dataframe(dev_list)
Source code in geecs_data_utils/scan_paths.py
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | |
list_device_folders ¶
list_device_folders() -> list[str]
Return device subfolder names from this scan folder.
Source code in geecs_data_utils/scan_paths.py
731 732 733 734 735 736 737 738 739 740 741 | |
device_folder ¶
device_folder(device: str) -> Path
Resolve '
Source code in geecs_data_utils/scan_paths.py
743 744 745 | |
build_asset_filename
staticmethod
¶
build_asset_filename(*, scan: int, shot: int, device: str, ext: str, variant: Optional[str] = None, device_file_stem: Optional[str] = None) -> str
Build canonical expected file naming.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scan
|
int
|
Scan and shot numbers. |
required |
shot
|
int
|
Scan and shot numbers. |
required |
device
|
str
|
Device name (also the in-filename stem unless overridden). |
required |
ext
|
str
|
File extension (with or without leading dot). |
required |
variant
|
str
|
Variant segment appended after the shot index. |
None
|
device_file_stem
|
str
|
Token to use in the filename between |
None
|
Source code in geecs_data_utils/scan_paths.py
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | |
build_asset_path ¶
build_asset_path(*, shot: int, device: str, ext: str, variant: Optional[str] = None, device_file_stem: Optional[str] = None) -> Path
Full expected path for one asset.
device is the subfolder name. device_file_stem overrides the
in-filename token if it differs from the folder name (defaults to
device). See :meth:build_asset_filename for details.
Source code in geecs_data_utils/scan_paths.py
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
infer_device_ext ¶
infer_device_ext(device: str, *, max_files: int = 5) -> str
Peek at up to max_files files to find proper file extension.
Source code in geecs_data_utils/scan_paths.py
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 | |
ScanData API
geecs_data_utils.scan_data.ScanData ¶
ScanData(*, paths: ScanPaths)
Container for a single scan: paths + scalar DataFrame + lazy asset index.
This class composes a :class:ScanPaths (path logic) and provides:
- Optional scalar DataFrame loading (s-file or TDMS→DataFrame).
- Lazy, normalized asset indexing (no bytes loaded).
- Convenience helpers for grouping/averaging images by Bin #.
- Flexible column resolution (case-insensitive, substring/regex).
- Per-bin scalar aggregation with configurable center and error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
ScanPaths
|
A pre-constructed :class: |
required |
Notes
Use the factories :meth:from_date and :meth:latest for ergonomic creation.
Methods:
| Name | Description |
|---|---|
from_date |
Construct a :class: |
latest |
Construct a :class: |
load_scalars |
Load the scalar DataFrame (s-file or TDMS converted). |
set_data_frame |
Attach a scalar DataFrame and invalidate dependent caches. |
list_columns |
List column names as strings (flattens MultiIndex columns if present). |
find_cols |
Flexible column search. |
resolve_col |
Resolve a loose column spec to a single best column name. |
add_local_alias |
Register a user-defined shorthand for a column name. |
set_binning_config |
Update binning configuration and invalidate cache. |
expected_paths_by_bin |
Group expected image paths by the current bin definition. |
reload_sfile |
Re-read the analysis s-file into |
copy_fresh_sfile_to_analysis |
Replace the analysis s-file with the fresh copy from the scan folder. |
load_ecs_live_dump |
Load and parse the ECS Live Dump file for this scan via |
Attributes:
| Name | Type | Description |
|---|---|---|
binned_scalars |
DataFrame
|
Aggregate scalar data into bins with configurable center and error metrics. |
Source code in geecs_data_utils/scan_data.py
221 222 223 224 225 226 227 228 229 230 231 232 | |
binned_scalars
property
¶
binned_scalars: DataFrame
Aggregate scalar data into bins with configurable center and error metrics.
For each bin defined by bin_col in the current :class:BinningConfig,
all selected numeric columns (value_cols) are aggregated. The result is a
wide DataFrame with a two-level column index:
(column_name, {"center", "err_low", "err_high"}).
Notes
- If
value_colsis None, all numeric columns in the scalar DataFrame are included (including the bin source column and Shotnumber). - The bin column is treated like any other numeric column: its per-bin center and errors are computed the same way as other variables.
- Error definitions (
err) control howerr_lowanderr_highare computed:"std": sample standard deviation (symmetric)."stderr": standard error of the mean (symmetric)."mad": median absolute deviation (scaled ifscale_to_sigma=True; symmetric)."iqr": interquartile range usingpercentiles; asymmetric offsets around the chosen center."percentile": arbitrary quantile range usingpercentiles; asymmetric offsets around the chosen center.
- Counts per bin are included under the pseudo-column
("count", "center").
Returns:
| Type | Description |
|---|---|
DataFrame
|
Binned scalar table with a MultiIndex on columns:
The row index corresponds to unique bin labels, which may be discrete values or numeric bin centers depending on the binning configuration. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no scalar DataFrame is loaded. |
KeyError
|
If the configured bin column is not found. |
from_date
classmethod
¶
from_date(*, year: int, month: int, day: int, number: int, experiment: Optional[str] = None, base_directory: Optional[Path] = None, load_scalars: bool = True, source: Literal['sfile', 'tdms'] = 'sfile', append_paths: bool = True, stem_override: Optional[dict[str, str]] = None) -> 'ScanData'
Construct a :class:ScanData from date/number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
Identify the scan. |
required |
month
|
int
|
Identify the scan. |
required |
day
|
int
|
Identify the scan. |
required |
number
|
int
|
Identify the scan. |
required |
experiment
|
int
|
Identify the scan. |
required |
base_directory
|
Optional[Path]
|
Base data root if not configured globally. |
None
|
load_scalars
|
bool
|
If True, load scalar DataFrame immediately. |
True
|
source
|
Literal['sfile', 'tdms']
|
|
'sfile'
|
append_paths
|
bool
|
If true, ad device/shot paths to df. |
True
|
stem_override
|
Optional[dict[str, str]]
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
ScanData
|
|
Source code in geecs_data_utils/scan_data.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
latest
classmethod
¶
latest(experiment: Optional[str] = None, *, year: Optional[int] = None, month: Optional[int] = None, day: Optional[int] = None, base_directory: Optional[Path] = None, load_scalars: bool = True, source: Literal['sfile', 'tdms'] = 'sfile') -> 'ScanData'
Construct a :class:ScanData for the latest scan on a date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment
|
Optional[str]
|
Experiment name. |
None
|
year
|
Optional[int]
|
Optional date components; defaults to today if omitted. |
None
|
month
|
Optional[int]
|
Optional date components; defaults to today if omitted. |
None
|
day
|
Optional[int]
|
Optional date components; defaults to today if omitted. |
None
|
base_directory
|
Optional[Path]
|
Base data root if not configured globally. |
None
|
load_scalars
|
bool
|
If True, load scalar DataFrame immediately. |
True
|
source
|
Literal['sfile', 'tdms']
|
|
'sfile'
|
Returns:
| Type | Description |
|---|---|
ScanData
|
|
Source code in geecs_data_utils/scan_data.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
load_scalars ¶
load_scalars(*, source: Literal['sfile', 'tdms'] = 'sfile', append_paths: bool = True, stem_override: Optional[dict[str, str]] = None) -> None
Load the scalar DataFrame (s-file or TDMS converted).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Literal['sfile', 'tdms']
|
|
'sfile'
|
append_paths
|
bool
|
If true, add device/shot paths to dataframe. |
True
|
stem_override
|
Optional[dict[str, str]]
|
Optional |
None
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the s-file is expected but missing. |
Source code in geecs_data_utils/scan_data.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
set_data_frame ¶
set_data_frame(df: DataFrame, *, append_paths: bool = True, stem_override: Optional[dict[str, str]] = None) -> None
Attach a scalar DataFrame and invalidate dependent caches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Scalar table for the scan (typically from s-file). |
required |
append_paths
|
bool
|
If true, add device shot paths to dataframe. |
True
|
stem_override
|
Optional[dict[str, str]]
|
Optional |
None
|
Source code in geecs_data_utils/scan_data.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | |
list_columns ¶
list_columns() -> List[str]
List column names as strings (flattens MultiIndex columns if present).
Returns:
| Type | Description |
|---|---|
list of str
|
|
Source code in geecs_data_utils/scan_data.py
423 424 425 426 427 428 429 430 431 | |
find_cols ¶
find_cols(query: Union[str, Sequence[str]], *, mode: ColumnMatchMode = 'contains', case_sensitive: bool = False) -> List[str]
Flexible column search.
Wrapper for find_cols in geecs_data_utils/data/columns.py.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
Union[str, Sequence[str]]
|
String or list of strings to search for. |
required |
mode
|
ColumnMatchMode
|
Search mode: |
'contains'
|
case_sensitive
|
bool
|
If True, match with case sensitivity. |
False
|
Returns:
| Type | Description |
|---|---|
list of str
|
Matching column names (flattened form). May be empty. |
Source code in geecs_data_utils/scan_data.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
resolve_col ¶
resolve_col(spec: str, *, mode: ColumnMatchMode = 'contains', case_sensitive: bool = False, prefer_exact_ci: bool = True) -> str
Resolve a loose column spec to a single best column name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
str
|
User-provided spec (may be an alias or partial/regex). |
required |
mode
|
ColumnMatchMode
|
Matching strategy used by :meth: |
'contains'
|
case_sensitive
|
bool
|
If True, enforce case-sensitive matching for the chosen mode. |
False
|
prefer_exact_ci
|
bool
|
Prefer exact (case-insensitive) matches over substring/regex matches. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Selected column name. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no match is found. |
Source code in geecs_data_utils/scan_data.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
add_local_alias ¶
add_local_alias(alias: str, actual_col: str) -> None
Register a user-defined shorthand for a column name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias
|
str
|
Local shorthand (e.g., |
required |
actual_col
|
str
|
Full column name present in the DataFrame. |
required |
Source code in geecs_data_utils/scan_data.py
523 524 525 526 527 528 529 530 531 532 533 534 | |
set_binning_config ¶
set_binning_config(**updates) -> None
Update binning configuration and invalidate cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**updates
|
Fields to replace on the current :class: |
{}
|
Source code in geecs_data_utils/scan_data.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 | |
expected_paths_by_bin ¶
expected_paths_by_bin(device: str, *, variant: Optional[str] = None, bin_col: Optional[str] = None, dropna_paths: bool = True, exists_only: bool = False) -> Dict[Hashable, List[Path]]
Group expected image paths by the current bin definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
str
|
Device name (subfolder). |
required |
variant
|
Optional[str]
|
Optional variant suffix used when creating expected-path columns. |
None
|
bin_col
|
Optional[str]
|
Override the configured bin column for this call. |
None
|
dropna_paths
|
bool
|
If True, drop rows with missing path strings. |
True
|
exists_only
|
bool
|
If True, filter out paths that do not currently exist on disk. |
False
|
Returns:
| Type | Description |
|---|---|
dict[Hashable, list[Path]]
|
Mapping {bin_value -> [image paths]}. |
Source code in geecs_data_utils/scan_data.py
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 | |
reload_sfile ¶
reload_sfile() -> None
Re-read the analysis s-file into self.data_frame.
Notes
This is a thin alias for load_scalars(source='sfile') to make intent explicit.
Source code in geecs_data_utils/scan_data.py
1058 1059 1060 1061 1062 1063 1064 1065 1066 | |
copy_fresh_sfile_to_analysis ¶
copy_fresh_sfile_to_analysis() -> None
Replace the analysis s-file with the fresh copy from the scan folder.
Copies:
<scan>/scans/ScanDataScanNNN.txt → <scan>/analysis/../sNNN.txt
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the source s-file in |
Source code in geecs_data_utils/scan_data.py
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 | |
load_ecs_live_dump ¶
load_ecs_live_dump() -> ECSDump
Load and parse the ECS Live Dump file for this scan via ScanPaths.
Returns:
| Type | Description |
|---|---|
ECSDump
|
Parsed ECS dump structured by device name. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no ECS dump file is available for this scan. |
Source code in geecs_data_utils/scan_data.py
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 | |