API Functions & Classes

Availability

The availability of a number of functions and classes in spectra-ui depend on the operation modes, which are summarized below.

Functions and classes whose availability depends on the operation mode. Those that are not listed here are available/effective in any modes.

Class/Scope

Functions/Methods

GUI/Interactive Mode

CLI Mode

global

DisplayParameters()

ConfigurePlot()

ShowPreProcessor()

ShowPostProcessor()

FitWindow()

ExpandWindow()

MoveWindowX()

MoveWindowY()

MoveWindowXY()

PreProcess

Export()

PlotScale()

PlotRange()

LinePlot()

SymbolPlot()

ContourPlot()

SurfacePlot()

DuplicatePlot()

CLI

all methods

PostProcessCLI

all methods

Usage

Usage of the API functions available in spectra-ui are given below.

spectra.Start(**kwargs)

Launch SPECTRA with options

Parameters:
  • kwargs (dict) – keyword argument to specify the the launch options

  • kwargs["src"] (str) – specify the location of the source files; “r” = remote (default), “l” = local

  • kwargs["browser"] (str) – specify the browser; “c” = Chrome (default), “e” = Edge, “f” = Firefox, “s” = Safari

  • kwargs["mode"] (str) – specify the operation mode; “g” = GUI, “i” = interactive, “c” = CLI

  • kwargs["file"] (str) – path to the parameter file to open (default = “”)

Returns:

None

Examples

>>> spectra.Start(src="l", file="./sample.json")
# open the source files in the local repository with the Chrome browser,
# with the parameter file "sample.json"
spectra.Exit()

Finish SPECTRA and exit

Parameters:

None

Returns:

None

spectra.Open(file)

Opens a SPECTRA parameter file.

Parameters:

file (str) – path to the parameter file

Returns:

None

Examples

>>> spectra.Open("./sample.json")
# open a parameter file "sample.json" in the current directory
spectra.Save(file=None)

Save the current parameters and configurations in a JSON file.

Parameters:

file (str) – path to the parameter file to save; if omitted, that specified in the former Open() command is used

Returns:

None

Examples

>>> spectra.Save("./sample2.json")
# save the parameters in a new file "sample2.json" in the current directory
>>> spectra.Save()
# save the parameters in the file specified in the former Open() command
spectra.Set(category, label, value)

Set a parameter or an option

Parameters:
  • category (string) – specify the category of the target parameter, should be either of “acc” (Accelerator), “src” (Light Source), “config” (Configurations) or “outfile” (Output File)

  • label (string) – name of the target parameter

  • value (any) – value to be set

Returns:

None

Examples

>>> spectra.Set("acc", "eGeV", 6.0)
# set the electron energy to 6.0 GeV

Note

Refer to the keyword list for the name of the target parameter.

spectra.Get(category, label)

Get a value of a parameter automatically evaluated and being shown in the GUI

Parameters:
  • category (string) – specify the category of the target parameter, should be either of “acc” (Accelerator), “src” (Light Source), “config” (Configurations) or “outfile” (Output File)

  • label (string) – name of the target parameter

Returns:

value of the specified parameter

Examples

>>> spectra.Get("src", "e1st")
# Get the fundamental photon energy of undulator radiation

Note

Refer to the keyword list for the name of the target parameter.

spectra.LoadWigner4CMD(file)

Load an output file generated in the former calculation (2D or 4D Wigner function) to perform the CMD (coherent mode decomposition).

Parameters:

file (str) – path to the output file

Returns:

None

Examples

>>> spectra.LoadWigner4CMD("./output.json") # load the output file "output.json" in the current directory
spectra.LoadWigner4Propagation(file)

Load an output file generated in the former calculation (2D or 4D Wigner function) to perform the wavefront propagation.

Parameters:

file (str) – path to the output file

Returns:

None

Examples

>>> spectra.LoadWigner4Propagation("./output.json") # load the output file "output.json" in the current directory
spectra.LoadCMD(file)

Load an output file generated in the former calculation (CMD) to perform the modal analysis using the CMD result.

Parameters:

file (str) – path to the output file

Returns:

None

Examples

>>> spectra.LoadCMD("./output.json") # load the output file "output.json" in the current directory
spectra.LoadBunchFactor(file)

Load an output file generated in the former calculation (coherent radiation with the FEL mode) to reuse the evolution of the bunch factor.

Parameters:

file (str) – path to the output file

Returns:

None

Examples

>>> spectra.LoadBunchFactor("./output.json") # load the output file "output.json" in the current directory
spectra.ShowMain()

Switch the tabbled panel to “Main”.

Parameters:

None

Returns:

None

spectra.DisplayParameters(*categs, **kwargs)

Display the parameters and configurations currently in memory as an HTML file in the CLI mode. Not available only in the GUI and interactive modes.

Parameters:
  • categs (variable length list) – list of strings to specify the parameter category: “acc”, “src” and “config”; if omitted, all categories are shown

  • kwargs (dict) – keyword argument to specify the font; if omitted, “arial 12px” is used

  • kwargs["fontfamily"] (str) – family (“arial”, etc.)

  • kwargs["fontsize"] (str) – size (“12px”, etc.)

Returns:

None

Examples

>>> spectra.DisplayParameters("acc", "src")
# displays the parameters in "Accelerator" and "Light Source" categories.
spectra.ConfigurePlot(**kwargs)

Set the configurations of the plot to be generated by post-processing or pre-processing in the CLI mode. Not available only in the GUI and interactive modes.

Parameters:

kwargs (dict) – keyword argument to specify the plot configuration; refer to Note below

Returns:

None

Examples

>>> spectra.ConfigurePlot(xscale="Logarithmic", yscale="Logarithmic")
>>> spectra.PostProcess.Plot(data="sample1", item="Flux Density")
# plot the spectra of flux density in "sample1" using a log-log scale

Note

Refer to the keyword list for available keys and values.

spectra.SelectBL(bl)

Select the beamline parameter set.

Parameters:

bl – name of the target parameter set

Returns:

None

Examples

>>> spectra.SelectBL("BM-BL") # select the parameter set "BM-BL"
spectra.SelectAcc(acc)

Select the accelerator parameter set.

Parameters:

acc – name of the target parameter set

Returns:

None

Examples

>>> spectra.SelectBL("BM Section") # select the parameter set "BM Section"
spectra.SelectSrc(src)

Select the light source parameter set.

Parameters:

src – name of the target parameter set

Returns:

None

Examples

>>> spectra.SelectSrc("Bending Magnet") # select the parameter set "Bending Magnet"
spectra.SelectConfig(conf)

Select the configurations parameter set.

Parameters:

conf – name of the target parameter set

Returns:

None

Examples

>>> spectra.SelectSrc("BM BL") # select the parameter set "BM BL"
spectra.SetMPI(enable, processes)

Set the MPI configurations for parallel computing.

Parameters:
  • enable (bool) – enable/disable parallel computing

  • processes (number) – number of MPI processes

Returns:

None

Examples

>>> spectra.SetMPI(True, 4) # enable parallel computing with 4 MPI processes
spectra.SetParallel(scheme, processes)

Set the configurations for parallel computing.

Parameters:
  • scheme (str) – parallel computing method (“MPI” or “Multithread” to enable parallel computing, “None” to disable)

  • processes (number) – number of MPI processes or threads

Returns:

None

Examples

>>> spectra.SetParallel("MPI", 4) # enable parallel computing with 4 MPI processes
spectra.SetAccuracy(item, value)

Set the numerical accuracy.

Parameters:
  • item (string) – name of the target item

  • value (any) – value to be set

Returns:

None

Examples

>>> spectra.SetAccuracy("accdisctra", 2) # make the longitudinal integration step finer

Note

Refer to the keyword list for the name of the target parameter.

spectra.SelectCalculation(*items)

Select the type of calculation

Parameters:

items (variable length list) – list of strings to specify the type of calculation

Returns:

None

Examples

>>> spectra.SelectCalculation("far", "energy", "fdensa")
# select "Far Field & Ideal Condition::Energy Dependence::Angular Flux Density"

Note

Refer to the keyword list for the target calulation type.

spectra.StartCalculation(**kwargs)

Start the calculation process

Parameters:
  • kwargs (dict) – keyword argument to specify the path to the output file and its format

  • kwargs["folder"] (str) – directory to put the output file

  • kwargs["prefix"] (str) – name of the output file

  • kwargs["serial"] (number) – serial number of the output file

  • kwargs["format"] (str) – format of the output file

Returns:

None

Examples

>>> spectra.StartCalculation(folder=".", prefix="sample", serial=1)
# start the calculation to generate an output file "./sample-1.json"

Note

If more than one calculation process is created before, this funcion simply launches the existing processes and the arguments are not functional.

spectra.GetResult()

Retrieve the calculation result not handled by Post-Processor (when the output data is 0-dimensional, i.e., has no independent variables).

Parameters:

None

Returns:

calculation result (dict)

Examples

>>> spectra.SelectCalculation("fixed", "far", "fdensa")
# select "Fixed Point Calculation::Far Field & Ideal Condition::Angular Flux Density", which calculates photon flux density etc. at a fixed energy and observation point
>>> spectra.StartCalculation()
>>> result = spectra.GetResult()
# result["Flux Density"] gives the angular photon flux density

Note

If the latest output data can be handled by Post-Processor, this function returns None. Use PostProcess or PostProcessCLI classes instead.

spectra.CreateProcess(**kwargs)

Create a calculation process with the current parameters

Parameters:
  • kwargs (dict) – keyword argument to specify the path to the output file and its format

  • kwargs["folder"] (str) – directory to put the output file

  • kwargs["prefix"] (str) – name of the output file

  • kwargs["serial"] (number) – serial number of the output file

  • kwargs["format"] (str) – format of the output file

Returns:

None

Examples

>>> spectra.CreateProcess(folder=".", prefix="sample", serial=1)
# create a calculation process to generate an output file "./sample-1.json"
spectra.LoadOutput(file)

Load an output file generated in the former calculation for post-processing.

Parameters:

file (str) – path to the output file

Returns:

None

Examples

>>> spectra.LoadOutput("./output.json") # load the output file "output.json" in the current directory
spectra.ShowPreProcessor()

Switch the tabbled panel to “Pre-Processing”.

Parameters:

None

Returns:

None

spectra.ShowPostProcessor()

Switch the tabbled panel to “Post-Processing”.

Parameters:

None

Returns:

None

spectra.Scan(category, label, initial, final, points=11, **kwargs)

Create a parameter-scan process (1D).

Parameters:
  • category (string) – specify the category of the target parameter, should be either of “acc” (Accelerator), “src” (Light Source) or “config” (Configurations)

  • label (string) – name of the target parameter

  • initial (number) – initial value for scanning

  • final (number) – final value for scanning

  • points (number) – number of points for scanning

  • kwargs (dict) – keyword argument to specify the path to the output file and its format

  • kwargs["folder"] (str) – directory to put the output file

  • kwargs["prefix"] (str) – name of the output file

  • kwargs["serial"] (number) – serial number of the (single) output file, if kwargs[“bundle”] is True

  • kwargs["format"] (str) – format of the output file

  • kwargs["bundle"] (bool) – if True, the output data is bundled and saved in a single file

  • kwargs["iniSN"] (number) – initial suffix number for scan, if kwargs[“bundle”] is False

  • kwargs["interval"] (number) – step interval if the target parameter is an integer

Returns:

None

Examples

>>> spectra.Scan("acc", "eGeV", 6, 8, folder=".", prefix="scan", bundle=True)
    # scan the electron energy from 6 to 8 GeV with an interval of 0.2 GeV (11 points);
    # the output file is "./scan.json", where the bundled data are saved
spectra.ScanX(category, label, initial, final, points=11, **kwargs)

Create a parameter-scan process (1D, along x axis).

Parameters:
  • category (string) – specify the category of the target parameter, should be either of “acc” (Accelerator), “src” (Light Source) or “config” (Configurations)

  • label (string) – name of the target parameter

  • initial (number) – initial value for scanning

  • final (number) – final value for scanning

  • points (number) – number of points for scanning

  • kwargs (dict) – keyword argument to specify the path to the output file and its format

  • kwargs["folder"] (str) – directory to put the output file

  • kwargs["prefix"] (str) – name of the output file

  • kwargs["serial"] (number) – serial number of the (single) output file, if kwargs[“bundle”] is True

  • kwargs["format"] (str) – format of the output file

  • kwargs["bundle"] (bool) – if True, the output data is bundled and saved in a single file

  • kwargs["iniSN"] (number) – initial suffix number for scan, if kwargs[“bundle”] is False

  • kwargs["interval"] (number) – step interval if the target parameter is an integer

