Skip to content

Rework of gwpy.cli module to reduce complexity

Duncan Macleod requested to merge github/fork/duncanmmacleod/cli-args into develop

This PR reworks the gwpy.cli module and its documentation with the following goals

  • make it more modular
  • reduce complexity

@areeda's original system is intact here, I've just refactored a number of the internals to use multiple inheritance.

The code is backwards compatible.

The full command line help for products is now easier to read, mainly thanks to using argument groups:

$ gwpy-plot timeseries --help
usage: gwpy-plot timeseries [-h] [-v] [-s] --chan CHAN [CHAN ...]
                            [--start START [START ...]] [--duration DURATION]
                            [-c FRAMECACHE | -n HOSTNAME | --frametype FRAMETYPE]
                            [--highpass HIGHPASS] [--lowpass LOWPASS]
                            [--notch [NOTCH [NOTCH ...]]] [-g WxH] [--dpi DPI]
                            [--interactive] [--title TITLE]
                            [--suptitle SUPTITLE] [--out OUT]
                            [--legend [LEGEND [LEGEND ...]]] [--nolegend]
                            [--nogrid] [--style FILE] [--xlabel XLABEL]
                            [--xmin XMIN] [--xmax XMAX]
                            [--xscale XSCALE | --logx] [--epoch EPOCH]
                            [--ylabel YLABEL] [--ymin YMIN] [--ymax YMAX]
                            [--yscale YSCALE | --logy]

Help options:
  -h, --help            show this help message and exit

Verbosity options:
  -v, --verbose         increase verbose output (default: 1)
  -s, --silent          show only fatal errors (default: False)

Data options:
  What data to load

  --chan CHAN [CHAN ...]
                        channels to load (default: None)
  --start START [START ...]
                        Starting GPS times (required) (default: None)
  --duration DURATION   Duration (seconds) [10] (default: 10)

Data source options:
  Where to get the data

  -c FRAMECACHE, --framecache FRAMECACHE
                        read data from cache (default: None)
  -n HOSTNAME, --nds2-server HOSTNAME
                        name of nds2 server to use, default is to try all of
                        them (default: None)
  --frametype FRAMETYPE
                        GWF frametype to read from (default: None)

Signal processing options:
  What to do with the data before plotting

  --highpass HIGHPASS   Frequency for highpass filter (default: None)
  --lowpass LOWPASS     Frequency for lowpass filter (default: None)
  --notch [NOTCH [NOTCH ...]]
                        Frequency for notch (can give multiple) (default:
                        None)

Plot options:
  -g WxH, --geometry WxH
                        size of resulting image (default: 1200x600)
  --dpi DPI             dots-per-inch for figure (default: 100.0)
  --interactive         when running from ipython allows experimentation
                        (default: False)
  --title TITLE         One or more title lines (default: None)
  --suptitle SUPTITLE   1st title line (larger than the others) (default:
                        None)
  --out OUT             output filename (default: gwpy.png)
  --legend [LEGEND [LEGEND ...]]
                        strings to match data files (default: None)
  --nolegend            do not display legend (default: False)
  --nogrid              do not display grid lines (default: False)
  --style FILE          path to custom matplotlib style sheet, see
                        http://matplotlib.org/users/style_sheets.html#style-
                        sheets for details of how to write one (default: None)

X axis options:
  --xlabel XLABEL       X axis label (default: None)
  --xmin XMIN           min value for X axis (default: None)
  --xmax XMAX           max value for X axis (default: None)
  --xscale XSCALE       scale for X axis (default: None)
  --logx                use logarithmic X axis (default: None)
  --epoch EPOCH         center X axis on this GPS time (default: None)

Y axis options:
  --ylabel YLABEL       Y axis label (default: None)
  --ymin YMIN           min value for Y axis (default: None)
  --ymax YMAX           max value for Y axis (default: None)
  --yscale YSCALE       scale for Y axis (default: None)
  --logy                use logarithmic Y axis (default: None)

The documentation has also been pared back a bit, mainly to make it easier to maintain between changes, and the examples updated to use mainly open data release GPS times.

Merge request reports