cli
CLI module for gwframe.
call_operation ¶
call_operation(operation_func, input_files: list[Path], output_dir: Path | None, in_place: bool, **operation_kwargs) -> list[str]
Call an operation function, handling single-file output case.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_func
|
callable
|
Operation function from operations module |
required |
input_files
|
list[Path]
|
Input files to process |
required |
output_dir
|
Path or None
|
Output directory or file path |
required |
in_place
|
bool
|
Whether to modify in place |
required |
**operation_kwargs
|
Additional keyword arguments for operation_func |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
output_files |
list[str]
|
List of output file paths |
Source code in gwframe/cli.py
combine ¶
combine(input_sources: list[Path] = Argument(..., help='N source files or N source directories to combine (N >= 2)', exists=True), output_dir: Path = Option(..., '--output-dir', '-o', help='Output directory for combined files'), keep: list[str] | None = Option(None, '--keep', '-k', help='Only include these channels (can be specified multiple times)'), drop: list[str] | None = Option(None, '--drop', '-d', help='Exclude these channels (can be specified multiple times)'))
Combine channels from N sources covering the same time ranges.
Takes N files (covering the same time) or N directories (with matching frame sets) and merges their channels. All sources must be the same type.
Examples: gwframe combine file1.gwf file2.gwf -o output/ gwframe combine dir1/ dir2/ -o output/ --keep L1:STRAIN --keep L1:LSC gwframe combine dir1/ dir2/ -o output/ --drop L1:UNWANTED
Source code in gwframe/cli.py
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 287 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 | |
drop ¶
drop(input_paths: list[Path] = Argument(..., help='Input GWF file(s) or directory/directories to process', exists=True), output_dir: Path | None = Option(None, '--output-dir', '-o', help='Output directory or file for processed files'), channels: list[str] = Option(..., '--channel', '-c', help='Channel(s) to drop (can be specified multiple times)'), in_place: bool = Option(False, '--in-place', '-i', help='Modify files in place instead of creating new ones'), recursive: bool = Option(False, '--recursive', '-r', help='Recurse into subdirectories when processing directories'))
Remove specified channels from frame files.
Accepts files or directories.
Examples: gwframe drop input.gwf -o output.gwf -c L1:UNWANTED_CHANNEL gwframe drop input.gwf --in-place -c L1:UNWANTED_CHANNEL gwframe drop data/ -o output/ -c L1:CHAN1 -c L1:CHAN2
Source code in gwframe/cli.py
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 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 391 392 393 394 395 396 397 398 399 400 401 402 | |
expand_paths ¶
Expand paths to list of files, handling both files and directories.
Directories are searched for *.gwf files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
list[Path]
|
List of file or directory paths |
required |
recursive
|
bool
|
If True, recurse into subdirectories (default: False) |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
files |
list[Path]
|
Expanded list of file paths |
Source code in gwframe/cli.py
impute ¶
impute(input_paths: list[Path] = Argument(..., help='Input GWF file(s) or directory/directories to process', exists=True), output_dir: Path | None = Option(None, '--output-dir', '-o', help='Output directory or file for processed files'), replace_value: float = Option(float('nan'), '--replace-value', '-r', help='Value to replace (default: NaN)'), fill_value: float = Option(0.0, '--fill-value', '-f', help='Value to use for replacement (will be cast to appropriate dtype)'), channels: list[str] | None = Option(None, '--channel', '-c', help='Channel(s) to impute (can be specified multiple times)'), in_place: bool = Option(False, '--in-place', '-i', help='Modify files in place instead of creating new ones'), recursive: bool = Option(False, '--recursive', help='Recurse into subdirectories when processing directories'))
Replace specific values in frame file channels with a fill value.
Accepts files or directories.
Examples: gwframe impute input.gwf -o output.gwf gwframe impute input.gwf --in-place --fill-value 0.0 --channel L1:STRAIN gwframe impute data/ -o output/ --replace-value -999.0 --fill-value 0.0
Source code in gwframe/cli.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 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 | |
inspect ¶
inspect(input_path: Path = Argument(..., help='GWF file to inspect', exists=True), verbose: int = Option(0, '--verbose', '-v', count=True, help='Increase verbosity (-v channels, -vv frames, -vvv per-channel detail)'))
Show metadata and channel information for a GWF file.
Verbosity levels:
(default) File summary: GPS range, frame/channel counts, compression
-v Add channel listing with types (adc/proc/sim)
-vv Add per-frame table
-vvv Add per-channel detail (sample rate, dtype, units, samples)
Examples: gwframe inspect data.gwf gwframe inspect -v data.gwf gwframe inspect -vvv data.gwf
Source code in gwframe/cli.py
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 | |
main ¶
recompress ¶
recompress(input_paths: list[Path] = Argument(..., help='Input GWF file(s) or directory/directories to process', exists=True), output_dir: Path | None = Option(None, '--output-dir', '-o', help='Output directory or file for processed files'), compression: str = Option('ZERO_SUPPRESS_OTHERWISE_GZIP', '--compression', '-c', case_sensitive=False, help='Compression type (e.g., RAW, GZIP, DIFF_GZIP)'), level: int = Option(6, '--level', '-l', help='Compression level (0-9)', min=0, max=9), in_place: bool = Option(False, '--in-place', '-i', help='Modify files in place instead of creating new ones'), recursive: bool = Option(False, '--recursive', '-r', help='Recurse into subdirectories when processing directories'))
Rewrite frame files with different compression settings.
Accepts files or directories.
Examples: gwframe recompress input.gwf -o output.gwf -c GZIP -l 9 gwframe recompress input.gwf --in-place -c GZIP -l 9 gwframe recompress data/ -o output/ -c RAW
Source code in gwframe/cli.py
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 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 808 809 810 811 812 813 814 815 816 817 818 819 820 | |
rename ¶
rename(input_paths: list[Path] = Argument(..., help='Input GWF file(s) or directory/directories to process', exists=True), output_dir: Path | None = Option(None, '--output-dir', '-o', help='Output directory or file for processed files'), channel_map: list[str] = Option(..., '--map', '-m', help='Channel mapping in format OLD=>NEW (can be specified multiple times)'), in_place: bool = Option(False, '--in-place', '-i', help='Modify files in place instead of creating new ones'), recursive: bool = Option(False, '--recursive', '-r', help='Recurse into subdirectories when processing directories'))
Rename channels in frame files.
Accepts files or directories.
Examples: gwframe rename input.gwf -o output.gwf -m "L1:OLD_CHAN=>L1:NEW_CHAN" gwframe rename input.gwf -o output/ -m "L1:OLD_CHAN=>L1:NEW_CHAN" gwframe rename input.gwf --in-place -m "L1:OLD_CHAN=>L1:NEW_CHAN" gwframe rename data/ -o output/ -m "L1:OLD_CHAN=>L1:NEW_CHAN" gwframe rename data/*.gwf -o output/ -m "L1:CHAN1=>L1:NEW1" -m "L1:CHAN2=>L1:NEW2"
Source code in gwframe/cli.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 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 | |
replace ¶
replace(base_paths: list[Path] = Argument(..., help='Base GWF file(s) or directory/directories', exists=True), update_paths: list[Path] = Option(..., '--update', '-u', help='GWF file(s) or directory/directories containing updated channel data', exists=True), output_dir: Path = Option(..., '--output-dir', '-o', help='Output directory for processed files'), channels: list[str] | None = Option(None, '--channel', '-c', help='Channel(s) to replace (if not specified, replaces all)'), recursive: bool = Option(False, '--recursive', '-r', help='Recurse into subdirectories when processing directories'))
Replace data in channels with updated versions from another frame file.
Accepts files or directories.
Examples: gwframe replace base.gwf --update updated.gwf -o output/ -c L1:STRAIN gwframe replace base_dir/ --update update_dir/ -o output/ gwframe replace data/.gwf --update updates/.gwf -o output/ --recursive
Source code in gwframe/cli.py
resize ¶
resize(input_paths: list[Path] = Argument(..., help='Input GWF file(s) or directory/directories to process', exists=True), output_dir: Path | None = Option(None, '--output-dir', '-o', help='Output directory or file for processed files'), duration: float = Option(..., '--duration', '-d', help='Target frame duration in seconds'), in_place: bool = Option(False, '--in-place', '-i', help='Modify files in place instead of creating new ones'), recursive: bool = Option(False, '--recursive', '-r', help='Recurse into subdirectories when processing directories'))
Resize frames to a different duration (e.g., 64s to 4s).
Accepts files or directories.
Examples: gwframe resize input.gwf -o output.gwf -d 4.0 gwframe resize input.gwf --in-place -d 4.0 gwframe resize data/ -o output/ -d 4.0
Source code in gwframe/cli.py
select ¶
select(input_paths: list[Path] = Argument(..., help='Input GWF file(s) or directory/directories to process', exists=True), output_dir: Path | None = Option(None, '--output-dir', '-o', help='Output directory or file for processed files'), channels: list[str] = Option(..., '--channel', '-c', help='Channel(s) to keep (can be specified multiple times)'), in_place: bool = Option(False, '--in-place', '-i', help='Modify files in place instead of creating new ones'), recursive: bool = Option(False, '--recursive', '-r', help='Recurse into subdirectories when processing directories'))
Keep only specified channels in frame files, removing all others.
Accepts files or directories.
Examples: gwframe select input.gwf -o output.gwf -c L1:STRAIN gwframe select input.gwf --in-place -c L1:STRAIN gwframe select data/ -o output/ -c L1:CHAN1 -c L1:CHAN2
Source code in gwframe/cli.py
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 442 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 476 477 478 479 480 | |
validate_output_options ¶
Validate that output options are correctly specified.