This commit is contained in:
2023-05-01 11:28:04 +02:00
parent 3a83f3cf34
commit abe3bcb19c
265 changed files with 28663 additions and 1295 deletions

BIN
script/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -9,8 +9,8 @@
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MA-ID:DONE" value="DONE" operation="wait"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MA-PC:CSCALER.INPB" value="1" operation="putq"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MA-PC-PS2:SET:DMD:RAMPRATE:TPM" value="1.15" operation="putq" delay="15.0"/>
<dimension>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="X07MA-PHS-E:GO.A" readback="X07MA-PGM:CERBK" settlingTime="0.5" id="Energy">
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="X07MA-PHS-E:GO.A" readback="X07MA-PGM:CERBK" settlingTime="0.5" asynchronous="false" id="Energy">
<positions>1236.9 1243.9</positions>
</positioner>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X07MA-ES1-AI:SIGNAL0" id="TEY"/>
@@ -22,8 +22,8 @@
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="ARIDI-PCT:CURRENT" id="RingCurrent"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X07MA-ES1-AI:SIGNAL4" id="fieldAnalogX"/>
</dimension>
<dimension>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RegionPositioner" name="X07MA-PC:GO" readback="X07MA-PC-PS2:STS:PMCURRENT" settlingTime="0.0" id="field">
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RegionPositioner" name="X07MA-PC:GO" readback="X07MA-PC-PS2:STS:PMCURRENT" settlingTime="0.0" asynchronous="false" id="field">
<region>
<preAction xsi:type="ChannelAction" channel="X07MA-PC-PS2:M:GO.A" value="-4.0" operation="putq"/>
<start>0.0</start>
@@ -33,23 +33,19 @@
</positioner>
</dimension>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MA-PC-PS2:SET:DMD:RAMPRATE:TPM" value="2" operation="putq" delay="15.0"/>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="tey_norm">
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="tey_norm">
<mapping xsi:type="IDParameterMapping" refid="TEY" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="I0" variable="d"/>
<script>
import math
<script>import math
def process(c,d):
return c/d
</script>
return c/d</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="trans_norm">
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="trans_norm">
<mapping xsi:type="IDParameterMapping" refid="trans" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="I0" variable="d"/>
<script>
import math
<script>import math
def process(c,d):
return c/d
</script>
return c/d</script>
</manipulation>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="field" y="tey_norm" title="TEY norm vs field"/>

View File

@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="XRD_XRF_otf_200ms_17200eV_XY_tisbe_Cu_HR2um"/>
<description>tisbe Cu sample, Norway
</description>
<scan>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ID2:ENERGY" value="17.2" timeout="30.0" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ID2:HARMONIC" value="13" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES3:SET-DCT-TIME" value="0.2" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:StopAll" value="1" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:EraseAll" value="1" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:Capture" value="0" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:LazyOpen" value="1" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:PresetMode" value="0" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:CollectMode" value="1" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:PresetReal" value="0.2" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:ListMode" value="0" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:PixelAdvanceMode" value="1" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:IgnoreGate" value="0" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:PixelsPerRun" value="4000" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:NumCapture" value="4000" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:EnableCallbacks" value="1" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:DataType" value="Float32" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:NDArrayMode" value="1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:AutoSave" value="1" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:AutoPixelsPerBuffer" value="0" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:PixelsPerBuffer" value="1" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:AutoIncrement" value="1" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:FileWriteMode" value="2" operation="putq" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES2-CRL:BSRS" value="0" timeout="0.2" delay="0.2"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES2-CRL:RSCN.PROC" value="1" timeout="0.2" delay="0.2"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES3:SMPL-BTN" value="1" delay="0.2"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:BlockingCallbacks" value="1" delay="0.2"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:DeleteDriverFile" value="0" delay="0.2"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES3:START-CSMPL" value="1" delay="0.5"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES3:START-CSMPL" value="0" delay="0.5"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="myriotrigger:vars:mode" value="0" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:PhotonEnergy" value="17200" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:ThresholdEnergy" value="8600" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:AcquireTime" value="0.18" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:AcquirePeriod" value="0.19" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:CompressionAlgo" value="1" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:FWNImagesPerFile" value="500" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:TriggerMode" value="2" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:NumTriggers" value="1000000" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:SaveFiles" value="1" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:FWAutoRemove" value="1" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:CreateDirectory" value="-2" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:ManualTrigger" value="1" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:Acquire" value="1" operation="putq" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-OP-MO:ENERGY" value="16.9" timeout="60.0" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-OP-MO:ENERGY" value="17" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-OP-MO:ENERGY" value="17.1" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-OP-MO:ENERGY" value="17.15" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-OP-MO:ENERGY" value="17.19" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-OP-MO:ENERGY" value="17.195" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-OP-MO:ENERGY" value="17.198" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-OP-MO:ENERGY" value="17.199" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-OP-MO:ENERGY" value="17.2" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-EH-SH1size" value="0.05" delay="0.2"/>
<cdimension zigzag="false" dataGroup="false">
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:Capture" value="1" operation="putq" timeout="0.2"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:StartAll" value="1" operation="putq" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES3:START-CSMPL" value="1" timeout="0.4" delay="1.0"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES3:SMPL-BTN" value="1" operation="putq" delay="0.2"/>
<positioner name="X05LA-ES2-MA:6DTRX1" id="TRX">
<start>-0.15</start>
<end>0.52</end>
<stepSize>0.002</stepSize>
<integrationTime>0.2</integrationTime>
<additionalBacklash>0.005</additionalBacklash>
</positioner>
<detector name="TRIGGER1" scr="false" id="trigger"/>
<detector name="X05LA-ES3:SAI_05" scr="true" id="i0"/>
<detector name="X05LA-ES3:SAI_06" scr="true" id="Diode"/>
<detector name="X05LA-SITORO:dxp1:CurrentPixel" scr="true" id="CurrentPixel"/>
<detector name="X05LA-SITORO:ROIStat1:1:Total_RBV" scr="true" id="aArKa"/>
<detector name="X05LA-SITORO:ROIStat1:2:Total_RBV" scr="true" id="aFeKa"/>
<detector name="X05LA-SITORO:ROIStat1:3:Total_RBV" scr="true" id="aFeKb"/>
<detector name="X05LA-SITORO:ROIStat1:4:Total_RBV" scr="true" id="aZnKa"/>
<detector name="X05LA-SITORO:ROIStat1:5:Total_RBV" scr="true" id="aSeKa"/>
<detector name="X05LA-SITORO:ROIStat1:16:Total_RBV" scr="true" id="aCuKa"/>
<detector name="X05LA-SITORO:ROIStat1:7:Total_RBV" scr="true" id="aYKa"/>
<detector name="X05LA-SITORO:ROIStat1:9:Total_RBV" scr="true" id="aCaKa"/>
<detector name="X05LA-SITORO:ROIStat2:1:Total_RBV" scr="true" id="bArK"/>
<detector name="X05LA-SITORO:ROIStat2:2:Total_RBV" scr="true" id="bFeKa"/>
<detector name="X05LA-SITORO:ROIStat2:19:Total_RBV" scr="true" id="bBrKa"/>
<detector name="X05LA-SITORO:ROIStat2:4:Total_RBV" scr="true" id="bZnKa"/>
<detector name="X05LA-SITORO:ROIStat2:5:Total_RBV" scr="true" id="bSeKa"/>
<detector name="X05LA-SITORO:ROIStat2:16:Total_RBV" scr="true" id="bCuKa"/>
<detector name="X05LA-SITORO:ROIStat2:7:Total_RBV" scr="true" id="bYKa"/>
<detector name="X05LA-SITORO:ROIStat2:9:Total_RBV" scr="true" id="bCaKa"/>
<detector name="X05LA-SITORO:ROIStat3:1:Total_RBV" scr="true" id="cArKa"/>
<detector name="X05LA-SITORO:ROIStat3:2:Total_RBV" scr="true" id="cFeka"/>
<detector name="X05LA-SITORO:ROIStat3:3:Total_RBV" scr="true" id="cFeKb"/>
<detector name="X05LA-SITORO:ROIStat3:4:Total_RBV" scr="true" id="cZnKa"/>
<detector name="X05LA-SITORO:ROIStat3:5:Total_RBV" scr="true" id="cSeKa"/>
<detector name="X05LA-SITORO:ROIStat3:16:Total_RBV" scr="true" id="cCuKa"/>
<detector name="X05LA-SITORO:ROIStat3:7:Total_RBV" scr="true" id="cYKa"/>
<detector name="X05LA-SITORO:ROIStat3:9:Total_RBV" scr="true" id="cCaKa"/>
<detector name="X05LA-SITORO:ROIStat4:1:Total_RBV" scr="true" id="dArKa"/>
<detector name="X05LA-SITORO:ROIStat4:2:Total_RBV" scr="true" id="dFeKa"/>
<detector name="X05LA-SITORO:ROIStat4:3:Total_RBV" scr="true" id="dFeKb"/>
<detector name="X05LA-SITORO:ROIStat4:4:Total_RBV" scr="true" id="dZnKa"/>
<detector name="X05LA-SITORO:ROIStat4:5:Total_RBV" scr="true" id="dSeKa"/>
<detector name="X05LA-SITORO:ROIStat4:16:Total_RBV" scr="true" id="dCuKa"/>
<detector name="X05LA-SITORO:ROIStat4:7:Total_RBV" scr="true" id="dYKa"/>
<detector name="X05LA-SITORO:ROIStat4:9:Total_RBV" scr="true" id="dCaKa"/>
<detector name="myriotrigger:vars:mean2" scr="true" id="myriotrigger2"/>
<detector name="myriotrigger:vars:mean1" scr="true" id="myriotrigger1"/>
<detector name="best0:BPM0:PosX" scr="true" id="BPMposX"/>
<detector name="best0:BPM0:PosY" scr="true" id="BPMposY"/>
<timestamp id="Timestamp"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:StopAll" value="1" operation="putq" delay="0.2"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:Capture" value="0" operation="putq" delay="0.2"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES3:START-CSMPL" value="0" delay="0.2"/>
</cdimension>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinearPositioner" name="X05LA-ES2-MA:6DTRY" readback="X05LA-ES2-MA:6DTRY.RBV" doneDelay="0.2" asynchronous="false" id="TRY">
<start>-0.0</start>
<end>1.0</end>
<stepSize>0.002</stepSize>
</positioner>
</dimension>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:AutoSave" value="0" delay="0.1"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:CollectMode" value="0" delay="0.1"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-SITORO:HDF1:Capture" value="0" delay="0.1"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES1-EIGER1:cam1:Acquire" value="0" delay="1.0"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-EH-SH1size" value="0.05" delay="10.0"/>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="mux">
<mapping xsi:type="IDParameterMapping" refid="Diode" variable="diode"/>
<mapping xsi:type="IDParameterMapping" refid="i0" variable="izero"/>
<script>import math
def process(izero, diode):
return -math.log(diode/izero)</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="diff">
<mapping xsi:type="IDParameterMapping" refid="trigger" variable="trigger"/>
<mapping xsi:type="IDParameterMapping" refid="CurrentPixel" variable="pixel"/>
<script>import math
def process(trigger, pixel):
return (trigger - pixel)</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="mux2">
<mapping xsi:type="IDParameterMapping" refid="myriotrigger1" variable="izero"/>
<mapping xsi:type="IDParameterMapping" refid="myriotrigger2" variable="diode"/>
<script>import math
def process(izero, diode):
return -math.log(diode/izero)</script>
</manipulation>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="mux" title="mux"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="aCaKa" title="CaKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="bCaKa" title="CaKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="cCaKa" title="CaKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="dCaKa" title="CaKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="aCuKa" title="CuKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="bCuKa" title="CuKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="cCuKa" title="CuKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="dCuKa" title="CuKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="aZnKa" title="ZnKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="bZnKa" title="ZnKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="bBrKa" title="BrKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="dSeKa" title="SeKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="Diode" title="Diode"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="i0" title="i0"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="trigger" title="Trigger"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="CurrentPixel" title="CurrentPixel"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="myriotrigger1" title="myriotrigger1"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="TRX" y="TRY" z="myriotrigger2" title="myriotrigger2"/>
</configuration>

View File

@@ -0,0 +1,23 @@
###################################################################################################
# Setting script parameters and return value
###################################################################################################
#Providing a map of global variables
#run ("52_ParametersAndReturn", {"start":10.0, "end":50.0, "step":40})
#Providing the locals dictionary
# The parameters are not set as globals, and nor script definitions
#run ("52_ParametersAndReturn", locals={"start":10.0, "end":50.0, "step":40})
#Setting sys.argv:
#run ("52_ParametersAndReturn", [10.0, 50.0, 40])
#In this case the parameters would be parsed as:
#start = sys.argv[0]
#end = sys.argv[1]
#step = sys.argv[2]
ret = lscan(ao1, ai1, start, end, step, 0.1)
set_return(ret[ai1])

View File

@@ -2,7 +2,7 @@ import math
import sys, traceback
from mathutils import fit_polynomial, PolynomialFunction
from plotutils import plot_line, plot_function
from ch.psi.pshell.swing.Shell import STDOUT_COLOR
from ch.psi.pshell.swing.Shell import getColorStdout
import org.apache.commons.math3.stat.correlation.PearsonsCorrelation as PearsonsCorrelation
start_task("outupdate", 0.0, 0.0)
@@ -146,7 +146,7 @@ try:
if marker is not None:
p.removeMarker(marker)
marker = p.addMarker(x2+res, p.AxisId.X, s, p.getBackground())
marker.setLabelPaint(STDOUT_COLOR)
marker.setLabelPaint(getColorStdout())
if linear_fit:
#Calculate, print and plot linear fit
pars_lin = (a0,a1) = fit_polynomial(ay, ax, 1)

View File

