Skip to content

Commit 1b6cb3f

Browse files
Fixed issue#66 and issue#67
1 parent 60b34de commit 1b6cb3f

4 files changed

Lines changed: 17 additions & 11 deletions

File tree

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ ZMXFILES/Fiber\ Coupling_POPunittest_NoFiberCompute.CFG
218218
ZMXFILES/Fiber\ Coupling_POPunittest_Phase.CFG
219219
ZMXFILES/Cooke\ 40\ degree\ field_unittest.CFG
220220
ZMXFILES/Cooke\ 40\ degree\ field_PreSettings_OnlyCardinals.CFG
221+
ZMXFILES/LENS.SES
222+
ZMXFILES/Cooke_40_degree_field_unittest.CFG
223+
ZMXFILES/Fiber_Coupling_POPunittest.CFG
224+
ZMXFILES/Fiber_Coupling_POPunittest_NoFiberCompute.CFG
225+
ZMXFILES/Fiber_Coupling_POPunittest_Phase.CFG
221226
ZMXFILES/speckleusingpop_gridsagsurf.CFG
222227
Examples/Scripts/pikachu2.zbf
223228
ZMXFILES/None
@@ -242,4 +247,3 @@ ZMXFILES/*.cfg
242247

243248
# Files that needs to be synced on/off sometimes
244249
*.dll
245-
ZMXFILES/LENS.SES

Test/pyZDDEunittest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,9 @@ def test_zModifySettings(self):
11451145
self.assertEqual(ret, -1)
11461146
# Pass valid parameters and string type value
11471147
ret = self.ln.zModifySettings(sfilename,'UN1_OPERAND', 'ZERN')
1148-
self.assertEqual(ret, 0)
1148+
self.assertEqual(ret, 0, 'This test fails in OpticStudio16 and above!')
1149+
# this test fails in OpticStidio16 and above, and I don't imagine Zemax
1150+
# fixing any bugs in the DDE interface.
11491151
if TestPyZDDEFunctions.pRetVar:
11501152
print('zModifySettings test successful')
11511153

pyzdde/zdde.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4135,7 +4135,7 @@ def zModifySettings(self, fileName, mType, value):
41354135
full name of the settings file, including the path & extension
41364136
mType : string
41374137
a mnemonic that indicates which setting within the file is to
4138-
be mdified. See the ZPL macro command "MODIFYSETTINGS" in the
4138+
be modified. See the ZPL macro command "MODIFYSETTINGS" in the
41394139
Zemax manual for a complete list of the ``mType`` codes
41404140
value : string or integer
41414141
the new data for the specified setting
@@ -4533,7 +4533,7 @@ def zOptimize(self, numOfCycles=0, algorithm=0, timeout=None):
45334533

45344534
See Also
45354535
--------
4536-
zHammer(), zLoadMerit(), zsaveMerit(), zOptimize2()
4536+
zHammer(), zLoadMerit(), zSaveMerit(), zOptimize2()
45374537
"""
45384538
cmd = "Optimize,{:1.2g},{:d}".format(numOfCycles,algorithm)
45394539
reply = self._sendDDEcommand(cmd, timeout)
@@ -7259,15 +7259,15 @@ def zGetPOP(self, settingsFile=None, displayData=False, txtFile=None,
72597259

72607260
# Point spacing
72617261
pts_line = line_list[_getFirstLineOfInterest(line_list, 'Point spacing')]
7262-
pat = r'-?\d\.\d{4,6}[Ee][-\+]\d{3}'
7262+
pat = r'-?\d\.\d{4,6}[Ee][-\+]\d{2,3}'
72637263
pts_x, pts_y = [float(i) for i in _re.findall(pat, pts_line)]
72647264

72657265
width_x = pts_x*grid_x
72667266
width_y = pts_y*grid_y
72677267

72687268
if data_is_irr:
72697269
# Peak Irradiance and Total Power
7270-
pat_i = r'-?\d\.\d{4,6}[Ee][-\+]\d{3}' # pattern for P. Irr, T. Pow,
7270+
pat_i = r'-?\d\.\d{4,6}[Ee][-\+]\d{2,3}' # pattern for P. Irr, T. Pow,
72717271
peakIrr, totPow = None, None
72727272
pi_tp_line = _getFirstLineOfInterest(line_list, 'Peak Irradiance')
72737273
if pi_tp_line: # Transfer magnitude doesn't have Peak Irradiance info
@@ -7293,7 +7293,7 @@ def zGetPOP(self, settingsFile=None, displayData=False, txtFile=None,
72937293
# Pilot_size, Pilot_Waist, Pos, Rayleigh [... available for
72947294
# both Phase and Irr data]
72957295
pat_fe = r'\d\.\d{6}' # pattern for fiber efficiency
7296-
pat_pi = r'-?\d\.\d{4,6}[Ee][-\+]\d{3}' # pattern for Pilot size/waist
7296+
pat_pi = r'-?\d\.\d{4,6}[Ee][-\+]\d{2,3}' # pattern for Pilot size/waist
72977297
pilotSize, pilotWaist, pos, rayleigh = None, None, None, None
72987298
pilot_line = line_list[_getFirstLineOfInterest(line_list, 'Pilot')]
72997299
p_size_info, p_waist_info, p_pos_info, p_rayleigh_info = pilot_line.split(',')
@@ -7328,7 +7328,7 @@ def zGetPOP(self, settingsFile=None, displayData=False, txtFile=None,
73287328

73297329
if displayData:
73307330
# Get the 2D data
7331-
pat = (r'(-?\d\.\d{4,6}[Ee][-\+]\d{3}\s*)' + r'{{{num}}}'
7331+
pat = (r'(-?\d\.\d{4,6}[Ee][-\+]\d{2,3}\s*)' + r'{{{num}}}'
73327332
.format(num=grid_x))
73337333
start_line = _getFirstLineOfInterest(line_list, pat)
73347334
powerGrid = _get2DList(line_list, start_line, grid_y)
@@ -7825,7 +7825,7 @@ def zGetPSF(self, which='fft', settingsFile=None, txtFile=None,
78257825
ctr_ref_line = line_list[_getFirstLineOfInterest(line_list, 'Center coordinates')]
78267826
else:
78277827
ctr_ref_line = line_list[_getFirstLineOfInterest(line_list, 'Reference Coordinates')]
7828-
ctr_ref_x, ctr_ref_y = [float(i) for i in _re.findall('-?\d\.\d{4,10}[Ee][-\+]\d{3}', ctr_ref_line)]
7828+
ctr_ref_x, ctr_ref_y = [float(i) for i in _re.findall('-?\d\.\d{4,10}[Ee][-\+]\d{2,3}', ctr_ref_line)]
78297829
img_grid_line = line_list[_getFirstLineOfInterest(line_list, 'Image grid size')]
78307830
img_grid_x, img_grid_y = [int(i) for i in _re.findall(r'\d{2,5}', img_grid_line)]
78317831
pupil_grid_line = line_list[_getFirstLineOfInterest(line_list, 'Pupil grid size')]
@@ -7834,7 +7834,7 @@ def zGetPSF(self, which='fft', settingsFile=None, txtFile=None,
78347834
center_point_x, center_point_y = [int(i) for i in _re.findall(r'\d{2,5}', center_point_line)]
78357835

78367836
# The 2D data
7837-
pat = (r'(-?\d\.\d{4,6}[Ee][-\+]\d{3}\s*)' + r'{{{num}}}'
7837+
pat = (r'(-?\d\.\d{4,6}[Ee][-\+]\d{2,3}\s*)' + r'{{{num}}}'
78387838
.format(num=img_grid_x))
78397839
start_line = _getFirstLineOfInterest(line_list, pat)
78407840
psfGridData = _get2DList(line_list, start_line, img_grid_y)

pyzdde/zfileutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ def readDetectorViewerTextFile(pyz, textFileName, displayData=False):
745745
def gridSagFile(z, dzBydx, dzBydy, d2zBydxdy, nx, ny, delx, dely, unitflag=0,
746746
xdec=0, ydec=0, fname='gridsag', comment=None, fext='.DAT'):
747747
"""generates Grid Sag ASCII file for specifying the additional sag terms of the
748-
grid sag surfacd
748+
grid sag surface
749749

750750
Parameters
751751
----------

0 commit comments

Comments
 (0)