Returns:

None

Examples

>>> spectra.ScanX("config", "xyfix", 0, 1, folder=".", prefix="scanx", bundle=True)
    # scan the horizontal observation position from 0 to 1 mm with an interval of 0.1 mm (11 points);
    # the output file is "./scanx.json", where the bundled data are saved
spectra.ScanY(category, label, initial, final, points=11, **kwargs)

Create a parameter-scan process (1D, along y axis).

Parameters:
  • category (string) – specify the category of the target parameter, should be either of “acc” (Accelerator), “src” (Light Source) or “config” (Configurations)

  • label (string) – name of the target parameter

  • initial (number) – initial value for scanning

  • final (number) – final value for scanning

  • points (number) – number of points for scanning

  • kwargs (dict) – keyword argument to specify the path to the output file and its format

  • kwargs["folder"] (str) – directory to put the output file

  • kwargs["prefix"] (str) – name of the output file

  • kwargs["serial"] (number) – serial number of the (single) output file, if kwargs[“bundle”] is True

  • kwargs["format"] (str) – format of the output file

  • kwargs["bundle"] (bool) – if True, the output data is bundled and saved in a single file

  • kwargs["iniSN"] (number) – initial suffix number for scan, if kwargs[“bundle”] is False

  • kwargs["interval"] (number) – step interval if the target parameter is an integer

Returns:

None

Examples

>>> spectra.ScanY("config", "xyfix", 0, 1, folder=".", prefix="scany", bundle=True)
    # scan the vertical observation position from 0 to 1 mm with an interval of 0.1 mm (11 points);
    # the output file is "./scany.json", where the bundled data are saved
spectra.ScanXY(category, label, initial, final, points=[11, 11], **kwargs)

Create a parameter-scan process (2D over x-y plane).

Parameters:
  • category (string) – specify the category of the target parameter, should be either of “acc” (Accelerator), “src” (Light Source) or “config” (Configurations)

  • label (string) – name of the target parameter

  • initial (list) – initial value for scanning

  • final (list) – final value for scanning

  • points (list) – number of points for scanning in x and y directions

  • kwargs (dict) – keyword argument to specify the path to the output file and its format

  • kwargs["folder"] (str) – directory to put the output file

  • kwargs["prefix"] (str) – name of the output file

  • kwargs["serial"] (number) – serial number of the (single) output file, if kwargs[“bundle”] is True

  • kwargs["format"] (str) – format of the output file

  • kwargs["bundle"] (bool) – if True, the output data is bundled and saved in a single file

  • kwargs["iniSN"] (number) – initial suffix number for scan, if kwargs[“bundle”] is False

  • kwargs["interval"] (list) – step interval if the target parameter is an integer

  • kwargs["link"] (bool) – if enabled, X and Y prameters are scanned at the same time

Returns:

None

Examples

>>> spectra.ScanXY("config", "xyfix", [0, 0], [1, 1], folder=".", prefix="scanxy", bundle=True)
    # scan the observation position in the 2D rectangular grid points defined by
    # (0,0) and (1,1) with an interval of 0.1 mm in both directions (11x11 points);
    # the output file is "./scanxy.json", where the bundled data are saved
spectra.FitWindow()

Adjust the size of the browser to show the whole parameters in the Main window. Not effective when Pre-Processing or Post-Processing windows are shown.

Parameters:

None

Returns:

None

spectra.ExpandWindow(**kwargs)

Expand or shrink the size of the browser.

Parameters:
  • kwargs (dict) – keyword argument to specify how to expand/shrink

  • kwargs["width"] (kwargs["w"] or) – scaling factor in the horizontal direction

  • kwargs["height"] (kwargs["h"] or) – scaling factor in the vertical direction

Returns:

None

Examples

