From f673dda85e03555111c14f410664906dbfbbf5e5 Mon Sep 17 00:00:00 2001 From: follath_r Date: Fri, 1 Sep 2017 16:21:37 +0200 Subject: [PATCH] Startup --- config/config.properties | 12 ++++++------ config/devices.properties | 4 ++++ script/PbpgPosXScan.py | 35 +++++++++++++++++++++++++++++++++++ script/PbpgPosYScan.py | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 script/PbpgPosXScan.py create mode 100644 script/PbpgPosYScan.py diff --git a/config/config.properties b/config/config.properties index 2f8a607..9004f2b 100644 --- a/config/config.properties +++ b/config/config.properties @@ -1,22 +1,22 @@ -#Tue Aug 29 17:25:22 CEST 2017 +#Wed Aug 30 13:50:49 CEST 2017 autoSaveScanData=true createSessionFiles=false dataLayout=default -dataPath={data}/{year}_{month}/{date}/{date}_{time}_{name} +dataPath={data}/{year}/{month}/{day}/{date}_{time}_{name} dataProvider=h5 dataScanFlushRecords=false dataScanPreserveTypes=false dataScanReleaseRecords=false dataServerPort=-1 -hostName=null -instanceName= +hostName= +instanceName=PH logDaysToLive=-1 -logLevel=Info +logLevel=Fine logLevelConsole=Off logPath={logs}/{date}_{time} scanStreamerPort=-1 serverEnabled=false -serverPort=8080 +serverPort=8095 simulation=false terminalEnabled=false terminalPort=3579 diff --git a/config/devices.properties b/config/devices.properties index 4548d75..bd1fbd5 100644 --- a/config/devices.properties +++ b/config/devices.properties @@ -1,3 +1,7 @@ +xbpm_x=ch.psi.pshell.epics.ChannelDouble|SARFE10-PBPG050:XBPM-XPOS|||true +xbpm_y=ch.psi.pshell.epics.ChannelDouble|SARFE10-PBPG050:XBPM-YPOS|||true +hamp_x=ch.psi.pshell.epics.ChannelDouble|SARFE10-PBPG050:HAMP-XPOS|||true +hamp_y=ch.psi.pshell.epics.ChannelDouble|SARFE10-PBPG050:HAMP-YPOS|||true dispatcher=ch.psi.pshell.bs.Dispatcher|https://dispatcher-api.psi.ch/sf||| cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889||| pbpg_mx=ch.psi.pshell.epics.Motor|SARFE10-PBPG050:MOTOR_X|||true diff --git a/script/PbpgPosXScan.py b/script/PbpgPosXScan.py new file mode 100644 index 0000000..fdc2379 --- /dev/null +++ b/script/PbpgPosXScan.py @@ -0,0 +1,35 @@ +from mathutils import fit_polynomial +from mathutils import PolynomialFunction +import math +from plotutils import plot_function +print "Starting" + + +#Creating averaging devices +av_hamp_x = create_averager(hamp_x, count = 10, interval = -1, name = "av_hamp_x") +av_xbpm_x = create_averager(xbpm_x, count = 10, interval = -1, name = "av_xbpm_x") +#av_hamp_x.monitored = True +av_xbpm_x.monitored = True + +#The actuals scan +r=lscan(pbpg_mx, [av_hamp_x, av_xbpm_x], -0.5, 0.5, 20, latency = 0.0) + +#Fitting +values = to_array(r.getReadable(0), 'd') +positions = r.getPositions(0) +pars_polynomial = (a0, a1, a2) = fit_polynomial(values, positions, 2) + +#Writing metadata to data file +path = get_exec_pars().scanPath +set_attribute(path, "a0", a0) +set_attribute(path, "a1", a1) +set_attribute(path, "a2", a2) + +#Plotting fit and writing fitting parameters +outp = "a0="+ ("%0.4f" % a0) + "a1="+ ("%0.4f" % a1) + "a2="+ ("%0.4f" % a2) +print outp +p = get_plots()[0] +p.addText((min(positions) + max(positions))/2, max(values), outp, Color.BLACK) +plot_function(p, PolynomialFunction(pars_polynomial), "Fit",positions, show_points = False, show_lines = True, color = Color.BLUE) + + diff --git a/script/PbpgPosYScan.py b/script/PbpgPosYScan.py new file mode 100644 index 0000000..4db2580 --- /dev/null +++ b/script/PbpgPosYScan.py @@ -0,0 +1,35 @@ +from mathutils import fit_polynomial +from mathutils import PolynomialFunction +import math +from plotutils import plot_function +print "Starting" + + +#Creating averaging devices +av_hamp_y = create_averager(hamp_y, count = 10, interval = -1, name = "av_hamp_y") +av_xbpm_y = create_averager(xbpm_y, count = 10, interval = -1, name = "av_xbpm_y") + +av_xbpm_y.monitored = True + +#The actuals scan +r=lscan(pbpg_my, [av_hamp_y, av_xbpm_y], -0.5, 0.5, 20, latency = 0.0) + +#Fitting +values = to_array(r.getReadable(0), 'd') +positions = r.getPositions(0) +pars_polynomial = (a0, a1) = fit_polynomial(values, positions, 1) + +#Writing metadata to data file +path = get_exec_pars().scanPath +set_attribute(path, "a0", a0) +set_attribute(path, "a1", a1) +#et_attribute(path, "a2", a2) + +#Plotting fit and writing fitting parameters +outp = "a0="+ ("%0.4f" % a0) + "a1="+ ("%0.4f" % a1) # "a2="+ ("%0.4f" % a2) +print outp +p = get_plots()[0] +p.addText((min(positions) + max(positions))/2, max(values), outp, Color.BLACK) +plot_function(p, PolynomialFunction(pars_polynomial), "Fit",positions, show_points = False, show_lines = True, color = Color.BLUE) + +