@@ -8,8 +8,8 @@ STEPS (int or tuple)
LATENCY (double)
RELATIVE (BOOLEAN)
"""
if get_exec_pars().source == CommandSource.ui:
if not get_exec_pars().args:
MOTOR = motor
SENSORS = (det.dataMatrix, scienta.spectrum, scienta.stats[0])
RANGE = (-5.0, 5.0)
@@ -17,6 +17,6 @@ if get_exec_pars().source == CommandSource.ui:
LATENCY = 0.0
RELATIVE = False
lscan(MOTOR, SENSORS, RANGE[0], RANGE[1], STEPS, LATENCY, RELATIVE, before_read=trig_scienta)

43
script/ManualScan.py Normal file
View File

@@ -0,0 +1,43 @@
###################################################################################################
#Manual scan: Manually setting positioners and reading back sensors, but still using
#the standard data handling and plotting of built-in scans.
###################################################################################################
mu.setSpeed(10.0)
pos1 = mu
pos2 = out
det1 =sin
det2 = arr
det3 = cm1#ri1
MOTOR_RANGE = (0.0, 8.0)
OUTPUT_SETPOINTS = (1.0, 2.0, 3.0)
FIXED_X = True
writables_names = [pos1.getName()]
readable_names = [det1.getName(), "arr[10]","cm1[3][2]"]
start = [ MOTOR_RANGE[0] if FIXED_X else -1, ]
stop = [ MOTOR_RANGE[1] if FIXED_X else -1]
steps = [int(MOTOR_RANGE[1]-MOTOR_RANGE[0])]
scan = ManualScan(writables_names, readable_names ,start, stop, steps, monitors = [sin])
#This option is to plot the foe each output value one 1D series, instead of all in a matrix plot
#set_exec_pars(line_plots = (det1, det2))
scan.start()
pos1.setSpeed(10.0)
for setpoint1 in frange(MOTOR_RANGE[0], MOTOR_RANGE[1], 1.0, True):
pos1.move(setpoint1)
for setpoint2 in OUTPUT_SETPOINTS:
pos2.write(setpoint2)
scan.append ([setpoint1], [pos1.read()], [det1.read(), det2.read(), cm1.read()])
scan.end()

View File

@@ -86,7 +86,7 @@ if EXPOSURES:
POSITIONERS = POSITIONERS + [exposure_index()]
SENSORS = SENSORS + [exposure()]
RANGE_E=[0, len(EXPOSURES)-1]
#set_exec_pars(manual_range=RANGE_E, manual_range_y=RANGE_Y)
CUSTOM_PLOT_TYPES[sin]=1
@@ -102,7 +102,7 @@ def gen():
xpos = CENTER_X + x_step*STEP_SIZE_X + (random.random()-0.5)*NOISE*2*STEP_SIZE_X
range_y= range(STEPS_Y, -STEPS_Y-1, -1) if (ZIGZAG and(x_index%2 ==1)) else range(-STEPS_Y, STEPS_Y+1)
for y_step in range_y:
ypos = CENTER_Y + y_step*STEP_SIZE_Y + (random.random()-0.5)*NOISE*2*STEP_SIZE_Y
ypos = CENTER_Y + y_step*STEP_SIZE_Y + (random.random()-0.5)*NOISE*2*STEP_SIZE_Y
if EXPOSURES:
range_e= range(len(EXPOSURES)-1,-1, -1) if (ZIGZAG and(y_index%2 ==1)) else range(len(EXPOSURES))
for e in range_e:
@@ -116,8 +116,9 @@ def gen():
try:
r = vscan(POSITIONERS, SENSORS , gen(), False,\
SETTLING_TIME, relative=False, zigzag = ZIGZAG, \
before_read=before_readout, after_read = after_read, \
SETTLING_TIME, relative=False, zigzag = ZIGZAG, initial_move=False, \
before_read=before_readout, after_read = after_readout, \
manual_range=RANGE_X, manual_range_y=RANGE_Y, \
compression = COMPRESSION, enabled_plots=ENABLED_PLOTS, \
keep=False, check_positions=False, plot_types=CUSTOM_PLOT_TYPES)
set_return(r)

73
script/ShellCommand.py Normal file
View File

@@ -0,0 +1,73 @@
#CAS.setServerPort(5064)
import java.util.function.BiFunction as BiFunction
class ShellCommand(RegisterBase, RegisterArray):
def __init__(self, name):
RegisterBase.__init__(self, name)
self.val = ""
self.debug=False
self.max_size = 10000
def getSize(self):
return 1
def doRead(self):
if self.debug:
print "READ: ", self.val
return self.val
def doWrite(self, val):
self.val = "RUNNING"
try:
if self.debug:
print "WRITE: ", val
cmd = str(val[0])
class eval_callback(BiFunction):
def apply(self_callback, ret, ex):
try:
if ex is not None:
err=ex.message
if "Exception:" in err:
err = err[err.index("Exception:")+10:].strip()
self.val = "ERR:" + err
else:
self.val = "RET:" + str(ret)
self.val = self.val[0:self.max_size]
except:
err=str(sys.exc_info()[1])
self.val = "EXC: " + err
if self.debug:
print self.val
#self.val = cmd
get_context().evalLineBackgroundAsync(cmd).handle(eval_callback())
except:
err=str(sys.exc_info()[1])
if "Exception:" in err:
err = err[err.index("Exception:")+10:].strip()
self.val = "EXC: " + err
self.val = self.val[0:self.max_size]
if self.debug:
print self.val
add_device(ShellCommand("sc"), True)
cas = CAS("TESTCAS:sc", sc, 'string')
#print caget("TESTCAS:sc","s")
#/Users/gobbo_a/anaconda3/envs/epics/epics/bin/darwin-x86

50
script/StateCAS.py Normal file
View File

@@ -0,0 +1,50 @@
class EpicsServerState(ReadonlyAsyncRegisterBase):
def __init__(self, name, channel, as_string=True):
RegisterBase.__init__(self, name)
self.channel=channel
self.as_string=as_string
self.val = "Unknown"
self.cas = None
self.state_change_listener=None
def doInitialize(self):
super(EpicsServerState, self).doInitialize()
if self.as_string:
self.cas = CAS(self.channel, self, 'string')
else:
self.cas = CAS(self.channel, self, 'byte')
if self.state_change_listener is None:
class StateChangeListener(ContextListener):
def onContextStateChanged(_self, state, former):
self.set(state)
self.state_change_listener = StateChangeListener()
get_context().addListener(self.state_change_listener)
def getSize(self):
if self.as_string:
return 1
else:
return 100
def doClose(self):
if self.state_change_listener:
get_context().removeListener(self.state_change_listener)
if self.cas:
self.cas.close()
self.cas = None
super(EpicsServerState, self).doClose()
def set(self, value):
if self.as_string:
self.onReadout(str(value))
else:
self.onReadout(string_to_list(str(value)))
if "server_state_channel" in globals():
server_state_channel.close()
server_state_channel = EpicsServerState("server_state_channel", "PSHELL_OP:STATE", False)
server_state_channel.initialize()

View File

@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="Test"/>
<variable name="K" value="0.0" description="Buffer K spacing for EXAFS k-spacing scans "/>
<variable name="N_cycles" value="0.0" description="Buffer N_cycles for EXAFS k-spacing scans "/>
<variable name="NINT" value="0.0" description="Counter for file number of Moche files"/>
<scan>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RegionPositioner" name="TESTIOC:TESTCALCOUT:Input" readback="TESTIOC:TESTCALCOUT:Input" settlingTime="0.1" asynchronous="false" id="Energy">
<region>
<start>0.0</start>
<end>10.0</end>
<stepSize>1.0</stepSize>
<function>
<mapping xsi:type="VariableParameterMapping" name="K" variable="K_v"/>
<mapping xsi:type="ChannelParameterMapping" channel="TESTIOC:TESTCALCOUT:Output" type="Double" variable="Ch"/>
<script>def calculate(parameter):
print "X"
nc=Ch.getValue()
print nc
#nc=nc*1.02
#N_Cycles.setValue(nc)
return parameter * 2
E_0=7112.0
h=6.626e-34
m=9.109e-31
k=parameter*1e10
K_v=k*1e-10
hk=(h/(2.*3.1415926))*k
E_joule=hk*hk / (2.*m)
E_eV=E_joule/1.6021e-19+E_0
return E_eV</script>
</function>
</region>
</positioner>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTSINUS:SinCalc" id="SIN"/>
</dimension>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="SIN" title="Sin"/>
</configuration>

46
script/Test3.xml Normal file
View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="Test"/>
<variable name="K" value="0.0" description="Buffer K spacing for EXAFS k-spacing scans "/>
<variable name="N_cycles" value="0.0" description="Buffer N_cycles for EXAFS k-spacing scans "/>
<variable name="NINT" value="0.0" description="Counter for file number of Moche files"/>
<scan>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RegionPositioner" name="" readback="TESTIOC:TESTCALCOUT:Input" settlingTime="0.1" asynchronous="false" id="Energy">
<region>
<start>0.0</start>
<end>10.0</end>
<stepSize>1.0</stepSize>
<function>
<mapping xsi:type="VariableParameterMapping" name="N_cycles" variable="K_v"/>
<mapping xsi:type="ChannelParameterMapping" channel="TESTIOC:TESTCALCOUT:Output" type="Double" variable="Ch"/>
<script>def calculate(parameter):
print "X"
nc=Ch.getValue()
print nc
#nc=nc*1.02
#N_Cycles.setValue(nc)
return parameter * 2
E_0=7112.0
h=6.626e-34
m=9.109e-31
k=parameter*1e10
K_v=k*1e-10
hk=(h/(2.*3.1415926))*k
E_joule=hk*hk / (2.*m)
E_eV=E_joule/1.6021e-19+E_0
return E_eV</script>
</function>
</region>
</positioner>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTSINUS:SinCalc" id="SIN"/>
</dimension>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="id951374">
<mapping xsi:type="IDParameterMapping" refid="SIN" variable=""/>
<script>def process():
return 0.0</script>
</manipulation>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="id951374" title="Sin"/>
</configuration>

24
script/Test4.xml Normal file
View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="Test"/>
<variable name="K" value="0.01" description="Buffer K spacing for EXAFS k-spacing scans "/>
<variable name="N_cycles" value="0.0" description="Buffer N_cycles for EXAFS k-spacing scans "/>
<variable name="NINT" value="100.0" description="Counter for file number of Moche files"/>
<scan>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinearPositioner" name="TESTIOC:TESTCALCOUT:Input" readback="" id="Energy">
<start>0.0</start>
<end>10.0</end>
<stepSize>1.0</stepSize>
</positioner>
</dimension>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="PseudoPositioner" id="POS">
<counts>1</counts>
</positioner>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTSINUS:SinCalc" id="SIN"/>
</dimension>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="SIN" title="Sin"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="Energy" y="POS" z="SIN"/>
</configuration>

19
script/Test4b.xml Normal file
View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="Test"/>
<variable name="K" value="0.01" description="Buffer K spacing for EXAFS k-spacing scans "/>
<variable name="N_cycles" value="0.0" description="Buffer N_cycles for EXAFS k-spacing scans "/>
<variable name="NINT" value="100.0" description="Counter for file number of Moche files"/>
<scan>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinearPositioner" name="TESTIOC:TESTCALCOUT:Input" readback="" id="Energy">
<start>0.0</start>
<end>0.0</end>
<stepSize>1.0</stepSize>
<endVar>NINT</endVar>
</positioner>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTSINUS:SinCalc" id="SIN"/>
</dimension>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="SIN" title="Sin"/>
</configuration>

17
script/Test4c.xml Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="Test"/>
<variable name="K" value="0.01" description="Buffer K spacing for EXAFS k-spacing scans "/>
<variable name="N_cycles" value="0.0" description="Buffer N_cycles for EXAFS k-spacing scans "/>
<variable name="NINT" value="100.0" description="Counter for file number of Moche files"/>
<variable name="var" value="1 2 3 4 5"/>
<scan>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="TESTIOC:TESTCALCOUT:Input" id="Energy">
<positions>var</positions>
</positioner>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTSINUS:SinCalc" id="SIN"/>
</dimension>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="SIN" title="Sin"/>
</configuration>

29
script/Test4e.xml Normal file
View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="Test"/>
<variable name="K" value="0.01" description="Buffer K spacing for EXAFS k-spacing scans "/>
<variable name="N_cycles" value="0.0" description="Buffer N_cycles for EXAFS k-spacing scans "/>
<variable name="NINT" value="=20.0" description="Counter for file number of Moche files"/>
<variable name="CH" value="TESTIOC:TESTSINUS:SinCalc"/>
<variable name="V" value="=NINT*2"/>
<scan>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinearPositioner" name="motor" readback="" settlingTime="0.1" asynchronous="false" id="Energy">
<start>0.0</start>
<end>0.0</end>
<stepSize>1.0</stepSize>
<endVar>V</endVar>
</positioner>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="CH" id="SIN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="ca://TESTIOC:TESTSINUS:SinCalc?samples=3&amp;interval=100" id="AVE"/>
</dimension>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="PseudoPositioner" settlingTime="0.5" id="POS">
<counts>1</counts>
</positioner>
</dimension>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="SIN" title="Sin"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="Energy" y="POS" z="SIN"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="AVE" title="Average"/>
</configuration>

5
script/Test5.xml Normal file
View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0">
<data/>
<scan/>
</configuration>

View File

@@ -6,18 +6,25 @@ class Trigger(ReadonlyRegisterBase):
trigger = Trigger()
trigger.initialize()
sca = "asd"
scan = None
def scan():
global sca
sca = mscan(trigger, [sc1, sin.cache], 20)
global scan
scan = mscan(trigger, [out, sin.cache])
print scan
scan_task = fork(scan)
scan_task = fork(scan)[0]
time.sleep(0.5)
for i in range(10):
for i in range(20):
trigger.update()
time.sleep(random.random()/5)
#ret = join(scan_task)
time.sleep(1.0)
ep=get_exec_pars()
ep.currentScan.abort()
#scan_task.cancel(True)
ret = join(scan_task)

41
script/align/Demo2D.py Normal file
View File

@@ -0,0 +1,41 @@
###################################################################################################
# Using bsearch(Binary Search) and hsearch(Hill Climbing Search) to find optimum
###################################################################################################
class Sensor(ReadonlyRegisterBase):
def doRead(self):
return 1000.0 - (math.pow(motor.take()-0.5, 2) + math.pow(pe.take()+2, 2))
add_device(Sensor("sensor"), True)
range_x, step_x=1.0, 0.1
range_y, step_y=10.0, 0.1
motor.speed=5.0
motor.move(0.0)
pe.move(0.0)
print "--------------- Full 2D Scan -----------------"
r = ascan([motor, pe], sensor, [-range_x,-range_y], [range_x,range_y], [step_x, step_x], relative=True, zigzag=True)
data = Convert.reshape(r[sensor], r.scan.numberOfSteps[0]+1, r.scan.numberOfSteps[1]+1)
data = [(data[i][::-1] if ((i%2)==1) else data[i]) for i in range(len(data))]
d=Data(to_array(data,'d'))
v,h=d.integrateVertically(), d.integrateHorizontally()
mv=fit(v)[1]
mh=fit(h)[1]
index = int(round(mh))*(r.scan.numberOfSteps[1]+1) + int(round(mv))
max_pe, max_motor= r[pe][index], r[motor][index]
print "2s scan peak at motor=" , max_motor , " pe=", max_pe
motor.move(max_motor)
pe.move(max_pe)
print "--------------- Binary Search -----------------"
motor.move(0.0);pe.move(0.0)
r = bsearch([motor, pe], sensor, [-range_x,-range_y], [range_x,range_y], [step_x/4, step_y/4], \
relative=True, maximum=True, strategy = "Normal", restore_position=False )
print "bsearch peak at position=", r.optimalPosition , " in ", len(r), "evaluations"
motor.move(0.0);pe.move(0.0)
print "--------------- Hill Climbing Search -----------------"
r = hsearch([motor, pe], sensor, [-range_x,-range_y],[range_x,range_y], [step_x*2, step_y*2], \
[step_x/4, step_y/4], relative=True, maximum=True, restore_position=False )
print "hsearch peak at position=", r.optimalPosition, " in ", len(r), "evaluations"

View File

@@ -0,0 +1,33 @@
###################################################################################################
# Simple alignment example
###################################################################################################
from mathutils import *
from plotutils import *
scan_range = 2.0
step_size = 0.1
r = lscan(motor,sinp,-scan_range,scan_range,[step_size,],relative=True)
p=get_plots()[0]
p.setLegendVisible(True)
y = r[sinp]
x = r[motor]
fit_pars = (offset, normalization, mean_val, sigma) = fit_gaussian_offset(y, x)
print fit_pars
if (mean_val is not None):
gaussian = GaussianOffset(*fit_pars)
plot_function(p, gaussian, "Fit" , x)
#Fitting error
if mean_val is None or mean_val<x[0] or mean_val>x[-1]:
mean_val= x[y.index(max(y))]
print "Fitting error - using max value"
p.addMarker(mean_val, None, "Mean=" + str(round(mean_val,2)), Color.LIGHT_GRAY)
motor.move(mean_val)

View File

@@ -1,4 +1,4 @@
import java.lang.Short as Short
import ch.psi.pshell.epics.CAS as CAS
import ch.psi.pshell.device.Register.RegisterArray as RegisterArray
import random
@@ -12,6 +12,7 @@ EPICS_PV_SUFFIX_STATUS = ":INIT"
EPICS_PV_SUFFIX_WIDTH = ":WIDTH"
EPICS_PV_SUFFIX_HEIGHT = ":HEIGHT"
EPICS_PV_SUFFIX_STREAM_ADDRESS = ":BSREADCONFIG"
EPICS_PV_SUFFIX_IMG = ":FPICTURE"
class Scalar(RegisterBase):
def __init__(self, name):
@@ -29,6 +30,7 @@ add_device(Scalar("cam_width"), True)
add_device(Scalar("cam_height"), True)
add_device(Scalar("cam_add"), True)
cam_width.write(IMG_WIDTH)
cam_height.write(IMG_HEIGHT)
cam_init.write("INIT")
@@ -42,6 +44,13 @@ cas3 = CAS(camera + EPICS_PV_SUFFIX_HEIGHT, cam_height, 'int')
cas4 = CAS(camera + EPICS_PV_SUFFIX_STREAM_ADDRESS, cam_add, 'string')
class Img(ReadonlyRegisterBase, ReadonlyRegisterArray):
def doRead(self):
return Convert.toPrimitiveArray(Convert.flatten(cam_server.getArray()),Short)
add_device(Img("cam_img"), True)
cas5 = CAS(camera + EPICS_PV_SUFFIX_IMG, cam_img, 'double')
print caget(camera + EPICS_PV_SUFFIX_STATUS)
print caget(camera + EPICS_PV_SUFFIX_WIDTH)
print caget(camera + EPICS_PV_SUFFIX_HEIGHT)

View File

@@ -1,3 +1,4 @@
def calc(a):
return a*2

2
script/cpy/BugMonitor.py Normal file
View File

@@ -0,0 +1,2 @@
av = create_averager(sin, 5 , monitored=True)
tscan ([sin,av], 100, 0.1)

170
script/cpy/Device.py Normal file
View File

@@ -0,0 +1,170 @@
class GenericDevice(Nameable):
cls=[ "ch.psi.pshell.device.GenericDevice", \
"ch.psi.utils.Observable", \
"ch.psi.pshell.device.Timestamped", \
"java.lang.AutoCloseable", \
"ch.psi.utils.Configurable", \
"ch.psi.pshell.device.Record" ]
def __init__(self, name=None, cls=GenericDevice.cls):
Nameable.__init__(self, name, cls)
self.simulated=False
self.state=State.Ready
self.monitored=False
self.polling=None
self.cache=None
self.age=None
def addListener(self, listener):
pass
def getListeners(self):
pass
def removeListener(self, listener):
pass
def removeAllListeners(self):
pass
def getTimestamp(self):
return 0
def getTimestampNanos(self):
return 0
def getConfig(self):
return None
def getState(self):
return State.Ready
def waitState(self, state, timeout):
return
def waitStateNot(self, state, timeout):
pass
def initialize(self):
pass
def isInitialized(self):
return True
def waitInitialized(self, timeout):
pass
def setSimulated(self):
self.simulated = True
def isSimulated(self):
return self.simulated
def isMonitored(self):
return self.monitored
def setMonitored(self,monitored):
self.monitored=self.monitored
def setPolling(self, interval):
self.polling=interval
def getPolling(self):
return self.polling
def isPollingBackground(self):
return self.polling and self.polling>0
def setAccessType(self, mode):
pass
def getAccessType(self):
return None
def take(self):
return self.cache
def getAge(self):
return self.age
def request(self):
self.update()
def update(self):
pass
def setWaitSleep(self, value):
pass
def getWaitSleep(self):
return 5
def isPolled(self):
return self.getPolling() > 0
def takeAsNumber(self):
cache = take();
try:
return float(cache)
except:
return None
def close(self):
pass
class Device(GenericDevice):
cls="ch.psi.pshell.device.Device"
def __init__(self, name=None):
GenericDevice.__init__(self, name, [Device.cls] + GenericDevice.cls)
def isReady():
return getState()==State.Ready
def waitReady(self, timeout):
return
def waitValue(self, value, timeout):
return
def waitValueNot(self, value, timeout):
return
def waitValueChange(self,timeout):
return false
def waitCacheChange(self,timeout):
return false
def getComponents(self):
return None
def getComponent(self, name):
return None
def getChildren(self):
return None
def getChild(self, name):
return None
def getParent(self):
return None
def setTriggers(self,triggers):
pass
def getTriggers(self):
return None
def takeTimestamped(self,):
return None
def isChild(self, device):
return False
dev= Device("test")
add_device(dev, True)

43
script/cpy/ManualScan.py Normal file
View File

@@ -0,0 +1,43 @@
###################################################################################################
#Manual scan: Manually setting positioners and reading back sensors, but still using
#the standard data handling and plotting of built-in scans.
###################################################################################################
mu.setSpeed(10.0)
pos1 = mu
pos2 = out
det1 =rs1
det2 = sin#rw1
det3 = out#ri1
MOTOR_RANGE = (0.0, 8.0)
OUTPUT_SETPOINTS = (1.0, 2.0, 3.0)
FIXED_X = True
writables_names = [pos1.getName(), pos2.getName()]
readable_names = [det1.getName(), det2.getName()]
start = [ MOTOR_RANGE[0] if FIXED_X else -1, OUTPUT_SETPOINTS[0]]
stop = [ MOTOR_RANGE[1] if FIXED_X else -1, OUTPUT_SETPOINTS[-1]]
steps = [int(MOTOR_RANGE[1]-MOTOR_RANGE[0]), len(OUTPUT_SETPOINTS)-1]
scan = ManualScan(writables_names, readable_names ,start, stop, steps, monitors = [sin])
#This option is to plot the foe each output value one 1D series, instead of all in a matrix plot
set_exec_pars(line_plots = (det1, det2))
scan.start()
pos1.setSpeed(10.0)
for setpoint1 in frange(MOTOR_RANGE[0], MOTOR_RANGE[1], 1.0, True):
pos1.move(setpoint1)
for setpoint2 in OUTPUT_SETPOINTS:
pos2.write(setpoint2)
scan.append ([setpoint1, setpoint2], [pos1.read(), pos2.read()], [det1.read(), det2.read()])
scan.end()

14
script/cpy/Signal.py Normal file
View File

@@ -0,0 +1,14 @@
import signal
def is_main_thread():
try:
# Backup the current signal handler
back_up = signal.signal(signal.SIGINT, signal.SIG_DFL)
except ValueError:
# Only Main Thread can handle signals
return False
# Restore signal handler
signal.signal(signal.SIGINT, back_up)
return True
print (is_main_thread())

View File

@@ -0,0 +1,48 @@
from functools import partial
import threading
import traceback
import socket
CTRL_CMD_PORT = 9587
msg=None
if ("ctrl_cmd_socket" in globals()) and (ctrl_cmd_socket is not None):
ctrl_cmd_socket.close()
ctrl_cmd_task_thread.join(5.0)
if ctrl_cmd_task_thread.is_alive():
raise Exception("Cannot stop ctrl_cmd_task_thread")
def on_ctrl_cmd(cmd):
global RE
print ("Control command: ", cmd)
if cmd=="abort":
if "RE" in globals():
if RE.state not in ['idle','paused', 'pausing']:
print ("Run Engine pause request")
RE.request_pause()
def ctlm_cmd_task(port,parent_thread, rc):
try:
global ctrl_cmd_socket
print ("Starting control command task")
quit=False
with socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) as ctrl_cmd_socket:
ctrl_cmd_socket.bind(("127.0.0.1", port))
ctrl_cmd_socket.settimeout(2.0)
while(quit==False) and (run_count==rc) and parent_thread.is_alive() and not ctrl_cmd_socket._closed:
try:
msg,add = ctrl_cmd_socket.recvfrom(100)
except socket.timeout:
continue
cmd =msg.decode('UTF-8')
on_ctrl_cmd(cmd)
if cmd=="exit":
quit=True
ctrl_cmd_socket.sendto("ack".encode('UTF-8'), add)
finally:
print("Quitting control command task")
ctrl_cmd_task_thread = threading.Thread(target=partial(ctlm_cmd_task, CTRL_CMD_PORT, threading.currentThread(), run_count))
ctrl_cmd_task_thread.setDaemon(True)
ctrl_cmd_task_thread.start()
#RE(rel_scan(dets, motor, -1, 1, 10))

75
script/cpy/TestJProxy.py Normal file
View File

@@ -0,0 +1,75 @@
from jep import jproxy
import random
class MyWritable(Writable):
def write(self, value):
print ("Write: ",value)
class MyReadable(Readable):
def read(self):
return random.random()
class MyReadableArray(ReadableArray):
def read(self):
ret = []
for i in range (self.getSize()):
ret.append(random.random())
return ret
def getSize(self):
return 20
class MyReadableCalibratedArray(ReadableCalibratedArray):
def read(self):
return rw1.read()
def getSize(self):
return rw1.getSize()
def getCalibration(self):
return ArrayCalibration(5,1000)
class MyReadableMatrix(ReadableMatrix):
def read(self):
ret = []
for i in range (self.getHeight()):
ret.append([random.random()] * self.getWidth())
return to_array(ret, 'd')
def getWidth(self):
return 80
def getHeight(self):
return 40
class MyReadableCalibratedMatrix(ReadableCalibratedMatrix):
def read(self):
return ri1.read()
def getWidth(self):
return ri1.getWidth()
def getHeight(self):
return ri1.getHeight()
def getCalibration(self):
return MatrixCalibration(2,4,100,200)
#plot([1,2,3])
ws1 = MyWritable("ws1")
rs1 = MyReadable("rs1")
rw1 = MyReadableArray("rw1")
ri1 = MyReadableMatrix("ri1")
ac1 = MyReadableCalibratedArray("ac1")
mc1 = MyReadableCalibratedMatrix("mc1")
t=lscan(ws1, (rs1, rw1, ri1, ac1, mc1), 0, 5, 5)

68
script/cpy/TestJProxy2.py Normal file
View File

@@ -0,0 +1,68 @@
from jep import jproxy
import random
"""
class proxy():
def __init__(self,cls):
self.cls=cls
def __call__(self, name):
return jproxy(self, self.cls)
@proxy(['ch.psi.pshell.device.Readable'])
"""
class Readable():
def __init__(self, name=None):
self.name=name
self.proxy=jproxy(self, ['ch.psi.pshell.device.Readable'])
def __call__(self):
return self.read()
def __getattribute__(self, name):
if name in ('proxy',):
return object.__getattribute__(self, name)
print(name)
return self.proxy.__getattribute__(name)
def getName(self):
if self.name :
return self.name
return str(self.__class__.__name__)
def read(self):
raise Exception ("Not implemented")
class ReadableScalar(Readable):
def read(self):
ret =random.random()
print (ret)
return ret
class ReadableWaveform(Readable):
def __call__(self):
return self.read()
def getSize(self):
return 20
def read(self):
ret = []
for i in range (self.getSize()):
ret.append(random.random())
return ret
def getName(self):
return "rw1"
#rs1 = jproxy(ReadableScalar(), ['ch.psi.pshell.device.Readable'])
rs1 = ReadableScalar()
#rw1 = jproxy(ReadableWaveform(), ['ch.psi.pshell.device.Readable$ReadableArray'])
#ri1 = jproxy(ReadableImage(), ['ch.psi.pshell.device.Readable$ReadableMatrix'])
#rw1=ReadableWaveform()
rs1.read()
#rw1.read()
#rs1 = jproxy(rs1 , ['ch.psi.pshell.device.Readable'])#
#tscan([rs1],10,0.1, save=False)

View File

@@ -0,0 +1,97 @@
###################################################################################################
#Data Manipulation: Using the data access API to generate and retrieve data
###################################################################################################
#Creating a 1D dataset from an array
path="group/data1"
data1d = [1.0, 2.0, 3.0, 4.0, 5.0]
save_dataset(path, data1d)
#Reading ii back
read =load_data(path)
print (list(read))
assert data1d==list(read)
plot(read)
#Creating a 2D dataset from an array with some attributes
data2d = [ [1.0, 2.0, 3.0, 4.0, 5.0], [2.0, 3.0, 4.0, 5.0, 6.0, ], [3.0, 4.0, 5.0, 6.0, 7.0]]
path="group/data2"
save_dataset(path, data2d)
set_attribute(path, "AttrString", "Value")
set_attribute(path, "AttrInteger", 1)
set_attribute(path, "AttrDouble", 2.0)
set_attribute(path, "AttrBoolean", True)
#Reading it back
read =load_data(path)
print (list(read))
plot(read)
#Creating a 3D dataset from an array
data3d = [ [ [1,2,3,4,5], [2,3,4,5,6], [3,4,5,6,7]], [ [3,2,3,4,5], [4,3,4,5,6], [5,4,5,6,7]]]
path="group/data3"
save_dataset(path, data3d)
#Reading it back
read =load_data(path,0)
print (list(read))
read =load_data(path,1)
print (list(read))
#Creating a INT dataset adding elements one by one
path = "group/data4"
create_dataset(path, 'i')
for i in range(10):
append_dataset(path,i)
#Creating a 2D data FLOAT dataset adding lines one by one
path = "group/data5"
create_dataset(path, 'd', False, (0,0))
for row in data2d:
append_dataset(path, row)
#Creating a Table (compund type)
path = "group/data6"
names = ["a", "b", "c", "d"]
types = ["d", "d", "d", "[d"]
lenghts = [0,0,0,5]
table = [ [1,2,3,[0,1,2,3,4]],
[2,3,4,[3,4,5,6,7]],
[3,4,5,[6,7,8,9,4]] ]
create_table(path, names, types, lenghts)
for row in table:
append_table(path, row)
flush_data()
#Read it back
read =load_data(path)
print (read)
#Writing scalars (datasets with rank 0)
save_dataset("group/val1", 1)
save_dataset("group/val2", 3.14)
save_dataset("group/val3", "test")
print (load_data("group/val1"))
print (load_data("group/val2"))
print (load_data("group/val3"))
time.sleep(1.0)
code="""def is_java_instance(obj, cls):
print(1)
###################################################################################################
#Access to context singleton
###################################################################################################
def get_context():
return core.Context.getInstance()
"""
comp=compile(code, '<string>', 'exec')
set_return(2)

178
script/cpy/bluesky.py Normal file
View File

@@ -0,0 +1,178 @@
import signal
signal.signal = lambda *args: None
###################################################################################################
#import matplotlib
#matplotlib.use('Qt5Agg')
import traceback
from bluesky import RunEngine
from bluesky.callbacks.best_effort import BestEffortCallback
from bluesky.utils import install_kicker
from bluesky.utils import ProgressBarManager
from ophyd.sim import det1, det2, det3, det4, det, motor, motor1, motor2, motor3,img, sig, direct_img, pseudo1x3
from ophyd import Signal
from ophyd.signal import EpicsSignal
from bluesky.plans import count, scan, rel_scan, list_scan, grid_scan, list_grid_scan
from bluesky.simulators import summarize_plan
import bluesky.plan_stubs as bps
from bluesky.plan_stubs import mv
import bluesky.preprocessors as bpp
from bluesky.preprocessors import SupplementalData
import databroker
#import suitcase
#import suitcase.csv
#from databroker import Broker
RE = RunEngine({})
bec = BestEffortCallback()
bec.disable_plots()
RE.subscribe(bec)
#db = Broker.named('temp')
#RE.subscribe(db.insert)
#RE.waiting_hook = ProgressBarManager()
dets = [det1, det2]
RE(count(dets, num=5))
RE(scan(dets, motor, -1, 1, 10))
dir (motor)
vel=motor.velocity.get()
motor.velocity.set(vel+1)
RE(scan(dets, motor, -1, 1, 10))
det.read()
det.get()
dets=[det]
RE(rel_scan(dets, motor, -1, 1, 10))
points = [1, 1, 2, 3, 5, 8, 13]
RE(list_scan(dets, motor, points))
dets=[det4]
RE(scan(dets,motor1, -1.5, 1.5, motor2, -0.1, 0.1, 11))
RE(list_scan(dets, motor1, [1, 1, 3, 5, 8], motor2, [25, 16, 9, 4, 1]))
RE(grid_scan(dets, motor1, -1.5, 1.5, 3, motor2, -0.1, 0.1, 5, motor3, 10, -10, 5))
RE(grid_scan(dets, motor1, -1.5, 1.5, 3, motor2, -0.1, 0.1, 5))
RE(grid_scan(dets, motor1, -1.5, 1.5, 3, motor2, -0.1, 0.1, 5, motor3, 10, -10, 5))
RE(list_grid_scan(dets, motor1, [1, 1, 2, 3, 5], motor2, [25, 16, 9]))
db[-1].table()
def coarse_and_fine(detectors, motor, start, stop):
yield from scan(detectors, motor, start, stop, 10)
yield from scan(detectors, motor, start, stop, 100)
RE(coarse_and_fine(dets, motor, -1, 1))
# Move motor1 to 1 and motor2 to 10, simultaneously. Wait for both to arrive.
RE(mv(motor1, 1, motor2, 10))
print (motor1.get().readback, motor2.get().readback)
# Move motor1 to 1 and motor2 to 10, simultaneously. Wait for both to arrive.
print (motor1.get(), motor2.get())
def move_then_count():
yield from mv(motor1, 1, motor2, 10)
yield from count(dets)
RE(move_then_count())
sd = SupplementalData()
RE.preprocessors.append(sd)
sd.baseline = [det1, det2, det3, motor1, motor2]
RE(scan([det], motor, -1, 1, 5))
print(db[-1].table("baseline"))
print(db[-1].table("primary"))
"""
docs = db[-1].documents(fill=True)
try:
suitcase.csv.export(docs, "~/data/bluesky")
except:
print (sys.exc_info()[1])
"""
motor.delay = 1.1 # simulate slow motor movement
sd.monitors=[motor]
RE(scan(dets, motor, -1, 1, 10))
print(db[-1].table("baseline"))
print(db[-1].table("monitor"))
#RE.resume()
#RE.abort()
#RE.stop()
RE(scan([det], motor, 1, 10, 10), user="alex")
for x in db(user="alex"):
print (x.table())
summarize_plan(count([det], 3))
summarize_plan(scan(dets, motor, -1, 1, 10))
summarize_plan(grid_scan(dets, motor1, -1.5, 1.5, 3, motor2, -0.1, 0.1, 5))
def one_run_one_event(detectors):
md = {
# Human-friendly names of detector Devices (useful for searching)
'detectors': [det.name for det in detectors],
# The Python 'repr's each argument to the plan
'plan_args': {'detectors': list(map(repr, detectors))},
# The name of this plan
'plan_name': 'one_run_one_event',
}
@bpp.stage_decorator(detectors)
@bpp.run_decorator(md=md)
def inner():
yield from bps.trigger_and_read(detectors)
return (yield from inner())
dets = [det1,det2]
RE(one_run_one_event(dets))
def conditional_break(threshold):
"""Set, trigger, read until the detector reads intensity < threshold"""
@bpp.stage_decorator([det, motor])
@bpp.run_decorator()
def inner():
i = 0
while True:
yield from bps.mv(motor, i)
readings = yield from bps.trigger_and_read([det])
if readings['det']['value'] < threshold:
break
i += 1
return (yield from inner())
RE(conditional_break(0.2))
#catalog = databroker.catalog()
dets=[pseudo1x3]
RE(scan(dets, motor, -1, 1, 10))
es = EpicsSignal("TESTIOC:TESTSINUS:SinCalc")
print (es.read())
try:
plot(direct_img.read()['img']['value'].data)
except:
traceback.print_exc()

30
script/cpy/bluesky2.py Normal file
View File

@@ -0,0 +1,30 @@
"""
RE = RunEngine({}, during_task=EventProcessingTask())
bec = BestEffortCallback()
bec.disable_plots()
RE.subscribe(bec)
RE.subscribe(handler)
motor.delay = 1.1 # simulate slow motor movement
ch1 = EpicsSignal("TESTIOC:TESTSINUS:SinCalc")
#TODO: DEmonstrate use of waveform and areadetector (Manual scan setup with the indexes in name)
#ch2 = EpicsSignal("TESTIOC:TESTWF2:MyWF", name="arr[10]")
#ch3 = EpicsSignal("TESTIOC:TESTWF2:MyWF", name="img[3][2]")det3=ReaderWrapper(sin)
"""
dets = [det1, det2]
RE(count(dets, num=5, delay=0.5))
RE(scan(dets, motor, 0, 1, 5))
RE(rel_scan(dets, motor, -1, 1, 10))
RE(list_scan(dets, motor, [1, 1, 2, 3, 5, 8, 13]))
RE(grid_scan(dets, motor1, -1.5, 1.5, 3, motor2, -0.1, 0.1, 5))
RE(list_grid_scan(dets, motor1, [1, 1, 2, 3, 5], motor2, [25, 16, 9]))
det4=ReaderWrapper(arr)
det5=ReaderWrapper(get_device("det").getDataMatrix() )
m1=MoverWrapper(get_device("motor"))
dets = [det1, det2, ch1, det3, det4, det5]
RE(scan(dets, m1, 0, 1, 5))

487
script/cpy/local.py Normal file
View File

@@ -0,0 +1,487 @@
###################################################################################################
# Deployment specific global definitions - executed after startup.py
###################################################################################################
###################################################################################################
#Devices for PShell standard scans
###################################################################################################
import random
####################################################################################################
# Simulated devices
####################################################################################################
add_device(DummyMotor("m1"), True)
add_device(DummyMotor("m2"), True)
add_device(DummyRegister("reg1",3), True)
add_device(DummyPositioner("p1"),True)
add_device(MotorGroupBase("mg1", m1, m2), True)
add_device(MotorGroupDiscretePositioner("dp1", mg1), True)
#Initial Configuration
if p1.getConfig().unit is None:
p1.getConfig().minValue = 0.0 #Not persisted
p1.getConfig().maxValue = 1000.0
p1.getConfig().unit = "mm"
p1.getConfig().save()
p1.initialize()
if dp1.getConfig().positions is None:
dp1.getConfig().positions = ["Park","Ready","Out","Clear"]
dp1.getConfig().motor1 = ["0.0","4.0","8.0" ,"0.0"]
dp1.getConfig().motor2 = ["0.0","5.0","3.0" ,"NaN"]
dp1.getConfig().save()
dp1.initialize()
#Update
m1.setMonitored(True)
m2.setMonitored(True)
####################################################################################################
# Readable / Writable objects can be created and used in scans
####################################################################################################
class MyWritable(Writable):
def write(self, value):
#print ("Write: ",value)
pass
class MyReadable(Readable):
def read(self):
return random.random()
class MyReadableArray(ReadableArray):
def read(self):
ret = []
for i in range (self.getSize()):
ret.append(random.random())
return to_array(ret,'d')
def getSize(self):
return 20
class MyReadableArrayNumpy(ReadableArray):
def read(self):
ret = numpy.ones(self.getSize(),'d')
return ret
def getSize(self):
return 20
class MyReadableMatrix(ReadableMatrix):
def read(self):
ret = []
for i in range (self.getHeight()):
ret.append([random.random()] * self.getWidth())
return to_array(ret, 'd')
def getWidth(self):
return 80
def getHeight(self):
return 40
class MyReadableMatrixNumpy(ReadableMatrix):
def read(self):
ret = numpy.ones((self.getHeight(), self.getWidth()),'d')
for i in range(self.getHeight()):
ret[i]=i
return to_array(ret, 'd')
def getWidth(self):
return 80
def getHeight(self):
return 40
ao1 = MyWritable("ao1")
ao2 = MyWritable("ao2")
ai1 = MyReadable("ai1")
ai2 = MyReadable("ai2")
wf1 = MyReadableArray("wf1")
wf2 = MyReadableArrayNumpy("wf2")
im1 = MyReadableMatrix("im1")
im2 = MyReadableMatrixNumpy("im2")
####################################################################################################
# Imaging
####################################################################################################
configured = os.path.exists(GenericDevice.getConfigFileName("src1"))
add_device(RegisterMatrixSource("src1", im1.proxy), True)
add_device(RegisterMatrixSource("src2", im2.proxy), True)
#src1.setPolling(100)
#src2.setPolling(100)
#Some configuration for so the imaging will work out of the box
if not configured:
src1.getConfig().colormapAutomatic = True
src1.getConfig().colormap = Colormap.Temperature
src1.getConfig().save()
src2.getConfig().colormapAutomatic = True
src2.getConfig().save()
###################################################################################################
#Embedding Bluesky
###################################################################################################
import signal
signal.signal = lambda *args: None
from bluesky import RunEngine
from bluesky.callbacks import CallbackBase
from bluesky.callbacks.best_effort import BestEffortCallback
from bluesky.utils import install_kicker, DuringTask
#from bluesky.utils import ProgressBarManager
from ophyd.sim import det1, det2, det3, det4, det, motor, motor1, motor2, motor3,img, sig, direct_img, pseudo1x3
from ophyd import Signal
from ophyd.signal import EpicsSignal
from bluesky.plans import count, scan, rel_scan, list_scan, grid_scan, list_grid_scan
from bluesky.simulators import summarize_plan
import bluesky.plan_stubs as bps
from bluesky.plan_stubs import mv
import bluesky.preprocessors as bpp
from bluesky.preprocessors import SupplementalData
#import databroker
from databroker import Broker
#import suitcase
#import suitcase.csv
CAN_PAUSE=True
#def on_ctrl_cmd(cmd):
def on_abort(parent_thread):
global RE
# print ("Control command: ", cmd)
# if cmd=="abort":
if "RE" in globals():
if RE.state not in ['idle','paused', 'pausing']:
if CAN_PAUSE:
print ("Abort command: Run Engine aborted")
sys.stderr=None
RE.abort("User abort")
return
else:
print ("Abort command: Run Engine pause request")
RE.request_pause()
return
tid=parent_thread.ident
exception = KeyboardInterrupt
ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), ctypes.py_object(exception))
def on_close(parent_thread):
on_abort(parent_thread)
from collections import deque
is_scan_paused = False
class MyHandler(CallbackBase):
def __init__(self):
self.queue= deque(maxlen=1000)
def clear(self):
self.queue.append(("clear",None))
def start(self, doc):
self.queue.append(("start",doc))
def stop(self, doc):
self.queue.append(("stop",doc))
def descriptor(self, doc):
self.queue.append(("descriptor",doc))
def resource(self, doc):
self.queue.append(("resource",doc))
def event(self, doc):
self.queue.append(("event",doc))
while is_scan_paused:
time.sleep(0.1)
def datum(self, doc):
self.queue.append(("datum",doc))
def event_page(self, doc):
self.queue.append(("event_page",doc))
def datum_page(self, doc):
self.queue.append(("datum_page",doc))
handler= MyHandler()
re_scan=re_res=None
class EventProcessingTask(DuringTask):
def __init__(self):
pass
def block(self, blocking_event):
global start_doc,descriptor_coc, stop_doc, event_doc, re_scan, re_res, __return__,__exception__
re_scan=None
while True:
done = blocking_event.wait(.1)
if done:
return
try:
check_pause()
while len(handler.queue):
(msg, doc) = handler.queue.popleft()
#print("-> " ,msg)
if msg=="start":
global start_doc
start_doc=doc
writables=doc.get('motors',[])
readables=doc.get('detectors',[])
start,stop, steps=-1,-1,doc.get('num_intervals',-1)
try:
if doc.get("plan_name","")=="grid_scan":
steps=[x-1 for x in doc['shape']]
start=[x[0] for x in doc['extents']]
stop=[x[1] for x in doc['extents']]
elif doc.get("plan_name","")=="list_grid_scan":
steps=[-1 for x in doc['shape']]
start=[x[0] for x in doc['extents']]
stop=[x[1] for x in doc['extents']]
elif doc.get("plan_name","")=="scan":
_,start,stop = doc['plan_args']['args']
elif doc.get("plan_name","")=="list_scan":
_,positions=doc['plan_args']['args']
start = min(positions)
stop = max(positions)
except:
pass
diags=None
monitors=None
meta={}
for k in start_doc.keys():
o=start_doc[k]
if o is not None:
if k=="extents":
o = str(o)
elif type(o) in (list, tuple):
o=to_array(o,'s')
elif type(o) == dict:
o=str(o)
meta[k]=o
re_res = None
re_scan = ManualScan(writables, readables ,start, stop, steps, diags=diags, monitors=monitors, meta=meta)
re_scan.scan.setCanPause(CAN_PAUSE)
re_scan.start()
elif msg=="stop":
global stop_doc
stop_doc=doc
if re_scan is not None:
if not re_scan.scan.isCompleted():
re_scan.end()
re_res = re_scan.scan.getResult()
sys.stderr=jep_stderr
elif msg=="descriptor":
global descriptor_doc
descriptor_doc=doc
elif msg=="event":
global event_doc
event_doc=doc
if (re_scan is not None) and not (re_scan.scan.isCompleted()):
setpoints=[]
readbacks=[]
detectors=[]
data=doc['data']
for dev in start_doc.get("motors",[]):
readbacks.append(data[dev])
try:
setpoints.append(data[dev+"_setpoint"])
except:
setpoints.append(data[dev])
for dev in start_doc.get("detectors",[]):
v=data[dev]
if str(type(v))=="<class 'jep.PyJArray'>":
v=numpy.array(v)
detectors.append(v)
re_scan.append (setpoints, readbacks, detectors)
elif msg=="resource":
pass
elif msg=="datum":
pass
elif msg=="event_page":
pass
elif msg=="datum_page":
pass
elif msg=="clear":
pass
elif msg=="check_pause":
pass
elif msg=="read":
try:
(dev)=doc
__return__ = dev.read()
except Exception as e:
__exception__ = e
elif msg=="write":
try:
(dev, value)=doc
dev.write(value)
__return__ = True
except Exception as e:
__exception__ = e
except Exception as e:
#print (e)
pass
def check_pause():
try:
global RE, re_scan, is_scan_paused
if CAN_PAUSE:
if ("RE" in globals()) and (re_scan is not None) and not (re_scan.scan.isCompleted()):
is_scan_paused =re_scan.scan.isPaused() and not re_scan.scan.isAborted()
else:
is_scan_paused = False
#if re_scan.scan.isAborted():
# if RE.state not in ['idle','paused', 'pausing']:
# print ("Scan abort")
# RE.abort("Scan abort")
"""
if re_scan.scan.isPaused():
if RE.state not in ['idle','paused', 'pausing']:
print ("Scan paused: Run Engine pause request")
RE.request_pause()
is_scan_paused = True
else:
if RE.state in ['paused', 'pausing']:
print ("Scan resumed: Run Engine resuming")
#RE.resume()
"""
except:
pass
class ReaderWrapper():
def __init__(self, dev):
self.dev=dev
self.name=dev.getName()
self.parent = None
try:
self.source = self.dev.getChannelName()
except:
self.source = "Unknown"
try:
try:
self.shape = [self.dev.getHeight(), self.dev.getWidth()]
self.shape_str = "["+str(self.shape[0])+"]"+"["+str(self.shape[1])+"]"
except:
self.shape = [self.dev.getSize()]
self.shape_str = "["+str(self.shape[0])+"]"
except:
self.shape = []
self.shape_str=""
try:
self.precision = self.dev.getPrecision()
except:
self.precision = None
self.description = {self.name: { \
'dtype':'number', \
'shape': self.shape, \
'source': self.source, \
'precision': self.precision \
}}
self.cfg_description = {"shape_str":{"dtype":"string", 'shape':(len(self.shape_str),), "source":""}, }
self.configuration = {"shape_str":{"value":self.shape_str, "timestamp":time.time()}}
self.name = self.name+self.shape_str
def read(self):
if is_main_thread():
return {self.name:{"value":self.dev.read(), "timestamp":time.time()}}
global __return__,__exception__
__return__ = __exception__ = None
handler.queue.append(("read", (self.dev)))
while (__return__ is None) and (__exception__ is None):
time.sleep(0.01)
if __exception__ is not None:
raise __exception__
return {self.name:{"value":__return__, "timestamp":time.time()}}
def describe(self):
return self.description
def describe_configuration(self):
return self.cfg_description
def read_configuration(self):
return self.configuration
class NullStatus:
"a simple Status object that is always immediately done"
def __init__(self):
self._cb = None
self.done = True
self.success = True
@property
def finished_cb(self):
return self._cb
@finished_cb.setter
def finished_cb(self, cb):
cb()
self._cb = cb
class MoverWrapper(ReaderWrapper):
def set(self, value):
if is_main_thread():
self.dev.write(value)
else:
global __return__,__exception__
__return__ = __exception__ = None
handler.queue.append(("write", (self.dev, value)))
while (__return__ is None) and (__exception__ is None):
time.sleep(0.01)
if __exception__ is not None:
raise __exception__
self.dev.waitReady(-1)
return NullStatus()
@property
def position(self):
return self.dev.getPosition()
def stop(self, *, success=False):
self.dev.stop()
RE = RunEngine({}, during_task=EventProcessingTask())
if CAN_PAUSE:
RE.pause_msg="User abort"
bec = BestEffortCallback()
bec.disable_plots()
RE.subscribe(bec)
RE.subscribe(handler)
motor.delay = 1.1 # simulate slow motor movement
ch1 = EpicsSignal("TESTIOC:TESTSINUS:SinCalc")
#TODO: DEmonstrate use of waveform and areadetector (Manual scan setup with the indexes in name)
#ch2 = EpicsSignal("TESTIOC:TESTWF2:MyWF", name="arr[10]")
#ch3 = EpicsSignal("TESTIOC:TESTWF2:MyWF", name="img[3][2]")det3=ReaderWrapper(sin)
dets = [det1, det2]

2796
script/cpy/startup_jep.py Normal file

File diff suppressed because it is too large Load Diff

30
script/cpy/testJepScan.py Normal file
View File

@@ -0,0 +1,30 @@
#r = tscan((sin,out), 100, 0.01)
#vector = [ 1, 3, 5, 10, 25, 40, 45, 47, 49]
#r = vscan(pv,(sin,out),vector,False, 0.5, title = "1D Vector")
#r = mscan(sin,(sin,out),-1, 3,0)
#r = rscan(pv,(sin,out) , [(0.0,5.0,1.0), (10.0,15.0,0.1), (20.0,25.0,1.0)] , 0.01)
#r = cscan(motor, (sin,out), 0.0, 2.0 , steps=10.0, time=4.)
print (get_exec_pars().getPath())
def before_pass(pass_num):
print ("Starting pass: " , pass_num)
def after_pass(pass_num):
print ("Finished pass: " , pass_num)
#set_exec_pars(layout="sf")
ret= lscan(inp, (sin,out), 0, 40, 50, 0.2, passes = 1, before_pass = before_pass, after_pass=after_pass,title = "Test")
#ret= lscan(inp, (sin,out), 0, 40, 50, 0.2)
#set_exec_pars(then="run('test/test3.py)")
#set_return([1.0, 3, [1,2,3,4]])
#1/0
#set_return("T\"es\"t")
#set_return([3.0,2])
set_return(ret)

115
script/cpy/xxx.py Normal file
View File

@@ -0,0 +1,115 @@
###################################################################################################
# This moddule is called by demo scripts to execute and embed CPython.
# Must be put in the scripts folder, or else in the python path.
###################################################################################################
import matplotlib
"""
['GTK3Agg', 'GTK3Cairo', 'MacOSX', 'nbAgg', 'Qt4Agg', 'Qt4Cairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo',
'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']
"""
matplotlib.use('Qt5Agg')
import sys
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
try:
import tkinter as tk
except:
import Tkinter as tk
def calc(array):
return np.transpose(array + array)
def test_pandas():
s = pd.Series([1,3,5,np.nan,6,8])
print (s)
dates = pd.date_range('20130101', periods=6)
print (dates)
df = pd.DataFrame(np.random.randn(6,4), index=dates, columns=list('ABCD'))
print (df)
df2 = pd.DataFrame({ 'A' : 1.,
'B' : pd.Timestamp('20130102'),
'C' : pd.Series(1,index=list(range(4)),dtype='float32'),
'D' : np.array([3] * 4,dtype='int32'),
'E' : pd.Categorical(["test","train","test","train"]),
'F' : 'foo' })
print (df2)
print (df2.dtypes)
print (df.head())
print (df.tail(3))
print (df.values)
print (df.describe())
print (df.T)
print (df.sort_index(axis=1, ascending=False))
#print (df.sort_values(by='B'))
print (df['A'])
print (df[0:3])
print (df.mean())
return str(df.mean())
def test_tkinter():
root = tk.Tk()
listb = tk.Listbox(root)
for item in ["Hello", "World"]:
listb.insert(0,item)
listb.pack()
root.mainloop()
print ("OK")
def test_matplotlib(start,stop,step):
import threading
x = np.arange(start,stop,step)
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()
return [start,stop,step]
test_pandas()
test_matplotlib(0,100,100)

30
script/cpython/gfitoff.py Normal file
View File

@@ -0,0 +1,30 @@
import numpy as np
import scipy.optimize
def gfitoff(x, y, off=None, amp=None, com=None, sigma=None):
if off is None:
off = y.min() # good enough starting point for offset
if com is None:
com = x[y.argmax()]
if amp is None:
amp = y.max() - off
# For normalised gauss curve sigma=1/(amp*sqrt(2*pi))
if sigma is None:
surface = np.trapz((y-off), x=x)
sigma = surface / (amp * np.sqrt(2 * np.pi))
try:
popt, pcov = scipy.optimize.curve_fit(gauss_fn, x, y, p0=[off, amp, com, sigma], method='lm')
popt[3] = abs(popt[3]) # sigma should be returned as positive
except Exception as e:
print("Gauss fitting not successful.\n" + str(e))
popt = [off, amp, com, abs(sigma)]
return popt
def gauss_fn(x, a, b, c, d):
return a + b * np.exp(-(np.power((x - c), 2) / (2 * np.power(d, 2))))

32
script/cpython/linfit.py Normal file
View File

@@ -0,0 +1,32 @@
import numpy as np
def linfit(x, y):
"""
Return linear fit
"""
p = np.polyfit(x, y, 1)
f = np.poly1d(p)
x_fit = np.linspace(min(x), max(x), 100)
y_fit = f(x_fit)
yhat = f(x)
ybar = np.sum(y)/len(y)
ssreg = np.sum((yhat - ybar)**2)
sstot = np.sum((y - ybar)**2)
R2 = ssreg / sstot
return (p, x_fit, y_fit, R2)
def test():
return np.ones(5)
def test2(name, x=None, y=None):
print (name,x,y)
ret = y*x
print (ret)
return ret
def add(x,y,z):
return x+y+z
def read_dev(dev):
return dev.read()

34
script/cpython/test.py Normal file
View File

@@ -0,0 +1,34 @@
from jeputils import import_py
import_py("cpython/linfit", "linfit")
import_py("cpython/gfitoff", "gfitoff")
import_py("CPython/linfit", "add")
import_py("CPython/linfit", "test")
import_py("CPython/linfit", "test2")
import_py("CPython/linfit", "read_dev")
print read_dev(sin)
a,b,c =to_array([0,1,2,3,4],'d'), to_array([5,6,7,8,9],'d'), to_array([10, 11, 12, 13, 14],'d')
print test()
print test2("x", x=a,y=b)
print add(a,b,c)
x=[0,1,2,3,4,5,6,7,8,9]
y=[1,2,3,6,9,6,3,2,1,0]
(p, x_fit, y_fit, R2) = linfit(x,y)
#print "Fit: ", (p, x_fit, y_fit, R2)
plot((y,y_fit), name=("data", "fit"),xdata=(x,x_fit))
time.sleep(2.0)
from mathutils import Gaussian
x=to_array([-200.30429237268825, -200.2650700434188, -200.22115208318002, -199.9457671375377, -199.86345548879072, -199.85213073174933, -199.35687977133284, -199.13811861090275, -197.97304970346386, -197.2952215624348, -195.09076092936948, -192.92276048970703, -191.96871876227698, -189.49577852322938, -187.9652790409825, -183.63756456925222, -180.04899765472996, -178.43839623242422, -174.07311671294445, -172.0410133577918, -165.90824309893102, -160.99771795989466, -159.30176653939253, -154.27688897558514, -152.0854103810786, -145.75652847587313, -140.80843828908465, -139.23982133191495, -134.27073891256106, -132.12649284133064, -125.95947209775511, -121.00309550337462, -119.26736932643232, -114.2706655484383, -112.07393889578914, -105.72295990367157, -100.8088439880125, -99.2034906238494, -94.30042325164636, -92.15010048151461, -85.92203653534293, -81.03913275494665, -79.27412793784428, -74.33487658582118, -72.06274362408762, -65.76562628131825, -60.91255356825276, -59.20334389560392, -54.33286972659312, -52.19387171350535, -45.94978737932291, -41.03014719193582, -39.301602568238906, -34.35572209014114, -32.04464301272608, -25.8221033382824, -20.922074315528747, -19.21590299233186, -14.31090212502093, -12.217203140101386, -5.9283722049240435, -0.9863587170369246, 0.7408048387279834, 5.71126832601389, 7.972628957879352, 14.204559894256546, 19.11839959633025, 20.8218087836657, 25.678748486941828, 27.822718344586864, 34.062659474970715, 38.9745656819391, 40.77409719734158, 45.72080631619803, 47.974156754056835, 54.23453768983539, 59.12020360609568, 60.77306570712026, 65.70734521458867, 67.8344660434617, 74.03187028154134, 78.96532114824849, 80.76070945985495, 85.74802197591286, 87.9140889204674, 94.18082276873524, 99.25790470037091, 100.68454787413205, 105.7213026221542, 107.79483801526698, 113.99555681638138, 119.0707052529143, 120.72715813056156, 125.77551384921307, 127.91257836719551, 134.2011330887875, 139.23043006997628, 140.71673537840158, 145.76288138835983, 147.80216629676042, 154.06420451405637, 159.0846626604798, 160.76183155710717, 165.73699067536242, 167.9265357747636, 173.96705069576544, 178.2522282751915, 179.9042617354548, 183.54586165856657, 185.23269803071796, 189.41678143751972, 191.87149157986588, 192.8741468985015, 195.0241934550453, 195.966634211846, 197.9821647518146, 198.99006812859284, 199.33202054855676, 199.91897441965887, 200.11536227958896, 200.22280936469997, 200.25181179127208],'d')
y=to_array([11.0, 6.0, 8.0, 5.0, 11.0, 7.0, 18.0, 11.0, 12.0, 10.0, 8.0, 6.0, 16.0, 4.0, 12.0, 9.0, 15.0, 14.0, 8.0, 20.0, 15.0, 8.0, 9.0, 11.0, 13.0, 12.0, 13.0, 15.0, 13.0, 20.0, 10.0, 7.0, 17.0, 11.0, 20.0, 13.0, 13.0, 23.0, 14.0, 10.0, 17.0, 15.0, 20.0, 16.0, 14.0, 13.0, 18.0, 22.0, 9.0, 20.0, 12.0, 14.0, 17.0, 19.0, 14.0, 14.0, 23.0, 19.0, 15.0, 20.0, 20.0, 21.0, 20.0, 23.0, 22.0, 15.0, 10.0, 17.0, 21.0, 15.0, 23.0, 23.0, 25.0, 18.0, 16.0, 21.0, 22.0, 16.0, 16.0, 14.0, 19.0, 20.0, 18.0, 20.0, 23.0, 13.0, 16.0, 20.0, 25.0, 15.0, 15.0, 17.0, 22.0, 26.0, 19.0, 30.0, 25.0, 17.0, 17.0, 23.0, 16.0, 27.0, 21.0, 21.0, 26.0, 27.0, 21.0, 17.0, 20.0, 20.0, 21.0, 19.0, 25.0, 19.0, 13.0, 23.0, 20.0, 20.0, 18.0, 20.0, 19.0, 25.0],'d')
[off, amp, com, sigma] = gfitoff(x, y, off=None, amp=None, com=None, sigma=None)
#print "Fit: ", [off, amp, com, sigma]
g = Gaussian(amp, com, sigma)
plot([y, [g.value(i)+off for i in x]], ["data", "fit"], xdata = x)

14
script/cpython/test2.py Normal file
View File

@@ -0,0 +1,14 @@
from jeputils import import_py
import_py("cpython/gfitoff", "gfitoff")
from mathutils import Gaussian
x=to_array([-200.30429237268825, -200.2650700434188, -200.22115208318002, -199.9457671375377, -199.86345548879072, -199.85213073174933, -199.35687977133284, -199.13811861090275, -197.97304970346386, -197.2952215624348, -195.09076092936948, -192.92276048970703, -191.96871876227698, -189.49577852322938, -187.9652790409825, -183.63756456925222, -180.04899765472996, -178.43839623242422, -174.07311671294445, -172.0410133577918, -165.90824309893102, -160.99771795989466, -159.30176653939253, -154.27688897558514, -152.0854103810786, -145.75652847587313, -140.80843828908465, -139.23982133191495, -134.27073891256106, -132.12649284133064, -125.95947209775511, -121.00309550337462, -119.26736932643232, -114.2706655484383, -112.07393889578914, -105.72295990367157, -100.8088439880125, -99.2034906238494, -94.30042325164636, -92.15010048151461, -85.92203653534293, -81.03913275494665, -79.27412793784428, -74.33487658582118, -72.06274362408762, -65.76562628131825, -60.91255356825276, -59.20334389560392, -54.33286972659312, -52.19387171350535, -45.94978737932291, -41.03014719193582, -39.301602568238906, -34.35572209014114, -32.04464301272608, -25.8221033382824, -20.922074315528747, -19.21590299233186, -14.31090212502093, -12.217203140101386, -5.9283722049240435, -0.9863587170369246, 0.7408048387279834, 5.71126832601389, 7.972628957879352, 14.204559894256546, 19.11839959633025, 20.8218087836657, 25.678748486941828, 27.822718344586864, 34.062659474970715, 38.9745656819391, 40.77409719734158, 45.72080631619803, 47.974156754056835, 54.23453768983539, 59.12020360609568, 60.77306570712026, 65.70734521458867, 67.8344660434617, 74.03187028154134, 78.96532114824849, 80.76070945985495, 85.74802197591286, 87.9140889204674, 94.18082276873524, 99.25790470037091, 100.68454787413205, 105.7213026221542, 107.79483801526698, 113.99555681638138, 119.0707052529143, 120.72715813056156, 125.77551384921307, 127.91257836719551, 134.2011330887875, 139.23043006997628, 140.71673537840158, 145.76288138835983, 147.80216629676042, 154.06420451405637, 159.0846626604798, 160.76183155710717, 165.73699067536242, 167.9265357747636, 173.96705069576544, 178.2522282751915, 179.9042617354548, 183.54586165856657, 185.23269803071796, 189.41678143751972, 191.87149157986588, 192.8741468985015, 195.0241934550453, 195.966634211846, 197.9821647518146, 198.99006812859284, 199.33202054855676, 199.91897441965887, 200.11536227958896, 200.22280936469997, 200.25181179127208],'d')
y=to_array([11.0, 6.0, 8.0, 5.0, 11.0, 7.0, 18.0, 11.0, 12.0, 10.0, 8.0, 6.0, 16.0, 4.0, 12.0, 9.0, 15.0, 14.0, 8.0, 20.0, 15.0, 8.0, 9.0, 11.0, 13.0, 12.0, 13.0, 15.0, 13.0, 20.0, 10.0, 7.0, 17.0, 11.0, 20.0, 13.0, 13.0, 23.0, 14.0, 10.0, 17.0, 15.0, 20.0, 16.0, 14.0, 13.0, 18.0, 22.0, 9.0, 20.0, 12.0, 14.0, 17.0, 19.0, 14.0, 14.0, 23.0, 19.0, 15.0, 20.0, 20.0, 21.0, 20.0, 23.0, 22.0, 15.0, 10.0, 17.0, 21.0, 15.0, 23.0, 23.0, 25.0, 18.0, 16.0, 21.0, 22.0, 16.0, 16.0, 14.0, 19.0, 20.0, 18.0, 20.0, 23.0, 13.0, 16.0, 20.0, 25.0, 15.0, 15.0, 17.0, 22.0, 26.0, 19.0, 30.0, 25.0, 17.0, 17.0, 23.0, 16.0, 27.0, 21.0, 21.0, 26.0, 27.0, 21.0, 17.0, 20.0, 20.0, 21.0, 19.0, 25.0, 19.0, 13.0, 23.0, 20.0, 20.0, 18.0, 20.0, 19.0, 25.0],'d')
[off, amp, com, sigma] = gfitoff(x, y, off=None, amp=None, com=None, sigma=None)
print "Fit: ", [off, amp, com, sigma]
g = Gaussian(amp, com, sigma)
plot([y, [g.value(i)+off for i in x]], ["data", "fit"], xdata = x)

BIN
script/diffcalc_test/.DS_Store vendored Normal file

Binary file not shown.

323
script/eiger.py Normal file
View File

@@ -0,0 +1,323 @@
from ijutils import *
from ch.psi.pshell.imaging.Overlays import *
from ch.psi.pshell.imaging.Utils import *
import ch.psi.pshell.imaging.Pen as Pen
import java.awt.Rectangle as Rectangle
import ch.psi.pshell.imaging.Data as Data
import ch.psi.pshell.device.Camera.DataType as DataType
import ch.psi.utils.Chrono as Chrono
import subprocess
import java.util.Arrays as Arrays
#GRAB_MIN_TIME = 1000
CONTINOUS_MODE_MIN_TIME = 4000
###############################################################################
# ROI Integration
###############################################################################
def start_eiger_ioc():
print "IOC started"
def stop_eiger_ioc():
print "IOC stopped"
def integrate_roi(source, x,y, w, h):
if source.data is None:
source.update()
rect = Rectangle(x,y, w, h)
roi = source.data.getRoi(rect)
outliers_mask = get_outliers_mask()
if outliers_mask is not None:
mask = outliers_mask.getRoi(rect)
roi.mult(mask)
outliers_threshold = get_outliers_threshold()
if outliers_threshold>0:
roi.threshold(outliers_threshold, False, 0.0)
return roi.integrate(False)
class RoiIntensitySourceListener (ImageListener):
def __init__(self, parent):
self.parent = parent
def onImage(self, origin, image, data):
self.parent.update()
def onError(self, origin, ex):
pass
class RoiIntensity(ReadonlyRegisterBase):
def __init__(self, name, source, x,y, w, h):
ReadonlyRegisterBase.__init__(self, name)
self.source=source
self.roi = x,y, w, h
self.source_listener = RoiIntensitySourceListener(self)
def doRead(self):
x,y, w, h = self.roi
ret= integrate_roi(self.source, x,y, w, h)
print "Read " + self.name + " -> " + str(ret)
return ret
def doSetMonitored(self, value):
if value:
self.source.addListener(self.source_listener)
else:
self.source.removeListener(self.source_listener)
def doClose(self):
self.source.removeListener(self.source_listener)
def create_roi_devices(roi_list, add = True):
rois = []
for r in roi_list:
roi = RoiIntensity(r, image, roi_list[r][0], roi_list[r][1], roi_list[r][2], roi_list[r][3])
if add:
add_device(roi, True)
rois.append(roi)
return rois
###############################################################################
# Frame integration
###############################################################################
#chrono_grab= Chrono()
def grab_frame(source, roi=None, wait_next=False, outliers_threshold=None, outliers_mask=None, retries=None, timeout=None):
global eiger_averaging_number_of_samples #, chrono_grab
#chrono_grab.waitTimeout(GRAB_MIN_TIME)
if outliers_threshold is None:
outliers_threshold = get_outliers_threshold()
if outliers_mask is None:
outliers_mask = get_outliers_mask()
if wait_next:
if retries is None:
retries = 3
if timeout is None:
timeout=10.0
exposures = 1 if (eiger_averaging_number_of_samples is None) else eiger_averaging_number_of_samples
retries=max(retries,1)
timeout = 5000
for try_count in range(retries):
try:
start =time.time()
id = image.take()
print "Waiting next "
source.waitNext(timeout)
#det.update()
#time.sleep(1)
print "Waiting done ", str(time.time()-start), " ", str(id), "->", str(image.take())
break
except java.util.concurrent.TimeoutException:
if try_count == (retries-1):
raise
msg = "Eiger timeout - retrying #" + str(try_count)
print msg
log(msg)
#ret = load_image(Utils.grayscale(source.output, Rectangle(roi[0], roi[1], roi[2], roi[3]) if (roi is not None) else None))
time.sleep(0.01)
data=source.data
if roi is not None:
data = data.getRoi(Rectangle(roi[0], roi[1], roi[2], roi[3]))
#ret = load_image(img)
if outliers_mask is not None:
data.mult(outliers_mask)
if outliers_threshold>0:
data.threshold(outliers_threshold, False, None)
#chrono_grab = Chrono()
return data
def grab_frames(source, samples, roi=None, wait_next=False, sleep=0, outliers_threshold=None, outliers_mask=None, retries=None, timeout=None):
frames = []
for i in range(samples):
if (i>0) and (sleep>0):
time.sleep(sleep)
aux = grab_frame(source, roi, wait_next, outliers_threshold, outliers_mask, retries, timeout)
frames.append(aux)
return frames
def integrate_frames(frames):
if frames is None or (len(frames)==0):
return None
ret = frames[0].copy()
for data in frames[1:]:
ret.sum(data)
return ret
f,f1,f2=None, None, None
def average_frames(frames):
global f,f1,f2
f1,f2 = frames
ret = integrate_frames(frames)
if ret is not None:
ret.div(len(frames))
f=ret
return ret
def _timestamp(prec=0):
t = time.time()
s = time.strftime("%y/%m/%d %H:%M:%S", time.localtime(t))
if prec > 0:
s += ("%.9f" % (t % 1,))[1:2+prec]
return s
def _save_as_tiff(data, filename, check=False, show = False, metadata={}):
if type(data) == Data:
ip = load_array(data.matrix)
else:
ip = data
#info = "Timestamp: " + _timestamp(3)
#for key,val in metadata.items():
# info = info + "\n" + str(key) + ": " + str(val)
#print "Info:" ,info
#ip.setProperty("Info", info)
metadata["Timestamp"] = time.strftime("%y/%m/%d %H:%M:%S",time.localtime())
if not os.path.exists(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
save_image(ip, filename,"tiff", metadata)
#finfo = open(filename + ".info", "w")
#for k, v in metadata.items():
# finfo.write(str(k) + ': '+ str(v) + '\n')
#info.close()
if check:
data = get_ip_array(ip)
ip=open_image(filename)
read = get_ip_array(ip)
if not Arrays.deepEquals(read, data):
print "Error checking array"
def save_as_tiff(data, filename, check=False, show = False, parallel=True, metadata={}):
if parallel:
return fork((_save_as_tiff,(data, filename, check, show, metadata)),)
else:
_save_as_tiff(data, filename, check, show, metadata)
def trigger_eiger(wait=True):
if wait:
image.waitNext(20000)
def get_eiger_exposure_readback():
return 1.0
def set_exposure_time(value, check = True, retries=5):
pass
def get_eiger_number_of_frames():
return 1
def set_eiger_number_of_frames(value, check = True):
pass
#Wait for channel to chenge
def stop_eiger():
pass
chrono_eiger = Chrono()
def init_eiger(exposure=None, check=True, retries=2):
"""
Set Eiger scan mode
"""
pass
def restore_eiger(check=True, retries=2, exposure_time = 0.2):
"""
Set Eiger default mode
"""
pass
def is_averaging_detector():
return False
eiger_averaging_number_of_samples=None
def apply_averaging_detector(value):
pass
def average_eiger_frames(samples, roi=None, wait_next=False, sleep=0, outliers_threshold=None, outliers_mask=None, retries=None, timeout=None):
global eiger_averaging_number_of_samples #, chrono_eiger
sample = int(samples)
ret = grab_frames(image, samples, roi, wait_next, sleep, outliers_threshold, outliers_mask, retries, timeout)
#print "Averaging frames " + str(len(ret)) + " " + str(ret[0].integrate(False)) + " " + str(ret[1].integrate(False)) + " " + str(ret[0].equals(ret[1]))
print "Averaging frames "
av = average_frames(ret) if samples > 1 else ret[0]
"""
for name,r in ROI.items():
s, s1, s2 =0.0, 0.0, 0.0
for i in range(r[2]):
for j in range(r[3]):
#s = s + d[r[0]+i][r[1]+j]
s = s + av.getElement(r[0]+i, r[1]+j, False)
s1 = s1 + ret[0].getElement(r[0]+i, r[1]+j, False)
s2 = s2 + ret[1].getElement(r[0]+i, r[1]+j, False)
print "- ", name, s, s1,s2
"""
return av
_outliers_mask_timestamp = 0
_outliers_mask = None
def get_outliers_mask(data_type='f'):
global _outliers_mask_timestamp, _outliers_mask
if get_exec_pars().start == _outliers_mask_timestamp:
return _outliers_mask
_outliers_mask_timestamp = get_exec_pars().start
try:
_outliers_mask = None
filename = get_outliers_mask_file()
if filename:
ip=open_image(filename)
#TRANSPOSE - ImageJ stores the data transposed
ip.getProcessor().rotate(-90)
ip.getProcessor().flipVertical()
array = get_ip_array(ip)
array = Convert.toPrimitiveArray(array, ScriptUtils.getType(data_type))
_outliers_mask = Data(array)
print "Generated outliers mask"
except:
pass
return _outliers_mask
if False:
integrate_roi(image, 10, 5, 20, 10)
add_device(RoiIntensity("Region1", image, 10, 5, 20, 10), True)
add_device(RoiIntensity("Region2", image, 10, 5, 40, 20), True)
import ch.psi.pshell.data.ProviderCSV as ProviderCSV
ProviderCSV.setDefaultItemSeparator(" ")
tscan((Region1, Region2), 10, 0.1, layout="table", provider = "csv")
ret = grab_frames(image, 10, sleep=0.1)
av = integrate_frames(ret)
save_as_tiff(av,"{images}/data.tif", True)
print "Success"

642
script/imaging/sim.py Normal file
View File

@@ -0,0 +1,642 @@
from ijutils import *
import java.lang.reflect
import flanagan.complex.ComplexMatrix as ComplexMatrix
import flanagan.math.Matrix as Matrix
import flanagan.complex.Complex as Complex
import org.jtransforms.fft.DoubleFFT_2D as DoubleFFT_2D
import math
from startup import ScriptUtils
import ij.plugin.filter.PlugInFilterRunner as PlugInFilterRunner
import ij.plugin.filter.ExtendedPlugInFilter as ExtendedPlugInFilter
import ij.plugin.filter.ExtendedPlugInFilter as ExtendedPlugInFilter
import java.lang.Thread as Thread
def new_array(type, *dimensions):
return java.lang.reflect.Array.newInstance(ScriptUtils.getPrimitiveType(type), *dimensions)
def load_stack(title, file_list, show=False):
ip_list = []
for f in file_list:
ip_list.append(open_image(expand_path(f)))
stack = create_stack(ip_list, title=title)
if show:
stack.show()
return stack
def load_test_stack(title="Test", show=False, size=9):
file_list = []
for index in range(40, 40+size):
file_list.append("{images}/TestObjAligner/i210517_0" + str(index) + "#001.tif")
return load_stack(title, file_list, show)
def load_corr_stack(title="Corr", show=False):
file_list = []
for index in range(40, 49):
file_list.append("{images}/TestObjAligner_corr/i210517_0" + str(index) + "#001.tif")
return load_stack(title, file_list, show)
def complex_edge_filtering(imp, complex=True, g_sigma=3.0, g_resolution=1e-4, show=False, java_code=False):
if java_code:
get_context().getPluginManager().loadInitializePlugin("Align_ComplexEdgeFiltering.java")
complex_edge_filter = get_context().getClassByName("Align_ComplexEdgeFiltering").newInstance()
complex_edge_filter.setup(str(g_sigma)+","+str(complex)+","+str(show), imp) #Gaussian blur radius, Complex (True) or Real (False), show dialog = False
complex_edge_filter.run(imp.getProcessor())
return complex_edge_filter.output
gb = GaussianBlur()
sobel_r = [1, 0, -1, 2, 0, -2, 1, 0, -1]
sobel_i = [1, 2, 1, 0, 0, 0, -1, -2, -1]
imp_r = imp.createImagePlus()
stack_r = ImageStack(imp.getWidth(), imp.getHeight())
if (complex):
imp_i = imp.createImagePlus()
stack_i = ImageStack(imp.getWidth(), imp.getHeight())
for i in range(1, imp.getImageStackSize() + 1):
ip_r = imp.getStack().getProcessor(i).duplicate().convertToFloat()
# Gaussian blurring
gb.blurGaussian(ip_r, g_sigma, g_sigma, g_resolution)
ip_i = ip_r.duplicate()
# Sobel edge filtering
ip_r.convolve3x3(sobel_r)
ip_i.convolve3x3(sobel_i)
stack_r.addSlice(imp.getStack().getSliceLabel(i), ip_r)
stack_i.addSlice(imp.getStack().getSliceLabel(i), ip_i)
IJ.showProgress(i, imp.getImageStackSize())
# imag
imp_i.setStack("EdgeImag_" + imp.getTitle(), stack_i);
imp_i.resetDisplayRange()
if show:
imp_i.show()
imp_i.updateAndDraw()
else:
imp_i = None
for i in range(1, imp.getImageStackSize() + 1):
ip_r = imp.getStack().getProcessor(i).duplicate().convertToFloat()
# Gaussian blurring
gb.blurGaussian(ip_r, g_sigma, g_sigma, g_resolution)
# Sobel edge filtering
ip_r.filter(ImageProcessor.FIND_EDGES)
stack_r.addSlice(imp.getStack().getSliceLabel(i), ip_r)
IJ.showProgress(i, imp.getImageStackSize())
# real
imp_r.setStack("EdgeReal_" + imp.getTitle(), stack_r)
imp_r.resetDisplayRange()
if show:
imp_r.show()
imp_r.updateAndDraw()
return [imp_r, imp_i]
class TranslationFilter(ExtendedPlugInFilter):
def __init__(self):
self.shifts=None
self.flags = (self.DOES_ALL-self.DOES_RGB)|self.DOES_STACKS|self.NO_CHANGES|self.FINAL_PROCESSING
self.imp=None
self.output = None
self.translated = None
self.pifr = None
self.nbslices = 0
self.processed = 0
def setup(self, arg, imp):
if "final"==arg:
self.output.setStack("REG_" + self.imp.getTitle(), self.translated)
return self.DONE
else:
if self.imp is None:
self.imp = imp;
return self.flags;
def showDialog(self,imp, command, pfr):
self.pifr = pfr
return flags
# Called by ImageJ to set the number of calls to run(ip) corresponding to 100% of the progress bar
def setNPasses(self, nPasses):
self.nbslices = nPasses;
self.output = self.imp.createImagePlus();
self.translated = ImageStack(self.imp.getWidth(), self.imp.getHeight(), self.nbslices)
#Process a FloatProcessor (with the CONVERT_TO_FLOAT flag, ImageJ does the conversion to float).
# Called by ImageJ for each stack slice (when processing a full stack); for RGB also called once for each color. */
def run(self, ip):
if Thread.currentThread().isInterrupted():
return
thisone = self.pifr.getSliceNumber()
nip = ip.duplicate().convertToFloat()
nip.setInterpolationMethod(ImageProcessor.BICUBIC)
if len(self.shifts) != self.nbslices:
xoff, yoff = self.shifts[1][3], self.shifts[1][2] # translate all the frame by the same shifts
else:
xoff, yoff = self.shifts[thisone-1][3], self.shifts[thisone-1][2]
nip.translate(xoff, yoff)
lbl = self.imp.getStack().getSliceLabel(thisone)
if lbl != None:
self.translated.addSlice(lbl, nip, thisone - 1)
else:
self.translated.addSlice("" + thisone, nip, thisone - 1)
self.translated.deleteSlice(thisone + 1)
self.processed+=1
IJ.showProgress(self.processed, self.nbslices);
def translate(stack, shifts, show=False, java_code=False):
WindowManager.setTempCurrentImage(stack)
if java_code:
get_context().getPluginManager().loadInitializePlugin("Align_TranslationFilter.java")
translation_filter = get_context().getClassByName("Align_TranslationFilter").newInstance()
translation_filter.imp = imp
translation_filter.shifts = shifts
pfr = PlugInFilterRunner(translation_filter, "", "" )
ret = translation_filter.output
else:
translation_filter = TranslationFilter()
translation_filter.shifts = shifts
translation_filter.imp = stack
pfr = PlugInFilterRunner(translation_filter, "", "" )
ret = translation_filter.output
if show:
ret.show()
ret.updateAndDraw()
return ret
def load_shifts(filename):
get_context().getPluginManager().loadInitializePlugin("ShiftsIO.java")
sio = get_context().getClassByName("ShiftsIO").newInstance()
return sio.load(expand_path(filename), "directshifts")
def save_shifts(filename, shifts):
get_context().getPluginManager().loadInitializePlugin("ShiftsIO.java")
sio = get_context().getClassByName("ShiftsIO").newInstance()
sio.save(expand_path(filename), shifts, "directshifts")
def ip_to_fft_array_2d(ip):
pixels = ip.getPixels()
w = ip.getWidth()
h = ip.getHeight()
data = new_array('d', h, w) # new double[h][w]
for j in range(h): # (int j = 0; j < h; j++)
for i in range(w): # for (int i = 0; i < w; i++)
data[j][i] = pixels[j * w + i]
return data
def ip_to_fft_complex_array_2d(ip_r, ip_i):
pixels_r = ip_r.getPixels()
pixels_i = ip_i.getPixels()
w = ip_r.getWidth()
h = ip_r.getHeight()
data = new_array('d', h, 2 * w) # new double[h][2*w];
for j in range(h): # (int j = 0; j < h; j++)
for i in range(w): # for (int i = 0; i < w; i++)
data[j][2 * i] = pixels_r[j * w + i]
data[j][2 * i + 1] = pixels_i[j * w + i];
return data
def fft_array_2d_to_complex_matrix(data, h, w):
m = ComplexMatrix(h,w)
for j in range(h): #for (int j = 0; j < h; j++) {
for i in range(w/2): # for (int i = 0; i <= w/2; i++) {
if (j > 0) and (i > 0) and (i < w/2):
m.setElement(j, i, Complex(data[j][2*i], data[j][2*i+1]))
m.setElement(h-j, w-i, Complex(data[j][2*i], -data[j][2*i+1]))
if (j == 0) and (i > 0) and (i < w/2):
m.setElement(0, i, Complex(data[0][2*i], data[0][2*i+1]))
m.setElement(0, w-i, Complex(data[0][2*i], -data[0][2*i+1]))
if (i == 0) and (j > 0) and (j < h/2):
m.setElement(j,0, Complex(data[j][0], data[j][1]))
m.setElement(h-j, 0, Complex(data[j][0], -data[j][1]))
m.setElement(j, w/2, Complex(data[h-j][1], -data[h-j][0]))
m.setElement(h-j, w/2, Complex(data[h-j][1], data[h-j][0]))
if (j == 0) and (i == 0):
m.setElement(0, 0, Complex(data[0][0], 0));
if (j == 0) and (i == w/2):
m.setElement(0, w/2, Complex(data[0][1], 0));
if (j == h/2) and (i == 0):
m.setElement(h/2, 0, Complex(data[h/2][0], 0));
if (j == h/2) and (i == w/2):
m.setElement(h/2, w/2, Complex(data[h/2][1], 0));
return m
def fft_complex_array_2d_to_complex_matrix(data, h, w):
m = ComplexMatrix(h,w);
for j in range(h): #for (int j = 0; j < h; j++) {
for i in range(w): # for (int i = 0; i < w; i++) {
m.setElement(j,i, Complex(data[j][2*i], data[j][2*i+1]))
return m
def complex_matrix_to_fft_array_2d(m):
w = m.getNcol()
h = m.getNrow()
data = new_array('d', h,w) #new double[h][w];
for j in range(h): #for (int j = 0; j < h; j++) {
for i in range(w): #for (int i = 0; i <= w/2; i++) {
if (j > 0) and (i > 0) and (i < w/2):
data[j][2*i] = m.getElementReference(j,i).getReal()
data[j][2*i+1] = m.getElementReference(j,i).getImag()
if (j == 0) and (i > 0) and (i < w/2):
data[0][2*i] = m.getElementReference(0,i).getReal()
data[0][2*i+1] = m.getEementReference(0,i).getImag()
if (i == 0) and (j > 0) and (j < h/2):
data[j][0] = m.getElementReference(j,0).getReal()
data[j][1] = m.getElementReference(j,0).getImag()
data[h-j][1] = m.getElementReference(j,w/2).getReal()
data[h-j][0] = m.getElementReference(h-j,w/2).getImag()
if (j == 0) and (i == 0):
data[0][0] = m.getElementReference(0,0).getReal()
if (j == 0) and (i == w/2):
data[0][1] = m.getElementReference(0,w/2).getReal()
if (j == h/2) and (i == 0):
data[h/2][0] = m.getElementReference(h/2,0).getReal()
if (j == h/2) and ( i == w/2):
data[h/2][1] = m.getElementReference(h/2,w/2).getReal()
return data
# convert a Complex Matrix into an 2d real part array data[0][][] and 2d imaginary part data[1][][]
def complex_matrix_to_real_array_2d(m):
w = m.getNcol()
h = m.getNrow()
data = new_array('d', 2,h,w) #new double[2][h][w];
for j in range(h): #for (int j = 0; j < h; j++) {
for i in range(w): #for (int i = 0; i < w; i++) {
data[0][j][i] = m.getElementReference(j,i).getReal()
data[1][j][i] = m.getElementReference(j,i).getImag()
return data;
def compute_fft(imp_r, imp_i, roi):
slices = imp_r.getStackSize()
ffts = java.lang.reflect.Array.newInstance(ComplexMatrix, slices) # new ComplexMatrix[slices]
for i in range(1, slices + 1):
if imp_i is None:
ip = imp_r.getStack().getProcessor(i)
ip.setRoi(roi)
curr = ip.crop().convertToFloat();
data = ip_to_fft_array_2d(curr)
ffts[i - 1] = fft2(data)
else:
ip1 = imp_r.getStack().getProcessor(i)
ip1.setRoi(roi)
curr_r = ip1.crop().convertToFloat()
ip2 = imp_i.getStack().getProcessor(i)
ip2.setRoi(roi)
curr_i = ip2.crop().convertToFloat()
data = ip_to_fft_complex_array_2d(curr_r, curr_i)
ffts[i - 1] = cfft2(data)
IJ.showProgress(i, slices)
return ffts
def element_product(a, b):
nr = a.getNrow()
nc = a.getNcol()
res = ComplexMatrix(nr, nc)
for j in range(nr): # (int j = 0; j < nr; j++) {
for i in range(nc): # (int i = 0; i < nc; i++) {
res.setElement(j, i, a.getElementReference(j, i).times(b.getElementReference(j, i)))
return res;
def fft_shift(complex_matrix):
nc = complex_matrix.getNcol()
nr = complex_matrix.getNrow()
out = ComplexMatrix(nr, nc)
midi = int(math.floor(nc / 2.0))
offi = int(math.ceil(nc / 2.0))
midj = int(math.floor(nr / 2.0))
offj = int(math.ceil(nr / 2.0))
for j in range(nr): # for (int j = 0; j < nr; j ++){
for i in range(nc): # for (int i = 0; i < nc; i++) {
if j < midj:
if i < midi:
out.setElement(j, i, complex_matrix.getElementReference(j + offj, i + offi))
else:
out.setElement(j, i, complex_matrix.getElementReference(j + offj, i - midi))
else:
if i < midi:
out.setElement(j, i, complex_matrix.getElementReference(j - midj, i + offi))
else:
out.setElement(j, i, complex_matrix.getElementReference(j - midj, i - midi))
return out
def ifft_shift(complex_matrix):
nc = complex_matrix.getNcol()
nr = complex_matrix.getNrow()
out = ComplexMatrix(nr, nc)
midi = int(math.ceil(nc / 2.0))
offi = int(math.floor(nc / 2.0))
midj = int(math.ceil(nr / 2.0))
offj = int(math.floor(nr / 2.0))
for j in range(nr): # (int j = 0; j < nr; j ++){
for i in range(nc): # for (int i = 0; i < nc; i++) {
if j < midj:
if i < midi:
out.setElement(j, i, complex_matrix.getElementReference(j + offj, i + offi))
else:
out.setElement(j, i, complex_matrix.getElementReference(j + offj, i - midi))
else:
if i < midi:
out.setElement(j, i, complex_matrix.getElementReference(j - midj, i + offi))
else:
out.setElement(j, i, complex_matrix.getElementReference(j - midj, i - midi))
return out;
def ifft_shift_real(matrix):
nc = matrix.getNcol()
nr = matrix.getNrow()
out = Matrix (nr, nc)
midi = int(math.ceil(nc/2.0))
offi = int(math.floor(nc/2.0))
midj = int(math.ceil(nr/2.0))
offj = int(math.floor(nr/2.0))
for j in range(nr): # for (int j = 0; j < nr; j ++){
for i in range(nc): #for (int i = 0; i < nc; i++) {
if j < midj:
if i < midi:
out.setElement(j, i, matrix.getElement(j+offj, i+offi))
else:
out.setElement(j, i, matrix.getElement(j+offj, i-midi))
else:
if i < midi:
out.setElement(j, i, matrix.getElement(j-midj, i+offi))
else:
out.setElement(j, i, matrix.getElement(j-midj, i-midi))
return out
# compute 2D fft from an image
def fft2(data):
h =len(data)
w = len(data[0])
fft = DoubleFFT_2D(h, w)
fft.realForward(data)
return fft_array_2d_to_complex_matrix(data, h, w)
# compute complex 2D fft from an image
def cfft2(data):
h = len(data)
w = len(data[0])
fft = DoubleFFT_2D(h, w/2)
fft.complexForward(data)
return fft_complex_array_2d_to_complex_matrix(data, h, w/2)
# compute inverse 2D fft from a complex matrix
def ifft2(m):
w = m.getNcol()
h = m.getNrow()
fft = DoubleFFT_2D(h, w)
data = complex_matrix_to_fft_array_2d(m)
fft.realInverse(data, True)
return data
# compute complex inverse 2D fft from a complex matrix
def cifft2(m):
w = m.getNcol()
h = m.getNrow()
fft = DoubleFFT_2D(h, w)
data = new_array('d', h, 2 * w) # new double[h][2*w];
for j in range(h): # for (int j=0; j<h; j++):
for i in range(w): # for (int i=0; i<w; i++) {
data[j][2 * i] = m.getElementReference(j, i).getReal()
data[j][2 * i + 1] = m.getElementReference(j, i).getImag()
fft.complexInverse(data, True)
out = ComplexMatrix(h, w)
for j in range(h): # (int j=0; j<h; j++) {
for i in range(w): # (int i=0; i<w; i++) {
out.setElement(j, i, data[j][2 * i], data[j][2 * i + 1])
return out;
def c_find_peak(m):
max = 0.0
realmax = 0.0
imagmax = 0.0
cmax = 0
rmax = 0
for j in range(m.getNrow()): # (int j = 0; j < m.getNrow(); j ++){
for i in range(m.getNcol()): # for (int i = 0; i < m.getNcol(); i++) {
if m.getElementReference(j, i).abs() > max:
max = m.getElementReference(j, i).abs()
realmax = m.getElementReference(j, i).getReal()
imagmax = m.getElementReference(j, i).getImag()
rmax = j
cmax = i
res = new_array("d", 5)
res[0] = math.sqrt(realmax * realmax + imagmax * imagmax)
res[1] = rmax
res[2] = cmax
res[3] = realmax
res[4] = imagmax
return res;
def sum_square_abs(m):
s = 0.0
for j in range(m.getNrow()): # (int j = 0; j < m.getNrow(); j ++):
for i in range(m.getNcol()): # for (int i = 0; i < m.getNcol(); i++):
s += m.getElementReference(j, i).squareAbs();
return s;
def dftups(complex_matrix, nor, noc, roff, coff, usfac):
# function out=dftups(in,nor,noc,usfac,roff,coff);
# Upsampled DFT by matrix multiplies, can compute an upsampled DFT in justa small region.
# usfac Upsampling factor (default usfac = 1)
# [nor,noc] Number of pixels in the output upsampled DFT, in
# units of upsampled pixels (default = size(in))
# roff, coff Row and column offsets, allow to shift the output array to
# a region of interest on the DFT (default = 0)
# Recieves DC in upper left corner, image center must be in (1,1)
# Loic Le Guyader - Jun 11, 2011 Java version for ImageJ plugin
# Manuel Guizar - Dec 13, 2007
# Modified from dftus, by J.R. Fienup 7/31/06
# This code is intended to provide the same result as if the following
# operations were performed
# - Embed the array "in" in an array that is usfac times larger in each
# dimension. ifftshift to bring the center of the image to (1,1).
# - Take the FFT of the larger array
# - Extract an [nor, noc] region of the result. Starting with the
# [roff+1 coff+1] element.
# It achieves this result by computing the DFT in the output array without
# the need to zeropad. Much faster and memory efficient than the
# zero-padded FFT approach if [nor noc] are much smaller than [nr*usfac nc*usfac]
nr = complex_matrix.getNrow()
nc = complex_matrix.getNcol()
# Compute kernels and obtain DFT by matrix products
amplitude = -2.0 * math.pi / (nc * usfac)
nor,noc=int(nor),int(noc)
u = Matrix(nc, 1)
for i in range(nc): # (int i = 0; i < nc; i++) {
u.setElement(i, 0, i - math.floor(nc / 2.0))
u = ifft_shift_real(u)
v = Matrix(1, noc)
for i in range(noc): # for (int i = 0; i < noc; i++) {
v.setElement(0, i, i - coff)
phase = u.times(v)
kernc = ComplexMatrix(nc, noc)
for j in range(nc): # for (int j = 0; j < nc; j++) {
for i in range(noc): # for (int i = 0; i < noc; i++) {
t = Complex()
t.polar(1.0, amplitude * phase.getElement(j, i));
kernc.setElement(j, i, t)
# ComplexMatrixPrint(kernc)
amplitude = -2.0 * math.pi / (nr * usfac)
w = Matrix(nor, 1)
for i in range(nor): # for (int i = 0; i < nor; i++) {
w.setElement(i, 0, i - roff)
x = Matrix(1, nr)
for i in range(nr): # for (int i = 0; i < nr; i++) {
x.setElement(0, i, i - math.floor(nr / 2.0))
x = ifft_shift_real(x)
nphase = w.times(x);
kernr = ComplexMatrix(nor, nr)
for j in range(nor): # for (int j = 0; j < nor; j++) {
for i in range(nr): # for (int i = 0; i < nr; i++) {
t = Complex();
t.polar(1.0, amplitude * nphase.getElement(j, i))
kernr.setElement(j, i, t)
# ComplexMatrixPrint(kernr);
return kernr.times(complex_matrix.times(kernc))
def dft_registration(ref, drifted, usfac):
m = ref.getNrow()
n = ref.getNcol()
output = new_array('d', 4) # new double[4]
# First upsample by a factor of 2 to obtain initial estimate
# Embed Fourier data in a 2x larger array
mlarge = m * 2
nlarge = n * 2
large = ComplexMatrix(mlarge, nlarge)
c = fft_shift(element_product(ref, drifted.conjugate()))
for j in range(m): # (int j = 0; j < m; j++):
for i in range(n): # (int i = 0; i < n; i++):
large.setElement(int(j + m - math.floor(m / 2.0)), int(i + n - math.floor(n / 2.0)), c.getElementReference(j, i))
# Compute crosscorrelation and locate the peak
CC = cifft2(ifft_shift(large));
peak = c_find_peak(CC); # max, r, c, max_r, max_c
# Obtain shift in original pixel grid from the position of the
# crosscorrelation peak
if peak[1] > m:
peak[1] = peak[1] - mlarge;
if peak[2] > n:
peak[2] = peak[2] - nlarge;
# If upsampling > 2, then refine estimate with matrix multiply DFT
if usfac > 2:
# DFT computation
# Initial shift estimate in upsampled grid
row_shift = round(peak[1] / 2.0 * usfac) / usfac
col_shift = round(peak[2] / 2.0 * usfac) / usfac
dftshift = math.floor(math.ceil(usfac * 1.5) / 2) # Center of output array at dftshift+1
# Matrix multiply DFT around the current shift estimate
cm = element_product(drifted, ref.conjugate())
nCC = dftups(cm, math.ceil(usfac * 1.5), math.ceil(usfac * 1.5), \
dftshift - row_shift * usfac, dftshift - col_shift * usfac, usfac)
nCC = nCC.times(1.0 / (m * n * usfac * usfac)).conjugate()
# Locate maximum and map back to original pixel grid
npeak = c_find_peak(nCC) # max_r, max_i, r, c
mrg00 = dftups(element_product(ref, ref.conjugate()), 1, 1, 0, 0, usfac)
rg00 = mrg00.getElementReference(0, 0).abs() / (m * n * usfac * usfac)
mrf00 = dftups(element_product(drifted, drifted.conjugate()), 1, 1, 0, 0, usfac)
rf00 = mrf00.getElementReference(0, 0).abs() / (m * n * usfac * usfac)
npeak[1] = npeak[1] - dftshift
npeak[2] = npeak[2] - dftshift
output[0] = math.sqrt(abs(1.0 - npeak[0] * npeak[0] / (rg00 * rf00))) # error
output[1] = math.atan2(npeak[4], npeak[3]) # diffphase
output[2] = row_shift + npeak[1] / usfac # delta row
output[3] = col_shift + npeak[2] / usfac # delta col
else:
# If upsampling = 2, no additional pixel shift refinement
rg00 = sum_square_abs(ref) / (mlarge * nlarge)
rf00 = sum_square_abs(drifted) / (mlarge * nlarge)
output[0] = math.sqrt(abs(1.0 - peak[0] * peak[0] / (rg00 * rf00))) # error
output[1] = math.atan2(peak[4], peak[3]) # diffphase
output[2] = peak[1] / 2.0 # delta row
output[3] = peak[2] / 2.0 # delta col
return output
def calculate_shifts(imp_r, imp_i, roi, upscale_factor=100, reference_slide=1, java_code=False):
if roi is None or roi.bounds.minX <0 or roi.bounds.minY<0 or roi.bounds.maxX>=imp_r.width or roi.bounds.maxY>=imp_r.height:
raise Exception("Invalid roi: " + str(roi))
if java_code:
get_context().getPluginManager().loadInitializePlugin("Align_ComputeShifts2.java")
compute_shifts_filter = get_context().getClassByName("Align_ComputeShifts2").newInstance()
compute_shifts_filter.setup(upscale_factor, False, imp_r, imp_i, 1, roi)
compute_shifts_filter.run(None)
return compute_shifts_filter.shifts
IJ.showStatus("1/2 Perform FFT of each slice")
ffts = compute_fft(imp_r, imp_i, roi)
# calculate shifts
IJ.showStatus("2/2 Calculate shifts between slices")
shifts = new_array('d', len(ffts), 6) # new double[ffts.length][6];
for i in range(len(ffts)): # (int i = 0; i < ffts.length; i++):
shifts[i][0] = reference_slide
shifts[i][1] = i + 1
temp = dft_registration(ffts[reference_slide - 1], ffts[i], upscale_factor)
shifts[i][2] = temp[2]
shifts[i][3] = temp[3]
shifts[i][4] = temp[0]
shifts[i][5] = temp[1]
IJ.showProgress(i + 1, len(ffts))\
return shifts # [ref, drifted, dr, dc, error, diffphase]
def to_ip(obj):
if is_string(obj):
obj = open_image(obj)
else:
if type(obj) == Data:
obj = obj.toBufferedImage(False)
if type(obj) == BufferedImage:
obj = load_image(obj)
return obj
def calculate_shift(ref,img, roi, g_sigma=3.0, upscale_factor=100):
ref = to_ip(ref)
img = to_ip(img)
stack = create_stack([ref,img])
ipr, ipi = complex_edge_filtering(stack, g_sigma=g_sigma, show=False)
shifts = calculate_shifts(ipr, ipi, roi, upscale_factor=upscale_factor, java_code=True)
xoff, yoff = shifts[1][3], shifts[1][2]
error, diffphase = shifts[1][4], shifts[1][5]
return xoff, yoff, error, diffphase
roi=Roi(256,0,128,128)
stack = load_test_stack(show=False, size=9)
ipr, ipi = complex_edge_filtering(stack, show=False)
shifts = calculate_shifts(ipr, ipi, roi, java_code=True)
#shifts= load_shifts("{images}/TestObjAligner/shifts.mat")
#stack = load_test_stack(show=True)
r=translate(stack, shifts, show=True)

45
script/jep/testdevs.py Normal file
View File

@@ -0,0 +1,45 @@
from jep import jproxy
import random
class WritableScalar():
def write(self, value):
print ("Write: ", value)
class ReadableScalar():
def read(self):
print ("Read")
return random.random()
class ReadableWaveform():
def getSize(self):
return 20
def read(self):
ret = []
for i in range (self.getSize()):
ret.append(random.random())
return ret
class ReadableImage():
def read(self):
ret = []
for i in range (self.getHeight()):
ret.append([random.random()] * self.getWidth())
return to_array(ret, 'd')
def getWidth(self):
return 80
def getHeight(self):
return 40
ws1 = jproxy(WritableScalar(), ['ch.psi.pshell.device.Writable'])
rs1 = jproxy(ReadableScalar(), ['ch.psi.pshell.device.Readable'])
rw1 = jproxy(ReadableWaveform(), ['ch.psi.pshell.device.Readable$ReadableArray'])
ri1 = jproxy(ReadableImage(),['ch.psi.pshell.device.Readable$ReadableMatrix'])
tscan(rs1, 10, 0.1)
lscan(ws1, rs1, 0.0, 10.0, 10)

View File

@@ -1,10 +1,45 @@
# TESTIOC:TESTSINUS:SinCalc
# TESTIOC:TESTWF2:MyWF
# TESTIOC:TESTCALCOUT:Input
# TESTIOC:TESTCALCOUT:Output
#get_context().dataManager.provider.embeddedAtributes = False
#get_context().dataManager.provider.ADD_ATTRIBUTE_FILE_TIMESTAMP = True
###################################################################################################
# EPICS utilities
###################################################################################################
##############
#####################################################################################
if get_context().getScriptType()==ScriptType.cpy:
def on_ctrl_cmd(cmd):
global RE
print ("Control command: ", cmd)
if cmd=="abort":
if "RE" in globals():
if RE.state not in ['idle','paused', 'pausing']:
print ("Run Engine pause request")
RE.request_pause()
abort()
def otf(mode="ENERGY", e1=None, e2=None, beta1=None, beta2=None, theta1=None, theta2=None, \
time=1.0, modulo=1, turn_off_beam=False):
"""
mode: "ENERGY" or "AMNGLE"
"""
run("otf", {"E1":450.0, "E2":460.0})
run("otf", {
"MODE":mode, \
"E1":float(e1) if e1 is not None else None, \
"E2":float(e2) if e2 is not None else None, \
"BETA1":float(beta1) if beta1 is not None else None, \
"BETA2":float(beta2) if beta2 is not None else None, \
"THETA1":float(theta1) if theta1 is not None else None, \
"THETA2":float(theta2) if theta2 is not None else None, \
"TIME":float(time), \
"MODULO":int(modulo), \
"ENDSCAN":turn_off_beam, \
})
def caget_str(ch):
return ''.join((chr(i) if i else "") for i in caget(ch))
@@ -73,17 +108,47 @@ def on_command_started(info):
def on_command_finished(info):
pass #print "Finished: " + str(info.script) + " Error: " + str(info.error)
def on_change_data_path(path):
print "Data path: " + str(path)
#print "Data path: " + str(path)
pass
def on_session_started(id):
print "Start session: ", id
#print "Start session: ", id
get_context().sessionManager.setMetadata("beamlineState", {"sin": sin.take(), "inp": inp.take()})
get_context().sessionManager.setMetadata("beamlineState2", {"sin": sin.take(), "inp": inp.take()})
def on_session_finished(id):
print "Stop session: ", id
#print "Stop session: ", id
get_context().sessionManager.setMetadata("scientificMetadata",SCI_METADATA)
get_context().sessionManager.setMetadata("scientificMetadata2",SCI_METADATA)
###################################################################################################
# Image filters
###################################################################################################
class DataFilter(Filter.DataFilter):
def process(self, data):
data=data.copy()
data.mult(2.0)
return data
data_filter = DataFilter("filter")
image.addListener(data_filter)
proc_data=ColormapAdapter("proc_data", data_filter)
add_device(proc_data, True)
class ImageFilter(Filter.ImageFilter):
def process(self, img):
return ImagingUtils.transpose(img)
image_filter = ImageFilter("filter")
image.addListener(image_filter)
#proc_image=ColormapAdapter("proc_image", image_filter)
add_device(image_filter, True)
image.refresh()
@@ -144,6 +209,7 @@ import random
#State listener: cleanup can be made at end of execution
def onStateChange(state, former, script):
#print state
if state == State.Closing:
#print "Closing the app"
pass
@@ -180,20 +246,26 @@ class SimulatedOutput(Writable):
def write(self, value):
pass
def getName(self):
return "sout"
class SimulatedInput(Readable):
#class SimulatedInput(Readable):
class SimulatedInput(ReadonlyRegisterBase):
def __init__(self):
self.x = 0.0
def read(self):
#def read(self):
def doRead(self):
self.x = self.x + 0.1
noise = (random.random() - 0.5) / 20.0
return math.sin(self.x) + noise
def getName(self):
return "sinp"
sout = SimulatedOutput()
sinp = SimulatedInput()
add_device(sinp, True)
#for m in mu, delta, gamma, eta, chi, phi:
# m.setSpeed(m.config.defaultSpeed)
#Controler Evenrt Listener
@@ -632,6 +704,9 @@ scan_val.set([0.0,] * MAX_ARRAY_DEV_SIZE )
#cas6= CAS("PSHELL:var",sin)
"""
#show_panel(master)
def plot_numpy_array(na, title = None):
plot( Convert.reshape(na.getData(),na.getDimensions()),title=title)
@@ -646,7 +721,6 @@ def run_fda(file_name, arguments={}):
#Convex hull plots
def clear_convex_hull_plot(title):
plots = get_plots(title = title)
@@ -893,4 +967,132 @@ class Counter(ReadonlyRegisterBase):
add_device(Counter("counter"), True)
def trigger_scienta():
"""
Trigger new acquisition
"""
scienta.start()
#scienta.waitNewImage(-1)
###################################################################################################
# Handlig diagnostics
###################################################################################################
###################################################################################################
# Handlig diagnostics
###################################################################################################
class AcquisitionMode(Readable.ReadableString):
def read(self):
return str(scienta.getAcquisitionMode())
_acquisition_mode=AcquisitionMode()
class EnergyMode(Readable.ReadableString):
def read(self):
return str(scienta.getEnergyMode())
_energy_mode=EnergyMode()
class LensMode(Readable.ReadableString):
def read(self):
return str(scienta.getLensMode())
_lens_mode=LensMode()
class DetectorMode(Readable.ReadableString):
def read(self):
return str(scienta.getDetectorMode())
_detector_mode=DetectorMode()
class PassEnergy(Readable):
def read(self):
return scienta.getPassEnergy()
_pass_energy=PassEnergy()
class ElementSet(Readable.ReadableString):
def read(self):
return str(scienta.getElementSet())
_element_set=ElementSet()
diag_channels = []
diag_channels.append(scienta.lowEnergy)
diag_channels.append(scienta.centerEnergy)
diag_channels.append(scienta.highEnergy)
diag_channels.append(scienta.energyWidth)
diag_channels.append(_acquisition_mode)
diag_channels.append(_energy_mode)
diag_channels.append(_lens_mode)
diag_channels.append(_detector_mode)
diag_channels.append(_pass_energy)
diag_channels.append(_element_set)
diag_channels = sorted(diag_channels, key=lambda channel: channel.name)
def get_diag_name(diag):
return ch.psi.utils.Str.toTitleCase(diag.getName()).replace(" ", "").replace("Readback", "")
def print_diag():
for f in diag_channels:
print "%-25s %s" % (get_diag_name(f) , str(f.read()))
def create_diag_datasets(parent = None):
if parent is None:
parent = get_exec_pars().group
group = parent + "attrs/"
for f in diag_channels:
create_dataset(group+get_diag_name(f) , 's' if (issubclass(type(f), Readable.ReadableString)) else 'd')
def append_diag_datasets(parent = None):
if parent is None:
parent = get_exec_pars().group
group = parent + "attrs/"
for f in diag_channels:
try:
x = f.read()
if x is None:
x = '' if (type(f) is ch.psi.pshell.epics.ChannelString) else float('nan')
append_dataset(group+get_diag_name(f), x)
except:
log("Error sampling " + str(get_diag_name(f)) + ": " + str(sys.exc_info()[1]))
def handle_diagnostics(rec):
#if beam_ok:
if get_exec_pars().save:
#Saving only once the diag data
if rec.index == 0:
create_diag_datasets()
append_diag_datasets()
def scan_2d(range_x, range_y, steps_x, steps_y, exposures=None, settling_time=0.1, zigzag=True, compression=False, dry_run=False):
if type(range_x)==float: range_x =[-range_x, range_x]
if type(range_y)==float: range_y =[-range_y, range_y]
return run("templates/Scan2D", { \
"DRY_RUN": dry_run, \
"RANGE_X": range_x, \
"RANGE_Y": range_y, \
"STEPS": [steps_x, steps_y], \
"EXPOSURES": exposures, \
"SETTLING_TIME": settling_time, \
"ZIGZAG": zigzag, \
"COMPRESSION": compression
})
"""
add_device(PipelineStream("p","localhost:8889", "simulation_sp"), True)
p.monitored=True
s=p.createSubsampled(1.0)
#show_panel(s)
show_panel(p)
"""
print "Finished initialization"

