Quickly plotting Finesse output with Pykat

In [1]:
import pykat

pykat.init_pykat_plotting()

from pykat import finesse

code = """
l l1 1 0 0 n1 
s s1 10 1 n1 n2
m m1 0.9 0.1 0 n2 n3
s s2 10 1 n3 n4
m m2 0.91 0.09 0 n4 n5

ad refl 0 n2
ad circ 0 n4
ad tran 0 n5
pd pd_cav n3

noplot refl

xaxis m2 phi lin 0 360 720
yaxis abs:deg
"""

kat = finesse.kat()
kat.parseCommands(code)

out = kat.run()
                                              ..-
    PyKat 0.8.1           _                  '(
                          \`.|\.__...-""""-_." )
       ..+-----.._        /  ' `            .-'
   . '            `:      7/* _/._\    \   (
  (        '::;;+;;:      `-"' =" /,`"" `) /
  L.        \`:::a:f            c_/     n_'
  ..`--...___`.  .    ,  
   `^-....____:   +.      www.gwoptics.org/pykat

--------------------------------------------------------------
Running kat - Started at 2015-12-02 12:12:38.512326

Finished in 0:00:00.045975
In [2]:
help(out.plot)
Help on method plot in module pykat.finesse:

plot(detectors=None, filename=None, show=True, yaxis=None, legend=True, loc=0, title=None) method of pykat.finesse.katRun instance
    This will generate a plot for the output data of this particular pykat run.
    It will attempt to generate a plot that shows all the various traces and plots
    by default for quick viewing of the data. Similar to that which would be
    generated by running the Finesse file from the command line.
    
    There are some additional keyword options to customise the plot output slightly:
    
        detectors: a list of detectors that you want to plot
        filename: providing a filename here will save the plot to a file. The format is given by the extension provided.
        show: True | False - whether to display the plot or not
        yaxis: Set the Finesse yaxis command to base the plot on. By default the original one will be used.
        legend: True | False - whether to include a legend
        loc: Location value for the legend, the usual matplotlib one.
        title: Provide a title for the plot if required.

In [3]:
# Plot everything using default settings of the Finesse file
fig = out.plot()
In [4]:
fig = out.plot(yaxis="log abs")
In [5]:
fig = out.plot(detectors=["refl","tran"],
               yaxis="log abs:deg")
In [6]:
fig = out.plot(filename="test_plot.pdf",
               title="Run with some setting blah",
               yaxis="log abs:deg",
               legend=False)