Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Command line interface #12

Closed
arkottke opened this issue Feb 16, 2021 · 3 comments · Fixed by #15
Closed

Feature Request: Command line interface #12

arkottke opened this issue Feb 16, 2021 · 3 comments · Fixed by #15

Comments

@arkottke
Copy link

It would be nice to be able to run the program from the command line for a list of files. This is the way that I have implemented by own HVSR calculation software. The following is an example of my command line interface:

usage: H/V Calculator [-h] [--version] [-a] [-c CONFIG] [-m {both,welch,sesame,raw_only}]
                      [-p {auto,manual}]
                      [inputs [inputs ...]]

Calculator for V/H ratios from mini-seed

positional arguments:
  inputs                Input file(s) to read

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -a, --all             Compute all usable
  -c CONFIG, --config CONFIG
                        Specify configuration
  -m {both,welch,sesame,raw_only}, --method {both,welch,sesame,raw_only}
                        Method for computing H/V ratio
  -p {auto,manual}, --peakselect {auto,manual}
                        Method for selecting the peak

A few things:

  • I would also add an argument for the output directory, and then a sub-directory would be based on the input file name.
  • In each output directory, standard plots and output files are created.
  • A configuration file can be specified so that an analysis is repeated. The configuration is also saved to the output to document that calculation.

I think such an interface would help in bulk processing of recordings. Additionally, interactively selecting frequency ranges could be done using matplotlib GUI support.

@jpvantassel
Copy link
Owner

jpvantassel commented Mar 21, 2021

I think this is a good idea and something that should be fairly straightforward to implement. Thanks for suggesting it!

My thinking on this is to:

  1. Create a new module called cli.py.
  2. Create several functions in cli.py which perform similar functions to the example notebooks (e.g., simple_hvsrpy_interface.ipynb).
  3. Use click or some other Python package to decorate these functions and handle the CLI details.
  4. Allow the CLI to be accessed as an entry_point to the hvsrpy package.

@jpvantassel jpvantassel changed the title Feature Request: Command line execution Feature Request: Command line interface Mar 21, 2021
@arkottke
Copy link
Author

That's exactly what I was thinking. I have read some very good things about click. As far as configuration of the calculation, I used JSON, but it doesn't have the ability to provide comments which is a significant drawback. Two alternatives that you might consider are json5 or toml.

@jpvantassel
Copy link
Owner

Update: A preliminary implementation of a command line interface has been added to the dev branch with commit 8505ff. My intent is make a release candidate for v1.0.0 which includes the CLI, among other changes, in the next week or two. In the meantime the CLI is functional, although not guaranteed to be 100% debugged. Feedback now (or after the RC comes out) is appreciated.

@jpvantassel jpvantassel linked a pull request Jul 21, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants