cli
Command Line Interface
Command line interface tool for SCT.
Design choices
The root command group is a LazyGroup (a RichGroup subclass) that
defers subcommand loading until invocation. This keeps import sct,
sct --version, sct --help and sct info fast, without importing the
scientific stack (perseo, numpy, …) or any analysis implementation.
Subcommands are still written as typer.Typer apps. The bridge function
_typer_to_click converts them to click.Command objects at load time so
they plug into the lazy group.
This avoids a rewrite of every subcommand while enabling deferred imports.
Note
typer.Typer does not expose a hook to intercept subcommand resolution:
commands are registered eagerly via add_typer(). Subclassing
RichGroup (which inherits from click.Group) gives
get_command() / list_commands() override points, which is what makes
true lazy loading possible.
Attributes
Classes
LazyGroup
Bases: RichGroup
A RichGroup whose subcommands are resolved (and imported) on demand.
typer.Typer registers subcommands eagerly via add_typer(), which
defeats lazy loading. By subclassing RichGroup (which provides the
rich-click help formatting) we override get_command() and
list_commands() to resolve subcommands only when they are actually
invoked or listed in help output.
get_command() returns a _DeferredCommand stub that holds only the
subcommand's name and short_help; the actual typer.Typer-based
command object (and all its imports) is materialized on first invocation.
invoke() also bridges Typer-forked exception types (Exit,
ClickException) back to click's own exceptions so that
Command.main() handles them correctly.
Attributes
Methods:
__init__
invoke
typer vendors its own copy of click internals (typer._click),
so its Exit and ClickException classes are distinct from
click.exceptions.Exit / click.exceptions.ClickException.
LazyGroup.invoke catches the Typer variants and re-raises them as the
corresponding click types so that Command.main() handles them correctly
in both CLI and test usage.
Functions:
Common utilities for command line implementations.
Attributes
RadiometricQuantityOption
module-attribute
ExternalCorrectionInputProductOption
module-attribute
Functions:
logging_to_file
Context manager to safely add a file handler to sct logger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | None
|
path to log file to be used, if None, no file handler is added |
required |
log_elapsed_time
Decorate function to log elapsed time with the given name.
graceful_exit
Decorate function to gracefully log and exit in case of errors.
CLI Utilities
Command Line Interface auxiliary utilities.
Attributes
Classes
Functions:
convert_rosamond_csv
convert_rosamond_csv(source: RosamondSourceOption, date: DateOption, output_directory: OutputDirectoryOption = None) -> None
Convert downloaded Rosamond Point Targets dataset .csv file to SCT compliant .csv file.
download_ionex_tec_maps
download_ionex_tec_maps(date: DateOption, analysis_center: AnalysisCenterOption, email: EmailOption, output_directory: OutputDirectoryOption) -> None
Download IONEX TEC maps from NASA/CDDIS archive.
download_tropospheric_vmf3_maps
download_tropospheric_vmf3_maps(date: DateOption, resolution: ResolutionOption, output_directory: OutputDirectoryOption) -> None
Download VMF3 Tropospheric Products.
convert_sarcalnet_json_to_csv
convert_sarcalnet_json_to_csv(source: SARCalNetSourceOption, product_date: ProductDateOption = None, output_directory: OutputDirectoryOption = None) -> None
Convert downloaded SARCalNet survey .json file to SCT compliant .csv file. Product date can be provided to select the closest survey available, otherwise the latest survey is selected.