fintrace.model

This module creates the Fintrace model, which inherits all attributes and methods of a finesse model while populating a dictionary with gtrace objects for ray-tracing and rendering.

Classes

FintraceModel

Optical configuration class for handling models of interferometers.

Module Contents

class fintrace.model.FintraceModel

Bases: finesse.Model

Optical configuration class for handling models of interferometers.

This class stores the interferometer configuration as a directed graph and contains methods to interface with this data structure.

Parameters:
  • *katscripts (str) – KatScripts to parse, parsed in order.

  • loadfile (Optional[str | PathLike]) – If present, this file will be loaded and parsed before parsing the katscripts.

gtrace_dict
laser_beam = None
laser_width = None
laser_length = None
laser_gauss = None
yamlfile = ''
__str__()

Prints current model info.

handle_shapes(shape, gtrace_dict)
build_from_yaml(yamlfile, gtrace=None, verbose=False)

Builds a finesse model from input yamlfile.

abstractmethod save_to_yaml(filename)
save_to_csv(filename)

Prints current model info.

print_model_info()
gtrace_plot(gtrace_dict: dict, finesse_cavities: dict, finesse_detectors: list, render=True, beam_origin='laser', skip_optics=[], grid=False, draw_width: bool | float = True, savefile=None, img_res=600, power_threshold=0.001, keep_dxf=False, keep_svg=False)

Plots the gtrace rendering of current finesse model.

Parameters:
  • gtrace_dict (dict) – Dictionary with populated gtrace objects generated during model initialization.

  • finesse_cavities (list) – List of cavities to plot and analyze.

  • finesse_detectors (list) – List of detectors to draw.

  • render (bool, optional) – Whether or not to render the gtrace model upon completion, or just return the unrendered Canvas object. Defaults to True.

  • beam_origin (str, optional) – Whether to use laser as initial beam origin or to create a beam with calculated cavity eigenmodes. Defaults to ‘laser’.

  • grid (bool, optional) – Whether or not to draw prewritten/ dynamic grid. Defaults to False.

  • draw_width (bool | float, optional) – Whether or not to draw

  • True (beamwidths throughout the rendering. If)

  • default (uses a)

  • float (sigma of 2.63. If a)

  • sigma. (uses that value as)

  • True. (Defaults to)

  • savefile (_type_, optional) – Path to save rendered (if applicable) drawing, without extensions!. If none is provided, it will produce gtrace.png in your current working directory. Defaults to None.

  • img_res (int, optional) – Choice of image resolution. Defaults to 600.

  • power_threshold (float, optional) – Threshold to use in the nonsequential beamtrace, which plots all beams until a beam falls below the set power threshold. Defaults to 1e-3.

  • keep_dxf (bool, optional) – Whether to save the originally rendered dxf file. Defaults to False.

  • keep_svg (bool, optional) – Whether to save rendered svg file. Defaults to False.

Returns:

If render is set to false, will return populated

Canvas object for rendering.

Return type:

Canvas

trace_cavities(cavity_traces: list = ['all'], savepath=None, q_at=None, imshow=False, show=False, plot=['all'], direction=None, astig_difference=True, verbose=False) None

Draws beam trace(s) of each cavity specified by args, that are also specified in the .yaml config file.

Parameters:
  • cavity_trace (list, optional) – list of cavities you wish to trace. Defaults to [‘all’].

  • savepath (str, optional) – Path to where you’d like to save the figures produced. Defaults to None.

  • q_at (str, optional) – Node to print the q-parameter within an eigenmode.

  • imshow (bool, optional) – When true, will plot beam intensity at given q_at on image. Defaults to False.

  • show (bool, optional) – When true, will call plt.show() and bring up the figures of each plot. Defaults to False.

Raises:

KeyError – If cavity name listed is not found yamlfile.

trace_beam(beamtrace: list, q_at=None, q_in=None, plot=False, imshow=False, show: bool = False, savepath: str = None, direction: str = 'both', astig_difference: bool = True, **kwargs) None

Performs a beam trace from a given starting point and end point. The syntax for start and end nodes uses the finesse style. Can only have a start and end node no more, no less.

Parameters:
  • beamtrace (list) – Start and end nodes, with optional via node. List should be a maximum of 3 nodes, minimum of 2.

  • q_at (str, optional) – Node to print the q-parameter within an optical path generated with beamtrace.

  • q_in (complex, optional) – initial q to use beam propagation for beamtrace.

  • plot (bool, optional) – whether or not to plot the beam trace. Defaults to False.

  • imshow (bool, optional) – When true, will plot beam intensity at given q_at on image. Defaults to False.

  • show (bool, optional) – When true, will call plt.show() and bring up the figures of each plot. Defaults to False.

  • savepath (str, optional) – Path to where you’d like to save the figures produced. Defaults to None.

  • direction (str, optional) – Direction to do beam trace. Defaults to ‘both’.

Raises:
  • ValueError – Must define a start and end node.

  • AttributeError – The node does not have this port.

scan_cavity(cavity_names: list = ['all'], savepath=None, show=False, nm=7, yscale='linear')

Scans the cavity for higher-order mode resonance, normalizing each succesive HOM by 1/(n+m+1).

Parameters:
  • cavity_names (list, optional) – List of cavities

  • ['all']. (you wish to scan. Defaults to)

  • savepath (_type_, optional) – Place to save produced plot.

  • None. (Defaults to)

  • show (bool, optional) – Whether or not to display plot.

  • False. (Defaults to)

  • nm (int, optional) – Total number of HOMs to include.

  • 7. (Defaults to)

calculate_matched_mode(laser, cav: str)

Calculates the needed q-parameter for laser given a cavity to be matched to.

Parameters:
  • laser (Laser) – Laser object, as a model object

  • cav (str) – Name of cavity to match to.

Returns:

needed q parameters in x and y direction.

Return type:

(qx, qy)

match_beam(target_q: finesse.gaussian.BeamParam, from_node, match_node, start_q: finesse.gaussian.BeamParam, params, guess, dir=None)

Runs minimization function on mode mismatch with parameters set in arguments, which must be syntaxed the FINESSE way.

Parameters:
  • target_q (BeamParam) – Target q that you are trying to mode match to.

  • from_node (OpticalNode) – OpticalNode to start beam propagation to.

  • match_node (OpticalNode) – OpticalNode to end at and evaluate mode match at.

  • start_q (BeamParam) – Initial q to start beam propagation with.

  • params (list) – List of parameters (FINESSE syntax) in minimization function.

  • guess (list) – List of initial guesses for parameters that give minima.

  • dir (str) – either ‘x’ or ‘y’ to use mode matching direction. default is ‘x’.

plot_beam_trace(sol, *args, direction='both', astig_difference=True, filename=None, show=False)