Commit 8128076b authored by Daniel Brown's avatar Daniel Brown

Merge branch 'feature/cli' of git.ligo.org:finesse/pykat into feature/cli

parents 85871d20 430d2a14
......@@ -41,6 +41,13 @@ from .finesse import kat as katparser
"'modechanges': mode matching parameter changes during calculations, "
"'nodes': nodes found during cavity tracing, "
"'all': all trace results.")
@click.option("--powers", type=click.Choice(["dc", "carrier", "tem00"]),
multiple=True, help="Show powers at each node in the interferometer. This "
"option can be specified multiple times. The following "
"values are supported: "
"'dc': list dc powers, "
"'carrier': list powers in the f=0 fields, "
"'tem00': list powers in the TEM00 mode.")
@click.option("--maxtem", type=str, help="Maximum transverse electric mode. Can be either "
"an integer or 'off'.")
@click.option("--ignore-block", "ignored_blocks", multiple=True,
......@@ -51,8 +58,8 @@ from .finesse import kat as katparser
help="Save image of figure to file.")
@click.option("--display-graph", is_flag=True, help="Generate and display model node graph.")
@click.version_option(version=__version__, prog_name="Pykat")
def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, maxtem, ignored_blocks,
plot, save_figure, display_graph):
def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, powers, maxtem,
ignored_blocks, plot, save_figure, display_graph):
"""Base CLI command group"""
kat = katparser()
kat.load(file.name)
......@@ -110,13 +117,20 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, maxtem, i
for tracetype in trace:
traceval |= traceints[tracetype]
kat.trace = traceval
if powers:
powerval = 0
powerints = {"dc": 1, "carrier": 2, "tem00": 4}
for powertype in powers:
powerval |= powerints[powertype]
kat.parse("powers %i" % powerval)
results = kat.run()
if kat.trace:
if kat.trace or powers:
click.echo(results.stdout)
if has_xaxis and (plot or save_figure is not None):
results.plot(show=plot, filename=save_figure)
elif not kat.trace and not display_graph:
elif not kat.trace and not powers and not display_graph:
click.echo("No output requested.")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment