femto.writer module#

class Writer(filename, n_glass=1.5, n_environment=1.33, export_dir='', samplesize=(100, 50), laser='PHAROS', home=False, new_origin=(0.0, 0.0), warp_flag=False, rotation_angle=0.0, aerotech_angle=0.0, long_pause=0.5, short_pause=0.05, output_digits=6, speed_pos=5.0, flip_x=False, flip_y=False, _total_dwell_time=0.0, _shutter_on=False, _mode_abs=True)#

Bases: PGMCompiler, ABC

Abstract class representing a G-Code Writer object.

A Writer class is a super-object that can store homogeneous objects (Waveguides, Markers, Trenches, etc.) and provides methods to append objects, plot and export them as .pgm files.

abstract append(obj)#

Append objects.

Abstract method for appending objects to a Writer.

Parameters:

obj (Any) – Object to be appended to current Writer.

Return type:

None

abstract extend(obj)#

Extend objects list.

Abstract method for extending the object list of a Writer.

Parameters:

obj (list(any)) – List of objects to extend the Writer object list.

Return type:

None

abstract plot2d(fig=None, show_shutter_close=True, style=None)#

Plot 2D.

Abstract method for plotting the object stored in Writer’s object list.

Parameters:
  • fig (go.Figure, optional) – Optional plotly figure object, if no figure is provided a new one is created and updated with the object stored in the Writer class. If a figure is provided it is updated by adding the stored objects. The default behaviour is creating a new figure.

  • show_shutter_close (bool, optional) – Boolean flag, if True the movements with closed shutter are represented. The default value is False.

  • style (dict(str, Any)) – Plotly compatible styles options for representing the objects.

Returns:

Plotly figure with the 2D plot of the stored objects.

Return type:

go.Figure

See also

go.Figure

Plotly figure object.

abstract plot3d(fig=None, show_shutter_close=True, style=None)#

Plot 3D.

Abstract method for plotting the object stored in Writer’s object list.

Parameters:
  • fig (go.Figure, optional) – Optional plotly figure object, if no figure is provided a new one is created and updated with the object stored in the Writer class. If a figure is provided it is updated by adding the stored objects. The default behaviour is creating a new figure.

  • show_shutter_close (bool, optional) – Boolean flag, if True the movements with closed shutter are represented. The default value is False.

  • style (dict(str, Any)) – Plotly compatible styles options for representing the objects.

Returns:

Plotly figure with the 3D plot of the stored objects.

Return type:

go.Figure

See also

go.Figure

Plotly figure object.

abstract pgm(verbose=True)#

Export to PGM file.

Abstract method for exporting the objects stored in Writer object as PGM file.

Parameters:

verbose (bool, optional) – Boolean flag, if True some information about the exporting procedures are printed. The default value is False.

Return type:

None

See also

femto.pgmcompiler.PGMCompiler : class that convert lists of points to PGM file.

standard_2d_figure_update(fig)#

2D plot update.

Helper function that update a 2D plot by adding the rectangle representing the sample glass, the (0, 0) origin point and formats the axis.

Parameters:

fig (go.Figure) – Plotly Figure object to update.

Returns:

Input figure updated with sample glass shape, origin point and axis.

Return type:

go.Figure

static standard_3d_figure_update(fig)#

3D plot update.

Helper function that update a 3D plot by adding the sample glass, the (0, 0, 0) origin point and formats the axis.

Parameters:

fig (go.Figure) – Plotly Figure object to update.

Returns:

Input figure updated with sample glass shape, origin point and axis.

Return type:

go.Figure

filename: str#
class TrenchWriter(tc_list, dirname='TRENCH', **param)#

Bases: Writer

Trench Writer class.

append(obj)#

Append TrenchColumn objects.

Parameters:

obj (TrenchColumn) – TrenchColumn object to be added to object list.

Return type:

None

extend(obj)#

Extend trench list.

Extend the object list with a list of TrenchColumn objects.

Parameters:

obj (list(TrenchColumn)) – List of TrenchColumn objects to be added to object list.

Return type:

None

plot2d(fig=None, show_shutter_close=True, style=None)#

Plot 2D.

2D plot of the Trench objects contained in self.obj_list.

Parameters:
  • fig (go.Figure, optional) – Optional plotly figure object, if no figure is provided a new one is created and updated with the Trench objects stored in the Writer class. If a figure is provided it is updated by adding the stored objects. The default behaviour is creating a new figure.

  • show_shutter_close (bool, optional) – Boolean flag, if True the movements with closed shutter are represented. The default value is False.

  • style (dict(str, Any)) – Plotly compatible styles options for representing the objects.

