Skip to content

Commit

Permalink
Implement command-line interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nollety authored Jun 14, 2022
1 parent 70801dd commit 92ccb3a
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions src/ussa1976/__main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,59 @@
"""Command-line interface."""
import click
import numpy as np

from .core import compute


@click.command()
@click.option(
"--zstart",
"-z",
help="Start altitude [m]",
default=0.0,
show_default=True,
type=float,
)
@click.option(
"--zstop",
"-Z",
help="Stop altitude [m]",
default=1000000.0,
show_default=True,
type=float,
)
@click.option(
"--znum",
"-n",
help="Number of altitude points",
default=1001,
show_default=True,
type=int,
)
@click.option(
"--filename",
"-f",
help="Output file name",
default="ussa1976.nc",
show_default=True,
type=click.Path(writable=True),
)
@click.version_option()
def main() -> None:
"""Ussa1976."""
def main(
zstart: float,
zstop: float,
znum: int,
filename: str,
) -> None:
"""Compute the U.S. Standard Atmosphere 1976."""
click.echo(
f"Computing U.S. Standard Atmosphere 1976 between {zstart} and "
f"{zstop} meter on {znum} altitude points."
)
z = np.linspace(zstart, zstop, znum)
ds = compute(z=z)
click.echo(f"Writing results in {filename}")
ds.to_netcdf(filename)


if __name__ == "__main__":
Expand Down

0 comments on commit 92ccb3a

Please sign in to comment.