From bf1060b656946f17677b17918991538708d4d3ec Mon Sep 17 00:00:00 2001 From: gac-furka Date: Thu, 4 Sep 2025 11:21:05 +0200 Subject: [PATCH] Sep.2025 --- config/config.properties | 30 ++-- config/jcae.properties | 2 +- config/preferences.json | 137 ++++++++++++++++++ config/setup.properties | 22 +-- config/variables.properties | 4 +- devices/Camera Server.properties | 25 ++++ devices/CameraServer.properties | 25 ++++ devices/CurrentCamera.properties | 22 ++- devices/Image Integrator.properties | 25 ++++ devices/Time.properties | 11 ++ devices/cam_server.properties | 10 +- devices/dispatcher.properties | 8 +- devices/image.properties | 25 ++++ script/Eugenio_test.py | 7 + script/optimizeRIXS.py | 61 ++++++++ script/test/TestCScript.py | 5 + script/test/TestCamera.py | 15 ++ script/test/TestCameraScan.py | 30 ++++ script/test/TestStream.py | 19 +++ script/test/single_photon.c | 214 ++++++++++++++++++++++++++++ 20 files changed, 662 insertions(+), 35 deletions(-) create mode 100644 config/preferences.json create mode 100644 devices/Camera Server.properties create mode 100644 devices/CameraServer.properties create mode 100644 devices/Image Integrator.properties create mode 100644 devices/Time.properties create mode 100644 devices/image.properties create mode 100644 script/Eugenio_test.py create mode 100644 script/optimizeRIXS.py create mode 100644 script/test/TestCScript.py create mode 100644 script/test/TestCamera.py create mode 100644 script/test/TestCameraScan.py create mode 100644 script/test/TestStream.py create mode 100644 script/test/single_photon.c diff --git a/config/config.properties b/config/config.properties index e1a31ca..4dac07b 100644 --- a/config/config.properties +++ b/config/config.properties @@ -1,13 +1,16 @@ -#Tue Jul 13 11:02:20 CEST 2021 +#Thu Sep 04 11:18:13 CEST 2025 autoSaveScanData=true simulation=false +xscanCrlogicChannel=null dataScanSaveOutput=false userAuthenticator= dataScanSaveScript=false notifiedTasks= parallelInitialization=false +fdaSerialization=false dataTransferPath= saveConsoleSessionFiles=false +xscanAppendSuffix=true hostName= disableEmbeddedAttributes=false serverPort=8080 @@ -16,17 +19,24 @@ dataPath={data}/{year}_{month}/{date}/{date}_{time}_{name} serverEnabled=false depthDimension=0 logLevel=Info -dataLayout=default +dataLayout=sf disableDataFileLogs=false +dataScanSaveTimestamps=false sessionHandling=Off terminalEnabled=false notificationLevel=Off terminalPort=3579 dataTransferUser= -versionTrackingLogin={context}/svcusr-hlapp_robot +xscanContinuousUpdate=false +versionTrackingLogin=auto noBytecodeFiles=false -versionTrackingRemote=git@git.psi.ch\:pshell_config/satesf.git +versionTrackingRemote=https\://gitea.psi.ch/pshell_config/satesf.git +dataScanLazyTableCreation=false +pythonHome= +xscanMoveTimeout=600 +commandExecutionEvents=false logDaysToLive=30 +xscanCrlogicSimulated=false logLevelConsole=Off filePermissionsConfig=Public scanStreamerPort=-1 @@ -37,12 +47,16 @@ userManagement=false instanceName=FU dataServerPort=-1 hideServerMessages=false -dataScanReleaseRecords=false -dataScanPreserveTypes=false +dataScanReleaseRecords=true +dataScanPreserveTypes=true dataScanFlushRecords=false logPath={logs}/{date}_{time} -filePermissionsLogs=Protected -filePermissionsScripts=Group +filePermissionsLogs=Public +filePermissionsScripts=Public +xscanCrlogicPrefix=null filePermissionsData=Default +xscanCrlogicAbortable=true +createSessionFiles=false dataProvider=h5 +xscanCrlogicIoc=null saveCommandStatistics=false diff --git a/config/jcae.properties b/config/jcae.properties index dc49acc..3f16f2e 100644 --- a/config/jcae.properties +++ b/config/jcae.properties @@ -1,4 +1,4 @@ -#Tue Jul 13 10:47:57 CEST 2021 +#Thu Mar 02 09:41:37 CET 2023 ch.psi.jcae.ContextFactory.addressList= ch.psi.jcae.ContextFactory.serverPort= ch.psi.jcae.ContextFactory.maxArrayBytes=50000000 diff --git a/config/preferences.json b/config/preferences.json new file mode 100644 index 0000000..0c11fcb --- /dev/null +++ b/config/preferences.json @@ -0,0 +1,137 @@ +{ + "fontShellPanel" : { + "name" : "Monospaced", + "style" : 0, + "size" : 13 + }, + "fontShellCommand" : { + "name" : "SansSerif", + "style" : 0, + "size" : 13 + }, + "fontOutput" : { + "name" : "Monospaced", + "style" : 0, + "size" : 13 + }, + "fontEditor" : { + "name" : "Monospaced", + "style" : 0, + "size" : 13 + }, + "fontPlotLabel" : { + "name" : "SansSerif", + "style" : 0, + "size" : 11 + }, + "fontPlotTick" : { + "name" : "SansSerif", + "style" : 0, + "size" : 10 + }, + "fontPlotTitle" : { + "name" : "SansSerif", + "style" : 1, + "size" : 13 + }, + "fontTerminal" : { + "name" : "Monospaced", + "style" : 0, + "size" : 14 + }, + "tabSize" : 4, + "contentWidth" : 0, + "editorBackground" : null, + "editorForeground" : null, + "simpleEditor" : false, + "hideEditorLineNumbers" : false, + "hideEditorContextMenu" : false, + "consoleLocation" : "Left", + "dataPanelLocation" : "Status", + "openDataFilesInDocTab" : false, + "noVariableEvaluationPropagation" : false, + "processingScripts" : [ ], + "asyncViewersUpdate" : false, + "asyncHistoryPlotsUpdate" : false, + "scanPlotDisabled" : false, + "scanTableDisabled" : false, + "cachedDataPanel" : false, + "dataExtensions" : "", + "dataSubFiles" : "", + "hideFileName" : false, + "showEmergencyStop" : false, + "showHomingButtons" : false, + "showJogButtons" : false, + "hideScanPanel" : false, + "hideOutputPanel" : false, + "showXScanFileBrowser" : false, + "showQueueBrowser" : false, + "backgroundRendering" : false, + "showImageStatusBar" : true, + "persistRendererWindows" : false, + "defaultRendererColormap" : "Grayscale", + "linePlot" : "ch.psi.pshell.plot.LinePlotJFree", + "matrixPlot" : "ch.psi.pshell.plot.MatrixPlotJFree", + "surfacePlot" : "null", + "timePlot" : "ch.psi.pshell.plot.TimePlotJFree", + "plotsDetached" : false, + "plotsHidden" : false, + "plotLayout" : "Vertical", + "quality" : "High", + "defaultPlotColormap" : "Temperature", + "markerSize" : 2, + "plotBackground" : null, + "gridColor" : null, + "outlineColor" : null, + "disableOffscreenBuffer" : false, + "defaultPanels" : [ { + "deviceClassName" : "ch.psi.pshell.epics.Scaler", + "panelClassName" : "ch.psi.pshell.swing.ScalerPanel" + }, { + "deviceClassName" : "ch.psi.pshell.epics.Scienta", + "panelClassName" : "ch.psi.pshell.swing.ScientaPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.Motor", + "panelClassName" : "ch.psi.pshell.swing.MotorPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.MasterPositioner", + "panelClassName" : "ch.psi.pshell.swing.MasterPositionerPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.ProcessVariable", + "panelClassName" : "ch.psi.pshell.swing.ProcessVariablePanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.MotorGroup", + "panelClassName" : "ch.psi.pshell.swing.MotorGroupPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.DiscretePositioner", + "panelClassName" : "ch.psi.pshell.swing.DiscretePositionerPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.Camera", + "panelClassName" : "ch.psi.pshell.swing.CameraPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.Slit", + "panelClassName" : "ch.psi.pshell.swing.SlitPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.HistogramGenerator", + "panelClassName" : "ch.psi.pshell.swing.HistogramGeneratorPanel" + }, { + "deviceClassName" : "ch.psi.pshell.bs.Stream", + "panelClassName" : "ch.psi.pshell.swing.StreamPanel" + }, { + "deviceClassName" : "ch.psi.pshell.bs.StreamChannel", + "panelClassName" : "ch.psi.pshell.swing.StreamChannelPanel" + }, { + "deviceClassName" : "ch.psi.pshell.camserver.CamServerStream", + "panelClassName" : "ch.psi.pshell.swing.CamServerStreamPanel" + }, { + "deviceClassName" : "ch.psi.pshell.camserver.CamServerService", + "panelClassName" : "ch.psi.pshell.swing.CamServerServicePanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.ReadonlyRegister$ReadonlyRegisterArray", + "panelClassName" : "ch.psi.pshell.swing.DeviceValueChart" + }, { + "deviceClassName" : "ch.psi.pshell.device.ReadonlyRegister$ReadonlyRegisterMatrix", + "panelClassName" : "ch.psi.pshell.swing.DeviceValueChart" + } ], + "scriptPopupDialog" : "None" +} \ No newline at end of file diff --git a/config/setup.properties b/config/setup.properties index 303a64d..6517743 100644 --- a/config/setup.properties +++ b/config/setup.properties @@ -1,23 +1,25 @@ -#Tue Jul 13 10:19:02 CEST 2021 +#Tue Aug 16 17:06:20 CEST 2022 scriptPath={home}/script sessionsPath={outp}/sessions -pluginsPath={home}/plugins configFileDevices={config}/devices.properties -consoleSessionsPath={sessions}/console -libraryPath={script}; {script}/Lib -contextPath={outp}/context -configFilePlugins={config}/plugins.properties +xscanPath={script} +queuePath={script} extensionsPath={home}/extensions configPath={home}/config configFileSessions={config}/sessions.properties userSessionsPath={sessions}/user dataPath={outp}/data -devicesPath={home}/devices configFileVariables={config}/variables.properties -configFileSettings={config}/settings.properties wwwPath={home}/www logPath={outp}/log -imagesPath={outp}/images configFile={config}/config.properties -scriptType=py configFileTasks={config}/tasks.properties +pluginsPath={home}/plugins +consoleSessionsPath={sessions}/console +libraryPath={script}; {script}/Lib +contextPath={outp}/context +configFilePlugins={config}/plugins.properties +devicesPath={home}/devices +configFileSettings={config}/settings.properties +imagesPath={outp}/images +scriptType=py diff --git a/config/variables.properties b/config/variables.properties index dcd571b..5e7c4a2 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,2 +1,4 @@ -#Tue Jul 13 10:26:28 CEST 2021 +#Thu Aug 14 17:54:29 CEST 2025 +LastRunDate=230706 DaySequentialNumber=0 +FileSequentialNumber=38 diff --git a/devices/Camera Server.properties b/devices/Camera Server.properties new file mode 100644 index 0000000..bfafbd2 --- /dev/null +++ b/devices/Camera Server.properties @@ -0,0 +1,25 @@ +#Fri Jan 28 13:02:14 CET 2022 +spatialCalOffsetY=NaN +spatialCalOffsetX=NaN +colormapLogarithmic=false +scale=1.0 +grayscale=false +spatialCalScaleX=NaN +spatialCalScaleY=NaN +colormapMax=NaN +rescaleOffset=0.0 +roiWidth=-1 +colormap=Grayscale +invert=false +colormapMin=NaN +rotation=0.0 +rotationCrop=false +rescaleFactor=1.0 +spatialCalUnits=mm +flipVertically=false +roiHeight=-1 +flipHorizontally=false +colormapAutomatic=false +roiY=0 +roiX=0 +transpose=false diff --git a/devices/CameraServer.properties b/devices/CameraServer.properties new file mode 100644 index 0000000..4ac9e77 --- /dev/null +++ b/devices/CameraServer.properties @@ -0,0 +1,25 @@ +#Mon Jan 16 16:00:16 CET 2023 +spatialCalOffsetY=NaN +spatialCalOffsetX=NaN +colormapLogarithmic=false +scale=1.0 +grayscale=false +spatialCalScaleX=NaN +spatialCalScaleY=NaN +colormapMax=NaN +rescaleOffset=0.0 +roiWidth=-1 +colormap=Grayscale +invert=false +colormapMin=NaN +rotation=0.0 +rotationCrop=false +rescaleFactor=1.0 +spatialCalUnits=mm +flipVertically=false +roiHeight=-1 +flipHorizontally=false +colormapAutomatic=false +roiY=0 +roiX=0 +transpose=false diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index 4a4a0b8..2db809a 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,21 +1,27 @@ -#Tue Jul 13 10:41:25 CEST 2021 -spatialCalOffsetY=-50.11933174224343 -spatialCalOffsetX=-50.11933174224343 +#Thu Sep 04 11:18:24 CEST 2025 +00= +spatialCalOffsetY=5.000000083214129 +spatialCalOffsetX=97.00000825529783 colormapLogarithmic=false scale=1.0 grayscale=false -spatialCalScaleX=-1.0 -spatialCalScaleY=-1.0 -colormapMax=255.0 +iY=0 +spatialCalScaleX=-41.322312446489725 +spatialCalScaleY=-41.32231376540493 +colormapMax=40.0 rescaleOffset=0.0 roiWidth=-1 -colormap=Flame +colormap=Grayscale +imageWidth=2528 invert=false colormapMin=0.0 rotation=0.0 rotationCrop=false rescaleFactor=1.0 +imageHeight=162 spatialCalUnits=mm +0= +1= flipVertically=false roiHeight=-1 flipHorizontally=false @@ -23,3 +29,5 @@ colormapAutomatic=true roiY=0 roiX=0 transpose=false +regionStartX=33 +regionStartY=1000 diff --git a/devices/Image Integrator.properties b/devices/Image Integrator.properties new file mode 100644 index 0000000..a000887 --- /dev/null +++ b/devices/Image Integrator.properties @@ -0,0 +1,25 @@ +#Tue May 23 15:34:25 CEST 2023 +spatialCalOffsetY=-50.08912655971479 +spatialCalOffsetX=-50.01953888237593 +colormapLogarithmic=false +scale=1.0 +grayscale=false +spatialCalScaleX=-1.0 +spatialCalScaleY=-1.0 +colormapMax=7.0 +rescaleOffset=0.0 +roiWidth=-1 +colormap=Temperature +invert=false +colormapMin=0.0 +rotation=0.0 +rotationCrop=false +rescaleFactor=1.0 +spatialCalUnits=mm +flipVertically=false +roiHeight=-1 +flipHorizontally=false +colormapAutomatic=true +roiY=0 +roiX=0 +transpose=false diff --git a/devices/Time.properties b/devices/Time.properties new file mode 100644 index 0000000..65076d2 --- /dev/null +++ b/devices/Time.properties @@ -0,0 +1,11 @@ +#Mon Jan 30 10:57:25 CET 2023 +minValue=NaN +unit=null +offset=0.0 +maxValue=NaN +rotation=false +precision=-1 +sign_bit=0 +scale=1.0 +description=null +resolution=NaN diff --git a/devices/cam_server.properties b/devices/cam_server.properties index 4d2a40a..a790293 100644 --- a/devices/cam_server.properties +++ b/devices/cam_server.properties @@ -1,11 +1,11 @@ -#Tue Jul 13 10:38:24 CEST 2021 -spatialCalOffsetY=NaN -spatialCalOffsetX=NaN +#Wed Dec 08 16:50:32 CET 2021 +spatialCalOffsetY=-50.10141987829615 +spatialCalOffsetX=-50.075987841945285 colormapLogarithmic=false scale=1.0 grayscale=false -spatialCalScaleX=NaN -spatialCalScaleY=NaN +spatialCalScaleX=-1.0 +spatialCalScaleY=-1.0 colormapMax=NaN rescaleOffset=0.0 roiWidth=-1 diff --git a/devices/dispatcher.properties b/devices/dispatcher.properties index ab0b56a..87ee3de 100644 --- a/devices/dispatcher.properties +++ b/devices/dispatcher.properties @@ -1,12 +1,14 @@ -#Tue Jul 13 10:39:33 CEST 2021 +#Tue Nov 28 10:33:39 CET 2023 +sendStrategy=complete_all keepListeningOnStop=false disableCompression=false sendBuildChannelConfig=at_startup parallelHandlerProcessing=true +analizeHeader=false +sendAwaitFirstMessage=false +headerReservingAllocator=false socketType=DEFAULT validationInconsistency=keep_as_is byteBufferAllocator=false mappingIncomplete=fill_null sendSyncTimeout=0 -sendStrategy=complete_all -sendAwaitFirstMessage=false diff --git a/devices/image.properties b/devices/image.properties new file mode 100644 index 0000000..9552775 --- /dev/null +++ b/devices/image.properties @@ -0,0 +1,25 @@ +#Tue Jul 13 11:39:18 CEST 2021 +spatialCalOffsetY=NaN +spatialCalOffsetX=NaN +colormapLogarithmic=false +scale=1.0 +grayscale=false +spatialCalScaleX=NaN +spatialCalScaleY=NaN +colormapMax=NaN +rescaleOffset=0.0 +roiWidth=-1 +colormap=Grayscale +invert=false +colormapMin=NaN +rotation=0.0 +rotationCrop=false +rescaleFactor=1.0 +spatialCalUnits=mm +flipVertically=false +roiHeight=-1 +flipHorizontally=false +colormapAutomatic=false +roiY=0 +roiX=0 +transpose=false diff --git a/script/Eugenio_test.py b/script/Eugenio_test.py new file mode 100644 index 0000000..d3036e6 --- /dev/null +++ b/script/Eugenio_test.py @@ -0,0 +1,7 @@ + +channel_x = Channel('S10BD01-DBPM020:X1') +channel_y = Channel('SINSB01-RSYS:SET-BEAM-PHASE') + + +av = create_averager(channel_x, 10, 0.1) +#lscan(channel_y, av, 70., 90., 20, latency=0.5) \ No newline at end of file diff --git a/script/optimizeRIXS.py b/script/optimizeRIXS.py new file mode 100644 index 0000000..c243c3d --- /dev/null +++ b/script/optimizeRIXS.py @@ -0,0 +1,61 @@ +N_POSITION_BAND = 10.0 + + + # EInkommentieren fuer Messungen Mit PSCR136 + # Auskommentieren fuer Messungen Mit PCEL + # +cam_server.start("SATES21-CAMS-PATT1", True) +cam_server.stream.waitCacheChange(-1) +i= cam_server.stream.getChild("x_fwhm") +i_avg = create_averager(i, 30, interval = -1) + + +# muss auskommentiert bleiben +#Keithley = Channel("SATOP31-CSSU-PCEL1381:READOUT",'d', monitored ='True') + +#_avg = create_averager(Keithley, 5, interval = -1) + +def beam_ok(): + I0 = caget ("SATFE10-PEPG046:PHOTON-ENERGY-PER-PULSE-AVG") + if I0 > 100: + return "Yes" + else : + return "No" + + +def before_sampling(rec): + while beam_ok() == "No": + time.sleep(0.1) + print(".") + +def after_sampling(rec): + if beam_ok() == "No": + rec.invalidate() + + +i0 = Channel("SATFE10-PEPG046:PHOTON-ENERGY-PER-PULSE-AVG",'d') + + +class VLSSGM(RegisterBase): + def doWrite(self, value): + caput ("SATOP11-OSGM087:SetEnergy", value) + time.sleep(0.2) + cawait('SATOP11-OSGM087:MOVING', 1, timeout = 20.0, type = 'i') + def doRead(self): + return caget("SATOP11-OSGM087:photonenergy") + +athos = VLSSGM() +athos.initialize() + +#lscan( athos, [i0,i_avg], 520.0, 540, 1.0, 0.5, setpoints=True,zigzag=True) # Scans mit PSCR136 +#lscan( athos, [i0,K_avg], 833.5, 837, 0.05, 0.5, setpoints=True,zigzag=True) # Scans mit PCEL + + + +#caput ("ATHOS:SetEnergy", 680.0) +tscan( [i_avg], 10, 1 , passes=1) + + + + + diff --git a/script/test/TestCScript.py b/script/test/TestCScript.py new file mode 100644 index 0000000..da80aba --- /dev/null +++ b/script/test/TestCScript.py @@ -0,0 +1,5 @@ +add_device(Stream("st", "sf-daqsync-15.psi.ch:9006", SocketType.PULL), True) +st.start() +show_panel(st) + +bscan(st, 10, -1, save=False, lazy=True) diff --git a/script/test/TestCamera.py b/script/test/TestCamera.py new file mode 100644 index 0000000..04e3ea5 --- /dev/null +++ b/script/test/TestCamera.py @@ -0,0 +1,15 @@ +CAMERA = "SATES30-RIXS-CAM01" +CAMERA = "SATES31-CAMS187-RIXS1" +CAMERA = "SATES30-CAMS182-GIGE5" +CAMERA_URL = caget(CAMERA + ":BSREADCONFIG").replace("tcp://daq", "tcp://") +#CAMERA_URL ="tcp://129.1.247.78:8199" +print CAMERA_URL + +st1 = Stream("st1", CAMERA_URL, SocketType.PULL) +#st1.debug=True +st1.initialize() +st1.start() +st1.waitCacheChange(1000) + +show_panel(st1) +#add_device(st1.getChildren()[0], True) \ No newline at end of file diff --git a/script/test/TestCameraScan.py b/script/test/TestCameraScan.py new file mode 100644 index 0000000..9aaa2dc --- /dev/null +++ b/script/test/TestCameraScan.py @@ -0,0 +1,30 @@ +CAMERA = "SATES30-RIXS-CAM01" +CAMERA_URL = caget(CAMERA + ":BSREADCONFIG").replace("tcp://daq", "tcp://") +SAMPLES = 3 +TIMEOUT = 10.0 +CHANNEL_IMG = CAMERA+":FPICTURE" + + +add_device(Stream("cs", CAMERA_URL, SocketType.PULL), True) +#image = cs.addMatrix(CAMERA+":FPICTURE") +cs.createMatrix = True +cs.start() +cs.waitCacheChange(3000) + + +image = cs.getChild(CHANNEL_IMG) +add_device(image, True) + + +PLOT_TYPES={CHANNEL_IMG:"ch.psi.pshell.plot.MatrixPlotRenderer"} +#bscan(cs, 5, None) + + + +bscan(cs, SAMPLES, TIMEOUT, enabled_plots=[cs]) +#add_device(st1.getChildren()[0], True) + + + +mscan(image, image, SAMPLES, TIMEOUT, plot_types=PLOT_TYPES) +tscan (image, 3, 1.0, plot_types=PLOT_TYPES) \ No newline at end of file diff --git a/script/test/TestStream.py b/script/test/TestStream.py new file mode 100644 index 0000000..bf56c86 --- /dev/null +++ b/script/test/TestStream.py @@ -0,0 +1,19 @@ +#Add device: will be visible in Device tab -> device panel is opened double clicking the device name. +#In the device panel you can plot data double-clicking each chanel. +add_device (Stream("st", cam_server.getStream("SATES30-RIXS-CAM01_proc"), SocketType.PULL), True) +st.start() + +#Open the panel programatically +show_panel(st) + +#Saves and displays 5 messages +bscan(st, 5) + +#Saves and displays messages for 3 seconds, plotting arrays as line plots (1d) +bscan(st, -1, 3.0, line_plots=list(st.getChildren())) + +#Just saves the stream, no display (Good idea if 100Hz) +bscan(st, -1, 3.0, display=False) + +#Just displays the stream, no saving +bscan(st, 5, -1, save=False, line_plots=list(st.getChildren())) \ No newline at end of file diff --git a/script/test/single_photon.c b/script/test/single_photon.c new file mode 100644 index 0000000..eb84e6b --- /dev/null +++ b/script/test/single_photon.c @@ -0,0 +1,214 @@ +#include "module.c" +#include +#include +#include +#include +#include + + +const char *CHANNEL_NAMES[] = {"EVENT_NUM", "EVENT_I", "EVENT_J", "EVENT_CHARGE", "EVENT_ETA_X", "EVENT_ETA_Y", "EVENT_I_INTERP", "EVENT_J_INTERP"}; + + +const int MAX_NUM_EVENTS= 100; // max number of events per frame +const int EVENT_CHANNELS = 7; + + +struct events_double func_ph_1d_double( double *frame, int i_dim, int j_dim, double *th_m); +//struct decl. +struct events_double { + double **evnt_ijc; + int evnt_num; +}; + + + +//def process_image(image, pulse_id, timestamp, x_axis, y_axis, parameters, bsdata=None): +PyObject *process(PyObject *self, PyObject *args) +{ + PyArrayObject *image; + long pulse_id; + PyObject /*double*/ *timestamp; + long seconds, nanos; + PyArrayObject *x_axis; + PyArrayObject *y_axis; + PyObject *pars; + PyObject *bsdata; + + //if (!PyArg_ParseTuple(args, "OldOOO|O", &image, &pulse_id, ×tamp, &x_axis, &y_axis, &pars, &bsdata)) + if ( !PyArg_ParseTuple(args, "OlOOOO|O", &image, &pulse_id, ×tamp, &x_axis, &y_axis, &pars, &bsdata) || + !PyArg_ParseTuple(timestamp, "ll", &seconds, &nanos) ) + return NULL; + + if (pulse_id < 0) { + PyErr_SetString(moduleErr, "Invalid Pulse ID"); + return NULL; + } + + //Acessing image + int element_size = image->descr->elsize; + int dims = image->nd; + int size_x = image->dimensions[1]; + int size_y = image->dimensions[0]; + unsigned short* img_data = (unsigned short*)image->data; + + + int i,j,l; + int i_dim=size_y; + int j_dim=size_x; + + double *threshold = malloc(i_dim*j_dim*sizeof(double)); + for(i=0; i=MAX_NUM_EVENTS){ + break; + } + for(j=0;j=MAX_NUM_EVENTS){ + break; + } + + + // 2x2 version + charge = frame[i*j_dim+j]+frame[(i+1)*j_dim+j] + frame[i*j_dim+(j+1)]+frame[(i+1)*j_dim+j+1]; + + //pixel by pixel threshold + th = th_m[i*j_dim +j]; + + //check if charge above threshold + if(charge>th) { + eta_x = (frame[(i+1)*j_dim + j ]+frame[(i+1)*j_dim + (j+1)])/charge; + eta_y = (frame[ i*j_dim + (j+1)]+frame[(i+1)*j_dim + (j+1)])/charge; + i_interp = i + (C[0] + C[1]*eta_x+ C[2]*pow(eta_x,2) + C[3]*pow(eta_x,3) + C[4]*pow(eta_x,4)+ C[5]*pow(eta_x,5) + C[6]*pow(eta_x,6) + C[7]*pow(eta_x,7)); + j_interp = j + (D[0] + D[1]*eta_y+ D[2]*pow(eta_y,2) + D[3]*pow(eta_y,3) + D[4]*pow(eta_y,4)+ D[5]*pow(eta_y,5) + D[6]*pow(eta_y,6) + D[7]*pow(eta_y,7)); + + // 1st case: first event + if(evt_i==0){ + evt_p[0][evt_i] = i; + evt_p[1][evt_i] = j; + evt_p[2][evt_i] = charge; + evt_p[3][evt_i] = eta_x; + evt_p[4][evt_i] = eta_y; + evt_p[5][evt_i] = i_interp; // + evt_p[6][evt_i] = j_interp; // + evt_i++; + + } else { + // 2nd case: not 1st event. we check if it is a neighbourg of the previos events and if charge is larger + n=0; + evt_m_i = evt_i; + for(m=0; m