Returns:

Plotly figure with the 2D plot of the stored Trench.

Return type:

go.Figure

plot3d(fig=None, show_shutter_close=True, style=None)#

Plot 3D - Not implemented.

Return type:

go.Figure

pgm(verbose=True)#

Export to PGM file.

Function for the compilation of TrenchColumn objects. For each trench in the column, the function first compile a PGM file for border (or wall) and for the floor inside a directory given by the user (self.base_folder). Secondly, the function produce a FARCALL.pgm program to fabricate all the trenches in the column.

Parameters:

verbose (bool, optional) – Boolean flag, if True some information about the exporting procedures are printed. The default value is False.

Return type:

None

See also

femto.pgmcompiler.PGMCompiler : class that convert lists of points to PGM file.

export_array2d(filename, x, y, speed, forced_deceleration=False)#

Export 2D path to PGM file.

Helper function that produces a series of movements at given traslation speed and without shuttering operations for a 2D point matrix. The function parse the points input points, applies the rotation and homothety transformations and parse all the LINEAR instructions.

Parameters:
  • filename (pathlib.Path) – Filename of the output PGM file.

  • x (numpy.ndarray) – x coordinates array [mm].

  • y (numpy.ndarray) – y coordinates array [mm].

  • speed (float | list[float]) – Translation speed [mm/s].

  • forced_deceleration (bool) – Add a G9 command before LINEAR movements to reduce the acceleration to zero after the motion is completed.

Return type:

None

See also

pgmcompiler.transform_points

series of geometrical transformation on input points.

pathlib.Path

class representing cross-system filepaths.

filename: str#
class UTrenchWriter(utc_list, dirname='U-TRENCH', **param)#

Bases: TrenchWriter

U-Trench Writer class.

append(obj)#

Append UTrenchColumn objects.

Parameters:

obj (UTrenchColumn) – UTrenchColumn object to be added to object list.

Return type:

None

filename: str#
obj_list: list[TrenchColumn]#
trenches: list[Trench]#
dirname: str#
class WaveguideWriter(wg_list, **param)#

Bases: Writer

Waveguide Writer class.

append(obj)#

Append Waveguide objects.

Parameters:

obj (Waveguide) – Waveguide object to be added to object list.

Return type:

None

extend(obj)#

Extend waveguide list.

Extend the object list with a list of Waveguide objects.

Parameters:

obj (list(Waveguide)) – List of Waveguide objects to be added to object list.

Return type:

None

plot2d(fig=None, show_shutter_close=True, style=None)#

Plot 2D.

2D plot of the Waveguide objects contained in self.obj_list.

Parameters:
  • fig (go.Figure, optional) – Optional plotly figure object, if no figure is provided a new one is created and updated with the Waveguide objects stored in the Writer class. If a figure is provided it is updated by adding the stored objects. The default behaviour is creating a new figure.

  • show_shutter_close (bool, optional) – Boolean flag, if True the movements with closed shutter are represented. The default value is False.

  • style (dict(str, Any)) – Plotly compatible styles options for representing the objects.

Returns:

Plotly figure with the 2D plot of the stored Waveguide.

Return type:

go.Figure

plot3d(fig=None, show_shutter_close=True, style=None)#

Plot 3D.

3D plot of the Waveguide objects contained in self.obj_list.

Parameters:
  • fig (go.Figure, optional) – Optional plotly figure object, if no figure is provided a new one is created and updated with the Waveguide objects stored in the Writer class. If a figure is provided it is updated by adding the stored objects. The default behaviour is creating a new figure.

  • show_shutter_close (bool, optional) – Boolean flag, if True the movements with closed shutter are represented. The default value is False.

  • style (dict(str, Any)) – Plotly compatible styles options for representing the objects.

Returns:

Plotly figure with the 2D plot of the stored Waveguide.

Return type:

go.Figure

pgm(verbose=True)#

Export to PGM file.

Function for the compilation of Waveguide objects. The function produces a single file containing all the instructions of the waveguides.

Parameters:

verbose (bool, optional) – Boolean flag, if True some information about the exporting procedures are printed. The default value is False.

Return type:

None

See also

femto.pgmcompiler.PGMCompiler : class that convert lists of points to PGM file.

filename: str#
class NasuWriter(nw_list, **param)#