>>> spectra.ExpandWindow("w"=1.2, "h"=0.8)
    # expand/shrink the window size by 1.2 (horizontal) and 0.8 (vertical)
spectra.MoveWindowX(pos)

Move the browser horizontally.

Parameters:

pos (str or number) – “l” (left), “c” (center), “r” (right), or a pixel number to specify the horizontal position

Returns:

None

Examples

>>> spectra.MoveWindowX("l") # move to the left
>>> spectra.MoveWindowX(100) # move to x = 100px
spectra.MoveWindowY(pos)

Move the browser vertically.

Parameters:

pos (str or number) – “t” (top), “c” (center), “b” (bottom), or a pixel number to specify the vertical position

Returns:

None

Examples

>>> spectra.MoveWindowY("t") # move to the top
>>> spectra.MoveWindowY(100) # move to y = 100px
spectra.MoveWindowXY(x, y)

Move the browser in both directions.

Parameters:
  • x (str or number) – “l” (left), “c” (center), “r” (right), or a pixel number to specify the horizontal position

  • y (str or number) – “t” (top), “c” (center), “b” (bottom), or a pixel number to specify the vertical position

Returns:

None

Examples

>>> spectra.MoveWindowXY("l", "t") # move to the left & top
>>> spectra.MoveWindowXY(100, 100) # move to (x, y) = (100px, 100px)
class spectra.PreProcess

PreProcess class bundles various functions for the operation of pre-processor.

Note

Several functions are not available in the CLI mode. Refer to availability for details.

static Import(item, filename)

Import data from a file prepared by the user.

Parameters:
  • item (str) – name of the target data

  • filename (str) – name of the data file

Returns:

None

Examples

>>> spectra.PreProcess.Import("Field Profile", "./uerror_model.dat")
# import the data file "uerror_model.dat" in the current directory as the field distribution for the "User Defined" source

Note

Refer to the keyword list for the data type available in SPECTRA.

static LoadParticle(filename=None)

Load the particle data

Parameters:

filename (str) – name of the data file; if not specified, load the file specified in “Particle Distribution”

Returns:

None

Examples

>>> spectra.PreProcess.LoadParticle("./particles.dat")
# load the particle data from "particles.dat" in the current directory
static ParticleDataFormat(**kwargs)

Set the particle data format

Parameters:
  • kwargs (dict) – keyword argument to specify the format

  • kwargs["unitxy"] (str) – unit for x and y (m, mm)

  • kwargs["unitxyp"] (str) – unit for x’ and y’ (rad, mrad)

  • kwargs["unitt"] (str) – unit for time (s, ps, fs, m, mm)

  • kwargs["unitE"] (str) – unit for energy (GeV, MeV, gamma)

  • kwargs["index"] (list) – column indices for x, x’, y, y’, t, E

  • kwargs["pcharge"] (number) – charge/particle (C)

  • kwargs["bins"] (number) – number of bins/RMS bunch length to evaluate slice parameters

Returns:

None

Examples

>>> spectra.PreProcess.ParticleDataFormat(index=[2,3,4,5,1,6], unitE="gamma")
# the particle data is arranged as t, x, x', y, y', E
# the energy is given in gamma (Lorentz factor)
static PlotSliceParameter(item, **kwargs)

Plot the slice parameter along the electron bunch

Parameters:
  • item (str) – name of the target parameter

  • kwargs (dict) – keyword argument to specify the plot size (not available in interactive mode)

  • kwargs["width"] (int) – set the width of the plot

  • kwargs["height"] (int) – set the height of the plot

Returns:

None

Examples

>>> spectra.PreProcess.PlotSliceParameter("Current Profile")
# plot the current profile of the electron bunch
static PlotParticles(**kwargs)

Plot the particle distribution in a given 2D phase space

Parameters:
  • kwargs (dict) – keyword argument to specify the configuration of the plot

  • kwargs["x"] (str) – coordinate for the x axis

  • kwargs["y"] (str) – coordinate for the y axis

  • kwargs["max"] (number) – maximum particles to plot

  • kwargs["width"] (int) – set the width of the plot (not available in interactive mode)

  • kwargs["height"] (int) – set the height of the plot (not available in interactive mode)

