GWL package

Submodules

GWL.GWL_parser module

class GWL.GWL_parser.GWLobject[source]

Bases: object

This is the main class used to read/write/create GWL files for the Nanoscribe.

Basic usage example:

#!/usr/bin/env python3
from GWL.GWL_parser import GWLobject

obj = GWLobject()
obj.addVoxel([10, 20, 30, 40])
obj.addVoxel([11, 21, 31, 41])
obj.addVoxel([12, 22, 32, 42])
obj.startNewVoxelSequence()
obj.addVoxel([5, 6, 7])
obj.addVoxel([8, 9, 10])
obj.addVoxel([5, 6, 7])
obj.addVoxel([8, 9, 10])
obj.startNewVoxelSequence()
obj.addVoxel([5, 6, 7])
obj.addVoxel([8, 9, 10])
obj.writeGWL('foo.gwl')

This should produce a file named ‘foo.gwl’ containing:

10.000  20.000  30.000  40.000
11.000  21.000  31.000  41.000
12.000  22.000  32.000  42.000
Write
5.000   6.000   7.000
8.000   9.000   10.000
5.000   6.000   7.000
8.000   9.000   10.000
Write
5.000   6.000   7.000
8.000   9.000   10.000
Write

Attributes:

  • Writing settings:
Variables:
  • set_lower_to_origin – If true, offsets the structure so that the lower corner is at (0,0,0). Defaults to False.
  • write_power – Write out power values. Defaults to False.
  • Power compensation settings (set the slope to zero for a constant power):
Variables:

Note

They currently only have an effect when writeGWLWithPowerCompensation() is used. Not when writeGWL() is used.

Inner workings:

The voxels are stored in GWL_voxels. This is the most important attribute. It stores all voxels in a list of the form [ write_sequence_0, write_sequence_1, … ] where:

  • the write_sequence_i are of the form [voxel_0, voxel_1, …]
  • the voxel_i of the form [x, y, z] or [x, y, z, power].
DwellTime = None

in ms = 1e-3 seconds

GWL_voxels = None

“List of lists of voxels”.

PC_bool_InverseWriting = None

PC_bool_InverseWriting

PC_bool_LaserPowerCommand = None

PC_bool_LaserPowerCommand

PC_float_height = None

PC_float_height

PC_interfaceAt = None

PC_interfaceAt

PC_laser_power_at_z0 = None

PC_laser_power_at_z0

PC_slope = None

PC_slope (set the slope to zero for a constant power)

PositionMaximum = None

Maximum of X, Y, Z and power. Updated with updateLimits() and retrievable with getLimits().

PositionMinimum = None

Minimum of X, Y, Z and power. Updated with updateLimits() and retrievable with getLimits().

addBlockCentroSize(centro, size, LineDistance_Horizontal=0.1, LineDistance_Vertical=0.2, BottomToTop=False, direction=None)[source]
addBlockLowerUpper(lower, upper, LineDistance_Horizontal=0.1, LineDistance_Vertical=0.2, BottomToTop=False, direction=None)[source]
addFlatLine(P1, P2, line_distance, line_number, power=-1)[source]
addGWLobject(obj)[source]
addHorizontalCircle(center, radius, power, PointDistance_max, startAngle=0, endAngle=6.283185307179586, closed_loop=False)[source]
addHorizontalDisk(center, radius, power, PointDistance)[source]
addHorizontalGrating(P1, P2, LineNumber, LineDistance)[source]
addLine(P1, P2, power=-1)[source]
addLineCylinder(P1, P2, power, inner_radius, outer_radius, PointDistance_r, PointDistance_theta)[source]
addPowerCompensation(laser_power_at_z0, K, interfaceAt=0, bool_InverseWriting=False, float_height=0)[source]

Add a 4th power component to voxels based on the formula:

  • LP(Z) = (1+K*(Z-interfaceAt))*LP(0) if bool_InverseWriting=False
  • LP(Z) = (1+K*((H-Z)+interfaceAt))*LP(0) if bool_InverseWriting=True
