Ejemplo n.º 1
0
	def __init__(self,parent):
		LabelFrame.__init__(self, parent, borderwidth=0)

		entryWidth = 7
		xPad1 = 30
		xPad2 = 5

		self.errorXLowerLimitL = Label(self)
		self.errorXLowerLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorXLowerLimitL.grid(row=0,column=0,padx=(10,xPad2),pady=5,sticky="W")
		self.errorXLowerLimitE.grid(row=0,column=1,padx=(xPad2,xPad1),pady=5)

		self.errorXUpperLimitL = Label(self)
		self.errorXUpperLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorXUpperLimitL.grid(row=1,column=0,padx=(10,xPad2),pady=5,sticky="W")
		self.errorXUpperLimitE.grid(row=1,column=1,padx=(xPad2,xPad1),pady=5)

		self.errorYLowerLimitL = Label(self)
		self.errorYLowerLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorYLowerLimitL.grid(row=0,column=2,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorYLowerLimitE.grid(row=0,column=3,padx=(xPad2,xPad1),pady=5)

		self.errorYUpperLimitL = Label(self)
		self.errorYUpperLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorYUpperLimitL.grid(row=1,column=2,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorYUpperLimitE.grid(row=1,column=3,padx=(xPad2,xPad1),pady=5)

		self.errorResolutionL = Label(self,text="Resolution: ")
		self.errorResolutionE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorResolutionE.insert(0,ERROR_SURFACE_DEFAULT_RESOLUTION)
		self.errorResolutionL.grid(row=0,column=4,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorResolutionE.grid(row=0,column=5,padx=(xPad2,xPad1),pady=5,sticky="E")

		self.errorSurfaceB = Button(self,text=" Calculate error surface ")
		self.errorSurfaceB.grid(row=1,column=4,columnspan=2,padx=(xPad1,xPad1),sticky="EW")
		self.errorSurfaceB.configure(state=tkinter.ACTIVE)
Ejemplo n.º 2
0
	def __init__(self,parent):
		LabelFrame.__init__(self, parent, borderwidth=0)
		
		entryWidth = 7
		xPad1 = 30
		xPad2 = 5
		
		self.errorXLowerLimitL = Label(self)
		self.errorXLowerLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorXLowerLimitL.grid(row=0,column=0,padx=(10,xPad2),pady=5,sticky="W")
		self.errorXLowerLimitE.grid(row=0,column=1,padx=(xPad2,xPad1),pady=5)
		
		self.errorXUpperLimitL = Label(self)
		self.errorXUpperLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorXUpperLimitL.grid(row=1,column=0,padx=(10,xPad2),pady=5,sticky="W")
		self.errorXUpperLimitE.grid(row=1,column=1,padx=(xPad2,xPad1),pady=5)
		
		self.errorYLowerLimitL = Label(self)
		self.errorYLowerLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorYLowerLimitL.grid(row=0,column=2,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorYLowerLimitE.grid(row=0,column=3,padx=(xPad2,xPad1),pady=5)
		
		self.errorYUpperLimitL = Label(self)
		self.errorYUpperLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorYUpperLimitL.grid(row=1,column=2,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorYUpperLimitE.grid(row=1,column=3,padx=(xPad2,xPad1),pady=5)
		
		self.errorResolutionL = Label(self,text="Resolution: ")
		self.errorResolutionE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorResolutionE.insert(0,ERROR_SURFACE_DEFAULT_RESOLUTION)
		self.errorResolutionL.grid(row=0,column=4,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorResolutionE.grid(row=0,column=5,padx=(xPad2,xPad1),pady=5,sticky="E")
		
		self.errorSurfaceB = Button(self,text=" Calculate error surface ")
		self.errorSurfaceB.grid(row=1,column=4,columnspan=2,padx=(xPad1,xPad1),sticky="EW")
		self.errorSurfaceB.configure(state=tkinter.ACTIVE)
Ejemplo n.º 3
0
class ErrorSurfaceFrame(LabelFrame):

	def __init__(self,parent):
		LabelFrame.__init__(self, parent, borderwidth=0)

		entryWidth = 7
		xPad1 = 30
		xPad2 = 5

		self.errorXLowerLimitL = Label(self)
		self.errorXLowerLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorXLowerLimitL.grid(row=0,column=0,padx=(10,xPad2),pady=5,sticky="W")
		self.errorXLowerLimitE.grid(row=0,column=1,padx=(xPad2,xPad1),pady=5)

		self.errorXUpperLimitL = Label(self)
		self.errorXUpperLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorXUpperLimitL.grid(row=1,column=0,padx=(10,xPad2),pady=5,sticky="W")
		self.errorXUpperLimitE.grid(row=1,column=1,padx=(xPad2,xPad1),pady=5)

		self.errorYLowerLimitL = Label(self)
		self.errorYLowerLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorYLowerLimitL.grid(row=0,column=2,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorYLowerLimitE.grid(row=0,column=3,padx=(xPad2,xPad1),pady=5)

		self.errorYUpperLimitL = Label(self)
		self.errorYUpperLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorYUpperLimitL.grid(row=1,column=2,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorYUpperLimitE.grid(row=1,column=3,padx=(xPad2,xPad1),pady=5)

		self.errorResolutionL = Label(self,text="Resolution: ")
		self.errorResolutionE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorResolutionE.insert(0,ERROR_SURFACE_DEFAULT_RESOLUTION)
		self.errorResolutionL.grid(row=0,column=4,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorResolutionE.grid(row=0,column=5,padx=(xPad2,xPad1),pady=5,sticky="E")

		self.errorSurfaceB = Button(self,text=" Calculate error surface ")
		self.errorSurfaceB.grid(row=1,column=4,columnspan=2,padx=(xPad1,xPad1),sticky="EW")
		self.errorSurfaceB.configure(state=tkinter.ACTIVE)

	def update(self,xSymbol,ySymbol,xLL,xUL,yLL,yUL):

		self.xSymbol = xSymbol
		self.ySymbol = ySymbol

		self.errorXLowerLimitL.configure(text="Lower limit ("+self.xSymbol+"): ")
		self.errorXLowerLimitE.insertNew(xLL)

		self.errorXUpperLimitL.configure(text="Upper limit ("+self.xSymbol+"): ")
		self.errorXUpperLimitE.insertNew(xUL)

		self.errorYLowerLimitL.configure(text="Lower limit ("+self.ySymbol+"): ")
		self.errorYLowerLimitE.insertNew(yLL)

		self.errorYUpperLimitL.configure(text="Upper limit ("+self.ySymbol+"): ")
		self.errorYUpperLimitE.insertNew(yUL)

	def getSurfaceParameters(self):

		xLowerLimit = helper_functions.validateValue(self.errorXLowerLimitE.get(),
									self.xSymbol + " lower limit must be a positive number",
									"float",
									lowerBound=0)
		xUpperLimit = helper_functions.validateValue(self.errorXUpperLimitE.get(),
									self.xSymbol + " upper limit must be greater than the lower limit",
									"float",
									strictLowerBound=xLowerLimit)
		yLowerLimit = helper_functions.validateValue(self.errorYLowerLimitE.get(),
									self.ySymbol + " lower limit must be a positive number",
									"float",
									lowerBound=0)
		yUpperLimit = helper_functions.validateValue(self.errorYUpperLimitE.get(),
									self.ySymbol + " upper limit must be greater than the lower limit",
									"float",
									strictLowerBound=yLowerLimit)
		resolution = helper_functions.validateValue(self.errorResolutionE.get(),
								   "Resolution must be " + str(ERROR_SURFACE_MIN_RESOLUTION) + " \u2264 x \u2264 " + str(ERROR_SURFACE_MAX_RESOLUTION),
								   "int",
								   lowerBound=ERROR_SURFACE_MIN_RESOLUTION,
								   upperBound=ERROR_SURFACE_MAX_RESOLUTION)

		return [xLowerLimit,xUpperLimit,yLowerLimit,yUpperLimit,resolution]

	def clear(self):
		self.errorXLowerLimitE.insertNew("")
		self.errorXUpperLimitE.insertNew("")
		self.errorYLowerLimitE.insertNew("")
		self.errorYUpperLimitE.insertNew("")
Ejemplo n.º 4
0
	def __init__(self,parent, padX, padY):

		LabelFrame.__init__(self,parent,borderwidth=0)

		# Total volume
		self.totalEstimatedVolume_L = Label(self,text="Estimated total volume (km\u00B3): ")
		self.totalEstimatedVolume_E = CustomEntry(self,width=10,justify="right")
		self.totalEstimatedVolume_E.setUserEditable(False)
		self.totalEstimatedVolume_E.grid(row=0,column=1,padx=10,pady=padY,sticky="E")
		self.totalEstimatedVolume_L.grid(row=0,column=0,sticky="W",padx=10)

		# Relative squared error
		self.relativeSquaredError_L = Label(self,text="Mean relative squared error: ")
		self.relativeSquaredError_L.grid(row=1,column=0,sticky="W",padx=10,pady=padY)
		self.relativeSquaredError_E = CustomEntry(self,width=10,justify="right")
		self.relativeSquaredError_E.grid(row=1,column=1,padx=10,sticky="E")
		self.relativeSquaredError_E.setUserEditable(False)

		# Equation
		self.equation_L = Label(self,text="Equation: ")
		self.equation_E = CustomEntry(self,width=10,justify="right")
		self.equation_E.setUserEditable(False)

		# General
		self.parameters_L = Label(self,text="Parameters:")
		self.calculate_B = Button(self,text="Recalculate",width=12)
		self.reset_B = Button(self,text="Reset",width=8)



		#########
		## Exp ##
		#########

		# Segment combobox
		self.expSeg_CB = Combobox(self,state="readonly",width=10)

		# Segment volume
		self.expSegVolume_L = Label(self,text="Segment volume (km\u00B3): ")
		self.expSegVolume_E = CustomEntry(self, width=10, justify="right")
		self.expSegVolume_E.setUserEditable(False)

		# Segment start
		self.expSegStartLimit_L = Label(self,text="Start of segment: ")
		self.expSegStartLimit_E = NumericEntry(self, width=10, justify="right")
		self.expSegStartLimit_E.setSF(NUMBER_OF_SF)

		# Segment end
		self.expSegEndLimit_L = Label(self,text="End of segment: ")
		self.expSegEndLimit_E = NumericEntry(self, width=10, justify="right")
		self.expSegEndLimit_E.setSF(NUMBER_OF_SF)

		# Segment coefficient
		self.expSegCoefficent_L = Label(self,text="Segment coefficient, c: ")
		self.expSegCoefficent_E = NumericEntry(self, width=10, justify="right")
		self.expSegCoefficent_E.setSF(NUMBER_OF_SF)

		# Segment exponent
		self.expSegExponent_L = Label(self,text="Segment exponent, m: ")
		self.expSegExponent_E = NumericEntry(self, width=10, justify="right")
		self.expSegExponent_E.setSF(NUMBER_OF_SF)


		#########
		## Pow ##
		#########

		# Coefficient
		self.powCoefficient_L = Label(self,text="Coefficient, c: ")
		self.powCoefficient_E = NumericEntry(self,width=10, justify="right")
		self.powCoefficient_E.setSF(NUMBER_OF_SF)

		# Exponent
		self.powExponent_L = Label(self,text="Exponent, m: ")
		self.powExponent_E = NumericEntry(self,width=10, justify="right")
		self.powExponent_E.setSF(NUMBER_OF_SF)

		# Proximal limit
		self.powProximalLimit_L = Label(self,text="Proximal limit: ")
		self.powProximalLimit_E = NumericEntry(self,width=10, justify="right")
		self.powProximalLimit_E.setSF(NUMBER_OF_SF)

		# Distal limit
		self.powDistalLimit_L = Label(self,text="Distal limit: ")
		self.powDistalLimit_E = NumericEntry(self,width=10, justify="right")
		self.powDistalLimit_E.setSF(NUMBER_OF_SF)

		# Suggested proximal limit
		self.powSuggestedProximalLimit_L = Label(self,text="Suggested proximal limit: ")
		self.powSuggestedProximalLimit_E = CustomEntry(self,width=10, justify="right")
		self.powSuggestedProximalLimit_E.setUserEditable(False)



		#########
		## Wei ##
		#########

		# lambda
		self.weiLambdaL = Label(self,text="Estimated \u03BB: ")
		self.weiLambdaE = NumericEntry(self,width=10, justify="right")
		self.weiLambdaE.setSF(NUMBER_OF_SF)

		# k
		self.weiKL = Label(self,text="Estimated k: ")
		self.weiKE = NumericEntry(self,width=10, justify="right")
		self.weiKE.setSF(NUMBER_OF_SF)

		# theta
		self.weiThetaL = Label(self,text="Estimated \u03B8: ")
		self.weiThetaE = NumericEntry(self,width=10, justify="right")
		self.weiThetaE.setSF(NUMBER_OF_SF)


		self.components = {
			Model.EXP : [
				self.expSeg_CB,
				self.expSegVolume_L, self.expSegVolume_E,
				self.expSegStartLimit_L, self.expSegStartLimit_E,
				self.expSegEndLimit_L, self.expSegEndLimit_E,
				self.expSegCoefficent_L, self.expSegCoefficent_E,
				self.expSegExponent_L, self.expSegExponent_E
			],

			Model.POW : [
				self.powCoefficient_L, self.powCoefficient_E,
				self.powExponent_L, self.powExponent_E,
				self.powProximalLimit_L, self.powProximalLimit_E,
				self.powDistalLimit_L, self.powDistalLimit_E,
				self.powSuggestedProximalLimit_L, self.powSuggestedProximalLimit_E
			],

			Model.WEI : [
				self.weiLambdaL, self.weiLambdaE,
				self.weiKL, self.weiKE,
				self.weiThetaL, self.weiThetaE,
			],

		}
Ejemplo n.º 5
0
class StatsFrame(LabelFrame):

	def __init__(self,parent, padX, padY):

		LabelFrame.__init__(self,parent,borderwidth=0)

		# Total volume
		self.totalEstimatedVolume_L = Label(self,text="Estimated total volume (km\u00B3): ")
		self.totalEstimatedVolume_E = CustomEntry(self,width=10,justify="right")
		self.totalEstimatedVolume_E.setUserEditable(False)
		self.totalEstimatedVolume_E.grid(row=0,column=1,padx=10,pady=padY,sticky="E")
		self.totalEstimatedVolume_L.grid(row=0,column=0,sticky="W",padx=10)

		# Relative squared error
		self.relativeSquaredError_L = Label(self,text="Mean relative squared error: ")
		self.relativeSquaredError_L.grid(row=1,column=0,sticky="W",padx=10,pady=padY)
		self.relativeSquaredError_E = CustomEntry(self,width=10,justify="right")
		self.relativeSquaredError_E.grid(row=1,column=1,padx=10,sticky="E")
		self.relativeSquaredError_E.setUserEditable(False)

		# Equation
		self.equation_L = Label(self,text="Equation: ")
		self.equation_E = CustomEntry(self,width=10,justify="right")
		self.equation_E.setUserEditable(False)

		# General
		self.parameters_L = Label(self,text="Parameters:")
		self.calculate_B = Button(self,text="Recalculate",width=12)
		self.reset_B = Button(self,text="Reset",width=8)



		#########
		## Exp ##
		#########

		# Segment combobox
		self.expSeg_CB = Combobox(self,state="readonly",width=10)

		# Segment volume
		self.expSegVolume_L = Label(self,text="Segment volume (km\u00B3): ")
		self.expSegVolume_E = CustomEntry(self, width=10, justify="right")
		self.expSegVolume_E.setUserEditable(False)

		# Segment start
		self.expSegStartLimit_L = Label(self,text="Start of segment: ")
		self.expSegStartLimit_E = NumericEntry(self, width=10, justify="right")
		self.expSegStartLimit_E.setSF(NUMBER_OF_SF)

		# Segment end
		self.expSegEndLimit_L = Label(self,text="End of segment: ")
		self.expSegEndLimit_E = NumericEntry(self, width=10, justify="right")
		self.expSegEndLimit_E.setSF(NUMBER_OF_SF)

		# Segment coefficient
		self.expSegCoefficent_L = Label(self,text="Segment coefficient, c: ")
		self.expSegCoefficent_E = NumericEntry(self, width=10, justify="right")
		self.expSegCoefficent_E.setSF(NUMBER_OF_SF)

		# Segment exponent
		self.expSegExponent_L = Label(self,text="Segment exponent, m: ")
		self.expSegExponent_E = NumericEntry(self, width=10, justify="right")
		self.expSegExponent_E.setSF(NUMBER_OF_SF)


		#########
		## Pow ##
		#########

		# Coefficient
		self.powCoefficient_L = Label(self,text="Coefficient, c: ")
		self.powCoefficient_E = NumericEntry(self,width=10, justify="right")
		self.powCoefficient_E.setSF(NUMBER_OF_SF)

		# Exponent
		self.powExponent_L = Label(self,text="Exponent, m: ")
		self.powExponent_E = NumericEntry(self,width=10, justify="right")
		self.powExponent_E.setSF(NUMBER_OF_SF)

		# Proximal limit
		self.powProximalLimit_L = Label(self,text="Proximal limit: ")
		self.powProximalLimit_E = NumericEntry(self,width=10, justify="right")
		self.powProximalLimit_E.setSF(NUMBER_OF_SF)

		# Distal limit
		self.powDistalLimit_L = Label(self,text="Distal limit: ")
		self.powDistalLimit_E = NumericEntry(self,width=10, justify="right")
		self.powDistalLimit_E.setSF(NUMBER_OF_SF)

		# Suggested proximal limit
		self.powSuggestedProximalLimit_L = Label(self,text="Suggested proximal limit: ")
		self.powSuggestedProximalLimit_E = CustomEntry(self,width=10, justify="right")
		self.powSuggestedProximalLimit_E.setUserEditable(False)



		#########
		## Wei ##
		#########

		# lambda
		self.weiLambdaL = Label(self,text="Estimated \u03BB: ")
		self.weiLambdaE = NumericEntry(self,width=10, justify="right")
		self.weiLambdaE.setSF(NUMBER_OF_SF)

		# k
		self.weiKL = Label(self,text="Estimated k: ")
		self.weiKE = NumericEntry(self,width=10, justify="right")
		self.weiKE.setSF(NUMBER_OF_SF)

		# theta
		self.weiThetaL = Label(self,text="Estimated \u03B8: ")
		self.weiThetaE = NumericEntry(self,width=10, justify="right")
		self.weiThetaE.setSF(NUMBER_OF_SF)


		self.components = {
			Model.EXP : [
				self.expSeg_CB,
				self.expSegVolume_L, self.expSegVolume_E,
				self.expSegStartLimit_L, self.expSegStartLimit_E,
				self.expSegEndLimit_L, self.expSegEndLimit_E,
				self.expSegCoefficent_L, self.expSegCoefficent_E,
				self.expSegExponent_L, self.expSegExponent_E
			],

			Model.POW : [
				self.powCoefficient_L, self.powCoefficient_E,
				self.powExponent_L, self.powExponent_E,
				self.powProximalLimit_L, self.powProximalLimit_E,
				self.powDistalLimit_L, self.powDistalLimit_E,
				self.powSuggestedProximalLimit_L, self.powSuggestedProximalLimit_E
			],

			Model.WEI : [
				self.weiLambdaL, self.weiLambdaE,
				self.weiKL, self.weiKE,
				self.weiThetaL, self.weiThetaE,
			],

		}

	def getParameters(self, model):
		if model == Model.EXP:
			return {
				"c" : 			helper_functions.validateValue(self.expSegCoefficent_E.get(), 	"Coefficient, c, must be a number", 									"float"),
				"m" : 			helper_functions.validateValue(self.expSegExponent_E.get(), 	"Exponent, m, must be a number", 										"float"),
				"segStart" : 	helper_functions.validateValue(self.expSegStartLimit_E.get(), 	"'Start of segment' must be a number > 0", 								"float", lowerBound=0),
				"segEnd" : 		helper_functions.validateValue(self.expSegEndLimit_E.get(), 	"'End of segment' must be a number greater than the 'Start of segment'","float", strictLowerBound=float(self.expSegStartLimit_E.get())),
			}
		elif model == Model.POW:
			return {
				"c" : 			helper_functions.validateValue(self.powCoefficient_E.get(), "coefficient, c, must be a number", "float"),
				"m" : 			helper_functions.validateValue(self.powExponent_E.get(), 	"exponent, m, must be a number", 	"float")
			}
		elif model == Model.WEI:
			return {
				"lambda" : 		helper_functions.validateValue(self.weiLambdaE.get(), 	"\u03BB must be a positive number", "float", strictLowerBound=0),
				"k" : 			helper_functions.validateValue(self.weiKE.get(), 		"k must be a positive number", 		"float", strictLowerBound=0),
				"theta" : 		helper_functions.validateValue(self.weiThetaE.get(), 	"\u03B8 must be a positive number", "float", strictLowerBound=0)
			}
Ejemplo n.º 6
0
    def __init__(self, parent):
        LabelFrame.__init__(self, parent, text="Model", borderwidth=5)

        self.selection = tkinter.IntVar()

        self.exponential = Radiobutton(self,
                                       text="Exponential model",
                                       variable=self.selection,
                                       value=Model.EXP.value,
                                       command=self.changeSelection)
        self.powerlaw = Radiobutton(self,
                                    text="Power law model",
                                    variable=self.selection,
                                    value=Model.POW.value,
                                    command=self.changeSelection)
        self.weibull = Radiobutton(self,
                                   text="Weibull model",
                                   variable=self.selection,
                                   value=Model.WEI.value,
                                   command=self.changeSelection)

        self.exponential.grid(row=0,
                              column=0,
                              sticky="W",
                              padx=10,
                              pady=(self.topPadding, 5))
        self.powerlaw.grid(row=1, column=0, sticky="W", padx=10, pady=5)
        self.weibull.grid(row=2, column=0, sticky="W", padx=10, pady=(5, 0))

        seperator = Separator(self, orient=tkinter.VERTICAL)
        seperator.grid(row=0,
                       column=1,
                       rowspan=3,
                       sticky="NS",
                       padx=(20, 10),
                       pady=(self.topPadding, 0))

        ## Exponential setup

        self.expNumberOfSegments_L = Label(self, text="Number of segments: ")
        self.expNumberOfSegments_E = Entry(self, width=5, justify="right")

        self.expNumberOfSegments_E.insert(
            0, settings.EXP_DEFAULT_NUMBER_OF_SEGMENTS)

        self.expWidgets = [
            self.expNumberOfSegments_L, self.expNumberOfSegments_E
        ]

        ## Power law setup

        self.powProximalLimit_L = Label(self,
                                        text="Proximal limit of integration: ")
        self.powProximalLimit_E = Entry(self, width=5, justify="right")
        self.powDistalLimit_L = Label(self,
                                      text="Distal limit of integration: ")
        self.powDistalLimit_E = Entry(self, width=5, justify="right")

        self.powProximalLimit_E.insert(0, settings.POW_DEFAULT_PROXIMAL_LIMIT)
        self.powDistalLimit_E.insert(0, settings.POW_DEFAULT_DISTAL_LIMIT)

        self.powWidgets = [
            self.powProximalLimit_L, self.powProximalLimit_E,
            self.powDistalLimit_L, self.powDistalLimit_E
        ]

        ## Weibull setup

        self.weiNumberOfRuns_L = Label(self, text="Number of runs: ")
        self.weiNumberOfRuns_E = Entry(self, width=5, justify="right")
        self.weiIterationsPerRun_L = Label(self, text="Iterations per run: ")
        self.weiIterationsPerRun_E = Entry(self, width=5, justify="right")

        self.weiEstimatedTime_L = Label(self, text="Estimated time (s): ")
        self.weiEstimatedTime_E = CustomEntry(self, width=5, justify="right")
        self.weiEstimatedTime_E.setUserEditable(False)

        self.weiLambdaLowerBoundL = Label(self, text="\u03BB lower bound:")
        self.weiLambdaUpperBoundL = Label(self, text="\u03BB upper bound:")
        self.weiLambdaLowerBoundE = Entry(self, width=5, justify="right")
        self.weiLambdaUpperBoundE = Entry(self, width=5, justify="right")

        self.weiKLowerBoundL = Label(self, text="k lower bound:")
        self.weiKUpperBoundL = Label(self, text="k upper bound:")
        self.weiKLowerBoundE = Entry(self, width=5, justify="right")
        self.weiKUpperBoundE = Entry(self, width=5, justify="right")

        self.weiNumberOfRuns_E.insert(0, settings.WEI_DEFAULT_NUMBER_OF_RUNS)
        self.weiIterationsPerRun_E.insert(
            0, settings.WEI_DEFAULT_ITERATIONS_PER_RUN)
        self.weiLambdaLowerBoundE.insert(
            0, settings.WEI_DEFAULT_LAMBDA_LOWER_BOUND)
        self.weiLambdaUpperBoundE.insert(
            0, settings.WEI_DEFAULT_LAMBDA_UPPER_BOUND)
        self.weiKLowerBoundE.insert(0, settings.WEI_DEFAULT_K_LOWER_BOUND)
        self.weiKUpperBoundE.insert(0, settings.WEI_DEFAULT_K_UPPER_BOUND)

        self.weiWidgets = [
            self.weiNumberOfRuns_L, self.weiNumberOfRuns_E,
            self.weiIterationsPerRun_L, self.weiIterationsPerRun_E,
            self.weiEstimatedTime_L, self.weiEstimatedTime_E,
            self.weiLambdaLowerBoundL, self.weiLambdaUpperBoundL,
            self.weiLambdaLowerBoundE, self.weiLambdaUpperBoundE,
            self.weiKLowerBoundL, self.weiKUpperBoundL, self.weiKLowerBoundE,
            self.weiKUpperBoundE
        ]

        ## General

        self.currentWidgets = []
        self.selection.set(Model.EXP.value)
        self.changeSelection()
Ejemplo n.º 7
0
class ModelFrame(LabelFrame):

    topPadding = 12

    def __init__(self, parent):
        LabelFrame.__init__(self, parent, text="Model", borderwidth=5)

        self.selection = tkinter.IntVar()

        self.exponential = Radiobutton(self,
                                       text="Exponential model",
                                       variable=self.selection,
                                       value=Model.EXP.value,
                                       command=self.changeSelection)
        self.powerlaw = Radiobutton(self,
                                    text="Power law model",
                                    variable=self.selection,
                                    value=Model.POW.value,
                                    command=self.changeSelection)
        self.weibull = Radiobutton(self,
                                   text="Weibull model",
                                   variable=self.selection,
                                   value=Model.WEI.value,
                                   command=self.changeSelection)

        self.exponential.grid(row=0,
                              column=0,
                              sticky="W",
                              padx=10,
                              pady=(self.topPadding, 5))
        self.powerlaw.grid(row=1, column=0, sticky="W", padx=10, pady=5)
        self.weibull.grid(row=2, column=0, sticky="W", padx=10, pady=(5, 0))

        seperator = Separator(self, orient=tkinter.VERTICAL)
        seperator.grid(row=0,
                       column=1,
                       rowspan=3,
                       sticky="NS",
                       padx=(20, 10),
                       pady=(self.topPadding, 0))

        ## Exponential setup

        self.expNumberOfSegments_L = Label(self, text="Number of segments: ")
        self.expNumberOfSegments_E = Entry(self, width=5, justify="right")

        self.expNumberOfSegments_E.insert(
            0, settings.EXP_DEFAULT_NUMBER_OF_SEGMENTS)

        self.expWidgets = [
            self.expNumberOfSegments_L, self.expNumberOfSegments_E
        ]

        ## Power law setup

        self.powProximalLimit_L = Label(self,
                                        text="Proximal limit of integration: ")
        self.powProximalLimit_E = Entry(self, width=5, justify="right")
        self.powDistalLimit_L = Label(self,
                                      text="Distal limit of integration: ")
        self.powDistalLimit_E = Entry(self, width=5, justify="right")

        self.powProximalLimit_E.insert(0, settings.POW_DEFAULT_PROXIMAL_LIMIT)
        self.powDistalLimit_E.insert(0, settings.POW_DEFAULT_DISTAL_LIMIT)

        self.powWidgets = [
            self.powProximalLimit_L, self.powProximalLimit_E,
            self.powDistalLimit_L, self.powDistalLimit_E
        ]

        ## Weibull setup

        self.weiNumberOfRuns_L = Label(self, text="Number of runs: ")
        self.weiNumberOfRuns_E = Entry(self, width=5, justify="right")
        self.weiIterationsPerRun_L = Label(self, text="Iterations per run: ")
        self.weiIterationsPerRun_E = Entry(self, width=5, justify="right")

        self.weiEstimatedTime_L = Label(self, text="Estimated time (s): ")
        self.weiEstimatedTime_E = CustomEntry(self, width=5, justify="right")
        self.weiEstimatedTime_E.setUserEditable(False)

        self.weiLambdaLowerBoundL = Label(self, text="\u03BB lower bound:")
        self.weiLambdaUpperBoundL = Label(self, text="\u03BB upper bound:")
        self.weiLambdaLowerBoundE = Entry(self, width=5, justify="right")
        self.weiLambdaUpperBoundE = Entry(self, width=5, justify="right")

        self.weiKLowerBoundL = Label(self, text="k lower bound:")
        self.weiKUpperBoundL = Label(self, text="k upper bound:")
        self.weiKLowerBoundE = Entry(self, width=5, justify="right")
        self.weiKUpperBoundE = Entry(self, width=5, justify="right")

        self.weiNumberOfRuns_E.insert(0, settings.WEI_DEFAULT_NUMBER_OF_RUNS)
        self.weiIterationsPerRun_E.insert(
            0, settings.WEI_DEFAULT_ITERATIONS_PER_RUN)
        self.weiLambdaLowerBoundE.insert(
            0, settings.WEI_DEFAULT_LAMBDA_LOWER_BOUND)
        self.weiLambdaUpperBoundE.insert(
            0, settings.WEI_DEFAULT_LAMBDA_UPPER_BOUND)
        self.weiKLowerBoundE.insert(0, settings.WEI_DEFAULT_K_LOWER_BOUND)
        self.weiKUpperBoundE.insert(0, settings.WEI_DEFAULT_K_UPPER_BOUND)

        self.weiWidgets = [
            self.weiNumberOfRuns_L, self.weiNumberOfRuns_E,
            self.weiIterationsPerRun_L, self.weiIterationsPerRun_E,
            self.weiEstimatedTime_L, self.weiEstimatedTime_E,
            self.weiLambdaLowerBoundL, self.weiLambdaUpperBoundL,
            self.weiLambdaLowerBoundE, self.weiLambdaUpperBoundE,
            self.weiKLowerBoundL, self.weiKUpperBoundL, self.weiKLowerBoundE,
            self.weiKUpperBoundE
        ]

        ## General

        self.currentWidgets = []
        self.selection.set(Model.EXP.value)
        self.changeSelection()

    def changeSelection(self):

        for widget in self.currentWidgets:
            widget.grid_remove()

        modelType = Model(self.selection.get())

        sX = 10
        bX = 20

        if modelType == Model.EXP:
            self.expNumberOfSegments_L.grid(row=0,
                                            column=2,
                                            padx=(bX, sX),
                                            pady=(self.topPadding, 5),
                                            sticky="W")
            self.expNumberOfSegments_E.grid(row=0,
                                            column=3,
                                            padx=(sX, bX),
                                            pady=(self.topPadding, 5),
                                            sticky="W")
            self.currentWidgets = self.expWidgets
        elif modelType == Model.POW:
            self.powProximalLimit_L.grid(row=0,
                                         column=2,
                                         padx=(bX, sX),
                                         pady=(self.topPadding, 5),
                                         sticky="W")
            self.powProximalLimit_E.grid(row=0,
                                         column=3,
                                         padx=(sX, bX),
                                         pady=(self.topPadding, 5),
                                         sticky="W")
            self.powDistalLimit_L.grid(row=1,
                                       column=2,
                                       padx=(bX, sX),
                                       pady=5,
                                       sticky="W")
            self.powDistalLimit_E.grid(row=1,
                                       column=3,
                                       padx=(sX, bX),
                                       pady=5,
                                       sticky="W")
            self.currentWidgets = self.powWidgets
        elif modelType == Model.WEI:
            self.weiNumberOfRuns_L.grid(row=0,
                                        column=2,
                                        padx=(bX, sX),
                                        pady=(self.topPadding, 5),
                                        sticky="W")
            self.weiNumberOfRuns_E.grid(row=0,
                                        column=3,
                                        padx=(sX, bX),
                                        pady=(self.topPadding, 5),
                                        sticky="W")
            self.weiIterationsPerRun_L.grid(row=1,
                                            column=2,
                                            padx=(bX, sX),
                                            pady=5,
                                            sticky="W")
            self.weiIterationsPerRun_E.grid(row=1,
                                            column=3,
                                            padx=(sX, bX),
                                            pady=5,
                                            sticky="W")
            self.weiEstimatedTime_L.grid(row=2,
                                         column=2,
                                         padx=(bX, sX),
                                         pady=5,
                                         sticky="W")
            self.weiEstimatedTime_E.grid(row=2,
                                         column=3,
                                         padx=(sX, bX),
                                         pady=5,
                                         sticky="W")

            self.weiLambdaLowerBoundL.grid(row=0,
                                           column=4,
                                           padx=(bX, sX),
                                           pady=(self.topPadding, 5),
                                           sticky="W")
            self.weiLambdaLowerBoundE.grid(row=0,
                                           column=5,
                                           padx=(sX, bX),
                                           pady=(self.topPadding, 5))
            self.weiLambdaUpperBoundL.grid(row=1,
                                           column=4,
                                           padx=(bX, sX),
                                           pady=5,
                                           sticky="W")
            self.weiLambdaUpperBoundE.grid(row=1,
                                           column=5,
                                           padx=(sX, bX),
                                           pady=5)

            self.weiKLowerBoundL.grid(row=0,
                                      column=6,
                                      padx=(bX, sX),
                                      pady=(self.topPadding, 5),
                                      sticky="W")
            self.weiKLowerBoundE.grid(row=0,
                                      column=7,
                                      padx=(sX, sX),
                                      pady=(self.topPadding, 5))
            self.weiKUpperBoundL.grid(row=1,
                                      column=6,
                                      padx=(bX, sX),
                                      pady=5,
                                      sticky="W")
            self.weiKUpperBoundE.grid(row=1, column=7, padx=(sX, sX), pady=5)

            self.currentWidgets = self.weiWidgets

    def getModelDetails(self):
        modelType = Model(self.selection.get())
        values = [modelType]

        if modelType == Model.EXP:
            numberOfSegments = helper_functions.validateValue(
                self.expNumberOfSegments_E.get(),
                "The number of exponential segments must be 1 \u2264 n \u2264 "
                + str(settings.EXP_MAX_NUMBER_OF_SEGMENTS),
                "int",
                lowerBound=1,
                upperBound=settings.EXP_MAX_NUMBER_OF_SEGMENTS)
            values.append(numberOfSegments)

        elif modelType == Model.POW:
            proximalLimitKM = helper_functions.validateValue(
                self.powProximalLimit_E.get(),
                "The proximal limit of integration must be 0 \u2264 x \u2264 \u221E",
                "float",
                strictLowerBound=0,
                strictUpperBound=float('inf'))
            proximalLimitKM /= SQRT_PI

            distalLimitKM = helper_functions.validateValue(
                self.powDistalLimit_E.get(),
                "The distal limit of integration must be prox \u2264 x \u2264 \u221E",
                "float",
                strictLowerBound=proximalLimitKM,
                strictUpperBound=float('inf'))
            distalLimitKM /= SQRT_PI

            values.extend([proximalLimitKM, distalLimitKM])

        elif modelType == Model.WEI:
            numberOfRuns = helper_functions.validateValue(
                self.weiNumberOfRuns_E.get(),
                "The number of runs must be greater than 0",
                "int",
                strictLowerBound=0)

            iterationsPerRun = helper_functions.validateValue(
                self.weiIterationsPerRun_E.get(),
                "The number of iterations must be greater than 0",
                "int",
                strictLowerBound=0)

            lambdaLowerBound = helper_functions.validateValue(
                self.weiLambdaLowerBoundE.get(),
                "The lower bound for \u03BB must be a decimal", "float")

            lambdaUpperBound = helper_functions.validateValue(
                self.weiLambdaUpperBoundE.get(),
                "The upper bound for \u03BB must be greater than the lower bound",
                "float",
                strictLowerBound=lambdaLowerBound)

            kLowerBound = helper_functions.validateValue(
                self.weiKLowerBoundE.get(),
                "The lower bound for k must be numeric and less than 2",
                "float",
                strictUpperBound=2)

            kUpperBound = helper_functions.validateValue(
                self.weiKUpperBoundE.get(),
                "The upper bound for k must be greater than the lower bound and less than or equal to 2",
                "float",
                strictLowerBound=kLowerBound,
                upperBound=2)

            values.extend([
                numberOfRuns, iterationsPerRun,
                [[lambdaLowerBound, lambdaUpperBound],
                 [kLowerBound, kUpperBound]]
            ])

        return values
Ejemplo n.º 8
0
class ErrorSurfaceFrame(LabelFrame):
	
	def __init__(self,parent):
		LabelFrame.__init__(self, parent, borderwidth=0)
		
		entryWidth = 7
		xPad1 = 30
		xPad2 = 5
		
		self.errorXLowerLimitL = Label(self)
		self.errorXLowerLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorXLowerLimitL.grid(row=0,column=0,padx=(10,xPad2),pady=5,sticky="W")
		self.errorXLowerLimitE.grid(row=0,column=1,padx=(xPad2,xPad1),pady=5)
		
		self.errorXUpperLimitL = Label(self)
		self.errorXUpperLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorXUpperLimitL.grid(row=1,column=0,padx=(10,xPad2),pady=5,sticky="W")
		self.errorXUpperLimitE.grid(row=1,column=1,padx=(xPad2,xPad1),pady=5)
		
		self.errorYLowerLimitL = Label(self)
		self.errorYLowerLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorYLowerLimitL.grid(row=0,column=2,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorYLowerLimitE.grid(row=0,column=3,padx=(xPad2,xPad1),pady=5)
		
		self.errorYUpperLimitL = Label(self)
		self.errorYUpperLimitE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorYUpperLimitL.grid(row=1,column=2,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorYUpperLimitE.grid(row=1,column=3,padx=(xPad2,xPad1),pady=5)
		
		self.errorResolutionL = Label(self,text="Resolution: ")
		self.errorResolutionE = CustomEntry(self,width=entryWidth,justify="right")
		self.errorResolutionE.insert(0,ERROR_SURFACE_DEFAULT_RESOLUTION)
		self.errorResolutionL.grid(row=0,column=4,padx=(xPad1,xPad2),pady=5,sticky="W")
		self.errorResolutionE.grid(row=0,column=5,padx=(xPad2,xPad1),pady=5,sticky="E")
		
		self.errorSurfaceB = Button(self,text=" Calculate error surface ")
		self.errorSurfaceB.grid(row=1,column=4,columnspan=2,padx=(xPad1,xPad1),sticky="EW")
		self.errorSurfaceB.configure(state=tkinter.ACTIVE)
		
	def update(self,xSymbol,ySymbol,xLL,xUL,yLL,yUL):
		
		self.xSymbol = xSymbol
		self.ySymbol = ySymbol
		
		self.errorXLowerLimitL.configure(text="Lower limit ("+self.xSymbol+"): ")
		self.errorXLowerLimitE.insertNew(xLL)
		
		self.errorXUpperLimitL.configure(text="Upper limit ("+self.xSymbol+"): ")
		self.errorXUpperLimitE.insertNew(xUL)
		
		self.errorYLowerLimitL.configure(text="Lower limit ("+self.ySymbol+"): ")
		self.errorYLowerLimitE.insertNew(yLL)
		
		self.errorYUpperLimitL.configure(text="Upper limit ("+self.ySymbol+"): ")
		self.errorYUpperLimitE.insertNew(yUL)
		
	def getSurfaceParameters(self):
		
		xLowerLimit = helper_functions.validateValue(self.errorXLowerLimitE.get(),
									self.xSymbol + " lower limit must be a positive number",
									"float",
									lowerBound=0)
		xUpperLimit = helper_functions.validateValue(self.errorXUpperLimitE.get(),
									self.xSymbol + " upper limit must be greater than the lower limit",
									"float",
									strictLowerBound=xLowerLimit)
		yLowerLimit = helper_functions.validateValue(self.errorYLowerLimitE.get(),
									self.ySymbol + " lower limit must be a positive number",
									"float",
									lowerBound=0)
		yUpperLimit = helper_functions.validateValue(self.errorYUpperLimitE.get(),
									self.ySymbol + " upper limit must be greater than the lower limit",
									"float",
									strictLowerBound=yLowerLimit)
		resolution = helper_functions.validateValue(self.errorResolutionE.get(),
								   "Resolution must be " + str(ERROR_SURFACE_MIN_RESOLUTION) + " \u2264 x \u2264 " + str(ERROR_SURFACE_MAX_RESOLUTION),
								   "int",
								   lowerBound=ERROR_SURFACE_MIN_RESOLUTION,
								   upperBound=ERROR_SURFACE_MAX_RESOLUTION)
		
		return [xLowerLimit,xUpperLimit,yLowerLimit,yUpperLimit,resolution]
		
	def clear(self):
		self.errorXLowerLimitE.insertNew("")
		self.errorXUpperLimitE.insertNew("")
		self.errorYLowerLimitE.insertNew("")
		self.errorYUpperLimitE.insertNew("")
Ejemplo n.º 9
0
	def __init__(self,parent, padX, padY):
		
		LabelFrame.__init__(self,parent,borderwidth=0)
		
		# Total volume
		self.totalEstimatedVolume_L = Label(self,text="Estimated total volume (km\u00B3): ")
		self.totalEstimatedVolume_E = CustomEntry(self,width=10,justify="right")
		self.totalEstimatedVolume_E.setUserEditable(False)
		self.totalEstimatedVolume_E.grid(row=0,column=1,padx=10,pady=padY,sticky="E")
		self.totalEstimatedVolume_L.grid(row=0,column=0,sticky="W",padx=10)
		
		# Relative squared error
		self.relativeSquaredError_L = Label(self,text="Mean relative squared error: ")
		self.relativeSquaredError_L.grid(row=1,column=0,sticky="W",padx=10,pady=padY)
		self.relativeSquaredError_E = CustomEntry(self,width=10,justify="right")
		self.relativeSquaredError_E.grid(row=1,column=1,padx=10,sticky="E")
		self.relativeSquaredError_E.setUserEditable(False)
		
		# Equation
		self.equation_L = Label(self,text="Equation: ")
		self.equation_E = CustomEntry(self,width=10,justify="right")
		self.equation_E.setUserEditable(False)

		# General
		self.parameters_L = Label(self,text="Parameters:")
		self.calculate_B = Button(self,text="Recalculate",width=12)
		self.reset_B = Button(self,text="Reset",width=8)



		#########
		## Exp ##
		#########

		# Segment combobox
		self.expSeg_CB = Combobox(self,state="readonly",width=10)

		# Segment volume
		self.expSegVolume_L = Label(self,text="Segment volume (km\u00B3): ")
		self.expSegVolume_E = CustomEntry(self, width=10, justify="right")
		self.expSegVolume_E.setUserEditable(False)
		
		# Segment start
		self.expSegStartLimit_L = Label(self,text="Start of segment: ")
		self.expSegStartLimit_E = NumericEntry(self, width=10, justify="right")
		self.expSegStartLimit_E.setSF(NUMBER_OF_SF)

		# Segment end
		self.expSegEndLimit_L = Label(self,text="End of segment: ")
		self.expSegEndLimit_E = NumericEntry(self, width=10, justify="right")
		self.expSegEndLimit_E.setSF(NUMBER_OF_SF)

		# Segment coefficient
		self.expSegCoefficent_L = Label(self,text="Segment coefficient, c: ")
		self.expSegCoefficent_E = NumericEntry(self, width=10, justify="right")
		self.expSegCoefficent_E.setSF(NUMBER_OF_SF)

		# Segment exponent
		self.expSegExponent_L = Label(self,text="Segment exponent, m: ")
		self.expSegExponent_E = NumericEntry(self, width=10, justify="right")
		self.expSegExponent_E.setSF(NUMBER_OF_SF)
		

		#########
		## Pow ##
		#########

		# Coefficient
		self.powCoefficient_L = Label(self,text="Coefficient, c: ")
		self.powCoefficient_E = NumericEntry(self,width=10, justify="right")
		self.powCoefficient_E.setSF(NUMBER_OF_SF)

		# Exponent
		self.powExponent_L = Label(self,text="Exponent, m: ")
		self.powExponent_E = NumericEntry(self,width=10, justify="right")
		self.powExponent_E.setSF(NUMBER_OF_SF)

		# Proximal limit
		self.powProximalLimit_L = Label(self,text="Proximal limit: ")
		self.powProximalLimit_E = NumericEntry(self,width=10, justify="right")
		self.powProximalLimit_E.setSF(NUMBER_OF_SF)

		# Distal limit
		self.powDistalLimit_L = Label(self,text="Distal limit: ")
		self.powDistalLimit_E = NumericEntry(self,width=10, justify="right")
		self.powDistalLimit_E.setSF(NUMBER_OF_SF)

		# Suggested proximal limit
		self.powSuggestedProximalLimit_L = Label(self,text="Suggested proximal limit: ")
		self.powSuggestedProximalLimit_E = CustomEntry(self,width=10, justify="right")
		self.powSuggestedProximalLimit_E.setUserEditable(False)

		

		#########
		## Wei ##
		#########

		# lambda
		self.weiLambdaL = Label(self,text="Estimated \u03BB: ")
		self.weiLambdaE = NumericEntry(self,width=10, justify="right")
		self.weiLambdaE.setSF(NUMBER_OF_SF)

		# k
		self.weiKL = Label(self,text="Estimated k: ")
		self.weiKE = NumericEntry(self,width=10, justify="right")
		self.weiKE.setSF(NUMBER_OF_SF)

		# theta
		self.weiThetaL = Label(self,text="Estimated \u03B8: ")
		self.weiThetaE = NumericEntry(self,width=10, justify="right")
		self.weiThetaE.setSF(NUMBER_OF_SF)


		self.components = {
			Model.EXP : [
				self.expSeg_CB,
				self.expSegVolume_L, self.expSegVolume_E, 
				self.expSegStartLimit_L, self.expSegStartLimit_E,
				self.expSegEndLimit_L, self.expSegEndLimit_E,
				self.expSegCoefficent_L, self.expSegCoefficent_E,
				self.expSegExponent_L, self.expSegExponent_E
			],

			Model.POW : [
				self.powCoefficient_L, self.powCoefficient_E,
				self.powExponent_L, self.powExponent_E,
				self.powProximalLimit_L, self.powProximalLimit_E,
				self.powDistalLimit_L, self.powDistalLimit_E,
				self.powSuggestedProximalLimit_L, self.powSuggestedProximalLimit_E
			],

			Model.WEI : [
				self.weiLambdaL, self.weiLambdaE,
				self.weiKL, self.weiKE,
				self.weiThetaL, self.weiThetaE,
			],

		}
Ejemplo n.º 10
0
class StatsFrame(LabelFrame):
	
	def __init__(self,parent, padX, padY):
		
		LabelFrame.__init__(self,parent,borderwidth=0)
		
		# Total volume
		self.totalEstimatedVolume_L = Label(self,text="Estimated total volume (km\u00B3): ")
		self.totalEstimatedVolume_E = CustomEntry(self,width=10,justify="right")
		self.totalEstimatedVolume_E.setUserEditable(False)
		self.totalEstimatedVolume_E.grid(row=0,column=1,padx=10,pady=padY,sticky="E")
		self.totalEstimatedVolume_L.grid(row=0,column=0,sticky="W",padx=10)
		
		# Relative squared error
		self.relativeSquaredError_L = Label(self,text="Mean relative squared error: ")
		self.relativeSquaredError_L.grid(row=1,column=0,sticky="W",padx=10,pady=padY)
		self.relativeSquaredError_E = CustomEntry(self,width=10,justify="right")
		self.relativeSquaredError_E.grid(row=1,column=1,padx=10,sticky="E")
		self.relativeSquaredError_E.setUserEditable(False)
		
		# Equation
		self.equation_L = Label(self,text="Equation: ")
		self.equation_E = CustomEntry(self,width=10,justify="right")
		self.equation_E.setUserEditable(False)

		# General
		self.parameters_L = Label(self,text="Parameters:")
		self.calculate_B = Button(self,text="Recalculate",width=12)
		self.reset_B = Button(self,text="Reset",width=8)



		#########
		## Exp ##
		#########

		# Segment combobox
		self.expSeg_CB = Combobox(self,state="readonly",width=10)

		# Segment volume
		self.expSegVolume_L = Label(self,text="Segment volume (km\u00B3): ")
		self.expSegVolume_E = CustomEntry(self, width=10, justify="right")
		self.expSegVolume_E.setUserEditable(False)
		
		# Segment start
		self.expSegStartLimit_L = Label(self,text="Start of segment: ")
		self.expSegStartLimit_E = NumericEntry(self, width=10, justify="right")
		self.expSegStartLimit_E.setSF(NUMBER_OF_SF)

		# Segment end
		self.expSegEndLimit_L = Label(self,text="End of segment: ")
		self.expSegEndLimit_E = NumericEntry(self, width=10, justify="right")
		self.expSegEndLimit_E.setSF(NUMBER_OF_SF)

		# Segment coefficient
		self.expSegCoefficent_L = Label(self,text="Segment coefficient, c: ")
		self.expSegCoefficent_E = NumericEntry(self, width=10, justify="right")
		self.expSegCoefficent_E.setSF(NUMBER_OF_SF)

		# Segment exponent
		self.expSegExponent_L = Label(self,text="Segment exponent, m: ")
		self.expSegExponent_E = NumericEntry(self, width=10, justify="right")
		self.expSegExponent_E.setSF(NUMBER_OF_SF)
		

		#########
		## Pow ##
		#########

		# Coefficient
		self.powCoefficient_L = Label(self,text="Coefficient, c: ")
		self.powCoefficient_E = NumericEntry(self,width=10, justify="right")
		self.powCoefficient_E.setSF(NUMBER_OF_SF)

		# Exponent
		self.powExponent_L = Label(self,text="Exponent, m: ")
		self.powExponent_E = NumericEntry(self,width=10, justify="right")
		self.powExponent_E.setSF(NUMBER_OF_SF)

		# Proximal limit
		self.powProximalLimit_L = Label(self,text="Proximal limit: ")
		self.powProximalLimit_E = NumericEntry(self,width=10, justify="right")
		self.powProximalLimit_E.setSF(NUMBER_OF_SF)

		# Distal limit
		self.powDistalLimit_L = Label(self,text="Distal limit: ")
		self.powDistalLimit_E = NumericEntry(self,width=10, justify="right")
		self.powDistalLimit_E.setSF(NUMBER_OF_SF)

		# Suggested proximal limit
		self.powSuggestedProximalLimit_L = Label(self,text="Suggested proximal limit: ")
		self.powSuggestedProximalLimit_E = CustomEntry(self,width=10, justify="right")
		self.powSuggestedProximalLimit_E.setUserEditable(False)

		

		#########
		## Wei ##
		#########

		# lambda
		self.weiLambdaL = Label(self,text="Estimated \u03BB: ")
		self.weiLambdaE = NumericEntry(self,width=10, justify="right")
		self.weiLambdaE.setSF(NUMBER_OF_SF)

		# k
		self.weiKL = Label(self,text="Estimated k: ")
		self.weiKE = NumericEntry(self,width=10, justify="right")
		self.weiKE.setSF(NUMBER_OF_SF)

		# theta
		self.weiThetaL = Label(self,text="Estimated \u03B8: ")
		self.weiThetaE = NumericEntry(self,width=10, justify="right")
		self.weiThetaE.setSF(NUMBER_OF_SF)


		self.components = {
			Model.EXP : [
				self.expSeg_CB,
				self.expSegVolume_L, self.expSegVolume_E, 
				self.expSegStartLimit_L, self.expSegStartLimit_E,
				self.expSegEndLimit_L, self.expSegEndLimit_E,
				self.expSegCoefficent_L, self.expSegCoefficent_E,
				self.expSegExponent_L, self.expSegExponent_E
			],

			Model.POW : [
				self.powCoefficient_L, self.powCoefficient_E,
				self.powExponent_L, self.powExponent_E,
				self.powProximalLimit_L, self.powProximalLimit_E,
				self.powDistalLimit_L, self.powDistalLimit_E,
				self.powSuggestedProximalLimit_L, self.powSuggestedProximalLimit_E
			],

			Model.WEI : [
				self.weiLambdaL, self.weiLambdaE,
				self.weiKL, self.weiKE,
				self.weiThetaL, self.weiThetaE,
			],

		}

	def getParameters(self, model):
		if model == Model.EXP:
			return {
				"c" : 			helper_functions.validateValue(self.expSegCoefficent_E.get(), 	"Coefficient, c, must be a number", 									"float"),
				"m" : 			helper_functions.validateValue(self.expSegExponent_E.get(), 	"Exponent, m, must be a number", 										"float"),
				"segStart" : 	helper_functions.validateValue(self.expSegStartLimit_E.get(), 	"'Start of segment' must be a number > 0", 								"float", lowerBound=0),
				"segEnd" : 		helper_functions.validateValue(self.expSegEndLimit_E.get(), 	"'End of segment' must be a number greater than the 'Start of segment'","float", strictLowerBound=float(self.expSegStartLimit_E.get())),
			}
		elif model == Model.POW:
			return {
				"c" : 			helper_functions.validateValue(self.powCoefficient_E.get(), "coefficient, c, must be a number", "float"),
				"m" : 			helper_functions.validateValue(self.powExponent_E.get(), 	"exponent, m, must be a number", 	"float")
			}
		elif model == Model.WEI:
			return {
				"lambda" : 		helper_functions.validateValue(self.weiLambdaE.get(), 	"\u03BB must be a positive number", "float", strictLowerBound=0),
				"k" : 			helper_functions.validateValue(self.weiKE.get(), 		"k must be a positive number", 		"float", strictLowerBound=0),
				"theta" : 		helper_functions.validateValue(self.weiThetaE.get(), 	"\u03B8 must be a positive number", "float", strictLowerBound=0)
			}
Ejemplo n.º 11
0
	def __init__(self,parent):        
		LabelFrame.__init__(self,parent,text="Model",borderwidth=5)
		
		self.selection = tkinter.IntVar()
		
		self.exponential = Radiobutton(self,text="Exponential model",variable=self.selection,value=Model.EXP.value,command=self.changeSelection)
		self.powerlaw = Radiobutton(self,text="Power law model",variable=self.selection,value=Model.POW.value,command=self.changeSelection)
		self.weibull = Radiobutton(self,text="Weibull model",variable=self.selection,value=Model.WEI.value,command=self.changeSelection)

		self.exponential.grid(row=0,column=0,sticky="W",padx=10,pady=(self.topPadding,5))
		self.powerlaw.grid(row=1,column=0,sticky="W",padx=10,pady=5)
		self.weibull.grid(row=2,column=0,sticky="W",padx=10,pady=(5,0))
		
		seperator = Separator(self, orient=tkinter.VERTICAL)
		seperator.grid(row=0, column=1, rowspan=3, sticky="NS", padx=(20,10), pady=(self.topPadding,0))
		
		## Exponential setup

		self.expNumberOfSegments_L = Label(self,text="Number of segments: ")
		self.expNumberOfSegments_E = Entry(self,width=5, justify="right")

		self.expNumberOfSegments_E.insert(0, settings.EXP_DEFAULT_NUMBER_OF_SEGMENTS)

		self.expWidgets = [self.expNumberOfSegments_L,self.expNumberOfSegments_E]
		
		## Power law setup

		self.powProximalLimit_L = Label(self,text="Proximal limit of integration: ")
		self.powProximalLimit_E = Entry(self,width=5, justify="right")
		self.powDistalLimit_L = Label(self,text="Distal limit of integration: ")
		self.powDistalLimit_E = Entry(self,width=5, justify="right")

		self.powProximalLimit_E.insert(0, settings.POW_DEFAULT_PROXIMAL_LIMIT)
		self.powDistalLimit_E.insert(0, settings.POW_DEFAULT_DISTAL_LIMIT)

		self.powWidgets = [self.powProximalLimit_L,self.powProximalLimit_E,
						   self.powDistalLimit_L,self.powDistalLimit_E]
		
		## Weibull setup

		self.weiNumberOfRuns_L = Label(self,text="Number of runs: ")
		self.weiNumberOfRuns_E = Entry(self,width=5, justify="right")
		self.weiIterationsPerRun_L = Label(self,text="Iterations per run: ")
		self.weiIterationsPerRun_E = Entry(self,width=5, justify="right")

		self.weiEstimatedTime_L = Label(self,text="Estimated time (s): ")
		self.weiEstimatedTime_E = CustomEntry(self,width=5, justify="right")
		self.weiEstimatedTime_E.setUserEditable(False)

		self.weiLambdaLowerBoundL = Label(self,text="\u03BB lower bound:")
		self.weiLambdaUpperBoundL = Label(self,text="\u03BB upper bound:")
		self.weiLambdaLowerBoundE = Entry(self,width=5, justify="right")
		self.weiLambdaUpperBoundE = Entry(self,width=5, justify="right")

		self.weiKLowerBoundL = Label(self,text="k lower bound:")
		self.weiKUpperBoundL = Label(self,text="k upper bound:")
		self.weiKLowerBoundE = Entry(self,width=5, justify="right")
		self.weiKUpperBoundE = Entry(self,width=5, justify="right")

		self.weiNumberOfRuns_E.insert(0, settings.WEI_DEFAULT_NUMBER_OF_RUNS)
		self.weiIterationsPerRun_E.insert(0, settings.WEI_DEFAULT_ITERATIONS_PER_RUN)
		self.weiLambdaLowerBoundE.insert(0, settings.WEI_DEFAULT_LAMBDA_LOWER_BOUND)
		self.weiLambdaUpperBoundE.insert(0, settings.WEI_DEFAULT_LAMBDA_UPPER_BOUND)
		self.weiKLowerBoundE.insert(0, settings.WEI_DEFAULT_K_LOWER_BOUND)
		self.weiKUpperBoundE.insert(0, settings.WEI_DEFAULT_K_UPPER_BOUND)

		
		self.weiWidgets = [self.weiNumberOfRuns_L,self.weiNumberOfRuns_E,
						   self.weiIterationsPerRun_L,self.weiIterationsPerRun_E,
						   self.weiEstimatedTime_L,self.weiEstimatedTime_E,
						   self.weiLambdaLowerBoundL,self.weiLambdaUpperBoundL,self.weiLambdaLowerBoundE,self.weiLambdaUpperBoundE,
						   self.weiKLowerBoundL,self.weiKUpperBoundL,self.weiKLowerBoundE,self.weiKUpperBoundE]
		
		## General

		self.currentWidgets = []
		self.selection.set(Model.EXP.value)
		self.changeSelection()
Ejemplo n.º 12
0
class ModelFrame(LabelFrame):
	
	topPadding = 12

	def __init__(self,parent):        
		LabelFrame.__init__(self,parent,text="Model",borderwidth=5)
		
		self.selection = tkinter.IntVar()
		
		self.exponential = Radiobutton(self,text="Exponential model",variable=self.selection,value=Model.EXP.value,command=self.changeSelection)
		self.powerlaw = Radiobutton(self,text="Power law model",variable=self.selection,value=Model.POW.value,command=self.changeSelection)
		self.weibull = Radiobutton(self,text="Weibull model",variable=self.selection,value=Model.WEI.value,command=self.changeSelection)

		self.exponential.grid(row=0,column=0,sticky="W",padx=10,pady=(self.topPadding,5))
		self.powerlaw.grid(row=1,column=0,sticky="W",padx=10,pady=5)
		self.weibull.grid(row=2,column=0,sticky="W",padx=10,pady=(5,0))
		
		seperator = Separator(self, orient=tkinter.VERTICAL)
		seperator.grid(row=0, column=1, rowspan=3, sticky="NS", padx=(20,10), pady=(self.topPadding,0))
		
		## Exponential setup

		self.expNumberOfSegments_L = Label(self,text="Number of segments: ")
		self.expNumberOfSegments_E = Entry(self,width=5, justify="right")

		self.expNumberOfSegments_E.insert(0, settings.EXP_DEFAULT_NUMBER_OF_SEGMENTS)

		self.expWidgets = [self.expNumberOfSegments_L,self.expNumberOfSegments_E]
		
		## Power law setup

		self.powProximalLimit_L = Label(self,text="Proximal limit of integration: ")
		self.powProximalLimit_E = Entry(self,width=5, justify="right")
		self.powDistalLimit_L = Label(self,text="Distal limit of integration: ")
		self.powDistalLimit_E = Entry(self,width=5, justify="right")

		self.powProximalLimit_E.insert(0, settings.POW_DEFAULT_PROXIMAL_LIMIT)
		self.powDistalLimit_E.insert(0, settings.POW_DEFAULT_DISTAL_LIMIT)

		self.powWidgets = [self.powProximalLimit_L,self.powProximalLimit_E,
						   self.powDistalLimit_L,self.powDistalLimit_E]
		
		## Weibull setup

		self.weiNumberOfRuns_L = Label(self,text="Number of runs: ")
		self.weiNumberOfRuns_E = Entry(self,width=5, justify="right")
		self.weiIterationsPerRun_L = Label(self,text="Iterations per run: ")
		self.weiIterationsPerRun_E = Entry(self,width=5, justify="right")

		self.weiEstimatedTime_L = Label(self,text="Estimated time (s): ")
		self.weiEstimatedTime_E = CustomEntry(self,width=5, justify="right")
		self.weiEstimatedTime_E.setUserEditable(False)

		self.weiLambdaLowerBoundL = Label(self,text="\u03BB lower bound:")
		self.weiLambdaUpperBoundL = Label(self,text="\u03BB upper bound:")
		self.weiLambdaLowerBoundE = Entry(self,width=5, justify="right")
		self.weiLambdaUpperBoundE = Entry(self,width=5, justify="right")

		self.weiKLowerBoundL = Label(self,text="k lower bound:")
		self.weiKUpperBoundL = Label(self,text="k upper bound:")
		self.weiKLowerBoundE = Entry(self,width=5, justify="right")
		self.weiKUpperBoundE = Entry(self,width=5, justify="right")

		self.weiNumberOfRuns_E.insert(0, settings.WEI_DEFAULT_NUMBER_OF_RUNS)
		self.weiIterationsPerRun_E.insert(0, settings.WEI_DEFAULT_ITERATIONS_PER_RUN)
		self.weiLambdaLowerBoundE.insert(0, settings.WEI_DEFAULT_LAMBDA_LOWER_BOUND)
		self.weiLambdaUpperBoundE.insert(0, settings.WEI_DEFAULT_LAMBDA_UPPER_BOUND)
		self.weiKLowerBoundE.insert(0, settings.WEI_DEFAULT_K_LOWER_BOUND)
		self.weiKUpperBoundE.insert(0, settings.WEI_DEFAULT_K_UPPER_BOUND)

		
		self.weiWidgets = [self.weiNumberOfRuns_L,self.weiNumberOfRuns_E,
						   self.weiIterationsPerRun_L,self.weiIterationsPerRun_E,
						   self.weiEstimatedTime_L,self.weiEstimatedTime_E,
						   self.weiLambdaLowerBoundL,self.weiLambdaUpperBoundL,self.weiLambdaLowerBoundE,self.weiLambdaUpperBoundE,
						   self.weiKLowerBoundL,self.weiKUpperBoundL,self.weiKLowerBoundE,self.weiKUpperBoundE]
		
		## General

		self.currentWidgets = []
		self.selection.set(Model.EXP.value)
		self.changeSelection()
		
	def changeSelection(self):
		
		for widget in self.currentWidgets:
			widget.grid_remove()

		modelType = Model(self.selection.get())
		
		sX = 10
		bX = 20
		
		if modelType == Model.EXP:
			self.expNumberOfSegments_L.grid(row=0,column=2,padx=(bX,sX),pady=(self.topPadding,5),sticky="W")
			self.expNumberOfSegments_E.grid(row=0,column=3,padx=(sX,bX),pady=(self.topPadding,5),sticky="W")
			self.currentWidgets = self.expWidgets
		elif modelType == Model.POW:
			self.powProximalLimit_L.grid(row=0,column=2,padx=(bX,sX),pady=(self.topPadding,5),sticky="W")
			self.powProximalLimit_E.grid(row=0,column=3,padx=(sX,bX),pady=(self.topPadding,5),sticky="W")
			self.powDistalLimit_L.grid(row=1,column=2,padx=(bX,sX),pady=5,sticky="W")
			self.powDistalLimit_E.grid(row=1,column=3,padx=(sX,bX),pady=5,sticky="W")
			self.currentWidgets = self.powWidgets
		elif modelType == Model.WEI:
			self.weiNumberOfRuns_L.grid(row=0,column=2,padx=(bX,sX),pady=(self.topPadding,5),sticky="W")
			self.weiNumberOfRuns_E.grid(row=0,column=3,padx=(sX,bX),pady=(self.topPadding,5),sticky="W")
			self.weiIterationsPerRun_L.grid(row=1,column=2,padx=(bX,sX),pady=5,sticky="W")
			self.weiIterationsPerRun_E.grid(row=1,column=3,padx=(sX,bX),pady=5,sticky="W")
			self.weiEstimatedTime_L.grid(row=2,column=2,padx=(bX,sX),pady=5,sticky="W")
			self.weiEstimatedTime_E.grid(row=2,column=3,padx=(sX,bX),pady=5,sticky="W")
			
			self.weiLambdaLowerBoundL.grid(row=0,column=4,padx=(bX,sX),pady=(self.topPadding,5),sticky="W")
			self.weiLambdaLowerBoundE.grid(row=0,column=5,padx=(sX,bX),pady=(self.topPadding,5))
			self.weiLambdaUpperBoundL.grid(row=1,column=4,padx=(bX,sX),pady=5,sticky="W")
			self.weiLambdaUpperBoundE.grid(row=1,column=5,padx=(sX,bX),pady=5)
			
			self.weiKLowerBoundL.grid(row=0,column=6,padx=(bX,sX),pady=(self.topPadding,5),sticky="W")
			self.weiKLowerBoundE.grid(row=0,column=7,padx=(sX,sX),pady=(self.topPadding,5))
			self.weiKUpperBoundL.grid(row=1,column=6,padx=(bX,sX),pady=5,sticky="W")
			self.weiKUpperBoundE.grid(row=1,column=7,padx=(sX,sX),pady=5)
			
			self.currentWidgets = self.weiWidgets
	
	def getModelDetails(self):
		modelType = Model(self.selection.get())
		values = [modelType]

		if modelType == Model.EXP:
			numberOfSegments = helper_functions.validateValue(
									self.expNumberOfSegments_E.get(),
									"The number of exponential segments must be 1 \u2264 n \u2264 " + str(settings.EXP_MAX_NUMBER_OF_SEGMENTS),
									"int",
									lowerBound=1,
									upperBound=settings.EXP_MAX_NUMBER_OF_SEGMENTS)
			values.append(numberOfSegments)
			
		elif modelType == Model.POW:
			proximalLimitKM = helper_functions.validateValue(
									self.powProximalLimit_E.get(),
									"The proximal limit of integration must be 0 \u2264 x \u2264 \u221E",
									"float",
									strictLowerBound=0,
									strictUpperBound=float('inf'))
			proximalLimitKM /= SQRT_PI
			
			distalLimitKM = helper_functions.validateValue(
									self.powDistalLimit_E.get(),
									"The distal limit of integration must be prox \u2264 x \u2264 \u221E",
									"float",
									strictLowerBound=proximalLimitKM,
									strictUpperBound=float('inf'))
			distalLimitKM /= SQRT_PI
			
			values.extend([proximalLimitKM,distalLimitKM])
			
		elif modelType == Model.WEI:
			numberOfRuns = helper_functions.validateValue(
									self.weiNumberOfRuns_E.get(),
									"The number of runs must be greater than 0",
									"int",
									strictLowerBound=0)
			
			iterationsPerRun = helper_functions.validateValue(
									self.weiIterationsPerRun_E.get(),
									"The number of iterations must be greater than 0",
									"int",
									strictLowerBound=0)
			
			lambdaLowerBound = helper_functions.validateValue(
									self.weiLambdaLowerBoundE.get(),
									"The lower bound for \u03BB must be a decimal",
									"float")
			  
			lambdaUpperBound = helper_functions.validateValue(
									self.weiLambdaUpperBoundE.get(),
									"The upper bound for \u03BB must be greater than the lower bound",
									"float",
									strictLowerBound=lambdaLowerBound)
			
			kLowerBound = helper_functions.validateValue(
									self.weiKLowerBoundE.get(),
									"The lower bound for k must be numeric and less than 2",
									"float",
									strictUpperBound=2)
												
			kUpperBound = helper_functions.validateValue(
									self.weiKUpperBoundE.get(),
									"The upper bound for k must be greater than the lower bound and less than or equal to 2",
									"float",
									strictLowerBound=kLowerBound,
									upperBound=2)
			
			values.extend([numberOfRuns,iterationsPerRun,[[lambdaLowerBound,lambdaUpperBound],[kLowerBound,kUpperBound]]])
		
		return values