From 396d0410b3150af0e98b506beac791df2a8499ad Mon Sep 17 00:00:00 2001 From: sfop Date: Tue, 5 Jul 2016 11:28:23 +0200 Subject: [PATCH] Startup --- script/PolyFitWithWeight.py | 29 +++++++++++++++++++++++++++ script/RFscan/phase_scan_caqtdm_dv.py | 4 ++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 script/PolyFitWithWeight.py diff --git a/script/PolyFitWithWeight.py b/script/PolyFitWithWeight.py new file mode 100644 index 0000000..e9e6b20 --- /dev/null +++ b/script/PolyFitWithWeight.py @@ -0,0 +1,29 @@ +from mathutils import * +from plotutils import * + + +x = [ 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0,18.0] +y = [ 30.0, 22.0, 12.0, 10.0, 11.0, 14.0, 21.0, 32.0] +v = [ 0.3, 0.8, 0.4, 0.3, 0.5, 0.4, 0.3, 0.2] + +w = [ 1/ max(i,0.1) for i in v] + + + +p=plot(None)[0] +p.setStyle(p.Style.ErrorY) +p.setLegendVisible(True) +s1 = LinePlotErrorSeries("Observed Data") +p.addSeries(s1) +for i in range(len(x)):\ + s1.appendData(x[i], y[i], v[i]) + + +pars_polynomial= fit_polynomial(y, x, 2, None, w) +function = PolynomialFunction(pars_polynomial) +plot_function(p, function, "Fit" , frange (min(x), max(x), 0.1), False) + +print "(a0,a1,a2) = " , pars_polynomial + +for xp in x: + print xp, poly(xp, pars_polynomial) \ No newline at end of file diff --git a/script/RFscan/phase_scan_caqtdm_dv.py b/script/RFscan/phase_scan_caqtdm_dv.py index 5ff2bb8..e39d6da 100644 --- a/script/RFscan/phase_scan_caqtdm_dv.py +++ b/script/RFscan/phase_scan_caqtdm_dv.py @@ -1,7 +1,7 @@ import ch.psi.pshell.epics.ControlledVariable as ControlledVariable -#if get_context().source != CommandSource.ui: -# prefix = args[0] + "-RSYS" +if get_context().source != CommandSource.ui: + prefix = args[0] + "-RSYS" start = caget(prefix + ":SET-SCAN-START") stop = caget(prefix + ":SET-SCAN-STOP")