addSphere(center, radius, power, HorizontalPointDistance, VerticalPointDistance, solid=False)[source]
addTubeWithVerticalLines(centro, inner_radius, outer_radius, height, power, PointDistance_r, PointDistance_theta, downwardWriting=True, zigzag=True)[source]
addVoxel(voxel)[source]

Adds a voxel to the last “writing sequence”. If there is none, a new one will be created. Equivalent to adding a line of the form “x y z [power]” in your .gwl file.

addXblock(P1, P2, LineNumber_Horizontal=None, LineDistance_Horizontal=0.1, LineNumber_Vertical=None, LineDistance_Vertical=0.2, BottomToTop=False)[source]
addYblock(P1, P2, LineNumber_Horizontal=None, LineDistance_Horizontal=0.1, LineNumber_Vertical=None, LineDistance_Vertical=0.2, BottomToTop=False)[source]
addZGrating(P1, P2, LineNumber, LineDistance, BottomToTop=False)[source]
addZblock(P1, P2, LineNumber_X=None, LineDistance_X=0.1, LineNumber_Y=None, LineDistance_Y=0.1)[source]
add_arguments(parser)[source]

Adds GWLobject related arguments to the given parser (an argparse.ArgumentParser instance).

See also: setAttributesFromParsedOptions()

appendVoxels()[source]

“append” a “line of voxels”

applyOffset(offset)[source]
applyTransformationMatrix(P, centro)[source]
clear()[source]
extendVoxels()[source]

“extend” with multiple “lines of voxels”

getLastVoxel()[source]
getLimits(update_limits=True)[source]

This function returns the minimum and maximum x,y,z coordinates.

To optimize speed, it only returns the currently stored limits, which should be computed while adding voxels. To update the limits, call updateLimits().

Parameters:update_limits (bool) – If true, updateLimits() will be called.
Returns:(PositionMinimum, PositionMaximum) where PositionMinimum and PositionMaximum are lists of size 4 containing [Xmin, Ymin, Zmin, Pmin] and [Xmax, Ymax, Zmax, Pmax] respectively.
getMeshData(position=[0, 0, 0])[source]
getMinDistanceBetweenVoxels()[source]
getNvoxels()[source]
getPower(z, PC_laser_power_at_z0=None, PC_slope=None, PC_interfaceAt=None, PC_bool_InverseWriting=None, PC_float_height=None)[source]

calculate power for a given z position

getVoxels(L)[source]

Returns a list of the voxels in the form specified in setVoxels().

get_argument_parser()[source]
maxDistanceBetweenLines = None

maximum acceptable distance from end of one line to start of next one

minDistanceBetweenLines = None

shortest distance from end of one line to start of next one

readGWL(filename)[source]
readSubstitutes(subsFile)[source]
reverse(reverse_line_order=True, reverse_voxel_order_per_line=True)[source]

Reverse the order of the voxels. Unlike reverse_line_order_on_write and reverse_voxel_order_per_line_on_write, this applies directly.

Parameters:
  • reverse_line_order

    If True, the order of the lines will be reversed, i.e.:

    voxel0
    voxel1
    voxel2
    Write
    voxel3
    voxel4
    voxel5
    Write
    

    becomes:

    voxel3
    voxel4
    voxel5
    Write
    voxel0
    voxel1
    voxel2
    Write
    
  • reverse_voxel_order_per_line

    If True, the order of the voxels in each line will be reversed, i.e.:

    voxel0
    voxel1
    voxel2
    Write
    voxel3
    voxel4
    voxel5
    Write
    

    becomes:

    voxel2
    voxel1
    voxel0
    Write
    voxel5
    voxel4
    voxel3
    Write
    
Returns:

None

reverse_line_order_on_write = None

If True, the order of the lines will be reversed during writing. See also: reverse()

reverse_voxel_order_per_line_on_write = None