103
script/otf.py Normal file
View File

@@ -0,0 +1,103 @@
#Debugging
if get_exec_pars().innerArgs is None:
E1 = 975
E2 = 985
TIME = 1 #min
DELAY = 0.0 #s
MODE = None #'LINEAR' #'CIRC +'
OFFSET = None
NAME = 'predefined'
ALPHA= None #0
print "\nStart energy scan..."
print E1,"eV ->",E2,"eV,",TIME,"min duration,",DELAY,"sec delay,",str(MODE),(str(ALPHA)+"deg") if (MODE=="LINEAR") else ""
set_exec_pars(reset=True, name= NAME)
call_mscan=True
move_mono=False # if true, X-Tremeo runs, if false channel defiend under Ch runs
#Scan
print "Start OTF"
scan_completed = False
try:
while True:
waiting = True
class Time(Readable):
def __init__(self):
self.start = time.time()
def read(self):
return time.time()-self.start
tm = Time()
class norm_tey(Readable):
def read(self):
return float(cadc1.take())/float(cadc2.take())
class norm_diode(Readable):
def read(self):
return float(cadc3.take())/float(cadc2.take())
# define channels for PGM paramters
position=sin
snaps = ()
diags = () #Must use cache because mscan evensts are called from monitor callback tread (or else async=False). Sensors are automatically handled.
sensors = [position,out]
def monitoring_task():
global scan_completed
time.sleep(3.0)
scan_completed = True
print('Scan completed ' + str(get_exec_pars().currentScan))
global scans
scans.append(get_exec_pars().currentScan)
get_exec_pars().currentScan.abort()
print('after abort ')
def before_pass(pass_num, scan):
print "Starting scan: " + str(scan)
monitoring_future = fork(monitoring_task)[0]
print("Scanning...\n")
try:
if call_mscan==True:
print('call mscan ')
mscan( position, sensors, -1, None, \
range="auto",domain_axis=position.name,
snaps=snaps, diags=diags, before_pass=before_pass)
else:
print('-------------------------------------')
print('DO NOT CALL mscan ')
print('-------------------------------------')
#endelse
finally:
print('.....mscan done ')
if not scan_completed:
print('... cancel monitoring_future..')
monitoring_future.cancel(True)
print('monitoring is done',monitoring_future.isDone())
print "Finished Energy scan."
if after_sample(): #Repeat if id error and not ABORT_ON_ID_ERROR:
break
except:
if not scan_completed:
print sys.exc_info()
raise
#endif
#endexcept
print('-------DONE --------------')
# Finally, if mon is not use
# return to initial position