Returns:

None

Examples

>>> spectra.PreProcess.PlotParticles(x="s (m)",y="Energy (GeV)",max=10000)
# plot E-t phase space distribution with maximum particle number of 10000
static Plot(item, **kwargs)

Calculate and plot the target item.

Parameters:
  • item (str) – name of the target item

  • kwargs (dict) – keyword argument to specify the configuration of the plot (not available in interactive mode)

  • kwargs["xrange"] (list) – set the range of the x axis

  • kwargs["yrange"] (list) – set the range of the y axis

  • kwargs["width"] (int) – set the width of the plot

  • kwargs["height"] (int) – set the height of the plot

Returns:

None

Examples

>>> spectra.PreProcess.Plot("2nd Integral")
# calculate and plot the 2nd field integral (electron orbit)
static SetCondition(**kwargs)

Set the conditions for pre-processing

Parameters:

kwargs – keyword argument to specify the conditions for pre-processing; refer to Note below

Returns:

None

Examples

>>> spectra.PreProcess.SetCondition(filtemin=1000, filtemax=100000)
>>> spectra.PreProcess.Plot("Transmission Rate")
# plot the transmission rate between 1000 eV and 100000 eV

Note

Refer to the keyword list for available keys and values.

static Export(dataname)

Export the pre-processed (and currently plotted) result as an ASCII file. Not available in the CLI mode.

Parameters:

dataname (str) – file name to export the pre-processed result

Returns:

None

Examples

>>> spectra.PreProcess.Export("./export.txt")
# export the pre-processed result to an ASCI file "export.txt"
static PlotScale(**kwargs)

Change the axis scale of the 1D plot. Not available in the CLI mode.

Parameters:
  • kwargs – keyword argument to specify the scale (Linear/Logarithmic) of the plot

  • kwargs["xscale"] (kwargs["x"] or) – select the scale of abscissa, “linear” or “log”

  • kwargs["yscale"] (kwargs["y"] or) – select the scale of ordinate, “linear” or “log”

Returns:

None

Examples

>>> spectra.PreProcess.PlotScale(x="log",y="log")
# Switch to the log-log plot
static PlotRange(**kwargs)

Specify the plotting range of the 1D or contour plot. Not available in the CLI mode.

Parameters:
  • kwargs – keyword argument to specify the range of the plot

  • kwargs["xrange"] (kwargs["x"] or) – specify the x range

  • kwargs["yrange"] (kwargs["y"] or) – specify the y range

Returns:

None

Examples

>>> spectra.PreProcess.PlotRange(x=[1,10],y=[-1,1])
# Specify the x range as [1, 10] and y range as [-1, 1]
static LinePlot(width, size)

Switch to the line plot. Not available in the CLI mode.

Parameters:
  • width – width of lines (should be > 0)

  • size – size of symbols (if 0, simple line plot)

Returns:

None

static SymbolPlot(size)

Switch to the symbol plot. Not available in the CLI mode.

Parameters:

size – size of symbols (should be > 0)

Returns:

None

static ContourPlot()

Switch to the contour plot. Not available in the CLI mode.

Parameters:

None

Returns:

None

static SurfacePlot(**kwargs)

Switch to the surface plot. Not available in the CLI mode.

Parameters:
  • kwargs – keyword argument to specify the configuration of the surface plot

  • kwargs["type"] – select the type of the surface plot; “shade” for a shaded surface plot, “color” for a surface plot with a color map

  • kwargs["wireframe"] – if True, wireframe is drawn on the surface

Returns:

None

Examples

>>> spectra.PreProcess.SurfacePlot(type=shade, wireframe=True)
# Switch to the surface plot with "shading" and "wireframe"
static SetUnit(item, unit)

Select the unit of the data to be imported.

Parameters:
  • item (str) – name of the target item

  • unit (str) – “unit” of the target item

Returns:

None

Examples

>>> spectra.PreProcess.SetUnit("zpos", "mm")
# The longitudinal position is given in mm in the data file to be imported.

Note

Refer to the keyword list for the name of the unit and possible options.

static DuplicatePlot(*titles)

Open a new window to duplicate the current plot with the same configuration. Not available in the CLI mode.

