commit ca1d73c31d7dcfc23ed6873701efaf637d76764e Author: voulot_d Date: Thu May 19 13:56:39 2016 +0200 Creation diff --git a/config/agkey b/config/agkey new file mode 100644 index 0000000..a5060b8 --- /dev/null +++ b/config/agkey @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEAvEQPJ+OW/ctH32MZKHln9+vXvMpST3UOJbk9nPTGM7bYYMjs +bEjg9hHNTHtr+VA4AtQzmzOXeAPqG5zy1lAcoPMrz3Kj9fou86cdMxbN6ei3rFVb +9dDSMLGrGAVuR+iTAch0FNVru5BvZm4s+fn3pyYuy1GcKLv7/pyYdoqiYdUm7ZDL +VhFJjtSmIswCArcv5rpvlTHLGmLirEq9KC6xkcoWnyPACAw/rbWKUuVobXcrcoic +G6N4gZt5Ekl7qg3AUFnKtw2/l6rfx4WFZjRdevGx7k14I4m6UCv/t040dMhCyUXJ +zP73WZTdV3TR4C643ZXkoXNlnlm8uOeSvOy85wIDAQABAoIBAFJddEP/Tg+637bb +pCYQ92t/wuLVoS0iCQ53/HyumggF9qRhQw4c1E7Tev37AUIR1m9mZy1/ZMUc8U8j +Wxpn8h54RLJ9dT4oNmJiumOflna/WZwLvC/PLCYhlLjtp1HOboJZMG/s7zUf+5zU +ltjGg5KdIdvR2H/5vkWmPQ2fmWszFVKbB+RPX9NbAcQMIXwATcIN3tbsISuydaf6 +w0Laa07oGpcMYTJzP1TJAVluUHWfouPoHdDcVc0g737o1wIFQ35e6bbYzM5zBkHJ +dQo7CeET+5+HZjsC9MQRiWw853GYJp0w+bKjDov/aIBJt6ZVx+KB8sZccSofVbaY +JvpwAAECgYEA6nHID0Lgo/P0aFneo38c9MlEdGRLxrfXwsY8LhnKtkF0wgz1Is40 +be6cVIz/XzXvHnB3WrAMsdz2MPiU4COz5T48z9hNcb/BMrVvNCN3x2Bu/FU4qMVU +vKJIhsL9Hq/TF3W0crA+DObvl9Kv4tIQ7hQK/xvbGpsoOiqV4A26Lu8CgYEAzZNa +Nl3W5Ut+VqaEdnED26pbZtzM8eLwioUNme9Etl+WrJQervNf8j8GJ8BUhOVjQrDT +hqA2bkXfBqxYaW2G8wnOVhq6jqLFfb3yZjpOsUf1T2x7naHW2Z3VEPlnMez2GJB/ +/jkRegcXqPMtk8TahbaY/gTjOc+eFTefuDuQUYkCgYAKxlfve59faaLd+ONmmDz4 +cxeWUdW5uFFOPlYduEm8vp1jHb1WcCuwsbq1mBVUhuIKgBi8LkMnGYSnE4WkF3/5 +FTcuRj6o76stbXFC8C5dF22CY1hLSWZvlPXIW8XOVz5YYax9aOQxK5vvWluDDSyC +BKHMv7b+LgtXQQXKWlcoOQKBgAv7hsqcdaYv3FFYq2fr9nmbWHCKdjezLqokT0Kl +u6+Vqsasa41vCiyol8dBYqvMYxjEDdBPDl0nHXTaHt0mUTNhYvGJ5U3jFvfZVoO2 +6ldTBm12uU3a3RcaKA0xPF6gnUeZRJyg3u/p8esbIZD3bHVWy1wjFMuN2n0KHPk0 +H5lhAoGAO8YqRVnHOoz7HeA16+LZoOorDA9r/NEN3/K/jgOJPfrm3CV205Ew7mvQ +Y6im34HAcjHp2fz/kxE0S4vd2iWapMpiQu0U2yvLdX+861pkM/ffAg6x3nEJChzp +lh8rxqEJy4PukTBxUAL0h5wnOWkRYFgOVcx60rHvYJZ8+Qf3lbc= +-----END RSA PRIVATE KEY----- diff --git a/config/config.properties b/config/config.properties new file mode 100644 index 0000000..426203c --- /dev/null +++ b/config/config.properties @@ -0,0 +1,31 @@ +#Thu May 19 13:16:56 CEST 2016 +autoSaveScanData=true +createSessionFiles=false +dataLayout=default +dataPath={data}/{year}_{month}/{date}/{date}_{time}_{exec} +dataProvider=default +dataScanFlushRecords=true +dataScanStrategy=default +dataServerPort=-1 +devicePoolFile={config}/devices.properties +deviceUpdateStrategyFile={config}/update.properties +hostName=null +instanceName=OP +logDaysToLive=-1 +logLevel=Info +logLevelConsole=Off +logPath={logs}/{date}_{time} +scanStreamerPort=-1 +scanStreamingPort=-1 +serverEnabled=true +serverPort=8080 +simulation=false +tasksFile={config}/tasks.properties +terminalEnabled=false +terminalPort=3579 +userAuthenticator= +userManagement=false +versionTrackingEnabled=true +versionTrackingLogin={context}/svcusr-hlapp_robot +versionTrackingManual=false +versionTrackingRemote=git@git.psi.ch\:pshell_config/sf-op.git diff --git a/config/devices.properties b/config/devices.properties new file mode 100644 index 0000000..142f569 --- /dev/null +++ b/config/devices.properties @@ -0,0 +1,16 @@ +bpm_1_down_gun=ch.psi.pshell.epics.Positioner|SINEG01-DBPM340:X1 SINEG01-DBPM340:Y1|Read||true +gun_sol_current=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:I-SET SINEG01-MSOL130:I-SET|||true +gun_phase=ch.psi.pshell.epics.Positioner|SINEG01-RSYS:SET-VSUM-PHASE SINEG01-RSYS:SET-VSUM-PHASE|||true +#SINSB01_phase=ch.psi.pshell.epics.Positioner|VA-SINSB01-RSYS100:SET-BEAM-PHASE VA-SINSB01-RSYS100:GET-BEAM-PHASE|||true +#BC1_energy=ch.psi.pshell.epics.ChannelDouble|VA-SINBC02-DBPM140:ENERGY|Read||true +#SARUN02_MCRX080=ch.psi.pshell.epics.Positioner|VA-SARUN02-MCRX080:I-SET VA-SARUN02-MCRX080:I-READ|||true +#SARUN02_MCRY080=ch.psi.pshell.epics.Positioner|VA-SARUN02-MCRY080:I-SET VA-SARUN02-MCRY080:I-READ|||true +#SARUN03_DBPM070_X=ch.psi.pshell.epics.ChannelDouble|VA-SARUN03-DBPM070:X1|Read||true +#chd=ch.psi.pshell.epics.ChannelDouble|VA-SINSB01-RSYS100:SET-BEAM-PHASE 3|||true +#pv=ch.psi.pshell.epics.ProcessVariable|VA-SINSB01-RSYS100:SET-BEAM-PHASE|||true +#cv=ch.psi.pshell.epics.ControlledVariable|VA-SINSB01-RSYS100:SET-BEAM-PHASE VA-SINSB01-RSYS100:GET-BEAM-PHASE|||true +#pos=ch.psi.pshell.epics.Positioner|VA-SINSB01-RSYS100:SET-BEAM-PHASE VA-SINSB01-RSYS100:GET-BEAM-PHASE|||true +#mot=ch.psi.pshell.device.DummyMotor||||true +#rf_phase=ch.psi.pshell.epics.ChannelDouble|MINSB03-RSYS:SET-VSUM-PHASE|||true +#rf_phase_rb=ch.psi.pshell.epics.ChannelDouble|MINSB03-RSYS:GET-VSUM-PHASE|Read||true +#rf_ampl_rb=ch.psi.pshell.epics.ChannelDouble|MINSB03-RSYS:GET-VSUM-AMPLT|Read||true diff --git a/config/jcae.properties b/config/jcae.properties new file mode 100644 index 0000000..1bae494 --- /dev/null +++ b/config/jcae.properties @@ -0,0 +1,7 @@ +#Wed May 04 14:26:21 CEST 2016 +ch.psi.jcae.ContextFactory.addressList=129.129.130.255 129.129.131.255 129.129.137.255 +ch.psi.jcae.ContextFactory.maxArrayBytes=10000000 +ch.psi.jcae.ChannelFactory.retries=2 +ch.psi.jcae.ChannelFactory.timeout=500 +ch.psi.jcae.impl.DefaultChannelService.retries=4 +ch.psi.jcae.impl.DefaultChannelService.timeout=1000 diff --git a/config/setup.properties b/config/setup.properties new file mode 100644 index 0000000..216c670 --- /dev/null +++ b/config/setup.properties @@ -0,0 +1,18 @@ +#Wed Dec 09 13:50:24 CET 2015 +configFile={config}/config.properties +configFileDevices={config}/devices.properties +configFilePlugins={config}/plugins.properties +configFileTasks={config}/tasks.properties +configFileUpdateStrategy={config}/update.properties +configPath={home}/config +contextPath={outp}/context +dataPath={outp}/data +devicesPath={home}/devices +extensionsPath={home}/extensions +libraryPath={script}; {script}/Lib +logPath={outp}/log +pluginsPath={home}/plugins +scriptPath={home}/script +scriptType=py +sessionsPath={outp}/sessions +wwwPath={home}/www diff --git a/devices/SARUN02-MCRX080.properties b/devices/SARUN02-MCRX080.properties new file mode 100644 index 0000000..2c5d4b7 --- /dev/null +++ b/devices/SARUN02-MCRX080.properties @@ -0,0 +1,8 @@ +#Wed Jan 06 17:01:23 CET 2016 +maxValue=5.0 +minValue=-5.0 +offset=0.0 +precision=3 +resolution=NaN +scale=1.0 +unit=A diff --git a/devices/SARUN02-MCRY080.properties b/devices/SARUN02-MCRY080.properties new file mode 100644 index 0000000..427a68a --- /dev/null +++ b/devices/SARUN02-MCRY080.properties @@ -0,0 +1,8 @@ +#Wed Jan 06 17:01:36 CET 2016 +maxValue=5.0 +minValue=-5.0 +offset=0.0 +precision=3 +resolution=NaN +scale=1.0 +unit=A diff --git a/devices/SARUN02_MCRX080.properties b/devices/SARUN02_MCRX080.properties new file mode 100644 index 0000000..671c895 --- /dev/null +++ b/devices/SARUN02_MCRX080.properties @@ -0,0 +1,8 @@ +#Wed Jan 06 17:10:52 CET 2016 +maxValue=5.0 +minValue=-5.0 +offset=0.0 +precision=3 +resolution=NaN +scale=1.0 +unit=A diff --git a/devices/SARUN02_MCRY080.properties b/devices/SARUN02_MCRY080.properties new file mode 100644 index 0000000..22e4997 --- /dev/null +++ b/devices/SARUN02_MCRY080.properties @@ -0,0 +1,8 @@ +#Wed Jan 06 17:11:05 CET 2016 +maxValue=5.0 +minValue=-5.0 +offset=0.0 +precision=3 +resolution=NaN +scale=1.0 +unit=A diff --git a/devices/SINSB01_phase.properties b/devices/SINSB01_phase.properties new file mode 100644 index 0000000..af191ca --- /dev/null +++ b/devices/SINSB01_phase.properties @@ -0,0 +1,8 @@ +#Wed Jan 06 16:18:41 CET 2016 +maxValue=360.0 +minValue=0.0 +offset=0.0 +precision=3 +resolution=NaN +scale=1.0 +unit=Degree diff --git a/devices/beam_phase.properties b/devices/beam_phase.properties new file mode 100644 index 0000000..149090e --- /dev/null +++ b/devices/beam_phase.properties @@ -0,0 +1,8 @@ +#Wed Dec 09 14:42:00 CET 2015 +maxValue=360.0 +minValue=0.0 +offset=0.0 +precision=3 +resolution=NaN +scale=1.0 +unit=Degree diff --git a/devices/bpm_1_down_gun.properties b/devices/bpm_1_down_gun.properties new file mode 100644 index 0000000..9ba674a --- /dev/null +++ b/devices/bpm_1_down_gun.properties @@ -0,0 +1,8 @@ +#Tue May 10 13:57:11 CEST 2016 +maxValue=NaN +minValue=NaN +offset=0.0 +precision=-1 +resolution=NaN +scale=1.0 +unit=null diff --git a/devices/cv.properties b/devices/cv.properties new file mode 100644 index 0000000..813be07 --- /dev/null +++ b/devices/cv.properties @@ -0,0 +1,8 @@ +#Fri Jan 08 10:12:30 CET 2016 +maxValue=360.0 +minValue=0.0 +offset=0.0 +precision=3 +resolution=NaN +scale=1.0 +unit=Degree diff --git a/devices/dp1.properties b/devices/dp1.properties new file mode 100644 index 0000000..771eef9 --- /dev/null +++ b/devices/dp1.properties @@ -0,0 +1,11 @@ +#Wed Dec 09 13:57:47 CET 2015 +motor1=0.0|4.0|8.0|0.0 +motor2=0.0|5.0|3.0|NaN +motor3=null +motor4=null +motor5=null +motor6=null +motor7=null +motor8=null +positions=Park|Ready|Out|Clear +precision=-1 diff --git a/devices/gun_phase.properties b/devices/gun_phase.properties new file mode 100644 index 0000000..5b67728 --- /dev/null +++ b/devices/gun_phase.properties @@ -0,0 +1,8 @@ +#Tue May 10 09:59:44 CEST 2016 +maxValue=180.0 +minValue=-179.99 +offset=0.0 +precision=2 +resolution=1.0 +scale=1.0 +unit=DEG diff --git a/devices/gun_sol_current.properties b/devices/gun_sol_current.properties new file mode 100644 index 0000000..c443463 --- /dev/null +++ b/devices/gun_sol_current.properties @@ -0,0 +1,8 @@ +#Tue May 10 09:38:33 CEST 2016 +maxValue=210.0 +minValue=0.0 +offset=0.0 +precision=3 +resolution=NaN +scale=1.0 +unit=A diff --git a/devices/m1.properties b/devices/m1.properties new file mode 100644 index 0000000..2823983 --- /dev/null +++ b/devices/m1.properties @@ -0,0 +1,12 @@ +#Wed Dec 09 13:57:47 CET 2015 +defaultSpeed=1.0 +estbilizationDelay=0 +maxSpeed=10.0 +maxValue=10.0 +minSpeed=0.1 +minValue=-10.0 +offset=0.0 +precision=2 +resolution=NaN +scale=1.0 +unit=mm diff --git a/devices/m2.properties b/devices/m2.properties new file mode 100644 index 0000000..2823983 --- /dev/null +++ b/devices/m2.properties @@ -0,0 +1,12 @@ +#Wed Dec 09 13:57:47 CET 2015 +defaultSpeed=1.0 +estbilizationDelay=0 +maxSpeed=10.0 +maxValue=10.0 +minSpeed=0.1 +minValue=-10.0 +offset=0.0 +precision=2 +resolution=NaN +scale=1.0 +unit=mm diff --git a/devices/m3.properties b/devices/m3.properties new file mode 100644 index 0000000..84d6771 --- /dev/null +++ b/devices/m3.properties @@ -0,0 +1,12 @@ +#Fri Jan 08 10:18:25 CET 2016 +defaultSpeed=1.0 +estbilizationDelay=0 +maxSpeed=10.0 +maxValue=10.0 +minSpeed=0.1 +minValue=-10.0 +offset=0.0 +precision=2 +resolution=NaN +scale=1.0 +unit=mm diff --git a/devices/mot.properties b/devices/mot.properties new file mode 100644 index 0000000..558d71a --- /dev/null +++ b/devices/mot.properties @@ -0,0 +1,12 @@ +#Fri Jan 08 10:07:38 CET 2016 +defaultSpeed=1.0 +estbilizationDelay=0 +maxSpeed=10.0 +maxValue=10.0 +minSpeed=0.1 +minValue=-10.0 +offset=0.0 +precision=2 +resolution=NaN +scale=1.0 +unit=mm diff --git a/devices/p1.properties b/devices/p1.properties new file mode 100644 index 0000000..fc08633 --- /dev/null +++ b/devices/p1.properties @@ -0,0 +1,8 @@ +#Wed Dec 09 13:57:47 CET 2015 +maxValue=1000.0 +minValue=0.0 +offset=0.0 +precision=-1 +resolution=NaN +scale=1.0 +unit=mm diff --git a/devices/pos.properties b/devices/pos.properties new file mode 100644 index 0000000..6f30f5f --- /dev/null +++ b/devices/pos.properties @@ -0,0 +1,8 @@ +#Fri Jan 08 10:13:11 CET 2016 +maxValue=90.0 +minValue=0.0 +offset=0.0 +precision=3 +resolution=NaN +scale=1.0 +unit=Degree diff --git a/devices/pv.properties b/devices/pv.properties new file mode 100644 index 0000000..5ea8da8 --- /dev/null +++ b/devices/pv.properties @@ -0,0 +1,8 @@ +#Fri Jan 08 10:09:44 CET 2016 +maxValue=0.0 +minValue=0.0 +offset=0.0 +precision=3 +resolution=0.01 +scale=1.0 +unit=Degree diff --git a/devices/src1.properties b/devices/src1.properties new file mode 100644 index 0000000..e46a54e --- /dev/null +++ b/devices/src1.properties @@ -0,0 +1,13 @@ +#Wed Dec 09 13:57:47 CET 2015 +colormap=Temperature +colormapAutomatic=true +colormapMax=255.0 +colormapMin=0.0 +flipHorizontally=false +flipVertically=false +grayscale=false +invert=false +rescaleFactor=1.0 +rescaleOffset=0.0 +rotation=0.0 +scale=1.0 diff --git a/devices/src2.properties b/devices/src2.properties new file mode 100644 index 0000000..09161b2 --- /dev/null +++ b/devices/src2.properties @@ -0,0 +1,13 @@ +#Wed Dec 09 13:57:47 CET 2015 +colormap=Grayscale +colormapAutomatic=true +colormapMax=255.0 +colormapMin=0.0 +flipHorizontally=false +flipVertically=false +grayscale=false +invert=false +rescaleFactor=1.0 +rescaleOffset=0.0 +rotation=0.0 +scale=1.0 diff --git a/script/Alignment/Gun_solenoid_alignment.py b/script/Alignment/Gun_solenoid_alignment.py new file mode 100644 index 0000000..d181868 --- /dev/null +++ b/script/Alignment/Gun_solenoid_alignment.py @@ -0,0 +1,34 @@ +#Tool to align the laser on the cathode. +# S. Bettoni, A. Gobbo, D. Voulot +#10/05/2016 + + +#Procedure: + #I switch off all the magnets between the gun solenoid and the screen or BPM used for the measurement + #I change the current of the gun soleoid + #I look at the centroid position (BPM or screen) downstream of the gun. + +#TO BE PUT THE SIGNAL I-READ IN THE DEVICE DEFINITION GUN SOLENOID + +#caput("shutter:state", Closed) + +start_I = 0.001 #20 +end_I = 0.005 #150 +step_I = 0.0001 #1 + +#Scan using the screen +r = lscan(gun_sol_current, [center_x, center_y], start_I, end_I, step_I, latency = 0.2) +#Scan using the BPM +#r = lscan(gun_sol_current, bpm_1_down_gun, start_I, end_I, step_I, latency = 0.2) + +#I take the result of the scan and I do the plots +x = r.getReadable(0) +y = r.getReadable(1) +plot(y, xdata=x, title = "CM") + + + + +#I save the entry in the logbook + + \ No newline at end of file diff --git a/script/Alignment/Laser_gun_alignment.py b/script/Alignment/Laser_gun_alignment.py new file mode 100644 index 0000000..a1df303 --- /dev/null +++ b/script/Alignment/Laser_gun_alignment.py @@ -0,0 +1,37 @@ +#Tool to align the laser on the cathode. +# S. Bettoni, A. Gobbo, D. Voulot +#10/05/2016 + +from operator import sub + + +#Procedure: + #I switch off all the magnets between the gun solenoid and the screen or BPM used for the measurement + #I change the current of the gun soleoid + #I look at the centroid position (BPM or screen) downstream of the gun. + +#TO BE PUT THE SIGNAL I-READ IN THE DEVICE DEFINITION GUN SOLENOID + +#caput("shutter:state", Closed) + +start_I = 0.001 #20 +end_I = 0.005 #150 +step_I = 0.001 #1 + +#Scan using the screen +r = lscan(gun_sol_current, [center_x, center_y], start_I, end_I, step_I, latency = 0.2) +#Scan using the BPM +#r = lscan(gun_sol_current, bpm_1_down_gun, start_I, end_I, step_I, latency = 0.2) + +#I take the result of the scan and I do the plots +x = r.getReadable(0) +y = r.getReadable(1) +p = plot(y, xdata=x, title = "CM") +yerr = 0.1 +xerr = 0.5 + + +#I save the entry in the logbook +#elog(title, message, attachments = [], author = None, category = "Info", domain = "", logbook = "SwissFEL commissioning data", encoding=1): +#elog("Test Simona", "message", author = "Simona", get_plot_snapshots(), logbook = "SwissFEL commissioning data", encoding=1) + \ No newline at end of file diff --git a/script/Alignment/test_Simona.py b/script/Alignment/test_Simona.py new file mode 100644 index 0000000..780779a --- /dev/null +++ b/script/Alignment/test_Simona.py @@ -0,0 +1,52 @@ + + + +import numpy as np +import matplotlib.pyplot as plt + +# example data +x = np.arange(0.5, 5.5, 0.5) +y = np.exp(-x) +xerr = 0.1 +yerr = 0.2 +ls = 'dotted' + +fig = plt.figure() +ax = fig.add_subplot(1, 1, 1) + +# standard error bars +plt.errorbar(x, y, xerr=xerr, yerr=yerr, ls=ls, color='blue') + +# including upper limits +uplims = np.zeros(x.shape) +uplims[[1, 5, 9]] = True +plt.errorbar(x, y + 0.5, xerr=xerr, yerr=yerr, uplims=uplims, ls=ls, + color='green') + +# including lower limits +lolims = np.zeros(x.shape) +lolims[[2, 4, 8]] = True +plt.errorbar(x, y + 1.0, xerr=xerr, yerr=yerr, lolims=lolims, ls=ls, + color='red') + +# including upper and lower limits +plt.errorbar(x, y + 1.5, marker='o', ms=8, xerr=xerr, yerr=yerr, + lolims=lolims, uplims=uplims, ls=ls, color='magenta') + +# including xlower and xupper limits +xerr = 0.2 +yerr = np.zeros(x.shape) + 0.2 +yerr[[3, 6]] = 0.3 +xlolims = lolims +xuplims = uplims +lolims = np.zeros(x.shape) +uplims = np.zeros(x.shape) +lolims[[6]] = True +uplims[[3]] = True +plt.errorbar(x, y + 2.1, marker='o', ms=8, xerr=xerr, yerr=yerr, + xlolims=xlolims, xuplims=xuplims, uplims=uplims, lolims=lolims, + ls='none', mec='blue', capsize=0, color='cyan') + +ax.set_xlim((0, 5.5)) +ax.set_title('Errorbar upper and lower limits') +plt.show() \ No newline at end of file diff --git a/script/SARUN02_MCOR_scan.py b/script/SARUN02_MCOR_scan.py new file mode 100644 index 0000000..9da63b9 --- /dev/null +++ b/script/SARUN02_MCOR_scan.py @@ -0,0 +1 @@ +ascan((SARUN02_MCRX080,SARUN02_MCRY080), (SARUN03_DBPM070), (-2.0,-2.0), (2.0,2.0), (5,5), 0.01) \ No newline at end of file diff --git a/script/SINSB01_phase_scan.py b/script/SINSB01_phase_scan.py new file mode 100644 index 0000000..f5c3dd1 --- /dev/null +++ b/script/SINSB01_phase_scan.py @@ -0,0 +1 @@ +lscan(SINSB01_phase, BC1_energy, 0.0, 360.0, 10.0, 2.0) \ No newline at end of file diff --git a/script/local.groovy b/script/local.groovy new file mode 100644 index 0000000..6cd1527 --- /dev/null +++ b/script/local.groovy @@ -0,0 +1,3 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Deployment specific global definitions - executed after startup.groovy +/////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/script/local.js b/script/local.js new file mode 100644 index 0000000..17db863 --- /dev/null +++ b/script/local.js @@ -0,0 +1,4 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Deployment specific global definitions - executed after startup.js +/////////////////////////////////////////////////////////////////////////////////////////////////// + diff --git a/script/local.py b/script/local.py new file mode 100644 index 0000000..f8a26f2 --- /dev/null +++ b/script/local.py @@ -0,0 +1,99 @@ +################################################################################################### +# Deployment specific global definitions - executed after startup.py +################################################################################################### + +from mathutils import estimate_peak_indexes, fit_gaussians, create_fit_point_list, Gaussian + +import java.awt.Color as Color + + +def fit(ydata, xdata = None): + """ + """ + if xdata is None: + xdata = frange(0, len(ydata), 1) + max_y= max(ydata) + index_max = ydata.index(max_y) + max_x= xdata[index_max] + print "Max index:" + str(index_max), + print " x:" + str(max_x), + print " y:" + str(max_y) + gaussians = fit_gaussians(ydata, xdata, [index_max,]) + (norm, mean, sigma) = gaussians[0] + p = plot([ydata],["data"],[xdata], title="Fit" )[0] + fitted_gaussian_function = Gaussian(norm, mean, sigma) + scale_x = [float(min(xdata)), float(max(xdata)) ] + points = max((len(xdata)+1), 100) + resolution = (scale_x[1]-scale_x[0]) / points + fit_y = [] + fit_x = frange(scale_x[0],scale_x[1],resolution, True) + for x in fit_x: + fit_y.append(fitted_gaussian_function.value(x)) + p.addSeries(LinePlotSeries("fit")) + p.getSeries(1).setData(fit_x, fit_y) + + if abs(mean - xdata[index_max]) < ((scale_x[0] + scale_x[1])/2): + print "Mean -> " + str(mean) + p.addMarker(mean, None, "Mean="+str(round(norm,2)), Color.MAGENTA.darker()) + return (norm, mean, sigma) + else: + p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.GRAY) + print "Invalid gaussian fit: " + str(mean) + return (None, None, None) + + + +def elog(title, message, attachments = [], author = None, category = "Info", domain = "", logbook = "SwissFEL commissioning data", encoding=1): + """ + Add entry to ELOG. + """ + if author is None: + author = "pshell" #controller.getUser().name + typ = "pshell" + entry = "" + + cmd = 'G_CS_ELOG_add -l "' + logbook+ '" ' + cmd = cmd + '-a "Author=' + author + '" ' + cmd = cmd + '-a "Type=' + typ + '" ' + cmd = cmd + '-a "Entry=' + entry + '" ' + cmd = cmd + '-a "Title=' + title + '" ' + cmd = cmd + '-a "Category=' + category + '" ' + cmd = cmd + '-a "Domain=' + domain + '" ' + for attachment in attachments: + cmd = cmd + '-f "' + attachment + '" ' + cmd = cmd + '-n ' + str(encoding) + cmd = cmd + ' "' + message + '"' + #print cmd + #os.system (cmd) + #print os.popen(cmd).read() + import subprocess + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) + (out, err) = proc.communicate() + if (err is not None) and err!="": + raise Exception(err) + print out + +def get_plot_snapshots(title = None, file_type = "jpg", temp_path = controller.setup.getContextPath()): + """ + Returns list with file names of plots snapshots from a plotting context. + """ + sleep(0.02) #Give some time to plot to be finished - it is not sync with acquisition + ret = [] + for p in get_plots(title): + file_name = os.path.abspath(temp_path + "/" + p.getTitle() + "." + file_type) + p.saveSnapshot(file_name , file_type) + ret.append(file_name) + return ret + + +class Sinusoid(ReadonlyRegisterBase): + def doRead(self): + self.x = self.x + 1.0 if hasattr(self, 'x') else 0.0 + return math.sin(self.x * math.pi / 180.0) + +add_device(Sinusoid("sim"), True) + +add_device(Sinusoid("center_x"), True) +add_device(Sinusoid("center_y"), True) +center_x.setPolling(100) +center_y.setPolling(100) \ No newline at end of file diff --git a/script/phase_scan.py b/script/phase_scan.py new file mode 100644 index 0000000..e36d125 --- /dev/null +++ b/script/phase_scan.py @@ -0,0 +1,36 @@ +""" +Parameters: +prefix +""" + +prefix = "MINSB03-RSYS" +start = -179.0 +stop = 180.0 +step = 10.0 + + + +rf_phase_setpoint = Channel(prefix + ":SET-VSUM-PHASE") +rf_phase_readback = Channel(prefix + ":GET-VSUM-PHASE") +rf_ampl_readback = Channel(prefix + ":GET-VSUM-AMPLT") + +r = lscan(rf_phase_setpoint, [rf_phase_readback, rf_ampl_readback, sim], start, stop, step , latency=0.2) + +plot(r.getReadable(2), xdata = r.getReadable(0), title = "data") + +#fit(r.getReadable(1)) + + +set_return(r.print()) + + +""" +r = lscan(rf_phase, [rf_phase_rb, rf_ampl_rb, sim], -179.0, 180, 10.0, latency=0.2) + +plot(r.getReadable(2), xdata = r.getReadable(0), title = "data") + +fit(r.getReadable(1)) + + +set_return(r.print()) +""" \ No newline at end of file diff --git a/script/region_scan_with_elog.py b/script/region_scan_with_elog.py new file mode 100644 index 0000000..45e1b04 --- /dev/null +++ b/script/region_scan_with_elog.py @@ -0,0 +1,7 @@ +#Execute the scan: 3 regions with different number of steps +a= rscan(ao1, (ai1,ai2), [(0,5,5), (10,15,20), (20,25,5)] , 0.01) + +msg = str(a) +msg = msg + "\nFile: " + get_context().path + ".h5" +msg = msg + "\n\n" + a.print() +elog("Region scan", msg , get_plot_snapshots()) diff --git a/script/test/bla.py b/script/test/bla.py new file mode 100644 index 0000000..bda6bfa --- /dev/null +++ b/script/test/bla.py @@ -0,0 +1,21 @@ +################################################################################################### +# Demonstrate use of scan callbacks to trigger a detector at falling edge. +################################################################################################### + + +def BeforeReadout(): + ao1.write(1) + ao1.write(0) + + #Example with an epics direct channel access + #caput("CHANNEL_NAME", 1) + #caput("CHANNEL_NAME", 0) + +index=0 + +def AfterReadout(): + global index + print "Aquired frame: " + str(index) + index=index+1 + +a= lscan((m1,m2), (ai1, ai2), (0,0), (4,8), steps=20, latency = 0.01, before_read=BeforeReadout, after_read=AfterReadout) \ No newline at end of file diff --git a/script/test/pouet.py b/script/test/pouet.py new file mode 100644 index 0000000..cc5d94f --- /dev/null +++ b/script/test/pouet.py @@ -0,0 +1,29 @@ +################################################################################################### +# Demonstrate the use of Line Scan: one or multiple positioners move together linearly. +################################################################################################### + + +#This optional preference limits the displayed plots +#set_preference(Preference.ENABLED_PLOTS, [ai1, ai2,]) + +#This optional preference displays wf1 as a 1d plot at each scan point, instead of a matrix plot +#set_preference(Preference.PLOT_TYPES, {wf1:1}) + +#Execute the scan: 200 steps, a1 from 0 to 40 +a= lscan(ao1, (ai1,ai2,wf1), 0, 40, 200, 0.01) + +#Also samples an image: +#a= lscan(ao1, (ai1,ai2,wf1), 0, 40, 200, 0.01) + +#Alternative: Steps of size 0.1, a1 from 0 to 40 +#a= lscan(ao1, (ai1,ai2,wf1), 0, 40, 0.5, 0.01) + +#2 positioners moving together in 200 steps, a1 from 0 to 40 and a2 from 0 to 100 +#a= lscan((ao1,ao2), (ai1,ai2,wf1), (0, 0), (40, 100), 200, 0.01) + +#Setting attributes to the scan group +path = get_current_group() +set_attribute(path, "AttrString", "Value") +set_attribute(path, "AttrInteger", 1) +set_attribute(path, "AttrDouble", 2.0) +set_attribute(path, "AttrBoolean", True) diff --git a/script/test/rf_phase_scan.py b/script/test/rf_phase_scan.py new file mode 100644 index 0000000..0cf1a41 --- /dev/null +++ b/script/test/rf_phase_scan.py @@ -0,0 +1 @@ +lscan(SINSB01_phase, energy_BC1, 0.0, 360.0, 10.0, 2.0) \ No newline at end of file diff --git a/script/test/test.py b/script/test/test.py new file mode 100644 index 0000000..bda6bfa --- /dev/null +++ b/script/test/test.py @@ -0,0 +1,21 @@ +################################################################################################### +# Demonstrate use of scan callbacks to trigger a detector at falling edge. +################################################################################################### + + +def BeforeReadout(): + ao1.write(1) + ao1.write(0) + + #Example with an epics direct channel access + #caput("CHANNEL_NAME", 1) + #caput("CHANNEL_NAME", 0) + +index=0 + +def AfterReadout(): + global index + print "Aquired frame: " + str(index) + index=index+1 + +a= lscan((m1,m2), (ai1, ai2), (0,0), (4,8), steps=20, latency = 0.01, before_read=BeforeReadout, after_read=AfterReadout) \ No newline at end of file diff --git a/script/test/toto.py b/script/test/toto.py new file mode 100644 index 0000000..9c6851c --- /dev/null +++ b/script/test/toto.py @@ -0,0 +1,21 @@ +################################################################################################### +# Demonstrate use of Vector Scan: one or multiple positioners set according to a position vector. +################################################################################################### + + +#1D vector scan, plot to 1D Vector tab +vector = [ 1, 3, 5, 10, 25, 40, 45, 47, 49] +a= vscan(ao1,(ai1,ai2),vector,False, 0.5, context = "1D Vector") + + + + +#2D vector scan, plot to 2D Vector tab +vector = [ [1,1] , [1,2] , [1,3] , [1,4] , + [1.5,2.5] , + [2,1] , [2,2] , [2,3] , [2,4] , + [2.5,2.5] , + [3,1] , [3,2] , [3,3] , [3,4] ] + +a= vscan((m1,m2),(ai1,ai2),vector,False, 0.1, context = "2D Vector") + diff --git a/script/test_Simona.py b/script/test_Simona.py new file mode 100644 index 0000000..1e8adaf --- /dev/null +++ b/script/test_Simona.py @@ -0,0 +1,52 @@ + + +#Simona test + +#!/usr/bin/env python +import numpy as np +import matplotlib.pyplot as plt + +# example data +x = np.arange(0.1, 4, 0.5) +y = np.exp(-x) + +# example variable error bar values +yerr = 0.1 + 0.2*np.sqrt(x) +xerr = 0.1 + yerr + +# First illustrate basic pyplot interface, using defaults where possible. +plt.figure() +plt.errorbar(x, y, xerr=0.2, yerr=0.4) +plt.title("Simplest errorbars, 0.2 in x, 0.4 in y") + +# Now switch to a more OO interface to exercise more features. +fig, axs = plt.subplots(nrows=2, ncols=2, sharex=True) +ax = axs[0,0] +ax.errorbar(x, y, yerr=yerr, fmt='o') +ax.set_title('Vert. symmetric') + +# With 4 subplots, reduce the number of axis ticks to avoid crowding. +ax.locator_params(nbins=4) + +ax = axs[0,1] +ax.errorbar(x, y, xerr=xerr, fmt='o') +ax.set_title('Hor. symmetric') + +ax = axs[1,0] +ax.errorbar(x, y, yerr=[yerr, 2*yerr], xerr=[xerr, 2*xerr], fmt='--o') +ax.set_title('H, V asymmetric') + +ax = axs[1,1] +ax.set_yscale('log') +# Here we have to be careful to keep all y values positive: +ylower = np.maximum(1e-2, y - yerr) +yerr_lower = y - ylower + +ax.errorbar(x, y, yerr=[yerr_lower, 2*yerr], xerr=xerr, + fmt='o', ecolor='g', capthick=2) +ax.set_title('Mixed sym., log y') + +fig.suptitle('Variable errorbars') + +plt.show() + diff --git a/script/test_didier.py b/script/test_didier.py new file mode 100644 index 0000000..4394e03 --- /dev/null +++ b/script/test_didier.py @@ -0,0 +1,38 @@ +################################################################################################### +# Multiple Gaussians peak search with mathutils.py +################################################################################################### + + +from mathutils import estimate_peak_indexes, fit_gaussians, create_fit_point_list + +start = 0 +end = 50 +step_size = 0.2 + +result= lscan(ao1,ai1,start,end,[step_size,]) + +readable = result.getReadable(0) +positions = result.getPositions(0) + +threshold = (min(readable) + max(readable))/2 +min_peak_distance = 5.0 + +peaks = estimate_peak_indexes(readable, positions, threshold, min_peak_distance) +print "Peak indexes: " + str(peaks) +print "Peak x: " + str(map(lambda x:positions[x], peaks)) +print "Peak y: " + str(map(lambda x:readable[x], peaks)) + + + +gaussians = fit_gaussians(readable, positions, peaks) + + +plots = plot([readable],["sin"],[positions], title="Data" ) +for i in range(len(peaks)): + peak = peaks[i] + (norm, mean, sigma) = gaussians[i] + if abs(mean - positions[peak]) < min_peak_distance: + print "Peak -> " + str(mean) + plots[0].addMarker(mean, None, "N="+str(round(norm,2)), None) + else: + print "Invalid gaussian fit: " + str(mean) diff --git a/script/test_scan_with_fit.py b/script/test_scan_with_fit.py new file mode 100644 index 0000000..c11684d --- /dev/null +++ b/script/test_scan_with_fit.py @@ -0,0 +1,7 @@ + + + +res = lscan(SINSB01_phase, BC1_energy, -90, 90, 21, latency = 1.0, relative = True) +y = res.getReadable(0) +x = res.getPositions(0) +fit(y, x) \ No newline at end of file