View File

@@ -1,5 +1,5 @@
for i in range(100):
for i in range(20):
out.write(i)
time.sleep(0.1)

1
script/queues/mxas.que Normal file
View File

@@ -0,0 +1 @@
[ [ [ false, "/sls/X05LA/Data1/x05laop/2021_10/20211024/ScanX_vsAngle_Energy1_XRF_NoMythen_10s_60deg_AudioTape_x5_vXX.xml", "", "Resume", "Aborted" ], [ false, "/sls/X05LA/Data1/x05laop/2021_10/20211024/ScanX_vsAngle_Energy2_XRF_NoMythen_10s_60deg_AudioTape_x5_vXX.xml", "", "Resume", "" ], [ false, "/sls/X05LA/Data1/x05laop/2021_10/20211024/ScanX_vsAngle_Energy1_XRF_WithMythen_10s_60deg_AudioTape_x5_vXX.xml", "", "Resume", "" ], [ false, "/sls/X05LA/Data1/x05laop/2021_10/20211024/ScanX_vsAngle_Energy2_XRF_WithMythen_10s_60deg_AudioTape_x5_vXX.xml", "", "Resume", "" ], [ false, "/sls/X05LA/Data1/x05laop/2021_10/20211024/ScanX_vsAngle_Energy1_XRF_WithMythen_10s_60deg_AudioTape_x5_vXX.xml", "", "Resume", "" ], [ false, "/sls/X05LA/Data1/x05laop/2021_10/20211027/XRD_XRF_otf_200ms_17995eV_XY_LYPC.xml", "", "Resume", "" ], [ false, "/sls/X05LA/Data1/x05laop/2021_10/20211027/XRD_XRF_otf_200ms_17995eV_XY_LYPC.xml", "", "Resume", "" ], [ true, "/sls/X05LA/Data1/x05laop/2021_10/20211027/XRD_XRF_otf_200ms_17995eV_XY_LYPC.xml", "", "Resume", "" ] ] ]

