Exemple #1
0
print('..........Total Error............')
print(CFit_toterr.get_full_description())
print('=' * 55)
print('..........Percent Error............')
CFit_pcterr = NonLinCurveFit(DS,
                             rhs_eqnStr='A*(c - d*x)**n',
                             constDinp=guessD,
                             fit_best_pcent=1)  # 1=fit best percent error
print(CFit_pcterr.get_full_description())
print('=' * 55)

# To set parameters to reference values from www.engineeringtoolbox.com do this:
print('..........Reference Curve Fit............')
CFit_ref = NonLinCurveFit(DS, rhs_eqnStr='A*(c - d*x)**n', constDinp=guessD)
CFit_ref.constD.update({'A': 101325, 'c': 1, 'd': 2.25577E-5, 'n': 5.25588})
CFit_ref.calc_std_values()
print(CFit_ref.get_full_description())

if got_plt:
    plt.plot(alt_mArr, PaArr, 'o', markersize=10)
    xPlotArr, yPlotArr = CFit_ref.get_xy_plot_arrays(Npoints=100,
                                                     logScale=False)
    plt.plot(xPlotArr, yPlotArr, '--', linewidth=5, label='Reference')
    xPlotArr, yPlotArr = CFit_toterr.get_xy_plot_arrays(Npoints=100,
                                                        logScale=False)
    plt.plot(xPlotArr, yPlotArr, '-', label='Total Error', linewidth=3)
    xPlotArr, yPlotArr = CFit_pcterr.get_xy_plot_arrays(Npoints=100,
                                                        logScale=False)
    plt.plot(xPlotArr, yPlotArr, '-', label='Percent Error')
    plt.title('Atmospheric Pressure')
    plt.legend()
Exemple #2
0
print("=" * 55)
print("..........Total Error............")
print(CFit_toterr.get_full_description())
print("=" * 55)
print("..........Percent Error............")
CFit_pcterr = NonLinCurveFit(
    DS, rhs_eqnStr="A*(c - d*x)**n", constDinp=guessD, fit_best_pcent=1
)  # 1=fit best percent error
print(CFit_pcterr.get_full_description())
print("=" * 55)

# To set parameters to reference values from www.engineeringtoolbox.com do this:
print("..........Reference Curve Fit............")
CFit_ref = NonLinCurveFit(DS, rhs_eqnStr="A*(c - d*x)**n", constDinp=guessD)
CFit_ref.constD.update({"A": 101325, "c": 1, "d": 2.25577e-5, "n": 5.25588})
CFit_ref.calc_std_values()
print(CFit_ref.get_full_description())

if got_plt:
    plt.plot(alt_mArr, PaArr, "o", markersize=10)
    xPlotArr, yPlotArr = CFit_ref.get_xy_plot_arrays(Npoints=100, logScale=False)
    plt.plot(xPlotArr, yPlotArr, "--", linewidth=5, label="Reference")
    xPlotArr, yPlotArr = CFit_toterr.get_xy_plot_arrays(Npoints=100, logScale=False)
    plt.plot(xPlotArr, yPlotArr, "-", label="Total Error", linewidth=3)
    xPlotArr, yPlotArr = CFit_pcterr.get_xy_plot_arrays(Npoints=100, logScale=False)
    plt.plot(xPlotArr, yPlotArr, "-", label="Percent Error")
    plt.title("Atmospheric Pressure")
    plt.legend()
    plt.show()