Parameters:

titles (variable length list) – titles of the plot

Returns:

None

class spectra.PostProcess

PostProcess class bundles various functions for the operation of post-processor.

Note

Not available in the CLI mode. Use “PostProcessCLI” class instead.

static Import(filename)

Import the output file for post-processing (visualization)

Parameters:

filename (str) – name of the output file

Returns:

None

Note

If successful, the imported data (“data set”) is named with the name of the output file without its directory and suffix (.json). Namely, a data name “sample1” is given to a dataset imported from an output file “/path/to/data/sample1.json”. This means that a data set is overwritten (and thus deleted) if another output file with the same name but in a different directly is imported later on.

static SelectData(dataname)

Select a data set for post-processing from those already imported.

Parameters:

dataname (str) – name of the data set to be selected

Returns:

None

static Plot(*items)

Plot the items in the currently selected data set.

Parameters:

items (variable length list) – name of the target items

Returns:

None

Examples

>>> spectra.PostProcess.Plot("Flux Density", "GA. Brilliance")
# plot the spectra of flux density and brilliance in the same graph
static SetDataType(type)

Select the target data type to plot

Parameters:

type (str) – data type name

Returns:

None

Examples

>>> spectra.PostProcess.SetDataType("Modal Flux")
# select "Modal Flux" data type evaluated by the CMD operation
>>> spectra.PostProcess.Plot("Integrated Modal Flux")
# plot the integrated modal flux as a function of the mode order

Note

Refer to the available data types for the name of the target parameter.

static Clear()

Clear all the data sets that have been imported.

Parameters:

None

Returns:

None

static Remove(dataname)

Remove a data set from the list.

Parameters:

dataname (str) – name of the data set to be removed

Returns:

None

static Export(dataname)

Export the data in the current plot as an ASCII file.

Parameters:

dataname (str) – file name to save the data

Returns:

None

static Save(dataname)

Save the current plot as a JSON file, which can be imported later to reproduce the plot.

Parameters:

dataname (str) – file name to save the data

Returns:

None

static ComparativePlot(*datanames)

Create a comparative plot of an item currently selected; more than one data set is retrieved and plotted in the same graph for comparison

Parameters:

names (data) – names of the data sets to be plotted

Returns:

None

Examples

>>> spectra.PostProcess.Plot("Flux Density") # specify "Flux Density" as the target item before creating a comparative plot
>>> spectra.PostProcess.ComparativePlot("sample-2", "sample-3")
# plot the spectra of flux density retrieved from two other output data "sample-2" and "sample-3"
static MultiPlot(*datanames)

Create a multiple plot; more than one data set is retrieved and plotted in the same window

Parameters:

datanames (variable length list) – names of the output data to be plotted

Returns:

None

Examples

>>> spectra.PostProcess.Plot("Flux Density")
>>> spectra.PostProcess.MultiPlot("Partial Flux")
# plot the spectra of flux density retrieved from two data sets "sample-1" and "sample-2"
static SetSlide(*slideno)

Set the slide number in the animation plot

Parameters:

slideno (variable length list) – slide number(s) to show

Returns:

None

Examples

>>> spectra.PostProcess.SetSlide(0) # show the 0th slide
static ComparativePlotCols(columns)

Define the number of columns for comparative plot with more than one plot area. This is effective for 2D plots or 1D plots with more than one target items.

Parameters:

columns (integer) – column number of comparative plot areas

Returns:

None

static MultiPlotCols(columns)

Define the number of columns for multiplot.

Parameters:

columns (integer) – column number of multiplot windows

Returns:

None

static PlotScale(**kwargs)

Change the axis scale of the 1D plot. Not available in the CLI mode.

Parameters:
  • kwargs – keyword argument to specify the scale (Linear/Logarithmic) of the plot

  • kwargs["xscale"] (kwargs["x"] or) – select the scale of abscissa, “linear” or “log”

  • kwargs["yscale"] (kwargs["y"] or) – select the scale of ordinate, “linear” or “log”

Returns:

None

Examples

>>> spectra.PreProcess.PlotScale(x="log",y="log")
# Switch to the log-log plot
NormalizePlot()