1
script/queues/q5.que Normal file
View File

@@ -0,0 +1 @@
[ [ [ true, "", "print 1", "Resume", "Success" ], [ true, "queues/q4.que", "", "Resume", "Success" ], [ true, "Test.xml", "", "Resume", "Success" ], [ true, "test/test0.py", "", "Resume", "Failure" ], [ true, "test/test1.py", "", "Resume", "Success" ], [ true, "", "sleep(5.0)", "Resume", "Success" ], [ true, "", "print 2", "Resume", "Success" ], [ true, "", "sleep(0.5)", "Resume", "Success" ], [ true, "", "print 3", "Resume", "Success" ], [ true, "", "sleep(0.5)", "Resume", "Success" ], [ true, "", "print 4", "Resume", "Success" ], [ true, "", "sleep(0.5)", "Resume", "Success" ], [ true, "", "print 5", "Resume", "Success" ], [ true, "", "i=0", "Resume", "Success" ], [ true, "queues/q6.que", "", "Resume", "Success" ], [ false, "queues/q6.que", "", "Resume", "Disabled" ], [ false, "queues/q6.que", "", "Resume", "Disabled" ], [ false, "queues/q6.que", "", "Resume", "Disabled" ] ] ]

1
script/queues/q6.que Normal file
View File

@@ -0,0 +1 @@
[ [ [ true, "", "i=i+1", "Resume", "" ], [ true, "", "print \"###>\"+str(i)", "Resume", "" ], [ true, "", "print 10", "Resume", "" ], [ true, "", "sleep(0.25)", "Resume", "" ], [ true, "", "print 20", "Resume", "" ], [ true, "", "sleep(0.25)", "Resume", "" ], [ true, "", "print 30", "Resume", "" ], [ true, "", "sleep(0.25)", "Resume", "" ], [ true, "", "print 40", "Resume", "" ], [ true, "", "sleep(0.25)", "Resume", "" ], [ true, "", "print 50", "Resume", "" ], [ true, "", "sleep(0.25)", "Resume", "" ], [ true, "", "print 60", "Resume", "" ], [ true, "", "print \"--->\"+str(i)", "Resume", "" ] ] ]

1
script/queues/qt.que Normal file
View File

@@ -0,0 +1 @@
[ [ [ true, "test/test1.py", "", "Abort", "Success", "00:00:01" ], [ true, "test/test3.py", "", "Resume", "Aborted", "00:00:02" ], [ true, "test/test3.py", "", "Resume", "", "00:00:03" ] ] ]

1
script/queues/tst.que Normal file
View File

@@ -0,0 +1 @@
[ [ [ false, "test_manip.xml", "", "Resume", "" ], [ false, "test_function_script.xml", "", "Resume", "" ], [ true, "BugSuperXAS.xml", "", "Resume", "" ], [ false, "testy.xml", "", "Resume", "" ], [ false, "xxx.xml", "", "Resume", "" ], [ false, "test/BugPhenix.xml", "", "Resume", "" ], [ false, "test/test_manip.xml", "", "Resume", "" ], [ false, "test/test_function_script.xml", "", "Resume", "" ], [ true, "test/BugSuperXAS.xml", "", "Resume", "" ], [ false, "test/testy.xml", "", "Resume", "" ], [ false, "test/xxx.xml", "", "Resume", "" ], [ false, "test/BugPhenix.xml", "", "Resume", "" ] ] ]

30
script/runotf.py Normal file
View File

@@ -0,0 +1,30 @@
import traceback
import imp
import os
import time
import string
import sys
import json
def otf(start, end, time, delay=0.0, mode = None, offset = None, alpha = None, name = None):
"""
"""
# print('in otf',name)
if name is None:
name = get_exec_pars().name
if len(name)> 38:
name = name[:38]
print('WARNING: Sample name too long. Name has been truncated.')
#print('in otf, call run \n')
run("otf", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "NAME":name, "ALPHA":float(alpha) if alpha is not None else None})
print('in otf, after run \n')
for i in range(5):
print "----- RUN " + str(i)
otf(i, i+1, 3, delay=0.0, mode = None, offset = None, alpha = None, name = "scan"+str(i))

