Commit ccf9d774 authored by Sean Leavey's avatar Sean Leavey

Add print noise and frequency command support

parent 27c81542
...@@ -57,6 +57,12 @@ from .finesse import kat as katparser ...@@ -57,6 +57,12 @@ from .finesse import kat as katparser
"switches off retracing even if it normally would be done.") "switches off retracing even if it normally would be done.")
@click.option("--deriv-h", type=float, help="Step size for numerical differentiation.") @click.option("--deriv-h", type=float, help="Step size for numerical differentiation.")
@click.option("--lambda0", type=str, help="Reference wavelength (m). Supports SI prefixes.") @click.option("--lambda0", type=str, help="Reference wavelength (m). Supports SI prefixes.")
@click.option("--print-frequencies", is_flag=True, default=False,
help="Print a table listing all the frequencies used in the simulation: carriers, "
"modulation sidebands and signal/quantum sidebands.")
@click.option("--print-noises", is_flag=True, default=False,
help="Print a list of all the quantum noise sources being considered in the "
"simulation and at which components and nodes it is present.")
@click.option("--ignore-block", "ignored_blocks", multiple=True, @click.option("--ignore-block", "ignored_blocks", multiple=True,
help="Ignore the specified block. Can be specified multiple times.") help="Ignore the specified block. Can be specified multiple times.")
@click.option("--plot/--no-plot", default=True, show_default=True, @click.option("--plot/--no-plot", default=True, show_default=True,
...@@ -73,8 +79,8 @@ from .finesse import kat as katparser ...@@ -73,8 +79,8 @@ from .finesse import kat as katparser
"executable. If not specified, the environment variable FINESSE_DIR is used.") "executable. If not specified, the environment variable FINESSE_DIR is used.")
@click.version_option(version=__version__, prog_name="Pykat") @click.version_option(version=__version__, prog_name="Pykat")
def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, powers, maxtem, phase, def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, powers, maxtem, phase,
retrace, deriv_h, lambda0, ignored_blocks, plot, save_figure, display_graph, save_input, retrace, deriv_h, lambda0, print_frequencies, print_noises, ignored_blocks, plot,
save_output, finesse_dir): save_figure, display_graph, save_input, save_output, finesse_dir):
"""Base CLI command group""" """Base CLI command group"""
if finesse_dir is None: if finesse_dir is None:
# Use default as required by kat object. # Use default as required by kat object.
...@@ -93,6 +99,9 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, powers, m ...@@ -93,6 +99,9 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, powers, m
nodegraph.view_pdf() nodegraph.view_pdf()
if simulate: if simulate:
# Default flag for showing simulation output. Overridden below as necessary.
output_to_show = False
if xstart is not None or xstop is not None or xsteps is not None or xscale is not None: if xstart is not None or xstop is not None or xsteps is not None or xscale is not None:
if not has_xaxis: if not has_xaxis:
click.echo("Limits can only be overridden when an xaxis is defined in FILE and " click.echo("Limits can only be overridden when an xaxis is defined in FILE and "
...@@ -132,6 +141,12 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, powers, m ...@@ -132,6 +141,12 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, powers, m
kat.deriv_h = deriv_h kat.deriv_h = deriv_h
if lambda0 is not None: if lambda0 is not None:
kat.lambda0 = lambda0 kat.lambda0 = lambda0
if print_frequencies:
kat.parse("frequency")
output_to_show = True
if print_noises:
kat.parse("printnoises")
output_to_show = True
if trace: if trace:
traceval = 0 traceval = 0
...@@ -143,6 +158,7 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, powers, m ...@@ -143,6 +158,7 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, powers, m
for tracetype in trace: for tracetype in trace:
traceval |= traceints[tracetype] traceval |= traceints[tracetype]
kat.trace = traceval kat.trace = traceval
output_to_show = True
if powers: if powers:
powerval = 0 powerval = 0
...@@ -150,13 +166,14 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, powers, m ...@@ -150,13 +166,14 @@ def cli(file, simulate, xstart, xstop, xsteps, xscale, noxaxis, trace, powers, m
for powertype in powers: for powertype in powers:
powerval |= powerints[powertype] powerval |= powerints[powertype]
kat.parse("powers %i" % powerval) kat.parse("powers %i" % powerval)
output_to_show = True
results = kat.run(save_output=save_output, save_kat=save_input) results = kat.run(save_output=save_output, save_kat=save_input)
if (kat.trace or powers) and results.rundata: if output_to_show and results.rundata:
click.echo(results.rundata) click.echo(results.rundata)
if has_xaxis and (plot or save_figure is not None): if has_xaxis and (plot or save_figure is not None):
results.plot(show=plot, filename=save_figure) results.plot(show=plot, filename=save_figure)
elif not kat.trace and not powers and not display_graph: elif not output_to_show and not display_graph:
click.echo("No output requested.") 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