Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Reasons for CLI

Krzysztof (Chris) Bernat edited this page Feb 23, 2017 · 15 revisions

Every now and the we ask our self the question. Do we (or better: does the user) need a CLI for the CCI Toolbox ? This page should summarize all argument pro and contra a CLI.

See also: Core Processing Requirements.

Using the CLI

$ cate set aero2007 load name=AEROSOL_ATSR2_ORAC_L3_V3.02_MONTHLY time_range=2007
$ cate set cloud2007 load name=CLOUD_L3S_MERGED_PHASE1_V1.0 time_range=2007
$ cate set cloud2007ga cate.ops.coregister master=aero2007 slave=cloud2007 method=nearest
$ cate set movie cate.ops.animated_map ds=aero2007,cloud2007ga mode=multiple
$ cate save movie file=movie.gif
$ cate set correlation cate.ops.pearson ds1=aero2007_sub ds2=cloud2007_sub mode=grid_map
$ cate save correlation.map file=grid_correlation.png
$ cate save correlation.stat file=correlation_statistics.txt

Using the Cate REPL

The alternative solution to having a CLI would be to use python for all user interaction. Instead of allowing the user to interact with the CCI Toolbox from the command line he first would have to launch a python (ectpython, it would automatically do the cate imports) REPL to interact with.

$ ectpython
> aero2007 = cate.load(name=AEROSOL_ATSR2_ORAC_L3_V3.02_MONTHLY, time_range=2007)
> cloud2007 = cate.load(name=CLOUD_L3S_MERGED_PHASE1_V1.0, time_range=2007)
> cloud2007ga = cate.ops.coregister(master=aero2007, slave=cloud2007, method=nearest)
> movie = cate.ops.animated_map(ds=[aero2007,cloud2007ga], mode=multiple)
> cate.save(movie,file=movie.gif)
> correlation = cate.ops.pearson(ds1=aero2007_sub, ds2=cloud2007_sub, mode=grid_map)
> cate.save(correlation.map, file=grid_correlation.png)
> cate.save(correlation.stat, file=correlation_statistics.txt)

Arguments why we need a CLI indead of a REPL

  • 👍 we control the syntax and the error message to the users. In case of the REPL we stick with the python syntax. Syntax errors are reported by the python parser. Especially for users without prior python knowledge this can be a problem.
  • 👍 The REPL make single command from the Shell complicated. (if you don't want to write a *.py file)
    $ ectpython -c "aero2007 = cate.load(name=AEROSOL_ATSR2_ORAC_L3_V3.02_MONTHLY, time_range=2007);cloud2007 = cate.load(name=CLOUD_L3S_MERGED_PHASE1_V1.0, time_range=2007); ..."
  • 👍 logging must happen within the individual operations. The CLI can handle this externally.
  • 👎 possible to use the power of python (libraries, control structures)
  • 👎 no parsing has to be developed, tested
  • 👎 rely on python documentation (searching for syntax errors)