BIN
script/scitest/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,70 @@
"""
Arguments:
DRY_RUN = True
RANGE_X (tuple (min, max))
RANGE_Y (tuple (min, max))
STEPS (tuple (x, y))
EXPOSURES (list or None)
SETTLING_TIME (double)
ZIGZAG (BOOLEAN)
COMPRESSION (BOOLEAN)
"""
#Deug
if (get_exec_pars().args is None) and (get_exec_pars().script=="Scan2D"):
DRY_RUN = True
RANGE_X = [-10.0,10.0]
RANGE_Y = [-10.0,10.0]
EXPOSURES = None # [0.1, 0.5, 1.0]
STEPS = [5, 5] #Integers = number of steps, Float = stepoSize
SETTLING_TIME = 0.1
ZIGZAG = True
COMPRESSION = False
print DRY_RUN
SENSORS = [sin, scienta.dataMatrix]
MOTORS = [m1, m2]
RELATIVE = True
START = [RANGE_X[0], RANGE_Y[0]]
STOP = [RANGE_X[1], RANGE_Y[1]]
ENABLED_PLOTS= [sin, scienta.dataMatrix]
CUSTOM_PLOT_TYPES = {scienta.dataMatrix:"ch.psi.pshell.plot.MatrixPlotRenderer"}
if EXPOSURES:
class exposure_index (Writable, Readable):
def __init__(self):
self.pos=0.0
def read(self):
return self.pos
def write(self, value):
scienta.setExposure(EXPOSURES[int(value)])
self.pos = value
class exposure (Readable):
def read(self):
return scienta.exposure
POSITIONERS = MOTORS + [exposure_index()]
_SENSORS = SENSORS + [exposure()]
START = START + [0.0]
STOP = STOP + [float(len(POSITIONERS)-1)]
if EXPOSURES:
r = ascan(POSITIONERS, _SENSORS , START, STOP, STEPS + [1.0], \
SETTLING_TIME, RELATIVE, zigzag = ZIGZAG, \
compression = COMPRESSION, enabled_plots=ENABLED_PLOTS, \
save=False,keep=False, check_positions=False, plot_types=CUSTOM_PLOT_TYPES)
else:
r = ascan(MOTORS, SENSORS , START, STOP, STEPS, \
SETTLING_TIME, RELATIVE, zigzag = ZIGZAG, \
compression = COMPRESSION, enabled_plots=ENABLED_PLOTS, \
save=False,keep=False, check_positions=False, plot_types=CUSTOM_PLOT_TYPES)
set_return(t)

BIN
script/test/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,759 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="XAS_V_L1677_CN"/>
<variable name="K" value="0.0" description="Buffer K spacing for EXAFS k-spacing scans "/>
<variable name="N_cycles" value="0.0" description="Buffer N_cycles for EXAFS k-spacing scans "/>
<variable name="NINT" value="0.0" description="Counter for file number of Moche files"/>
<scan>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ShellAction" command="/sls/X07MB/data/settings/Scripts/GUI_X07MB/X_X07MB_fda_file_to_EPICS.sh ${FILENAME}" checkExitValue="false"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ShellAction" command="/sls/X07MB/data/settings/Scripts/GUI_X07MB/X_X07MB_fda_write_header.py &amp;" checkExitValue="false"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-OP2:START-CSMPL" value="0" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-SITORO:StopAll" value="1" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-SITORO:CollectMode" value="0" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-SITORO:CollectMode" value="0" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-SITORO:PresetReal" value="0" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-OP2:TOTAL-CYCLES" value="2" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-OP2:SMPL" value="1" operation="put" type="String" delay="0.7"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-ES1-PP2:VO5" value="0" operation="put" type="String" delay="0.01"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-OP-WV1:WT_SET" value="1" operation="put" type="String" delay="0.05"/>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RegionPositioner" name="X07MB-OP-MO:E-SET" readback="X07MB-OP-MO:E-GET" settlingTime="0.2" id="Energy">
<region>
<preAction xsi:type="ChannelAction" channel="X07MB-OP2:TOTAL-CYCLES" value="5"/>
<start>5365.0</start>
<end>5460.0</end>
<stepSize>2.0</stepSize>
</region>
<region>
<preAction xsi:type="ChannelAction" channel="X07MB-OP2:TOTAL-CYCLES" value="5"/>
<start>5461.0</start>
<end>5520.0</end>
<stepSize>0.3</stepSize>
</region>
<region>
<preAction xsi:type="ChannelAction" channel="X07MB-OP2:TOTAL-CYCLES" value="5.0"/>
<start>3.83209893521</start>
<end>15.0</end>
<stepSize>0.05</stepSize>
<function>
<mapping xsi:type="VariableParameterMapping" name="K" variable="K_v"/>
<mapping xsi:type="ChannelParameterMapping" channel="X07MB-OP2:TOTAL-CYCLES" type="Double" variable="N_Cycles"/>
<script>
def calculate(parameter):
nc=N_Cycles.getValue()
nc=nc*1.01
N_Cycles.setValue(nc)
E_0=5465.0
h=6.626e-34
m=9.109e-31
k=parameter*1e10
K_v=k*1e-10
hk=(h/(2.*3.1415926))*k
E_joule=hk*hk / (2.*m)
E_eV=E_joule/1.6021e-19+E_0
return E_eV
</script>
</function>
</region>
</positioner>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-SITORO:EraseStart" value="1" operation="putq" type="String" timeout="1000.0" delay="0.075"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-OP2:SMPL" value="1" operation="put" type="String" timeout="1000.0" delay="0.1"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-OP2:SMPL-DONE" value="1" operation="wait" type="Integer" timeout="1000.0" delay="0.03"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-SITORO:StopAll" value="1" operation="put" type="String" timeout="1000.0" delay="0.05"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-SITORO:mca1.READ" value="1" operation="putq" type="String" timeout="1000.0" delay="0.05"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-SITORO:mca2.READ" value="1" operation="putq" type="String" timeout="1000.0" delay="0.05"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-SITORO:mca3.READ" value="1" operation="putq" type="String" timeout="1000.0" delay="0.05"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-SITORO:mca4.READ" value="1" operation="putq" type="String" timeout="1000.0" delay="0.05"/>
<guard>
<condition channel="ACOAU-ACCU:OP-MODE" value="6" type="Integer"/>
<condition channel="X07MA-FE-PH1:CLOSE4BL" value="1" type="Integer"/>
</guard>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-ES-MA1:ScanX.VAL" id="ScanX_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-ES-MA1:ScanY.VAL" id="ScanY_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP-SH2:size.VAL" id="SL2_hor_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP-SV2:size.VAL" id="SL2_vert_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-ES-RONTEC:TRX.VAL" id="DET_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP-MO:E-SET" id="Energy_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP-MO:BEAM-OFS" id="Mono_offset"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="ARIDI-PCT:CURRENT" id="I_SLS"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP2-SAI_07:MEAN" id="I0_KEITHLEY1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP-KEITH1:setGain" id="KEITHLEY1_GAIN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP2-SAI_08:MEAN" id="I1_KEITHLEY2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP-KEITH2:setGain" id="KEITHLEY2_GAIN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP2-SAI_06:MEAN" id="KEITHLEY3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP-KEITH3:setGain" id="KEITHLEY3_GAIN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP2-SAI_01:MEAN" id="KEITHLEY4_TEY"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-OP-KEITH4:setGain" id="KEITHLEY4_GAIN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca1.R0" id="D1_PKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca1.R1" id="D1_VKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca1.R2" id="D1_FeKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca2.R0" id="D2_PKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca2.R1" id="D2_VKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca2.R2" id="D2_FeKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca3.R0" id="D3_PKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca3.R1" id="D3_VKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca3.R2" id="D3_FeKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca4.R0" id="D4_PKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca4.R1" id="D4_VKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca4.R2" id="D4_FeKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:dxp1:InputCountRate" id="D1_ICR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:dxp1:OutputCountRate" id="D1_OCR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca1.ELTM" id="DD1_ELTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca1.ERTM" id="DD1_ERTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca1.DTIM" id="DD1_DTIM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:dxp2:InputCountRate" id="D2_ICR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:dxp2:OutputCountRate" id="D2_OCR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca2.ELTM" id="DD2_ELTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca2.ERTM" id="DD2_ERTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca2.DTIM" id="DD2_DTIM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:dxp3:InputCountRate" id="D3_ICR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:dxp3:OutputCountRate" id="D3_OCR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca3.ELTM" id="DD3_ELTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca3.ERTM" id="DD3_ERTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca3.DTIM" id="DD3_DTIM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:dxp4:InputCountRate" id="D4_ICR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:dxp4:OutputCountRate" id="D4_OCR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca4.ELTM" id="DD4_ELTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca4.ERTM" id="DD4_ERTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X07MB-SITORO:mca4.DTIM" id="DD4_DTIM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayDetector" arraySize="2048" name="X07MB-SITORO:mca1.VAL" id="Spec_1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayDetector" arraySize="2048" name="X07MB-SITORO:mca2.VAL" id="Spec_2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayDetector" arraySize="2048" name="X07MB-SITORO:mca3.VAL" id="Spec_3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayDetector" arraySize="2048" name="X07MB-SITORO:mca4.VAL" id="Spec_4"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Timestamp" id="TimeStamp"/>
</dimension>
<dimension>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="X07MB-ES-MA1:ScanX.VAL" readback="X07MB-ES-MA1:ScanX.RBV" id="ScanX">
<positions> -9.705</positions>
</positioner>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="X07MB-ES-MA1:ScanY.VAL" readback="X07MB-ES-MA1:ScanY.RBV" id="ScanY">
<positions> -21.5176</positions>
</positioner>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="X07MB-OP-SH2:size.VAL" readback="X07MB-OP-SH2:size.RBV" id="SL2_hor">
<positions> 1.0</positions>
</positioner>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="X07MB-OP-SV2:size.VAL" readback="X07MB-OP-SV2:size.RBV" id="SL2_vert">
<positions> 1.0</positions>
</positioner>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="X07MB-ES-RONTEC:TRX.VAL" readback="X07MB-ES-RONTEC:TRX.RBV" id="DET">
<positions> 70.0</positions>
</positioner>
</dimension>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-OP2:START-CSMPL" value="1" operation="put" type="String" delay="0.1"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ShellAction" command="/sls/X07MB/data/settings/Scripts/GUI_X07MB/X_X07MB_write_filename_to_file.sh ${FILENAME} &amp;" exitValue="0"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-OP2:START-CSMPL" value="1" operation="put" type="String" delay="0.1"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X07MB-OP-WV1:WT_SET" value="0" operation="put" type="String" delay="0.1"/>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D1_TrueICR">
<mapping xsi:type="IDParameterMapping" refid="D1_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D1_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD1_ERTM" variable="d"/>
<script>import math
def process(b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR) &lt;&gt; 0:
box = TrueICR
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D2_TrueICR">
<mapping xsi:type="IDParameterMapping" refid="D2_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D2_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD2_ERTM" variable="d"/>
<script>import math
def process(b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR) &lt;&gt; 0:
box = TrueICR
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D3_TrueICR">
<mapping xsi:type="IDParameterMapping" refid="D3_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D3_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD3_ERTM" variable="d"/>
<script>import math
def process(b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR) &lt;&gt; 0:
box = TrueICR
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D4_TrueICR">
<mapping xsi:type="IDParameterMapping" refid="D4_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D4_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD4_ERTM" variable="d"/>
<script>import math
def process(b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR) &lt;&gt; 0:
box = TrueICR
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D1_PKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D1_PKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D1_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D1_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD1_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D2_PKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D2_PKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D2_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D2_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD2_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D3_PKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D3_PKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D3_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D3_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD3_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D4_PKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D4_PKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D4_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D4_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD4_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="PKa_sum_cps">
<mapping xsi:type="IDParameterMapping" refid="D1_PKa_corr" variable="D1_PKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D2_PKa_corr" variable="D2_PKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D3_PKa_corr" variable="D3_PKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D4_PKa_corr" variable="D4_PKa_corr"/>
<script>import math
def process(D1_PKa_corr , D2_PKa_corr , D3_PKa_corr , D4_PKa_corr):
SUM_DET = 0.
SUM_DET = SUM_DET + D1_PKa_corr
SUM_DET = SUM_DET + D2_PKa_corr
SUM_DET = SUM_DET + D3_PKa_corr
SUM_DET = SUM_DET + D4_PKa_corr
return SUM_DET</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D1_VKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D1_VKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D1_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D1_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD1_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D2_VKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D2_VKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D2_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D2_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD2_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D3_VKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D3_VKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D3_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D3_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD3_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D4_VKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D4_VKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D4_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D4_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD4_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="VKa_sum_cps">
<mapping xsi:type="IDParameterMapping" refid="D1_VKa_corr" variable="D1_VKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D2_VKa_corr" variable="D2_VKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D3_VKa_corr" variable="D3_VKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D4_VKa_corr" variable="D4_VKa_corr"/>
<script>import math
def process(D1_VKa_corr , D2_VKa_corr , D3_VKa_corr , D4_VKa_corr):
SUM_DET = 0.
SUM_DET = SUM_DET + D1_VKa_corr
SUM_DET = SUM_DET + D2_VKa_corr
SUM_DET = SUM_DET + D3_VKa_corr
SUM_DET = SUM_DET + D4_VKa_corr
return SUM_DET</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D1_FeKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D1_FeKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D1_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D1_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD1_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D2_FeKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D2_FeKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D2_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D2_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD2_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D3_FeKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D3_FeKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D3_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D3_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD3_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D4_FeKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D4_FeKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D4_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D4_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD4_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="FeKa_sum_cps">
<mapping xsi:type="IDParameterMapping" refid="D1_FeKa_corr" variable="D1_FeKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D2_FeKa_corr" variable="D2_FeKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D3_FeKa_corr" variable="D3_FeKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D4_FeKa_corr" variable="D4_FeKa_corr"/>
<script>import math
def process(D1_FeKa_corr , D2_FeKa_corr , D3_FeKa_corr , D4_FeKa_corr):
SUM_DET = 0.
SUM_DET = SUM_DET + D1_FeKa_corr
SUM_DET = SUM_DET + D2_FeKa_corr
SUM_DET = SUM_DET + D3_FeKa_corr
SUM_DET = SUM_DET + D4_FeKa_corr
return SUM_DET</script>
</manipulation>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D1_ICR D2_ICR D3_ICR D4_ICR D1_TrueICR D2_TrueICR D3_TrueICR D4_TrueICR" title="ICR "/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D1_OCR D2_OCR D3_OCR D4_OCR" title="OCR "/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D1_VKa" title="D1_VKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D2_VKa" title="D2_VKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D3_VKa" title="D3_VKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D4_VKa" title="D4_VKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D1_VKa_corr" title="D1_VKa_corr"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D2_VKa_corr" title="D2_VKa_corr"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D3_VKa_corr" title="D3_VKa_corr"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D4_VKa_corr" title="D4_VKa_corr"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="I0_KEITHLEY1" title="KEITHLEY1 (I0)=f(Energy)"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="I1_KEITHLEY2" title="KEITHLEY2 (I1)=f(Energy)"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="KEITHLEY3" title="KEITHLEY3=f(Energy)"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="KEITHLEY4_TEY" title="KEITHLEY4_TEY=f(Energy)"/>
</configuration>

22
script/test/BugJep2.py Normal file
View File

@@ -0,0 +1,22 @@
writables=inp
readables= (sin,out)
start = 0
end =40
steps =50
latency=0.2
relative=False
passes=1
zigzag=False
latency_ms=int(latency*1000)
writables=to_list(string_to_obj(writables))
readables=to_list(string_to_obj(readables))
#start=to_list(start)
#end=to_list(end)
if type(steps) is float or is_list(steps):
steps = to_list(steps)
scan = scans.LineScan(writables,readables, start, end , steps, relative, latency_ms, int(passes), zigzag)
processScanPars(scan, pars)
scan.start()
ret= scan.getResult()

733
script/test/BugPhenix.xml Normal file
View File

@@ -0,0 +1,733 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="XAS_V_L1677_CN"/>
<variable name="K" value="0.0" description="Buffer K spacing for EXAFS k-spacing scans "/>
<variable name="N_cycles" value="0.0" description="Buffer N_cycles for EXAFS k-spacing scans "/>
<variable name="NINT" value="0.0" description="Counter for file number of Moche files"/>
<scan>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ShellAction" command="/bin/ls" checkExitValue="false"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ShellAction" command="/bin/ls" checkExitValue="false"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="0" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="0" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="0" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="0" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="2" operation="put" type="String" delay="0.05"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="put" type="String" delay="0.07"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="0" operation="put" type="String" delay="0.01"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="put" type="String" delay="0.05"/>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RegionPositioner" name="TESTIOC:TESTCALCOUT:Input" readback="TESTIOC:TESTCALCOUT:Input" settlingTime="0.3" id="Energy">
<region>
<preAction xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1"/>
<start>1.0</start>
<end>2.0</end>
<stepSize>0.2</stepSize>
</region>
<region>
<preAction xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1"/>
<start>2.0</start>
<end>3.0</end>
<stepSize>0.3</stepSize>
</region>
<region>
<start>4.0</start>
<end>5.0</end>
<stepSize>0.4</stepSize>
</region>
</positioner>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="put" type="String" timeout="1000.0" delay="0.1"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="wait" type="Integer" timeout="1000.0" delay="0.03"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="put" type="String" timeout="1000.0" delay="0.05"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="putq" type="String" timeout="1000.0" delay="0.05"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="putq" type="String" timeout="1000.0" delay="0.05"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="putq" type="String" timeout="1000.0" delay="0.05"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="ScanX_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="ScanY_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="SL2_hor_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="SL2_vert_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DET_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="Energy_set"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="Mono_offset"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="I_SLS"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="I0_KEITHLEY1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="KEITHLEY1_GAIN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="I1_KEITHLEY2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="KEITHLEY2_GAIN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="KEITHLEY3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="KEITHLEY3_GAIN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="KEITHLEY4_TEY"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="KEITHLEY4_GAIN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D1_PKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D1_VKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D1_FeKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D2_PKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D2_VKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D2_FeKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D3_PKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D3_VKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D3_FeKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D4_PKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D4_VKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D4_FeKa"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D1_ICR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D1_OCR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD1_ELTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD1_ERTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD1_DTIM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D2_ICR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D2_OCR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD2_ELTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD2_ERTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD2_DTIM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D3_ICR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D3_OCR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD3_ELTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD3_ERTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD3_DTIM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D4_ICR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="D4_OCR"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD4_ELTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD4_ERTM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="DD4_DTIM"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayDetector" arraySize="10" name="TESTIOC:TESTWF2:MyWF" id="Spec_1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayDetector" arraySize="10" name="TESTIOC:TESTWF2:MyWF" id="Spec_2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayDetector" arraySize="10" name="TESTIOC:TESTWF2:MyWF" id="Spec_3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayDetector" arraySize="10" name="TESTIOC:TESTWF2:MyWF" id="Spec_4"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Timestamp" id="TimeStamp"/>
</dimension>
<dimension>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="TESTIOC:TESTCALCOUT:Output" readback="TESTIOC:TESTCALCOUT:Output" id="ScanX">
<positions> 1.0</positions>
</positioner>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="TESTIOC:TESTCALCOUT:Output" readback="TESTIOC:TESTCALCOUT:Output" id="ScanY">
<positions> 1.0</positions>
</positioner>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="TESTIOC:TESTCALCOUT:Output" readback="TESTIOC:TESTCALCOUT:Output" id="SL2_hor">
<positions> 1.0</positions>
</positioner>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="TESTIOC:TESTCALCOUT:Output" readback="TESTIOC:TESTCALCOUT:Output" id="SL2_vert">
<positions> 1.0</positions>
</positioner>
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ArrayPositioner" name="TESTIOC:TESTCALCOUT:Output" readback="TESTIOC:TESTCALCOUT:Output" id="DET">
<positions> 1.0</positions>
</positioner>
</dimension>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="put" type="String" delay="0.1"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ShellAction" command="/bin/ls" exitValue="0"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="put" type="String" delay="0.1"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="0" operation="put" type="String" delay="0.1"/>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D1_TrueICR">
<mapping xsi:type="IDParameterMapping" refid="D1_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D1_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD1_ERTM" variable="d"/>
<script>import math
def process(b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR) &lt;&gt; 0:
box = TrueICR
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D2_TrueICR">
<mapping xsi:type="IDParameterMapping" refid="D2_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D2_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD2_ERTM" variable="d"/>
<script>import math
def process(b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR) &lt;&gt; 0:
box = TrueICR
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D3_TrueICR">
<mapping xsi:type="IDParameterMapping" refid="D3_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D3_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD3_ERTM" variable="d"/>
<script>import math
def process(b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR) &lt;&gt; 0:
box = TrueICR
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D4_TrueICR">
<mapping xsi:type="IDParameterMapping" refid="D4_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D4_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD4_ERTM" variable="d"/>
<script>import math
def process(b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR) &lt;&gt; 0:
box = TrueICR
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D1_PKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D1_PKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D1_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D1_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD1_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D2_PKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D2_PKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D2_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D2_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD2_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D3_PKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D3_PKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D3_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D3_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD3_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D4_PKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D4_PKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D4_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D4_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD4_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="PKa_sum_cps">
<mapping xsi:type="IDParameterMapping" refid="D1_PKa_corr" variable="D1_PKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D2_PKa_corr" variable="D2_PKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D3_PKa_corr" variable="D3_PKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D4_PKa_corr" variable="D4_PKa_corr"/>
<script>import math
def process(D1_PKa_corr , D2_PKa_corr , D3_PKa_corr , D4_PKa_corr):
SUM_DET = 0.
SUM_DET = SUM_DET + D1_PKa_corr
SUM_DET = SUM_DET + D2_PKa_corr
SUM_DET = SUM_DET + D3_PKa_corr
SUM_DET = SUM_DET + D4_PKa_corr
return SUM_DET</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D1_VKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D1_VKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D1_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D1_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD1_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D2_VKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D2_VKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D2_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D2_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD2_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D3_VKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D3_VKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D3_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D3_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD3_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D4_VKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D4_VKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D4_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D4_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD4_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="VKa_sum_cps">
<mapping xsi:type="IDParameterMapping" refid="D1_VKa_corr" variable="D1_VKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D2_VKa_corr" variable="D2_VKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D3_VKa_corr" variable="D3_VKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D4_VKa_corr" variable="D4_VKa_corr"/>
<script>import math
def process(D1_VKa_corr , D2_VKa_corr , D3_VKa_corr , D4_VKa_corr):
SUM_DET = 0.
SUM_DET = SUM_DET + D1_VKa_corr
SUM_DET = SUM_DET + D2_VKa_corr
SUM_DET = SUM_DET + D3_VKa_corr
SUM_DET = SUM_DET + D4_VKa_corr
return SUM_DET</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D1_FeKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D1_FeKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D1_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D1_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD1_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D2_FeKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D2_FeKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D2_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D2_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD2_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D3_FeKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D3_FeKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D3_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D3_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD3_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="D4_FeKa_corr">
<mapping xsi:type="IDParameterMapping" refid="D4_FeKa" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="D4_ICR" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="D4_OCR" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="DD4_ERTM" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = -1.0
return box
if (ICR) == 0:
box = -2.0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
try:
TrueICR = ICR * math.exp(TestICR * DeadTime)
except:
TrueICR = -10.
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=-3.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="FeKa_sum_cps">
<mapping xsi:type="IDParameterMapping" refid="D1_FeKa_corr" variable="D1_FeKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D2_FeKa_corr" variable="D2_FeKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D3_FeKa_corr" variable="D3_FeKa_corr"/>
<mapping xsi:type="IDParameterMapping" refid="D4_FeKa_corr" variable="D4_FeKa_corr"/>
<script>import math
def process(D1_FeKa_corr , D2_FeKa_corr , D3_FeKa_corr , D4_FeKa_corr):
SUM_DET = 0.
SUM_DET = SUM_DET + D1_FeKa_corr
SUM_DET = SUM_DET + D2_FeKa_corr
SUM_DET = SUM_DET + D3_FeKa_corr
SUM_DET = SUM_DET + D4_FeKa_corr
return SUM_DET</script>
</manipulation>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D1_ICR D2_ICR D3_ICR D4_ICR D1_TrueICR D2_TrueICR D3_TrueICR D4_TrueICR" title="ICR "/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D1_OCR D2_OCR D3_OCR D4_OCR" title="OCR "/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D1_VKa" title="D1_VKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D2_VKa" title="D2_VKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D3_VKa" title="D3_VKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D4_VKa" title="D4_VKa"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D1_VKa_corr" title="D1_VKa_corr"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D2_VKa_corr" title="D2_VKa_corr"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D3_VKa_corr" title="D3_VKa_corr"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="D4_VKa_corr" title="D4_VKa_corr"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="I0_KEITHLEY1" title="KEITHLEY1 (I0)=f(Energy)"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="I1_KEITHLEY2" title="KEITHLEY2 (I1)=f(Energy)"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="KEITHLEY3" title="KEITHLEY3=f(Energy)"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="Energy" y="KEITHLEY4_TEY" title="KEITHLEY4_TEY=f(Energy)"/>
</configuration>

249
script/test/BugSuperXAS.xml Normal file
View File