Specify if the plot is normalized for each slide.

Parameters:

normalize (bool) – boolean to specify the method of normalization

Returns:

None

static PlotRange(**kwargs)

Specify the plotting range of the 1D or contour plot. Not available in the CLI mode.

Parameters:
  • kwargs – keyword argument to specify the range of the plot

  • kwargs["xrange"] (kwargs["x"] or) – specify the x range

  • kwargs["yrange"] (kwargs["y"] or) – specify the y range

Returns:

None

Examples

>>> spectra.PreProcess.PlotRange(x=[1,10],y=[-1,1])
# Specify the x range as [1, 10] and y range as [-1, 1]
static LinePlot(width, size)

Switch to the line plot. Not available in the CLI mode.

Parameters:
  • width – width of lines (should be > 0)

  • size – size of symbols (if 0, simple line plot)

Returns:

None

static SymbolPlot(size)

Switch to the symbol plot. Not available in the CLI mode.

Parameters:

size – size of symbols (should be > 0)

Returns:

None

static ContourPlot()

Switch to the contour plot. Not available in the CLI mode.

Parameters:

None

Returns:

None

static SurfacePlot(**kwargs)

Switch to the surface plot. Not available in the CLI mode.

Parameters:
  • kwargs – keyword argument to specify the configuration of the surface plot

  • kwargs["type"] – select the type of the surface plot; “shade” for a shaded surface plot, “color” for a surface plot with a color map

  • kwargs["wireframe"] – if True, wireframe is drawn on the surface

Returns:

None

Examples

>>> spectra.PreProcess.SurfacePlot(type=shade, wireframe=True)
# Switch to the surface plot with "shading" and "wireframe"
static DuplicatePlot(*titles)

Open a new window to duplicate the current plot with the same configuration. Not available in the CLI mode.

Parameters:

titles (variable length list) – titles of the plot

Returns:

None

static StartAnimation()

Start an animation with the current plot (if available).

Parameters:

None

Returns:

None

class spectra.PostProcessCLI

PostProcessCLI class bundles various functions to plot the calculation results in the CLI mode.

Note

Not available except for the CLI mode. Use “PostProcess” class instead for other modes.

static Import(filename)

Import the output file for post-processing (visualization)

Parameters:

filename (str) – name of the output file

Returns:

None

Note

If successful, the imported data (“data set”) is named with the name of the output file without its directory and suffix (.json). Namely, a data name “sample1” is given to a dataset imported from an output file “/path/to/data/sample1.json”. This means that a data set is overwritten (and thus deleted) if another output file with the same name but in a different directly is imported later on.

static Plot(**kwargs)

Plot the items in the selected data sets.

Parameters:
  • kwargs – keyword argument to specify the data set and method to plot

  • kwargs["data"] (str or list) – select the data set(s)

  • kwargs["item"] (str or list) – select the item(s)

  • kwargs["type"] (str) – select the data type

  • kwargs["xy"] (str or list) – select the x (and y) axes for the plot; effective when more than 2 coordinate variables exist in the selected data set

  • kwargs["xrange"] (list) – set the range of the x axis

  • kwargs["yrange"] (list) – set the range of the y axis

  • kwargs["width"] (int) – set the width of the plot

  • kwargs["height"] (int) – set the height of the plot

Returns:

None

Examples

>>> spectra.PostProcess.Plot(data="sample1", item="Flux Density")
# plot the spectra of flux density in "sample1"
>>> spectra.PostProcess.Plot(data=["sample1", "sample2"], item=["Flux Density", "GA. Brilliance"])
# plot the spectra of flux density and brilliance in "sample1" and "sample2"

Note

When kwargs[“data”] and kwargs[“item”] are omitted, their values are automatically set. Refer to the available data types for available values for “type” and “item” keyword arguments.

static Clear()

Clear all the data sets from the post-processor to release the allocated memory.

Parameters:

None

Returns:

None

static Remove(*dataname)

Remove the data sets from the post-processor to release the allocated memory.

Parameters:

dataname (variable length list) – list of data names to remove

Returns:

None

Examples

>>> spectra.PostProcessCLI.Remove("sample1", "sample2")
# remove the data sets "sample1" and "sample2"