def setUp(self): unittest.TestCase.setUp(self) xArrNew = array([1, 2, 3, 4, 5, 6], dtype=double) yArrNew = array([10, 5.49, 0.89, -.14, -1.07, 0.84], dtype=double) self.myclass = DataSet(xArrNew, yArrNew, xName='xxx', yName='yyy', xUnits='sec', yUnits='ft', timeStamp=123.45)
def PcentError_Button_Click(self, event): self.evaluate_float_entries() if len(self.Listbox_1.curselection()): self.new_message('Showing Percent Error of:\n') i = int(self.Listbox_1.curselection()[0]) obj = self.equationL[i] self.add_to_messages(obj.get_full_description()) XY = self.guiObj.XYjob if XY.dataset: yeqnArr = obj.eval_xrange(XY.dataset.xArr) pcerrArr = -100.0 * (yeqnArr - XY.dataset.yArr ) / numpy.absolute(XY.dataset.yArr) errDS = DataSet(XY.dataset.xArr, pcerrArr, xName=XY.dataset.xName, yName=XY.dataset.yName + ' [100*(data - eqn)/data]', xUnits=XY.dataset.xUnits, yUnits=XY.dataset.yUnits) xArr = [XY.dataset.xmin, XY.dataset.xmax] yArr = [obj.pcent_std, obj.pcent_std] textLabelCurveL = [(xArr, yArr, 'red', 1, '--', '1 PcntStdDev') ] textLabelCurveL.append( (xArr, [-obj.pcent_std, -obj.pcent_std], 'red', 1, '--', '')) textLabelCurveL.append((xArr, [0., 0.], 'red', 1, '-', '')) self.guiObj.PlotWin.make_new_plot( dataset=errDS, textLabelCurveL=textLabelCurveL, title_str=XY.dataset.yName + ' Percent Error\n in eqn: ' + str(self.equationL[i].name), specialPtL=None, dataLabel='Percent Error', force_linear_y=True) else: self.new_message('No Selection for Percent Error.\n')
-1524, -1372, -1219, -1067, -914, -762, -610, -457, -305, -152, 0, 152, 305, 457, 610, 762, 914, 1067, 1219, 1372, 1524, 1829, 2134, 2438, 2743, 3048, 4572, 6096, 7620, 9144, 10668, 12192, 13716, 15240 ], dtype=double) PaArr = 1000.0 * array([ 121, 119, 117, 115, 113, 111, 109, 107, 105, 103, 101, 99.5, 97.7, 96, 94.2, 92.5, 90.8, 89.1, 87.5, 85.9, 84.3, 81.2, 78.2, 75.3, 72.4, 69.7, 57.2, 46.6, 37.6, 30.1, 23.8, 18.7, 14.5, 11.1 ], dtype=double) DS = DataSet(alt_mArr, PaArr, xName='altitude', yName='pressure', xUnits='m', yUnits='Pa') guessD = {'A': 101325, 'c': 1, 'd': 2.25577E-5, 'n': 5.25588} print('guessD Before', guessD) CFit_toterr = NonLinCurveFit(DS, rhs_eqnStr='A*(c - d*x)**n', constDinp=guessD, fit_best_pcent=0) # 0=fit best total error print('guessD After', guessD) print('=' * 55) print('..........Total Error............') print(CFit_toterr.get_full_description()) print('=' * 55)
def setUp(self): unittest.TestCase.setUp(self) self.myds = DataSet(xArr, yArr)
Percent Standard Deviation = 4.11221905227% y = 0.8315625 + 6.22254971591*x + 3.19353693182*x**2 """ try: from matplotlib import pyplot as plt got_plt = True except: got_plt = False from xymath.dataset import DataSet from xymath.linfit import LinCurveFit concL = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1] readingL = [1.54,2.03,3.17,3.67,4.89,6.73,6.74,7.87,8.86,10.35] DS = DataSet(concL, readingL, xName='Concentration', yName='Instrument Reading') print('\n\n') print('='*55) print(".... First show author's answer ....") Fit_ref = LinCurveFit(DS, xtranL=['const', 'x'] , ytran='y', cArrInp=[0.199, 9.7926], fit_best_pcent=0) # 0=fit best total error print(Fit_ref.get_full_description()) print('='*55) print('.... Then show XYmath answer ....') Fit_linear = LinCurveFit(DS, xtranL=['const', 'x'] , ytran='y', fit_best_pcent=0) # 0=fit best total error print(Fit_linear.get_full_description()) print('='*55)
""" try: from matplotlib import pyplot as plt got_plt = True except: got_plt = False from numpy import array from xymath.dataset import DataSet from xymath.nonlinfit import NonLinCurveFit xdata = array([-2,-1.64,-1.33,-0.7,0,0.45,1.2,1.64,2.32,2.9]) ydata = array([0.699369,0.700462,0.695354,1.03905,1.97389,2.41143, 1.91091,0.919576,-0.730975,-1.42001]) DS = DataSet(xdata, ydata, xName='x', yName='y') guessD = {'p1':1.0, 'p2':0.2} CFit = NonLinCurveFit(DS, rhs_eqnStr='p1*cos(p2*x) + p2*sin(p1*x)', constDinp=guessD, fit_best_pcent=0) # 0=fit best total error print( 'residuals from XYmath = %g'%sum( (CFit.eval_xrange( xdata ) - ydata)**2 ) ) print( 'residuals from author = 0.053812696547933969' ) print('') print(CFit.get_full_description()) if got_plt: plt.plot( xdata, ydata, 'o', markersize=10 ) xPlotArr, yPlotArr = CFit.get_xy_plot_arrays( Npoints=100, logScale=False) plt.plot( xPlotArr, yPlotArr ) plt.title('Trig Function: p1*cos(p2*x) + p2*sin(p1*x)')
def setUp(self): unittest.TestCase.setUp(self) self.myds = DataSet(xArr, yArr) self.myspline = Spline(self.myds, order=2, smoothing=0.0) self.mylinterp = Spline(self.myds, order=1, smoothing=0.0)