If True, the order of the voxels in each line will be reversed during writing. See also: reverse()

rotate(axis_point, axis_direction, angle_degrees)[source]
setAttributesFromParsedOptions(options)[source]

Sets the object’s attributes based on the ones from the options object (usually an argparse.ArgumentParser instance).

See also: add_arguments()

setVoxels(L)[source]

Set the voxels as a list of the form [[v0,v1,…], [vA,vB,…], …] where v* are voxel coordinates, i.e. [X,Y,Z] or [X,Y,Z,power].

set_lower_to_origin = None

If true, offsets the structure so that the lower corner is at (0,0,0)

startNewVoxelSequence()[source]

Starts a new voxel sequence, i.e. “adds a Write command” if you already had a “voxel sequence” before it when creating the .gwl file.

updateLimits()[source]

Updates the PositionMinimum and PositionMaximum attributes.

See also getLimits().

Returns:(PositionMinimum, PositionMaximum) where PositionMinimum and PositionMaximum are lists of size 4 containing [Xmin, Ymin, Zmin, Pmin] and [Xmax, Ymax, Zmax, Pmax] respectively.
writeGWL(filename, writingOffset=[0, 0, 0, 0], bool_LaserPowerCommand=False)[source]

Writes out the GWL file. This function is old and does not use the new power compensation attributes.

See also: writeGWLWithPowerCompensation()

writeGWLWithPowerCompensation(filename)[source]

Writes out the GWL file, but using the GWLobject’s attributes related to power compensation.

Note

The latest Nanowrite software supports new commands allowing easy changes to the power compensation (power slope, etc). Please test and use those instead. If they work, it will make functions like this one mostly obsolete. The new GWL commands are: psPowerProfile, psLoadPowerProfiles, psPowerSlope

Example:

FindInterfaceAt 0.5
PowerScaling 1.5
LaserPower 3
psPowerSlope 2
0 0 0
0 0 10
Write

This should be equivalent to the old:

0 0 0 3
0 0 10 90.0 % = 3 * 1 * (1 + 2*(z-0.5))*1.5
Write

The formula used is:

LPeff = LaserPower * eta(|nu|) * mu(z)

with:

eta(|nu|) = 1
mu(z) = (1 + psPowerSlope*(z-FindInterfaceAt))*PowerScaling
write_power = None

write out power values

GWL.GWL_parser.calculateNvoxelsAndInterVoxelDistance(Length, Voxelsize, Overlap)[source]

Calulates the number of voxels and the distance between them so that they fit into length “Length” with an overlap “Overlap”, i.e. so that:

  • InterVoxelDistance = (1-Overlap)*Voxelsize
  • (Nvoxels-1)*InterVoxelDistance + Voxelsize <= Length
GWL.GWL_parser.main()[source]
GWL.GWL_parser.test1()[source]
GWL.GWL_parser.test2()[source]

GWL.SpiralSphere module

class GWL.SpiralSphere.SpiralSphere[source]

Bases: GWL.GWL_parser.GWLobject

computePoints()[source]
getDiametre()[source]
getMeshData(position=[0, 0, 0])[source]
getRadius()[source]
setDiametre(diametre)[source]
setRadius(radius)[source]
writeGWL(filename, writingOffset=[0, 0, 0, 0])[source]

Writes out the GWL file. This function is old and does not use the new power compensation attributes.

See also: writeGWLWithPowerCompensation()

GWL.SpiralSphere.main()[source]
GWL.SpiralSphere.test()[source]

GWL.bmesh module

class GWL.bmesh.BMEdgeSeq[source]

Bases: object

new(v_list)[source]
class GWL.bmesh.BMFaceSeq[source]

Bases: object

new(v_list)[source]
class GWL.bmesh.BMVert(co=(0, 0, 0))[source]

Bases: object

class GWL.bmesh.BMVertSeq[source]

Bases: object

new(v_co)[source]
class GWL.bmesh.BMesh[source]

Bases: object

