lunar_toolkit.tools
¶
Find and run ISIS / ASP / GDAL tools; keyword options → flags; dry runs.
ToolError(message, returncode=None, stdout=None, stderr=None)
¶
Bases: RuntimeError
An external tool is missing or exited with a non-zero status.
find_tool(name)
¶
Path of executable name, or None when it cannot be found.
tool_env(tool_path)
¶
Environment for tool_path as a conda activation would set it.
Unset variables come from the env's conda env config vars (stored in
conda-meta/state), else ISISROOT, ISISDATA, PROJ_DATA and
GDAL_DATA default to the tool's environment prefix, so tools also run
from an env that was not activated (ASP and GDAL fail or crash without them).
format_command(argv)
¶
argv as one command line, quoted for the platform's shell.
dry_run()
¶
Record commands instead of running them.
Yields the list the commands are appended to (tool name first)::
with dry_run() as cmds:
pipeline.run(...)
for c in cmds:
print(format_command(c))
record_commands()
¶
Log the commands run executes: argv, cwd, started (Unix time),
seconds, returncode.
reuse_existing(path, force=False)
¶
Whether a step can be skipped because its output path already exists.
| Parameters: |
|
|---|
| Returns: |
|
|---|
run(tool, args=(), *, cwd=None, capture=False, check=True)
¶
Run tool with args; raise ToolError on failure.
With capture=True stdout/stderr are returned instead of streamed.
asp_options(options)
¶
Keyword options → ASP-style flags.
tr=5 → --tr 5; save_sparingly=True → --save-sparingly;
False / None are dropped; tuples and lists expand to several
arguments (t_projwin=(x0, y0, x1, y1)) while a string with spaces stays
one argument (remove_outliers_params="75 3 100 100"). Underscores
become dashes except in GDAL-style t_* options (--t_srs); single
letters get one dash (o="run/run" → -o run/run).
gdal_options(options)
¶
Keyword options → GDAL-style flags (a_nodata=0 → -a_nodata 0).
isis_params(params)
¶
Keyword parameters → ISIS key=value arguments.
A trailing underscore is dropped (from_=a.cub → from=a.cub),
booleans become true / false and None is skipped.