Skip to content

Commit

Permalink
Version 2.4.1
Browse files Browse the repository at this point in the history
Modified widget to only accept files whose name starts with D[digit]
Moved main script to bin/
Updated setup.py accordingly and removed some unused variables.
Renamed widget module to avoid duplicating package name.
Added simple tester to svn repository.
  • Loading branch information
rowen committed Oct 11, 2011
1 parent 52f7477 commit 1bef2c1
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 31 deletions.
2 changes: 0 additions & 2 deletions BuildForMac/extraPaths.txt

This file was deleted.

16 changes: 4 additions & 12 deletions BuildForMac/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
History:
2010-06-16 ROwen
2010-06-24 ROwen Modified for new package layout.
2011-10-11 ROwen Modified for newer package layout.
Deleted unused inclModules and inclPackages.
"""
import os
import shutil
Expand All @@ -30,20 +32,12 @@
import fitPlugPlateMeas

appName = "FitPlugPlateMeas"
mainScript = "fitPlugPlateMeas.py"
mainProg = os.path.join(pythonRoot, mainScript)
mainScript = "runFitPlugPlateMeas.py"
mainProg = os.path.join("bin", mainScript)
appPath = os.path.join("dist", appName + ".app")
iconFile = "%s.icns" % appName
versStr = fitPlugPlateMeas.__version__

inclModules = (
# "FileDialog",
)
# packages to include recursively
inclPackages = (
# "RO",
)

# see plistlib for more info
plist = dict(
CFBundleName = appName,
Expand Down Expand Up @@ -72,8 +66,6 @@
py2app = dict (
plist = plist,
iconfile = iconFile,
includes = inclModules,
packages = inclPackages,
)
),
)
Expand Down
22 changes: 22 additions & 0 deletions bin/runFitPlugPlateMeas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
from __future__ import with_statement
"""Fit plug plate measurements
History:
2011-10-11 ROwen Moved this code from a library module.
"""
import sys
import Tkinter
import fitPlugPlateMeas

filePathList = sys.argv[1:]
# strip first argument if it starts with "-", as happens when run as a Mac application
if filePathList and filePathList[0].startswith("-"):
filePathList = filePathList[1:]

root = Tkinter.Tk()
root.title("FitPlugPlateMeas")

fitPlugPlateWdg = fitPlugPlateMeas.FitPlugPlateMeasWdg(master=root, filePathList=filePathList)
fitPlugPlateWdg.pack(side="left", expand=True, fill="both")
root.mainloop()
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions python/fitPlugPlateMeas/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .version import *
from .fitPlugPlateMeasWdg import *
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
2011-02-25 ROwen Moved data fitting to the fitData module.
Modified to use RO.Wdg.DropletApp.
2011-03-18 ROwen Save fit data to a file.
2011-10-11 ROwen Renamed to avoid conflicting with package name. Moved __main__ elsewhere.
Modified to only process files whose name matches D[0-9][0-9]*
"""
import os.path
import re
Expand All @@ -26,9 +28,10 @@
import RO.Constants
import RO.StringUtil
import RO.Wdg
import fitData
from . import fitData
from .version import __version__

__version__ = "2.4"
__all__ = ["FitPlugPlateMeasWdg"]

class GraphWdg(Tkinter.Frame):
def __init__(self, master):
Expand Down Expand Up @@ -155,6 +158,8 @@ def __init__(self, master, filePathList=None):
height = 20,
font = "Courier 12", # want a fixed width font
printTraceback = True,
recursionDepth = 1,
patterns = "D[0-9][0-9]*",
)

self.logWdg.addOutput("""Plug Plate Fitter %s
Expand Down Expand Up @@ -401,18 +406,3 @@ def readFile(filePath):
outArr["nomDia"] = dataArr["nomDia"]
outArr["measRoundness"] = dataArr["measRoundness"]
return outArr, plateID, measDate


if __name__ == "__main__":
import sys
filePathList = sys.argv[1:]
# strip first argument if it starts with "-", as happens when run as a Mac application
if filePathList and filePathList[0].startswith("-"):
filePathList = filePathList[1:]

root = Tkinter.Tk()
root.title("FitPlugPlateMeas")

fitPlugPlateWdg = FitPlugPlateMeasWdg(master=root, filePathList=filePathList)
fitPlugPlateWdg.pack(side="left", expand=True, fill="both")
root.mainloop()
56 changes: 56 additions & 0 deletions python/fitPlugPlateMeas/testModel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python
"""A simple test of whether the fitter is working well.
This should be turned into a unit test that reports pass/fail.
"""
import numpy
import matplotlib.pyplot as pyplot
from . import fitData

posArr = numpy.arange(-1.0, 1.01, 0.1, dtype=float)
nomPos = numpy.zeros((len(posArr)**2,2))
i = 0
for x in posArr:
for y in posArr:
nomPos[i] = (x, y)
i += 1

pyplot.ion()

print "QuadrupoleModel"
qpModel = fitData.QuadrupoleModel()
qpModel.setMagnitudeAngle(0.1, 45.0)
print "desired coeffs=", qpModel.getCoeffs()
qpPos = qpModel.apply(nomPos)

for testCoeffs in ((1, 1), (10, 10), (0.5, -45)):
print "init coeffs=", testCoeffs
qpFit = fitData.ModelFit(
model = fitData.QuadrupoleModel(testCoeffs),
measPos = qpPos,
nomPos = nomPos,
doRaise = True,
)
print "fit coeffs=", qpFit.model.getCoeffs()


print "TransRotScaleModel"
trsModel = fitData.TransRotScaleModel((0.2, -0.3, 0.8, -0.9))
trsPos = trsModel.apply(nomPos)
print "desired coeffs=", trsModel.getCoeffs()

for testCoeffs in ((1, 1, 1, 1), (10, 10, 10, 10), (0.5, -0.6, 0.5, -0.5)):
print "init coeffs=", testCoeffs
trsFit = fitData.ModelFit(
model = fitData.TransRotScaleModel(testCoeffs),
measPos = trsPos,
nomPos = nomPos,
doRaise = True,
)
print "fit coeffs=", trsFit.model.getCoeffs()


# pyplot.plot(
# nomPos[:,0], nomPos[:,1], "b.",
# qpPos[:,0], qpPos[:,1], "r.",
# )
1 change: 1 addition & 0 deletions python/fitPlugPlateMeas/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "2.4.1"

0 comments on commit 1bef2c1

Please sign in to comment.