@@ -0,0 +1,249 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="Au_calib"/>
<scan>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Input" value="0" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Input" value="0" operation="put" type="String" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Input" value="0" operation="put" type="String" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Input" value="0" delay="0.1"/>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RegionPositioner" name="TESTIOC:TESTCALCOUT:Input" readback="TESTIOC:TESTCALCOUT:Input" settlingTime="0.3" doneDelay="0.3" asynchronous="false" id="posX">
<region>
<preAction xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="2" operation="put" type="Integer"/>
<start>-8.0</start>
<end>0.0</end>
<stepSize>1.2</stepSize>
</region>
</positioner>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="putq" delay="0.1"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="putq"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" delay="0.6"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" operation="wait" type="Integer" delay="0.2"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="TESTIOC:TESTCALCOUT:Output" value="1" delay="0.1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="Fluo-Ketek1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="SAI01-MEAN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="SAI02-MEAN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="SAI03-MEAN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="Ring-current"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="IntegrTimeSet"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="TESTIOC:TESTCALCOUT:Output" id="IntegrTimeGet"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Timestamp" id="Timestamp"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="dead_time"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="Fluo-Ketek2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="Sca1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ScaICR1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ScaOCR1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ERTM1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="Sca2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ScaICR2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ScaOCR2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ERTM2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="Sca3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ScaICR3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ScaOCR3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ERTM3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="Sca4"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ScaICR4"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ScaOCR4"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ERTM4"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="Sca5"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ScaICR5"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ScaOCR5"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="ERTM5"/>
</dimension>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TrueFluoChannel1">
<mapping xsi:type="IDParameterMapping" refid="Sca1" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="ScaICR1" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="ScaOCR1" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="ERTM1" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = 0
return box
if (ICR) == 0:
box = 0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
TrueICR = ICR * math.exp(TestICR * DeadTime)
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=0.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TrueFluoChannel2">
<mapping xsi:type="IDParameterMapping" refid="Sca2" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="ScaICR2" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="ScaOCR2" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="ERTM2" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = 0
return box
if (ICR) == 0:
box = 0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
TrueICR = ICR * math.exp(TestICR * DeadTime)
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=0.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TrueFluoChannel3">
<mapping xsi:type="IDParameterMapping" refid="Sca3" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="ScaICR3" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="ScaOCR3" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="ERTM3" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = 0
return box
if (ICR) == 0:
box = 0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
TrueICR = ICR * math.exp(TestICR * DeadTime)
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=0.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TrueFluoChannel4">
<mapping xsi:type="IDParameterMapping" refid="Sca4" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="ScaICR4" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="ScaOCR4" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="ERTM4" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = 0
return box
if (ICR) == 0:
box = 0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
TrueICR = ICR * math.exp(TestICR * DeadTime)
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=0.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TrueFluoChannel5">
<mapping xsi:type="IDParameterMapping" refid="Sca5" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="ScaICR5" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="ScaOCR5" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="ERTM5" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = 0
return box
if (ICR) == 0:
box = 0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
TrueICR = ICR * math.exp(TestICR * DeadTime)
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=0.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TotalFluo">
<mapping xsi:type="IDParameterMapping" refid="TrueFluoChannel1" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="TrueFluoChannel2" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="TrueFluoChannel3" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="TrueFluoChannel4" variable="d"/>
<mapping xsi:type="IDParameterMapping" refid="TrueFluoChannel5" variable="e"/>
<script>import math
def process(a,b,c,d,e):
SUM_DET = 0.
SUM_DET = SUM_DET + a
SUM_DET = SUM_DET + b
SUM_DET = SUM_DET + c
SUM_DET = SUM_DET + d
SUM_DET = SUM_DET + e
return SUM_DET</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TotalFluoXAS">
<mapping xsi:type="IDParameterMapping" refid="TotalFluo" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="SAI01-MEAN" variable="d"/>
<script>import math
def process(c,d):
return c/d</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="XAS-refer">
<mapping xsi:type="IDParameterMapping" refid="SAI01-MEAN" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="SAI02-MEAN" variable="b"/>
<script>import math
def process(a,b):
return math.log(math.fabs(a) /math.fabs(b))</script>
</manipulation>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="posX" y="SAI01-MEAN" title=" I0"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="posX" y="SAI02-MEAN" title=" I1"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="posX" y="XAS-refer" title=" XAS-trans"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="posX" y="TotalFluoXAS" title="XAS-Fluo"/>
</configuration>

View File

@@ -0,0 +1,250 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="Au_calib"/>
<scan>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X10DA-SITORO:CollectMode" value="0" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X10DA-ES1:START-CSMPL" value="0" operation="put" type="String" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X10DA-OP-MO3:KohzuModeBO.VAL" value="Auto" operation="put" type="String" delay="0.1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X10DA-SITORO:PresetReal" value="0" delay="0.1"/>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RegionPositioner" name="X10DA-ES1-MA1:TRX" readback="X10DA-ES1-MA1:TRX.VAL" settlingTime="0.3" doneDelay="0.3" asynchronous="false" id="posX">
<region>
<preAction xsi:type="ChannelAction" channel="X10DA-ES1:TOTAL-CYCLES" value="2" operation="put" type="Integer"/>
<start>-8.0</start>
<end>0.0</end>
<stepSize>0.2</stepSize>
</region>
</positioner>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X10DA-SITORO:EraseStart" value="1" operation="putq" delay="0.1"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X10DA-SITORO:Acquiring" value="Acquiring" operation="wait"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X10DA-ES1:SMPL" value="1" delay="0.6"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X10DA-ES1:SMPL-DONE" value="1" operation="wait" type="Integer" delay="0.2"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X10DA-SITORO:StopAll" value="1" delay="0.1"/>
<action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X10DA-SITORO:Acquiring" value="Done" operation="wait"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:CNT1_R0" id="Fluo-Ketek1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-ES1-SAI_01:MEAN" id="SAI01-MEAN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X10DA-ES1-SAI_02:MEAN" id="SAI02-MEAN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X10DA-ES1-SAI_03:MEAN" id="SAI03-MEAN"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="ARIDI-PCT:CURRENT" id="Ring-current"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X10DA-ES1:TOTAL-CYCLES" id="IntegrTimeSet"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" type="Double" name="X10DA-ES1:INTR-COUNT" id="IntegrTimeGet"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Timestamp" id="Timestamp"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:mca1.DTIM" id="dead_time"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:CNT2_R0" id="Fluo-Ketek2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:mca1.R0" id="Sca1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:dxp1:InputCountRate" id="ScaICR1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:dxp1:OutputCountRate" id="ScaOCR1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:mca1.ERTM" id="ERTM1"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:mca2.R0" id="Sca2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:dxp2:InputCountRate" id="ScaICR2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:dxp2:OutputCountRate" id="ScaOCR2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:mca2.ERTM" id="ERTM2"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:mca3.R0" id="Sca3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:dxp3:InputCountRate" id="ScaICR3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:dxp2:OutputCountRate" id="ScaOCR3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:mca3.ERTM" id="ERTM3"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:mca4.R0" id="Sca4"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:dxp4:InputCountRate" id="ScaICR4"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:dxp4:OutputCountRate" id="ScaOCR4"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:mca4.ERTM" id="ERTM4"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:mca5.R0" id="Sca5"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:dxp5:InputCountRate" id="ScaICR5"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:dxp5:OutputCountRate" id="ScaOCR5"/>
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="X10DA-SITORO:mca5.ERTM" id="ERTM5"/>
</dimension>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TrueFluoChannel1">
<mapping xsi:type="IDParameterMapping" refid="Sca1" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="ScaICR1" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="ScaOCR1" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="ERTM1" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = 0
return box
if (ICR) == 0:
box = 0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
TrueICR = ICR * math.exp(TestICR * DeadTime)
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=0.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TrueFluoChannel2">
<mapping xsi:type="IDParameterMapping" refid="Sca2" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="ScaICR2" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="ScaOCR2" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="ERTM2" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = 0
return box
if (ICR) == 0:
box = 0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
TrueICR = ICR * math.exp(TestICR * DeadTime)
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=0.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TrueFluoChannel3">
<mapping xsi:type="IDParameterMapping" refid="Sca3" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="ScaICR3" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="ScaOCR3" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="ERTM3" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = 0
return box
if (ICR) == 0:
box = 0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
TrueICR = ICR * math.exp(TestICR * DeadTime)
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=0.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TrueFluoChannel4">
<mapping xsi:type="IDParameterMapping" refid="Sca4" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="ScaICR4" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="ScaOCR4" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="ERTM4" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = 0
return box
if (ICR) == 0:
box = 0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
TrueICR = ICR * math.exp(TestICR * DeadTime)
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=0.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TrueFluoChannel5">
<mapping xsi:type="IDParameterMapping" refid="Sca5" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="ScaICR5" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="ScaOCR5" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="ERTM5" variable="d"/>
<script>import math
def process(a,b,c,d):
DeadTime = 1.182e-7
ICR = b
OCR = c
if (OCR) == 0:
box = 0
return box
if (ICR) == 0:
box = 0
return box
Test = 1.e8
TestICR = ICR
n = 0
while ((Test &gt; DeadTime) and (n &lt; 30)):
TrueICR = ICR * math.exp(TestICR * DeadTime)
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
if (OCR*d) &lt;&gt; 0:
box = a * TrueICR / OCR / d
if (OCR*d) == 0:
box=0.0
return box</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TotalFluo">
<mapping xsi:type="IDParameterMapping" refid="TrueFluoChannel1" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="TrueFluoChannel2" variable="b"/>
<mapping xsi:type="IDParameterMapping" refid="TrueFluoChannel3" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="TrueFluoChannel4" variable="d"/>
<mapping xsi:type="IDParameterMapping" refid="TrueFluoChannel5" variable="e"/>
<script>import math
def process(a,b,c,d,e):
SUM_DET = 0.
SUM_DET = SUM_DET + a
SUM_DET = SUM_DET + b
SUM_DET = SUM_DET + c
SUM_DET = SUM_DET + d
SUM_DET = SUM_DET + e
return SUM_DET</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="TotalFluoXAS">
<mapping xsi:type="IDParameterMapping" refid="TotalFluo" variable="c"/>
<mapping xsi:type="IDParameterMapping" refid="SAI01-MEAN" variable="d"/>
<script>import math
def process(c,d):
return c/d</script>
</manipulation>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" returnArray="false" id="XAS-refer">
<mapping xsi:type="IDParameterMapping" refid="SAI01-MEAN" variable="a"/>
<mapping xsi:type="IDParameterMapping" refid="SAI02-MEAN" variable="b"/>
<script>import math
def process(a,b):
return math.log(math.fabs(a) /math.fabs(b))</script>
</manipulation>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="posX" y="SAI01-MEAN" title=" I0"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="posX" y="SAI02-MEAN" title=" I1"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="posX" y="XAS-refer" title=" XAS-trans"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="posX" y="TotalFluoXAS" title="XAS-Fluo"/>
</configuration>

View File

@@ -0,0 +1,6 @@
st= Stream("st", "tcp://localhost:5554", SocketType.SUB)
m=st.addMatrix("image")
st.initialize()
st.start(True)
show_panel(m)

View File

@@ -0,0 +1,8 @@
from ijutils import *
ip_list = []
for index in range(40,49):
ip_list.append(open_image(expand_path("{images}/TestObjAligner/i210517_0" + str(index) + "#001.tif")))
stack = create_stack(ip_list, title = "Test")

32
script/test/TSTIMGSIM3.py Normal file
View File

@@ -0,0 +1,32 @@
import traceback
run ("imaging/sim")
show=True
stack = load_test_stack(show=False)
shifts= load_shifts("{images}/TestObjAligner/shifts.mat")
if show:
ret.show()
ret.updateAndDraw()
#stack = load_test_stack(show=True)
#get_context().getPluginManager().loadInitializePlugin("Align_TranslationFilter.java")
#translation_filter = get_context().getClassByName("Align_TranslationFilter").newInstance()
#shifts= load_shifts("{images}/TestObjAligner/shifts.mat")
"""
translation_filter.shifts = shifts
pfr = PlugInFilterRunner(translation_filter, "", "" )
ret = translation_filter.output
if show:
ret.show()
ret.updateAndDraw()
#stack = load_test_stack(show=False)
#r=translate(stack, shifts, True, java_code=True)
"""
#translate(stack, shifts, show=True, java_code=True)

14
script/test/Test2DCont.py Normal file
View File

@@ -0,0 +1,14 @@
STEPS = 10
class Line(ReadonlyRegisterBase):
def doRead(self):
r1 = cscan(m1, (ai1), 0.0, 1.0 , steps=STEPS, save=False)
return r1[ai1]
def getSize(self):
return STEPS+1
line=Line()
lscan(ai2, line, 0, 10, 1.0)

View File

@@ -0,0 +1,24 @@
#av=create_averager(arr,1,)
#print av.sum.read()
#tscan(av.sum, 10,0.1)
#CHANNEL_NAME= "TESTIOC:TESTWF2:MyWF"
#tscan("ca://" + CHANNEL_NAME + "?op=sum", 10, 1.0)
#av=create_averager(arr,1,)
#print av.sum.read()
#tscan(av.sum, 10,0.1)
s = ArrayRegisterStats(arr.cache).sum
s.asyncUpdate=True
tscan((arr,s), 10,1.0)
#plot(ars.sum.read())

View File

@@ -0,0 +1,10 @@
class StringChannel(RegisterBase):
def doRead(self):
return self.val if hasattr(self, 'val') else ""
def doWrite(self, val):
self.val = val
reg=StringChannel()
reg.initialize()
cas3 = CAS("TESTCAS:CH", reg, 'string')

View File

@@ -0,0 +1,47 @@
run("CPython/wrapper")
x=[0,1,2,3,4,5,6,7,8,9]
y=[1,2,3,6,9,6,3,2,1,0]
#(p, x_fit, y_fit, R2) = linfit(x,y)
#plot((y,y_fit), name=("data", "fit"),xdata=(x,x_fit))
#x=to_array(x,'f')
#y=to_array(y,'f')
def _from_npa(obj):
if isinstance(obj, jep.NDArray):
ret = obj.data
if len(obj.dimensions)>1:
ret=Convert.reshape(ret, obj.dimensions)
return ret
if isinstance(obj, java.util.List) or isinstance(obj,tuple) or isinstance(obj,list):
ret=[]
for i in range(len(obj)):
ret.append(_from_npa(obj[i]))
if isinstance(obj,tuple):
return type(ret)
return ret
return obj
def _to_npa(obj):
if isinstance(obj, PyArray):
return to_npa(obj, dimensions = Arr.getShape(obj))
if isinstance(obj, java.util.List) or isinstance(obj,tuple) or isinstance(obj,list):
ret=[]
for i in range(len(obj)):
ret.append(_to_npa(obj[i]))
if isinstance(obj,tuple):
return tuple(ret)
return ret
return obj
def call_py(module, function, *args):
print _to_npa(args)
ret = call_jep(module, function, _to_npa(args))
return _from_npa(ret)
#ret = call_py("CPython/linfit", "linfit",x,y)
(p, x_fit, y_fit, R2) = call_py("CPython/linfit", "linfit",x,y)
#(p, x_fit, y_fit, R2) = linfit(x,y)
plot((y,y_fit), name=("data", "fit"),xdata=(x,x_fit))

1
script/test/TestCmd.py Normal file
View File

@@ -0,0 +1 @@
exec_cmd("ls")

View File

@@ -0,0 +1,31 @@
###################################################################################################
# This is an option to implement a 2D continuous scan
###################################################################################################
STEPS_M1 = 10
STEPS_M2 = 5
class Sensor(ReadableArray):
def read(self):
r1 = cscan(m1, (ai1), 0.0, 1.0 , steps=STEPS_M1, save=False, display=False)
return r1[ai1]
def getSize(self):
return STEPS_M1+1
def getName(self):
return "sensor"
"""
p = plot(None, title="2d Plot")[0]
def after_read(record, scan):
if record.setpoints[1] == scan.getStart()[1]:
p.addSeries(LinePlotSeries(str(record[ao1])))
p.getSeries(p.numberOfSeries-1).appendData(record[ao2], record[ai1])
"""
set_exec_pars(print_scan=True)
#lscan(m2, Sensor(), 0, 1.0, STEPS_M2, after_read=after_read)
s1=Sensor()
lscan(m2, s1, 0, 1.0, STEPS_M2)

24
script/test/TestConfig.py Normal file
View File

@@ -0,0 +1,24 @@
#Jython BUG: Sometimes getConfig(self) won'' override ProcessVariableBase.getConfig.
#E.g.: energy.getUnit() fails (calls getConfig)
#But energy.getConfig() works
class Energy(ControlledVariableBase):
def __init__(self, name):
ControlledVariableBase.__init__(self, name, None)
self.setReadback(phi.readback)
def doRead(self):
return phi.read()
def doWrite(self, val):
print "Do something"
phi.write(val)
def getConfig(self):
print "Get"
return phi.getConfig()
add_device(Energy("energy",), True)

View File

@@ -4,7 +4,7 @@
#Creating a 1D dataset from an array
path="group/data1"
path="data1"
data1d = [1.0, 2.0, 3.0, 4.0, 5.0]
save_dataset(path, data1d)
#Reading ii back
@@ -15,7 +15,7 @@ plot(read)
#Creating a 2D dataset from an array with some attributes
data2d = [ [1.0, 2.0, 3.0, 4.0, 5.0], [2.0, 3.0, 4.0, 5.0, 6.0, ], [3.0, 4.0, 5.0, 6.0, 7.0]]
path="group/data2"
path="data2"
save_dataset(path, data2d)
set_attribute(path, "AttrString", "Value")
set_attribute(path, "AttrInteger", 1)
@@ -28,7 +28,7 @@ plot(read)
#Creating a 3D dataset from an array
data3d = [ [ [1,2,3,4,5], [2,3,4,5,6], [3,4,5,6,7]], [ [3,2,3,4,5], [4,3,4,5,6], [5,4,5,6,7]]]
path="group/data3"
path="data3"
save_dataset(path, data3d)
#Reading it back
read =load_data(path,0)
@@ -37,28 +37,28 @@ read =load_data(path,1)
print read.tolist()
#Creating a INT dataset adding elements one by one
path = "group/data4"
path = "data4"
create_dataset(path, 'i')
for i in range(10):
append_dataset(path,i)
#Creating a 2D data FLOAT dataset adding lines one by one
path = "group/data5"
path = "data5"
create_dataset(path, 'd', False, (0,0))
for row in data2d:
append_dataset(path, row)
#Creating a Table (compund type)
path = "group/data6"
path = "data6"
names = ["a", "b", "c", "d"]
types = ["d", "d", "d", "[d"]
table_types = ["d", "d", "d", "[d"]
lenghts = [0,0,0,5]
table = [ [1,2,3,[0,1,2,3,4]],
[2,3,4,[3,4,5,6,7]],
[3,4,5,[6,7,8,9,4]] ]
create_table(path, names, types, lenghts)
create_table(path, names, table_types, lenghts)
for row in table:
append_table(path, row)
flush_data()
@@ -68,11 +68,11 @@ print read
#Writing scalars (datasets with rank 0)
save_dataset("group/val1", 1)
save_dataset("group/val2", 3.14)
save_dataset("group/val3", "test")
print load_data("group/val1")
print load_data("group/val2")
print load_data("group/val3")
save_dataset("val1", 1)
save_dataset("val2", 3.14)
save_dataset("val3", "test")
print load_data("val1")
print load_data("val2")
print load_data("val3")

View File

@@ -0,0 +1,14 @@
scale_min=100
scale_max=150
colormap = Colormap.Temperature #Colormap.Grayscale
while(True):
try:
i=image.data.toBufferedImage(scale_min, scale_max, colormap, False)
show_panel(i)
except:
print sys.exc_info()[2]
break
time.sleep(1.0)

View File

@@ -0,0 +1,24 @@
import ch.psi.utils.swing.SwingUtils as SwingUtils
import ch.psi.pshell.swing.DiscretePositionerPanel as DiscretePositionerPanel
import ch.psi.pshell.swing.DiscretePositionerSelector as DiscretePositionerSelector
import ch.psi.pshell.swing.RegisterPanel as RegisterPanel
"""
setp = scienta.getChannelCtrl()+":LENS_MODE"
rbck = scienta.getChannelCtrl()+":LENS_MODE_RBV"
dp = DiscretePositioner("lens_mode", setp, rbck)
dp.monitored=True
add_device(dp, True)
pn=DiscretePositionerSelector()
pn.setDevice(dp)
SwingUtils.showDialog(App.getInstance().mainFrame, dp.name, None, pn)
show_panel(dp)
"""
reg=sin #scienta.getEnergyStepSize()
rp=RegisterPanel()
rp.setDevice(None)
SwingUtils.showDialog(App.getInstance().mainFrame, reg.name, None, rp)

View File

@@ -0,0 +1,6 @@
class Measurement (ImageMeasurement):
def calc(self, data):
return data.getRoi(Rectangle(10,10,20,20)).integrate(False)
tscan(Measurement(src2, "roi"), 10, 0.2)

View File

@@ -0,0 +1,31 @@
def after_read(rec,scan):
print rec[energy], rec[sin]
#r = mscan(energy, sin.cache, after_read=after_read)
#Execute the scan: sample undefined number of samples until a condition is met, with auto range
scan_completed=False
def after_read(record, scan):
global scan_completed
print record[sin]
if motor.isReady():
scan_completed=True
scan.abort()
motor.move(0.0)
motor.moveAsync(3.0)
try:
r = mscan(motor.readback, [motor.readback, sin.cache], after_read=after_read, range=[0.0, 3.0], domain_axis=motor.readback.name)
except ScanAbortedException as ex:
if not scan_completed: raise
motor.moveAsync(0.0)
print r[sin]
#print r[0][sin]
print r[0][motor.readback]

21
script/test/TestJEP.py Normal file
View File

@@ -0,0 +1,21 @@
from jeputils import import_py
import_py("CPython/linfit", "linfit")
import_py("CPython/gfitoff", "gfitoff")
x=[0,1,2,3,4,5,6,7,8,9]
y=[1,2,3,6,9,6,3,2,1,0]
(p, x_fit, y_fit, R2) = linfit(x,y)
#print "Fit: ", (p, x_fit, y_fit, R2)
plot((y,y_fit), name=("data", "fit"),xdata=(x,x_fit))
from mathutils import Gaussian
x=to_array([-200.30429237268825, -200.2650700434188, -200.22115208318002, -199.9457671375377, -199.86345548879072, -199.85213073174933, -199.35687977133284, -199.13811861090275, -197.97304970346386, -197.2952215624348, -195.09076092936948, -192.92276048970703, -191.96871876227698, -189.49577852322938, -187.9652790409825, -183.63756456925222, -180.04899765472996, -178.43839623242422, -174.07311671294445, -172.0410133577918, -165.90824309893102, -160.99771795989466, -159.30176653939253, -154.27688897558514, -152.0854103810786, -145.75652847587313, -140.80843828908465, -139.23982133191495, -134.27073891256106, -132.12649284133064, -125.95947209775511, -121.00309550337462, -119.26736932643232, -114.2706655484383, -112.07393889578914, -105.72295990367157, -100.8088439880125, -99.2034906238494, -94.30042325164636, -92.15010048151461, -85.92203653534293, -81.03913275494665, -79.27412793784428, -74.33487658582118, -72.06274362408762, -65.76562628131825, -60.91255356825276, -59.20334389560392, -54.33286972659312, -52.19387171350535, -45.94978737932291, -41.03014719193582, -39.301602568238906, -34.35572209014114, -32.04464301272608, -25.8221033382824, -20.922074315528747, -19.21590299233186, -14.31090212502093, -12.217203140101386, -5.9283722049240435, -0.9863587170369246, 0.7408048387279834, 5.71126832601389, 7.972628957879352, 14.204559894256546, 19.11839959633025, 20.8218087836657, 25.678748486941828, 27.822718344586864, 34.062659474970715, 38.9745656819391, 40.77409719734158, 45.72080631619803, 47.974156754056835, 54.23453768983539, 59.12020360609568, 60.77306570712026, 65.70734521458867, 67.8344660434617, 74.03187028154134, 78.96532114824849, 80.76070945985495, 85.74802197591286, 87.9140889204674, 94.18082276873524, 99.25790470037091, 100.68454787413205, 105.7213026221542, 107.79483801526698, 113.99555681638138, 119.0707052529143, 120.72715813056156, 125.77551384921307, 127.91257836719551, 134.2011330887875, 139.23043006997628, 140.71673537840158, 145.76288138835983, 147.80216629676042, 154.06420451405637, 159.0846626604798, 160.76183155710717, 165.73699067536242, 167.9265357747636, 173.96705069576544, 178.2522282751915, 179.9042617354548, 183.54586165856657, 185.23269803071796, 189.41678143751972, 191.87149157986588, 192.8741468985015, 195.0241934550453, 195.966634211846, 197.9821647518146, 198.99006812859284, 199.33202054855676, 199.91897441965887, 200.11536227958896, 200.22280936469997, 200.25181179127208],'d')
y=to_array([11.0, 6.0, 8.0, 5.0, 11.0, 7.0, 18.0, 11.0, 12.0, 10.0, 8.0, 6.0, 16.0, 4.0, 12.0, 9.0, 15.0, 14.0, 8.0, 20.0, 15.0, 8.0, 9.0, 11.0, 13.0, 12.0, 13.0, 15.0, 13.0, 20.0, 10.0, 7.0, 17.0, 11.0, 20.0, 13.0, 13.0, 23.0, 14.0, 10.0, 17.0, 15.0, 20.0, 16.0, 14.0, 13.0, 18.0, 22.0, 9.0, 20.0, 12.0, 14.0, 17.0, 19.0, 14.0, 14.0, 23.0, 19.0, 15.0, 20.0, 20.0, 21.0, 20.0, 23.0, 22.0, 15.0, 10.0, 17.0, 21.0, 15.0, 23.0, 23.0, 25.0, 18.0, 16.0, 21.0, 22.0, 16.0, 16.0, 14.0, 19.0, 20.0, 18.0, 20.0, 23.0, 13.0, 16.0, 20.0, 25.0, 15.0, 15.0, 17.0, 22.0, 26.0, 19.0, 30.0, 25.0, 17.0, 17.0, 23.0, 16.0, 27.0, 21.0, 21.0, 26.0, 27.0, 21.0, 17.0, 20.0, 20.0, 21.0, 19.0, 25.0, 19.0, 13.0, 23.0, 20.0, 20.0, 18.0, 20.0, 19.0, 25.0],'d')
[off, amp, com, sigma] = gfitoff(x, y, off=None, amp=None, com=None, sigma=None)
#print "Fit: ", [off, amp, com, sigma]
g = Gaussian(amp, com, sigma)
plot([y, [g.value(i)+off for i in x]], ["data", "fit"], xdata = x)

View File

@@ -1,39 +1,16 @@
tutorial_path = "src/main/assembly/help/Tutorial_py/"
run(tutorial_path+"SimulatedDevices")
import ch.psi.pshell.data.LayoutDefault
class LayoutParallelScan(ch.psi.pshell.data.LayoutDefault):
class MyLayout(ch.psi.pshell.data.LayoutDefault):
def getDefaultGroup(self, scan):
return scan.readables[0].name
return str("test")
get_context().dataManager.setLayout(MyLayout())
#get_context().pluginManager.addDynamicClass(LayoutParallel().getClass())
tscan (sin,10,0.1)
writer = get_context().dataManager.provider.writer
o=writer.object()
o.createSoftLink("/test/sin", "/data/data1")
o.createHardLink("/test/sin", "/data/data2")
#Does not work
#lay = LayoutParallelScan().getClass()
##print lay
#cls = Class.forName(lay.getCanonicalName(), True, lay.getClassLoader())
#3print cls
#set_exec_pars(layout = "org.python.proxies.__main__$LayoutParallelScan$25")
#Must restore the layout
#get_context().dataManager.setLayout(LayoutParallelScan())
set_exec_pars(layout = "Table")
def scan1():
print "scan1"
return lscan(ao1, ai1, 0, 40, 20, 0.1, title = "scan1")
def scan2():
print "scan2"
return lscan(ao2, ai2, 0, 40, 20, 0.1, title = "scan2")
parallelize(scan1, scan2)
o.createSoftLink("/test", "/link1") #Not supported
o.createHardLink("/test", "/link2")

View File

@@ -0,0 +1,7 @@
master = MasterPositioner("master",mu, delta, gamma, eta)
add_device(master, True)
add_device(master.motorGroup, True)
show_panel(master)
show_panel(master.motorGroup)

View File

@@ -0,0 +1,3 @@
for i in frange(0.0, 1.0, 0.1):
master.move(i)
print mu.take(), delta.take(), gamma.take(), eta.take()

