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: - PC_laser_power_at_z0 – PC_laser_power_at_z0. Defaults to 100.
- PC_slope – PC_slope (set the slope to zero for a constant power). Defaults to 0.
- PC_interfaceAt – PC_interfaceAt. Defaults to 0.
- PC_float_height – PC_float_height. Defaults to 0.
- PC_bool_InverseWriting – PC_bool_InverseWriting. Defaults to False.
- PC_bool_LaserPowerCommand – PC_bool_LaserPowerCommand. Defaults to False.
Note
They currently only have an effect when
writeGWLWithPowerCompensation()
is used. Not whenwriteGWL()
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]¶
-
addHorizontalCircle
(center, radius, power, PointDistance_max, startAngle=0, endAngle=6.283185307179586, closed_loop=False)[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]¶
-
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()
-
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.
-
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()
.
-
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
-
reverse
(reverse_line_order=True, reverse_voxel_order_per_line=True)[source]¶ Reverse the order of the voxels. Unlike
reverse_line_order_on_write
andreverse_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 –
-
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()
-
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.SpiralSphere module¶
-
class
GWL.SpiralSphere.
SpiralSphere
[source]¶ Bases:
GWL.GWL_parser.GWLobject
GWL.bmesh module¶
GWL.box module¶
-
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.foobar_file module¶
-
class
GWL.foobar_file.
foobarClass
[source]¶ Bases:
GWL.GWL_parser.GWLobject
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])¶
-
connected
= False¶
-
e1_vec3
= array([1, 0, 0])¶
-
e2_vec3
= array([0, 1, 0])¶
-
e3_vec3
= array([0, 0, 1])¶
-
overlap_vec3
= array([0. , 0. , 0.5])¶
-
overlap_vec3_xyz
= array([0. , 0. , 0.5])¶
-
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])¶
-
GWL.rotation_example module¶
GWL.tilted_grating module¶
-
class
GWL.tilted_grating.
TiltedGrating
[source]¶ Bases:
GWL.GWL_parser.GWLobject
GWL.tube module¶
-
class
GWL.tube.
HalfTubeLargeWithInnerAndOuter
[source]¶ Bases:
GWL.tube.TubePapa
-
class
GWL.tube.
HorizontalCircleTubeWithConstantAngularStep
[source]¶ Bases:
GWL.GWL_parser.GWLobject
-
class
GWL.tube.
TruncatedTube
[source]¶ Bases:
GWL.GWL_parser.GWLobject
-
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)
-
class
GWL.tube.
TubeLarge
[source]¶ Bases:
GWL.tube.TubePapa
-
class
GWL.tube.
TubePapa
[source]¶ Bases:
GWL.GWL_parser.GWLobject
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
-
setLineNumberAndDistance_XY
()[source]¶ set LineNumber and LineDistance (WARNING: will set rod width accordingly)
-
GWL.woodpile_grid module¶
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()
-
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()
-