Bases: Writer

NasuWaveguide Writer class.

append(obj)#

Append NasuWaveguide objects.

Parameters:

obj (NasuWaveguide) – NasuWaveguide object to be added to object list.

Return type:

None

extend(obj)#

Extend Nasu waveguide list.

Extend the object list with a list of NasuWaveguide objects.

Parameters:

obj (list(NasuWaveguide)) – List of NasuWaveguide objects to be added to object list.

Return type:

None

plot2d(fig=None, show_shutter_close=True, style=None)#

Plot 2D.

2D plot of the NasuWaveguide objects contained in self.obj_list.

Parameters:
  • fig (go.Figure, optional) – Optional plotly figure object, if no figure is provided a new one is created and updated with the NasuWaveguide objects stored in the Writer class. If a figure is provided it is updated by adding the stored objects. The default behaviour is creating a new figure.

  • show_shutter_close (bool, optional) – Boolean flag, if True the movements with closed shutter are represented. The default value is False.

  • style (dict(str, Any)) – Plotly compatible styles options for representing the objects.

Returns:

Plotly figure with the 2D plot of the stored NasuWaveguide.

Return type:

go.Figure

plot3d(fig=None, show_shutter_close=True, style=None)#

Plot 3D.

3D plot of the NasuWaveguide objects contained in self.obj_list.

Parameters:
  • fig (go.Figure, optional) – Optional plotly figure object, if no figure is provided a new one is created and updated with the NasuWaveguide objects stored in the Writer class. If a figure is provided it is updated by adding the stored objects. The default behaviour is creating a new figure.

  • show_shutter_close (bool, optional) – Boolean flag, if True the movements with closed shutter are represented. The default value is False.

  • style (dict(str, Any)) – Plotly compatible styles options for representing the objects.

Returns:

Plotly figure with the 2D plot of the stored NasuWaveguide.

Return type:

go.Figure

pgm(verbose=True)#

Export to PGM file.

Function for the compilation of NasuWaveguide objects. The function produces a single file containing all the instructions of the waveguides.

Parameters:

verbose (bool, optional) – Boolean flag, if True some information about the exporting procedures are printed. The default value is False.

Return type:

None

See also

femto.pgmcompiler.PGMCompiler : class that convert lists of points to PGM file.

filename: str#
class MarkerWriter(mk_list, **param)#

Bases: Writer

Marker Writer class.

append(obj)#

Append Marker objects.

Parameters:

obj (Marker) – Marker object to be added to object list.

Return type:

None

extend(obj)#

Extend Marker list.

Extend the object list with a list of Marker objects.

Parameters:

obj (list(Marker)) – List of Marker objects to be added to object list.

Return type:

None

plot2d(fig=None, show_shutter_close=True, style=None)#

Plot 2D.

2D plot of the Marker objects contained in self.obj_list.

Parameters:
  • fig (go.Figure, optional) – Optional plotly figure object, if no figure is provided a new one is created and updated with the Marker objects stored in the Writer class. If a figure is provided it is updated by adding the stored objects. The default behaviour is creating a new figure.

  • show_shutter_close (bool, optional) – Boolean flag, if True the movements with closed shutter are represented. The default value is False.

  • style (dict(str, Any)) – Plotly compatible styles options for representing the objects.

Returns:

Plotly figure with the 2D plot of the stored Marker.

Return type:

go.Figure

plot3d(fig=None, show_shutter_close=True, style=None)#

Plot 3D.

3D plot of the Marker objects contained in self.obj_list.

Parameters:
  • fig (go.Figure, optional) – Optional plotly figure object, if no figure is provided a new one is created and updated with the Marker objects stored in the Writer class. If a figure is provided it is updated by adding the stored objects. The default behaviour is creating a new figure.

  • show_shutter_close (bool, optional) – Boolean flag, if True the movements with closed shutter are represented. The default value is False.

  • style (dict(str, Any)) – Plotly compatible styles options for representing the objects.

Returns:

Plotly figure with the 2D plot of the stored Marker.

Return type:

go.Figure

pgm(verbose=True)#

Export to PGM file.

Function for the compilation of Marker objects. The function produces a single file containing all the instructions of the markers and ablations.

Parameters:

verbose (bool, optional) – Boolean flag, if True some information about the exporting procedures are printed. The default value is False.

Return type:

None

See also

femto.pgmcompiler.PGMCompiler : class that convert lists of points to PGM file.

filename: str#