-
Notifications
You must be signed in to change notification settings - Fork 261
How to add a new program to mintpy
Notes on how to add a new program to mintpy
, using dem_error.py
as an example:
-
In
src/mintpy/cli
directory, create a scriptdem_error.py
for the command line interface (CLI), which usually includes the following functions:-
create_parser()
to create a CLI parser, with help message and example usage -
[optional]
read_template2inps()
to read the template options into a Namespace objectinps
-
cmd_line_parse()
to call the above two functions to parse the command line inputs, and/or apply extra checkings and default values (if it's not supported natively viaargparse
yet), in the order of:-
parse [--> import --> check --> default]
.
-
-
main()
to call both the CLI (cmd_line_parse
) and core functions (e.g., frommintpy.dem_error
), in the order of:parse --> import [--> run or skip] --> run
-
The idea is to import the basic (and fast) sub-module mintpy.utils.arg_utils
at the top of the script, and only import other (heavy) sub-modules if needed after parsing. Check mintpy.cli.dem_error.py
as an example.
-
In
src/mintpy
directory, create a scriptdem_error.py
for the core functionalities, with an overall function (e.g,correct_dem_error(inps)
) to be called by the CLI main function (e.g.,mintpy.cli.dem_error.main()
), and/or arun_or_skip()
function. Checkmintpy.dem_error.py
as an example. -
In
src/mintpy/__main__.py
file, add a sub-parser function for your script, and call it in the main parser function, so that it's available asmintpy dem_error
in the command line. -
In
setup.py
file, add an entry-point for your script, so that it's available asdem_error.py
in the command line.