GWL.bmesh.new()[source]

GWL.box module

GWL.box.createElevatedBoxWithSubstrate(DSTDIR)[source]
GWL.box.createLegs(DSTDIR, NAME='Legs.gwl', wall_thickness=1, leg_height=3, hole_width=4, box_size=10, overshoot=1, LineDistance_Horizontal=0.35, LineDistance_Vertical=0.35, BottomToTop=False, writingOffset=[0, 0, 0, 0])[source]
GWL.box.createSimpleBox(DSTDIR, NAME='SimpleBox.gwl', box_size=10, wall_height=5, wall_thickness=0, overshoot=3, LineDistance_Horizontal=0.35, LineDistance_Vertical=0.35, BottomToTop=False, writingOffset=[0, 0, 0, 0])[source]
GWL.box.createSubstrate(DSTDIR, NAME='Substrate.gwl', box_size=10, substrate_height=1, LineDistance_Horizontal=0.35, LineDistance_Vertical=0.35, BottomToTop=False, writingOffset=[0, 0, 0, 0])[source]
GWL.box.main()[source]

GWL.foobar_file module

class GWL.foobar_file.foobarClass[source]

Bases: GWL.GWL_parser.GWLobject

setProperty(N)[source]

GWL.generate_sphere module

GWL.parallelepiped module

class GWL.parallelepiped.Parallelepiped[source]

Bases: GWL.GWL_parser.GWLobject

A parallelepiped (i.e., a brick, possibly with non-orthogonal axes).

The block will be filled with lines going along e1, in layers in the (e1,e2) plane, stacked along e3.

LineNumber_vec3 = [5, 5, 5]
center_vec3 = array([0, 0, 0])
computeOutline()[source]
computePoints()[source]
computeVectors()[source]
connected = False
e1_vec3 = array([1, 0, 0])
e2_vec3 = array([0, 1, 0])
e3_vec3 = array([0, 0, 1])
getMeshData()[source]
getMinMaxPoints()[source]
getNormalizedVectors()[source]
overlap_vec3 = array([0. , 0. , 0.5])
overlap_vec3_xyz = array([0. , 0. , 0.5])
setFromLine(A, B, rod_width, rod_height, orthogonal, orientation)[source]
setSizeFromVectors()[source]
size_vec3 = array([1, 1, 1])
voxelsize_vec3 = array([0.15, 0.15, 0.45])
voxelsize_vec3_xyz = array([0.15, 0.15, 0.45])
writeGWL(filename, writingOffset=[0, 0, 0, 0])[source]

Writes out the GWL file. This function is old and does not use the new power compensation attributes.

See also: writeGWLWithPowerCompensation()

GWL.parallelepiped.test0()[source]
GWL.parallelepiped.test1()[source]

GWL.rotation_example module

GWL.tilted_grating module

class GWL.tilted_grating.TiltedGrating[source]

Bases: GWL.GWL_parser.GWLobject

computePoints()[source]
getMeshData()[source]
writeGWL(filename, writingOffset=[0, 0, 0, 0])[source]

Writes out the GWL file. This function is old and does not use the new power compensation attributes.

See also: writeGWLWithPowerCompensation()

GWL.tilted_grating.block_example()[source]
GWL.tilted_grating.block_example_2()[source]
GWL.tilted_grating.main()[source]

GWL.tube module

class GWL.tube.HalfTubeLargeWithInnerAndOuter[source]

Bases: GWL.tube.TubePapa

computePoints()[source]
class GWL.tube.HorizontalCircleTubeWithConstantAngularStep[source]

Bases: GWL.GWL_parser.GWLobject