View File

@@ -0,0 +1,4 @@
def before_read():
time.sleep(1.0)
tscan((sin,scienta.dataMatrix, det.dataMatrix), 5, 0.1, before_read=before_read, save=False, plot_types={scienta.dataMatrix:"ch.psi.pshell.plot.MatrixPlotRenderer"})

23
script/test/TestMonit.py Normal file
View File

@@ -0,0 +1,23 @@
def after_read(rec, scan):
if rec[sin] < 19.0:
rec.invalidate()
time.sleep(0.05)
print "Refused " + str(rec["sin"]) + " at " + str (time.time()- start)
else:
print "Acccepted " + str(rec["sin"]) + " at " + str (time.time()- start)
start= time.time()
r1 = mscan(sin, [sin, out],-1, 3, async=False, after_read=after_read)
print r1.getSize()
r2 = mscan(sin, [sin, out],-1, 3, async=True, after_read=after_read)
print r2.getSize()
r3 = mscan(sin, [sin, out],10, 4, async=False, after_read=after_read)
print r3.getSize()
r4 = mscan(sin, [sin, out],10, 4, async=True, after_read=after_read)
print r4.getSize()
#r1 = lscan(energy, [sin],0, 1, 10, 0.1, after_read=after_read)
#r1 = tscan(sin, 50, 0.1, fixed_rate = True, domain_axis="Time", after_read=after_read)

View File

@@ -0,0 +1,9 @@
def after_read(rec, scan):
if rec["sin"] < 15.0:
rec.invalidate()
time.sleep(0.1)
r1 = mscan(sin, [sin], 25, after_read=after_read)

125
script/test/TestMonitor.py Normal file
View File

@@ -0,0 +1,125 @@
###################################################################################################
# Example of saving diagostics and snapshots during a scan
###################################################################################################
DIAGS = [ai2]
SNAPS = [ai3, wf1]
ret = lscan(m1, ai1, 0.0, 1.0, 4, diags=DIAGS, snaps=SNAPS)
plot(ret.getSnap(wf1))
plot(ret.getDiag(ai2))
#All devices can be directly indexd
for dev in [m1, ai1, ai2, wf1, ai3]:
print dev.name, " -> ", ret[dev]
#Changing default folders
LayoutBase.PATH_SNAPS = "initial/"
LayoutBase.PATH_DIAGS = "status/"
LayoutBase.PATH_MONITORS = "events/"
LayoutBase.PATH_LOGS = "logbook/"
ret = lscan(m1, ai1, 0.0, 1.0, 4, diags=DIAGS, snaps=SNAPS)
ret = tscan(out, 10, 0.2, diags=[inp, arr], monitors=[inp, sin], snapshots=[inp, motor])
#set_exec_pars(flush=True)
#print ret[out]
print ret[sin]
print ret["arr"]
print ret[motor]
#print ret.getDiag(sin)
#print ret.getDiag(arr)
#ret = tscan(out, 10, 0.2, monitors=[sin, arr])
#plot(ret[sin][1], xdata=ret[sin][0])
#plot(ret[out], xdata=ret.timestamps)
"""
class OtfValue(ReadonlyAsyncRegisterBase):
def __init__(self, name):
ReadonlyAsyncRegisterBase.__init__(self, name)
def setValue(self, value,timestamp):
self.setCache(value,timestamp)
class OTF(Otf):
def __init__(self, name):
Otf.__init__(self, name)
self.addComponent(OtfValue("Channel1"))
self.addComponent(OtfValue("Channel2"))
self.components[0].setValue(float("NaN"), long(time.time()*10e6))
self.components[1].setValue(-1, long(time.time()*10e6))
self.initialize()
self.interrupted = False
def task(self):
start = time.time()
finished=False
while not self.interrupted and not finished:
time.sleep(0.1)
self.components[0].setValue(time.time(), long(time.time()*10e6))
finished = (time.time()-start)> 5.0
if not self.interrupted:
for i in range(20):
self.components[1].setValue(i, long(time.time()*10e6))
self.getLogger().info("Finished OTF")
self.state=State.Ready
def start(self):
self.state=State.Busy
self.interrupted = False
self.thread = fork(self.task)
def abort(self):
self.interrupted = True
self.getLogger().info("Interrupting OTF thread")
join(self.thread)
add_device(OTF("otf"), True)
ret = tscan(out, 10, 0.2, monitors=[otf])
"""
"""
class OTF(Otf):
def __init__(self, name):
Otf.__init__(self, name)
self.setCache(float("NaN"), long(time.time()*10e6))
self.initialize()
self.interrupted = False
def task(self):
start = time.time()
finished=False
while not self.interrupted and not finished:
time.sleep(0.1)
self.setCache(time.time(), long(time.time()*10e6))
finished = (time.time()-start)> 5.0
self.getLogger().info("Finished OTF")
self.state=State.Ready
def start(self):
self.state=State.Busy
self.interrupted = False
self.thread = fork(self.task)
def abort(self):
self.interrupted = True
self.getLogger().info("Interrupting OTF thread")
join(self.thread)
add_device(OTF("otf"), True)
ret = tscan(out, 10, 0.2, monitors=[otf])
plot(ret[otf][1], xdata=ret[otf][0])
"""
set_return(None)

View File

@@ -0,0 +1,44 @@
def append_dataset(path, data, index=None, type='d', shape=None):
"""Append data to dataset.
Args:
path(str): Path to dataset relative to the current persistence context root.
data(number or array or list): name of each column.
index(int or list, optional): if set then add the data in a specific position in the dataset.
If integer is the index in an array (data must be 1 order lower than dataset)
If a list, specifies the full coordinate for multidimensional datasets.
type(str, optional): array type 'b' = byte, 'h' = short, 'i' = int, 'l' = long, 'f' = float,
'd' = double, 'c' = char, 's' = String, 'o' = Object
default: 'd' (convert data to array of doubles)
shape(list, optional): only valid if index is a list, provides the shape of the data array.
In this case data must be a flattened one-dimensional array.
Returns:
None
"""
data = to_array(data, type)
if index is None:
get_context().dataManager.appendItem(path, data)
else:
if is_list(index):
if shape is None:
shape = [len(index)]
get_context().dataManager.setItem(path, data, index, shape)
else:
get_context().dataManager.setItem(path, data, index)
path = "data/data4d"
data3d = [ [ [1,2,3,4,5], [2,3,4,5,6], [3,4,5,6,7], [4,5,6,7,8]],
[ [2,2,3,4,5], [3,3,4,5,6], [5,4,5,6,7], [7,5,6,7,8]],
[ [3,2,3,4,5], [4,3,4,5,6], [6,4,5,6,7], [8,5,6,7,8]] ]
plot(data3d)
data = flatten(to_array(data3d,'i))
#save_dataset(path, data4d)
create_dataset(path, 'i', dimensions = [2, 3, 4, 5])
append_dataset(path, data, index = [0,0,0,0], type = 'i', shape=[1, 3, 4, 5])

View File

@@ -0,0 +1,30 @@
from jeputils import import_py
from mathutils import Gaussian
import traceback
import_py("CPython/linfit", "linfit")
import_py("CPython/gfitoff", "gfitoff")
def task(index):
try:
print index
x=[0,1,2,3,4,5,6,7,8,9]
y=[1,2,3,6,9,6,3,2,1,0]
(p, x_fit, y_fit, R2) = linfit(x,y)
#print "Fit: ", (p, x_fit, y_fit, R2)
plot((y,y_fit), name=("data", "fit"),xdata=(x,x_fit), title=str(index))
x=to_array([-200.30429237268825, -200.2650700434188, -200.22115208318002, -199.9457671375377, -199.86345548879072, -199.85213073174933, -199.35687977133284, -199.13811861090275, -197.97304970346386, -197.2952215624348, -195.09076092936948, -192.92276048970703, -191.96871876227698, -189.49577852322938, -187.9652790409825, -183.63756456925222, -180.04899765472996, -178.43839623242422, -174.07311671294445, -172.0410133577918, -165.90824309893102, -160.99771795989466, -159.30176653939253, -154.27688897558514, -152.0854103810786, -145.75652847587313, -140.80843828908465, -139.23982133191495, -134.27073891256106, -132.12649284133064, -125.95947209775511, -121.00309550337462, -119.26736932643232, -114.2706655484383, -112.07393889578914, -105.72295990367157, -100.8088439880125, -99.2034906238494, -94.30042325164636, -92.15010048151461, -85.92203653534293, -81.03913275494665, -79.27412793784428, -74.33487658582118, -72.06274362408762, -65.76562628131825, -60.91255356825276, -59.20334389560392, -54.33286972659312, -52.19387171350535, -45.94978737932291, -41.03014719193582, -39.301602568238906, -34.35572209014114, -32.04464301272608, -25.8221033382824, -20.922074315528747, -19.21590299233186, -14.31090212502093, -12.217203140101386, -5.9283722049240435, -0.9863587170369246, 0.7408048387279834, 5.71126832601389, 7.972628957879352, 14.204559894256546, 19.11839959633025, 20.8218087836657, 25.678748486941828, 27.822718344586864, 34.062659474970715, 38.9745656819391, 40.77409719734158, 45.72080631619803, 47.974156754056835, 54.23453768983539, 59.12020360609568, 60.77306570712026, 65.70734521458867, 67.8344660434617, 74.03187028154134, 78.96532114824849, 80.76070945985495, 85.74802197591286, 87.9140889204674, 94.18082276873524, 99.25790470037091, 100.68454787413205, 105.7213026221542, 107.79483801526698, 113.99555681638138, 119.0707052529143, 120.72715813056156, 125.77551384921307, 127.91257836719551, 134.2011330887875, 139.23043006997628, 140.71673537840158, 145.76288138835983, 147.80216629676042, 154.06420451405637, 159.0846626604798, 160.76183155710717, 165.73699067536242, 167.9265357747636, 173.96705069576544, 178.2522282751915, 179.9042617354548, 183.54586165856657, 185.23269803071796, 189.41678143751972, 191.87149157986588, 192.8741468985015, 195.0241934550453, 195.966634211846, 197.9821647518146, 198.99006812859284, 199.33202054855676, 199.91897441965887, 200.11536227958896, 200.22280936469997, 200.25181179127208],'d')
y=to_array([11.0, 6.0, 8.0, 5.0, 11.0, 7.0, 18.0, 11.0, 12.0, 10.0, 8.0, 6.0, 16.0, 4.0, 12.0, 9.0, 15.0, 14.0, 8.0, 20.0, 15.0, 8.0, 9.0, 11.0, 13.0, 12.0, 13.0, 15.0, 13.0, 20.0, 10.0, 7.0, 17.0, 11.0, 20.0, 13.0, 13.0, 23.0, 14.0, 10.0, 17.0, 15.0, 20.0, 16.0, 14.0, 13.0, 18.0, 22.0, 9.0, 20.0, 12.0, 14.0, 17.0, 19.0, 14.0, 14.0, 23.0, 19.0, 15.0, 20.0, 20.0, 21.0, 20.0, 23.0, 22.0, 15.0, 10.0, 17.0, 21.0, 15.0, 23.0, 23.0, 25.0, 18.0, 16.0, 21.0, 22.0, 16.0, 16.0, 14.0, 19.0, 20.0, 18.0, 20.0, 23.0, 13.0, 16.0, 20.0, 25.0, 15.0, 15.0, 17.0, 22.0, 26.0, 19.0, 30.0, 25.0, 17.0, 17.0, 23.0, 16.0, 27.0, 21.0, 21.0, 26.0, 27.0, 21.0, 17.0, 20.0, 20.0, 21.0, 19.0, 25.0, 19.0, 13.0, 23.0, 20.0, 20.0, 18.0, 20.0, 19.0, 25.0],'d')
[off, amp, com, sigma] = gfitoff(x, y, off=None, amp=None, com=None, sigma=None)
#print "Fit: ", [off, amp, com, sigma]
g = Gaussian(amp, com, sigma)
plot([y, [g.value(i)+off for i in x]], ["data", "fit"], xdata = x, title=str(index))
except:
traceback.print_exc()
task(0)
for i in range(3):
fork((task,(i+1,)))

View File

@@ -0,0 +1,32 @@
add_device(PipelineStream("p","localhost:8889", "simulation_sp"), True)
set_exec_pars(save=False)
#tscan(p.channels,10,0.1)
#Sync with stopped stream
p.update() #First update to create children devices
x_profile= p.getChannel("x_profile")
tscan((p,x_profile),3,0.1)
#Async on running stream
p.monitored=True
p.stream.waitValueChange(-1)
class StreamImage(ReadableMatrix):
def read(self):
return Convert.reshape(p.getValue("image") , (self.getHeight(), self.getWidth()))
def getWidth(self):
return p.getValue("width")
def getHeight(self):
return p.getValue("height")
mscan(p, StreamImage(), 5)
#Sync on running stream
tscan(p.channels,5,0.5)

View File

@@ -0,0 +1,8 @@
DIAGS = [wf1,im1]
SNAPS = [wf1,im1]
ret = lscan(m1, ai1, 0.0, 1.0, 4, diags=DIAGS, snaps=SNAPS)
plot(ret.getSnap(wf1))
plot(ret.getDiag(im1))

149
script/test/TestSpectrum.py Normal file
View File

@@ -0,0 +1,149 @@
#If running from editor
if (get_exec_pars().source == CommandSource.ui):
ROI = {"Region1": [10,5,20, 10], "Region2": [60,60,40, 40]}
SAVE_SPECTRUM = True
SAVE_IMAGES = True
WITH_I0 = False
SWITCH_POL = False
EXPOSURE = 1.0
AVERAGE = 2
NUMBER_SCANS =1
RANGES = [[500.0, 1000.0, 100.0]]
print "Starting AbsSpec: ",SAVE_SPECTRUM, SAVE_IMAGES, WITH_I0, SWITCH_POL, EXPOSURE, AVERAGE, NUMBER_SCANS, RANGES
run("eiger")
machine_cur=sin
Keithley_1_raw = cv
def get_dry_run():
return True
def set_outliers_threshold(value):
set_setting("OUTLIERS_THRESHOLD", int(value))
def get_outliers_threshold():
try:
return int(get_setting("OUTLIERS_THRESHOLD"))
except:
return 0
def get_outliers_mask_file():
return get_setting("OUTLIERS_MASK_FILE")
if SWITCH_POL:
init_pol_switch("Normal")
log("ROIs: " + str(ROI))
if len(RANGES) == 0:
raise Exception("No scan range defined")
start = time.time()
init_eiger(exposure=EXPOSURE)
set_exec_pars(name="AbsortionSpectrum", format="csv", layout="table")
tag= "AbsortionSpectrum_{seq}%03d_{count}%02d"
rois = create_roi_devices(ROI)
if AVERAGE>1:
for i in range(len(rois)):
rois[i].monitored = True
rois[i] = create_averager(rois[i], AVERAGE, -1)
rois[i].monitored = True
frames=[]
class SyncEnergy(Writable):
def write(self,pos):
if not get_dry_run():
put_energy(pos)
else:
print "Energy=" + str(pos)
sync_energy=SyncEnergy()
set_device_alias(sync_energy, "Energy") #Set display name
sensors = rois + [machine_cur]
if WITH_I0:
sensors = sensors + [Keithley_1_raw]
####
def __save_as_tiff(index, data, filename,metadata={}):
if type(data) == Data:
ip = load_array(data.matrix)
else:
ip = data
metadata["Timestamp"] = time.strftime("%y/%m/%d %H:%M:%S",time.localtime())
if not os.path.exists(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
save_image(ip, filename,"tiff", metadata)
d = get_ip_array(ip)
import java.util.Arrays as Arrays
ip=open_image(filename)
read = get_ip_array(ip)
if not Arrays.deepEquals(read, d):
print "Error reading array"
print index, filename
index=0
for name,r in ROI.items():
s=0.0
for i in range(r[2]):
for j in range(r[3]):
#s = s + d[r[0]+i][r[1]+j]
el=data.getElement(r[0]+i, r[1]+j, False)
s = s + (0 if (math.isnan(el)) else el)
roi = data.getRoi(Rectangle(r[0],r[1], r[2], r[3]))
print name, s, rois[index].take(), roi.integrate(False)
index=index+1
####
av=None
def grab_image(position, scan):
global av
av = average_eiger_frames(AVERAGE, roi=None, wait_next=True)
if SAVE_IMAGES:
filename = get_exec_pars().path + "/" + str(scan.currentPass) + "/s" + "{seq}%03d" + "_" + ("%03d.tif" % scan.recordIndex)
filename = get_context().setup.expandPath(filename)
#print filename
#save_as_tiff(av, filename, metadata={})
#fork((__save_as_tiff,(scan.recordIndex, av, filename)),)
__save_as_tiff(scan.recordIndex, av, filename)
class Average(ReadableMatrix):
def read(self):
return av.matrix
def getWidth(self):
return image.getData().getWidth()
def getHeight(self):
return image.getData().getHeight()
averager=Average()
set_device_alias(averager, "Image") #Set display name
sensors.append(averager)
#Initialize vartiables
if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
open_vg10()
def after_pass(pass_number, scan):
if SWITCH_POL:
if pass_number<scan.numberOfPasses:
switch_pol()
try:
rscan(sync_energy, sensors, RANGES, latency = 0.0 , passes = NUMBER_SCANS, tag=tag, before_read=grab_image, save=SAVE_SPECTRUM, split=True, keep=False, after_pass=after_pass)
finally:
if AVERAGE>1:
for i in range(len(rois)):
rois[i].parent.monitored = False # Remove listeners on the image
if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
close_vg10()
restore_eiger()
print "Running time: " + str(time.time() - start)

View File

@@ -0,0 +1,15 @@
STREAM_URL="tcp://localhost:5552"
st1=Stream("st1", STREAM_URL, SocketType.SUB)
st1.createMatrix = True
st1.initialize()
st1.start()
st1.waitCacheChange(2000)
show_panel(st1)
#bscan(st1, 10, -1)

View File

@@ -2,22 +2,33 @@ import ch.psi.pshell.bs.Provider as Provider
url="tcp://localhost:9999"
url="tcp://SFTEST-CVME-DBPM1:9001"
#url= "tcp://SIN-CVME-DBPM0421:9000"
p=Provider("provider", url, True)
p.config.keepListeningOnStop = True
p.config.parallelHandlerProcessing = False
p.config.byteBufferAllocator = True
st1 = Stream("st1", p)
url="tcp://localhost:5553"
#url="tcp://localhost:10101"
#p=Provider("provider", url, False)
#p.config.keepListeningOnStop = True
#p.config.parallelHandlerProcessing = False
#p.config.byteBufferAllocator = True
#st1 =
st1=Stream("st1", url, SocketType.SUB)
#st1.addScalar("scalar")
#st1.addMatrix("img")
#st1.addScalar("str")
#st1.addWaveform("waveform")
st1.initialize()
st1.start()
st1.waitCacheChange(20000)
st1.waitCacheChange(2000)
#try:
# bscan (st1, 5, 5, save=False)
#finally:
# st1.close()
"""
try:
bscan (st1, 5, 5, save=False)
finally:
st1.close()
try:
print st1.getValues()
finally:
st1.close()
"""

21
script/test/TestStrip.py Normal file
View File

@@ -0,0 +1,21 @@
import random
####################################################################################################
# Simulated Devices
####################################################################################################
class AnalogInput(ReadonlyRegisterBase):
def doRead(self):
time.sleep(0.001)
self.val = to_array(self.calc(), 'd')
return self.val
class Random(AnalogInput):
def calc(self):
return random.random()
for i in range(20):
r=Random("r"+str(i))
add_device(r, True)
r.polling=5

View File

@@ -0,0 +1,2 @@
CUSTOM_PLOT_TYPES = {scienta.dataMatrix:"ch.psi.pshell.plot.TablePlot"}
tscan(scienta.dataMatrix, 5, 0.1, save=False, plot_types=CUSTOM_PLOT_TYPES)

View File

@@ -0,0 +1,24 @@
import ch.psi.utils.swing.Terminal as Terminal
import ch.psi.utils.swing.SwingUtils as SwingUtils
terminal=None
view=App.getInstance().getMainFrame()
tabStatus=view.getStatusTab()
def showTerminal():
global terminal
terminal = Terminal(".", 13)
tabStatus.addTab("T", terminal)
index = tabStatus.getTabCount() - 1
SwingUtils.setTabClosable(tabStatus, index)
tabStatus.setSelectedComponent(terminal)
def hideTerminal():
global terminal
if terminal is not None:
tabStatus.remove(terminal)
terminal = None
for i in range (100):
showTerminal()
hideTerminal()

2
script/test/TestVscan.py Normal file
View File

@@ -0,0 +1,2 @@
vector = [ 1, 3, 5, 10, 25, 40, 45, 47, 49]
r1 = vscan(motor,(sin),vector,False, 0.5, relative=True,title = "1D Vector", before_read=None, after_read=None)

43
script/test/TstImgSim.py Normal file
View File

@@ -0,0 +1,43 @@
run ("imaging/sim")
stack = load_test_stack(show=True)
ipr, ipi = complex_edge_filtering(stack, complex=True, g_sigma = 3.0, show=False)
#complex_edge_filter = get_context().getClassByName("Align_ComplexEdgeFiltering").newInstance()
#translation_filter = get_context().getClassByName("Align_TranslationFilter2").newInstance()
#compute_shifts_filter = get_context().getClassByName("Align_ComputeShifts2").newInstance()
"""
ip_list = []
for index in range(40,49):
ip_list.append(open_image(expand_path("{images}/TestObjAligner/i210517_0" + str(index) + "#001.tif")))
stack = create_stack(ip_list, title = "Test")
stack.show()
complex_edge_filter.setup("2,True,False", stack) #Gaussian blur radius, Complex (True) or Real (False), show dialog = False
complex_edge_filter.r"un(stack.getProcessor())
imp_r, imp_i = complex_edge_filter.output
#imp_r.show()
#imp_i.show()
roi=Roi(258,0,256,256)
compute_shifts_filter.setup(10, False, ipr, ipi, 1, roi)
compute_shifts_filter.run(None)
shifts = compute_shifts_filter.shifts
translation_filter.shifts = shifts
translation_filter.setup("",stack)
translation_filter.run(stack.getProcessor())
translation_filter.registred.show();
translation_filter.registred.updateAndDraw();
"""
roi=Roi(258,0,256,256)
shifts = calculate_shifts(ipr, ipi, roi, 2)
r=translate(stack, shifts, True)

44
script/test/TstImgSim2.py Normal file
View File

@@ -0,0 +1,44 @@
from ijutils import Roi
#from sim import *
import traceback
run ("imaging/sim")
roi=Roi(0,0,128,128)
"""
stack = load_test_stack(show=True, size=2)
ipr, ipi = complex_edge_filtering(stack, show=False)
shifts = calculate_shifts(ipr, ipi, roi, java_code=True)
#shifts= load_shifts("{images}/TestObjAligner/shifts.mat")
#stack = load_test_stack(show=True)
r=translate(stack, shifts, show=True)
"""
ref = "{images}/TestObjAligner/i210517_040#001.tif"
img = "{images}/TestObjAligner/i210517_041#001.tif"
ref = open_image(ref)
img = open_image(img)
#ref=ref.getBufferedImage()
#img=img.getBufferedImage()
#ref=ca.data
img=grayscale(to_ip(ca.data))
ref = grayscale(ref.crop([Roi(0,0,452,452)])[0])
def calculate_shift(ref,img, roi, upscale_factor=100, reference_slide=1):
ref = to_ip(ref)
img = to_ip(img)
stack = create_stack([ref,img])
stack.show()
ipr, ipi = complex_edge_filtering(stack, show=False)
shifts = calculate_shifts(ipr, ipi, roi, java_code=True)
xoff, yoff = shifts[1][3], shifts[1][2]
error, diffphase = shifts[1][4], shifts[1][5]
r=translate(stack, shifts, show=True)
return xoff, yoff,error, diffphase
print calculate_shift(ref,img, roi)

View File

@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.psi.ch/~ebner/models/scan/1.0" numberOfExecution="1" failOnSensorError="true">
<data format="txt" fileName="VERSI_BEAMSTOP_SCAN"/>
<variable name="X_INIT" value="-2.0"/>
<variable name="X_FINAL" value="2.0"/>
<scan>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES3:START-CSMPL" value="1"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES3:SET-DCT-TIME" value="0.2"/>
<preAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES3:SMPL-BTN" value="1"/>
<cdimension zigzag="false" dataGroup="false">
<positioner name="X05LA-ES2-VERSI:TRXDO" id="versiBS_TRX">
<start>-2.0</start>
<end>2.0</end>
<stepSize>0.1</stepSize>
<integrationTime>0.2</integrationTime>
<additionalBacklash>0.25</additionalBacklash>
</positioner>
<detector name="TRIGGER1" scr="false" id="trigger"/>
<detector name="X05LA-ES3-SAI_06:CUR-MEAN" scr="true" id="SAI_BS_Diode"/>
<detector name="X05LA-ES3-SAI_05:CUR-MEAN" scr="true" id="microChamber"/>
<detector name="X05LA-ES3-SAI_07:CUR-MEAN" scr="true" id="transSiCDiode"/>
<detector name="X05LA-EH-QEM1:SumAll:MeanValue_RBV" scr="true" id="BMtotal"/>
<detector name="MTEST-X05LA-ES2-XRAYEYE:FEMTO-MEAN-CURR" scr="true" id="XrayEye"/>
</cdimension>
<dimension zigzag="false" dataGroup="false">
<positioner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinearPositioner" name="X05LA-ES2-VERSI:TRYDO" settlingTime="0.05" asynchronous="false" id="versiBS_TRY">
<start>0.0</start>
<end>2.0</end>
<stepSize>0.1</stepSize>
<startVar>X_INIT</startVar>
<endVar>X_FINAL</endVar>
</positioner>
</dimension>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES2-VERSI:TRXDO" value="0"/>
<postAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChannelAction" channel="X05LA-ES2-VERSI:TRYDO" value="0"/>
<manipulation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScriptManipulation" id="MANIP">
<script>def process():
return X_INIT + caget("X05LA-ES2-MA:6DTRY")
</script>
</manipulation>
</scan>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="versiBS_TRX" y="versiBS_TRY" z="SAI_BS_Diode" title="BS Diode"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="versiBS_TRX" y="versiBS_TRY" z="microChamber" title="I0"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="versiBS_TRX" y="versiBS_TRY" z="transSiCDiode" title="Si Diode"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlot" x="versiBS_TRX" y="versiBS_TRY" z="XrayEye" title="XrayEye"/>
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="versiBS_TRX" y="MANIP"/>
</configuration>

View File

@@ -1,3 +1,4 @@
def calc(a):
return a*4
print calc(10)

3128
script/test/inspect.py Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More