computePoints()[source]
getMeshData(position=[0, 0, 0])[source]
setCentro(vec3or4)[source]
setNumberOfSteps_R(NumberOfSteps_R)[source]
setNumberOfSteps_Theta(NumberOfSteps_Theta)[source]
setNumberOfSteps_Z(NumberOfSteps_Z)[source]
setStart_R(Start_R)[source]
setStart_ThetaDegrees(Start_ThetaDegrees)[source]
setStart_Z(Start_Z)[source]
setStepSize_R(StepSize_R)[source]
setStepSize_ThetaDegrees(StepSize_ThetaDegrees)[source]
setStepSize_Z(StepSize_Z)[source]
class GWL.tube.TruncatedTube[source]

Bases: GWL.GWL_parser.GWLobject

computePoints()[source]
getMeshData(position=[0, 0, 0])[source]
writeGWL(filename, writingOffset=[0, 0, 0, 0])[source]

Writes out the GWL file. This function is old and does not use the new power compensation attributes.

See also: writeGWLWithPowerCompensation()

class GWL.tube.Tube[source]

Bases: GWL.GWL_parser.GWLobject

This class allows you to create “tubes”, i.e. cylinders with an optional inner radius.

There are three writing methods available:

  • horizontal disks
  • vertical lines
  • spirals (with or without additional flat disks on top and bottom)
addTube()[source]
computePoints()[source]
getMeshData(position=[0, 0, 0])[source]
setAngularStepDegrees(x)[source]
setCentro(vec3)[source]
setHeight(height)[source]
setInnerRadius(inner_radius)[source]
setNumberOfSteps_R(x)[source]
setNumberOfSteps_Theta(x)[source]
setNumberOfSteps_Z(x)[source]
setOuterRadius(outer_radius)[source]
setStart_R(x)[source]
setStart_ThetaDegrees(x)[source]
setStart_Z(x)[source]
setStepSize_R(x)[source]
setStepSize_ThetaDegrees(x)[source]
setStepSize_Z(x)[source]
writeGWL(filename, writingOffset=[0, 0, 0, 0])[source]

Writes out the GWL file. This function is old and does not use the new power compensation attributes.

See also: writeGWLWithPowerCompensation()

class GWL.tube.TubeLarge[source]

Bases: GWL.tube.TubePapa

computePoints()[source]
class GWL.tube.TubePapa[source]

Bases: GWL.GWL_parser.GWLobject

computePoints()[source]
getMeshData(position=[0, 0, 0])[source]
writeGWL(filename, writingOffset=[0, 0, 0, 0])[source]

Writes out the GWL file. This function is old and does not use the new power compensation attributes.

See also: writeGWLWithPowerCompensation()

GWL.tube.suppressorFunction_Xmax(A, B, Xmin)[source]
GWL.tube.testTruncatedTube()[source]
GWL.tube.testTube()[source]
GWL.tube.usage_example()[source]

GWL.woodpile module

class GWL.woodpile.Woodpile[source]

Bases: object

This class allows you to create BFDTD and GWL files for a woodpile crystal.

NRodsPerLayer_X

Number of rods in a layer in the X direction

NRodsPerLayer_Y

Number of rods in a layer in the Y direction

Nlayers_Z

Number of layers in the Z direction

adaptXYMinMax()[source]
getGWLandBFDTDobjects()[source]
setLineNumberAndDistance_XY()[source]

set LineNumber and LineDistance (WARNING: will set rod width accordingly)

setLineNumberAndDistance_Z()[source]

set LineNumber and LineDistance (WARNING: will set rod height accordingly)

setOverlap3()[source]
setRodHeight()[source]

set rod height (WARNING: will set LineNumber and LineDistance accordingly)

setRodType()[source]
setRodWidth()[source]

set rod width (WARNING: will set LineNumber and LineDistance accordingly)

setVoxelSize3()[source]
writeBFDTD(filename)[source]
writeGWL(filename)[source]
write_BFDTD(filename)[source]
write_GWL(filename)[source]
GWL.woodpile.main()[source]

GWL.woodpile_grid module

GWL.woodpile_grid.commonHeader(file)[source]
GWL.woodpile_grid.createMainFile(filename, VoxelFile)[source]
GWL.woodpile_grid.createMainFile2(filename, file_list)[source]
GWL.woodpile_grid.createMasterFile(filename, mainfile_list)[source]
GWL.woodpile_grid.createSingleMainFile(filename, VoxelFile, LaserPower, ScanSpeed, Xoffset, Yoffset)[source]
GWL.woodpile_grid.createSubFiles(DSTDIR)[source]
GWL.woodpile_grid.createSubFiles2(DSTDIR)[source]
GWL.woodpile_grid.createSubFiles3(DSTDIR)[source]
GWL.woodpile_grid.single_woodpile(DSTDIR, NX, NY, NZ, interRodDistance, LaserPower, ScanSpeed, BottomToTop)[source]

GWL.SpiralPhasePlate module

class GWL.SpiralPhasePlate.SpiralPhasePlate[source]

Bases: GWL.GWL_parser.GWLobject

Spiral phase plate

Original algorithm and documentation by Dave Philips. Code ported to python3 by Mike Taverne, with added PyQt GUI and Blender addon.

This program generates coordinates to draw a spiral phase plate in the nanoscribe. The coordinates are ordered from top to bottom. Each layer is a series of concentric circels, with the z values changed to draw the appropriate tilted surface with a step. Each layer is drawn from the inside out (I’m not sure if inside out or outside in is best). I had some earlier problems with the disk spliting apart when developed at the discontinuity, so I have made sure that each ring is properly joined to itself.

There is a commented out if stataement in the middle of the coordinate for loop (lines 57 and 60), if you uncomment this then it will truncate the coordinates when their z values go negative.

The coordinates are produced in a big list with Nan in place of where nanoscribe needs a ‘write’ command. At the end, the coordinates are written to a file called ‘spiralphaseplate.gwl’, and the lines containing Nans are converted to ‘write’.

If the coordinate list is less than 5000 rows long then it is also plotted within Matlab.

Check that the created file is the same as the one created by the Matlab script: octave Phase_plate.m && ./rewriteGWL.py spiralphaseplate.gwl spiralphaseplate.PP.gwl && python3 Phase_plate.py && ./rewriteGWL.py spiralphaseplate2.gwl spiralphaseplate2.PP.gwl && diff spiralphaseplate.PP.gwl spiralphaseplate2.PP.gwl && checkcmd

octave Phase_plate.m ./rewriteGWL.py spiralphaseplate.gwl spiralphaseplate.PP.gwl python3 Phase_plate.py diff spiralphaseplate.PP.gwl /tmp/spiralphaseplate.gwl grep -c Write spiralphaseplate.PP.gwl /tmp/spiralphaseplate.gwl

for i in 1 2 3 4; do diff -q “$HOME/Desktop/spiralphaseplate_${i}.gwl” “/tmp/spiralphaseplate_${i}.PP.gwl”; done

Structural Parameter Inputs:

N_Discontinuities = None

number of steps around 360 degrees - this parameter is redundant as when you’re fabricating it, you only ever need 1 step, the height of which you can change to be any multiple of 2pi

N_HeightSteps = None

number of additional layers to draw beyond the top layer, i.e. if N_HeightSteps = 2, then total number of layers in the structure = 3)

add_arguments(parser)[source]

Adds GWLobject related arguments to the given parser (an argparse.ArgumentParser instance).

See also: setAttributesFromParsedOptions()

computePoints()[source]
get_argument_parser()[source]
heightStep = None

distance appart of each layer, in microns

maxHeight = None

height of phase step in microns

phiStep = None

angular separation of each writing anchor point around a circle, in degrees

radialStep = None

distance apart of each ring, in microns

radius = None

radius of phase plate in microns

setAttributesFromParsedOptions(options)[source]

Sets the object’s attributes based on the ones from the options object (usually an argparse.ArgumentParser instance).

See also: add_arguments()

writeFromParsedOptions(options)[source]
GWL.SpiralPhasePlate.testGWLobject()[source]
GWL.SpiralPhasePlate.testSpirals()[source]

Module contents