sardana-org / sardana

Moved to GitLab: https://gitlab.com/sardana-org/sardana
39 stars 51 forks source link

Error Scan Macro for recording with OneD and TwoD Controller #1671

Open steinbachfe opened 3 years ago

steinbachfe commented 3 years ago

Hello, I am trying to do some tests with twoD controller and I have an error which I don't understand. I switched to the Sardana demo which shows the same error. I tried it with the version 4.8 and 5.0 which resulted in the same error.

The problem occurs when running a scan macro e.g. ascan with a oneD controller or twoD controller. The error is not occuring when recording with a zeroD Controller or counter.

Traceback (most recent call last):
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/scan/gscan.py", line 1052, in step_scan
    for i in self.scan_loop():
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/scan/gscan.py", line 1156, in scan_loop
    self.stepUp(i, step, lstep)
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/scan/gscan.py", line 1268, in stepUp
    self.data.addRecord(data_line)
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/scan/scandata.py", line 393, in addRecord
    self.datahandler.addRecord(self, rc)
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/scan/recorder/datarecorder.py", line 68, in addRecord
    recorder.writeRecord(record)
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/scan/recorder/datarecorder.py", line 142, in writeRecord
    self._writeRecord(record)
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/recorders/output.py", line 263, in _writeRecord
    cell %= record.data
TypeError: must be real number, not tuple

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/msmacromanager.py", line 1672, in runMacro
    for step in macro_obj.exec_():
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/macro.py", line 2362, in exec_
    for i in it:
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/macros/scan.py", line 291, in run
    for step in self._gScan.step_scan():
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/scan/gscan.py", line 1067, in step_scan
    self.end()
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/scan/gscan.py", line 1018, in end
    self.data.end()
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/scan/scandata.py", line 503, in end
    self.datahandler.addRecord(self, rc)
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/scan/recorder/datarecorder.py", line 68, in addRecord
    recorder.writeRecord(record)
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/scan/recorder/datarecorder.py", line 142, in writeRecord
    self._writeRecord(record)
  File "/home/moke/.local/lib/python3.8/site-packages/sardana/macroserver/recorders/output.py", line 263, in _writeRecord
    cell %= record.data
TypeError: must be real number, not tuple

Maybe you can try to reproduce the error with the demo version or can tell me why it is not working. :)

Thanks, Felix

reszelaz commented 3 years ago

Hi Felix! I tried it using sar_demo setup and I do not get the error that you get:

Door_issue1671_1 [1]: sar_demo
Creating motor controller motctrl09 ...
Created motctrl09
Creating motor mot33 ...
Created mot33
Creating motor mot34 ...
Created mot34
Creating motor mot35 ...
Created mot35
Creating motor mot36 ...
Created mot36
Creating counter controller ctctrl09 ...
Created ctctrl09
Creating counter channel ct02 ...
Created ct02
Creating counter channel ct33 ...
Created ct33
Creating counter channel ct34 ...
Created ct34
Creating counter channel ct35 ...
Created ct35
Creating 0D controller zerodctrl09 ...
Created zerodctrl09
Creating 0D channel zerod33 ...
Created zerod33
Creating 0D channel zerod34 ...
Created zerod34
Creating 0D channel zerod35 ...
Created zerod35
Creating 0D channel zerod36 ...
Created zerod36
Creating 1D controller onedctrl09 ...
Created onedctrl09
Creating 1D channel oned09 ...
Created oned09
Creating 2D controller twodctrl09 ...
Created twodctrl09
Creating 2D channel twod09 ...
Created twod09
Creating Slit slitctrl09 with gap09 , offset09 ...
Created slitctrl09
Creating trigger controller tgctrl09 ...
Created tgctrl09
Creating trigger element tg09 ...
Created tg09
Connecting trigger/gate element tg09 with counter/timer controller ctctrl09
Creating IORegister controller iorctrl09 ...
Created iorctrl09
Creating IORegister ior17 ...
Created ior17
Creating IORegister ior18 ...
Created ior18
Creating measurement group mntgrp09 ...
Created mntgrp09
Setting mntgrp09 as ActiveMntGrp
Creating instruments: /slit, /mirror and /monitor ...
Assigning elements to instruments...
DONE!

Door_issue1671_1 [2]: defmeas mntgrp10 ct02 oned09 twod09
Created mntgrp10

Door_issue1671_1 [3]: set_meas mntgrp10

Door_issue1671_1 [4]: ascan mot33 0 1 1 0.1
ScanDir is not defined. This operation will not be stored persistently. Use "expconf" or "newfile" to configure data storage (or eventually "senv ScanDir <abs directory>")
Scan #1 started at Fri Jul 30 07:17:04 2021. It will take at least 0:00:00.482843
 #Pt No    mot33      ct02     oned09    twod09      dt   
   0         0        0.1     (1024,)   (1024, 1024)  0.0479608
   1         1        0.1     (1024,)   (1024, 1024)  0.486872
Scan #1 ended at Fri Jul 30 07:17:04 2021, taking 0:00:00.627713. Dead time 65.6% (setup time 2.5%, motion dead time 49.0%)

Door_issue1671_1 [5]: newfile [/tmp/scan.h5 /tmp/scan.dat]
ScanDir is      : /tmp
ScanFile set to : scan.h5
                  scan.dat
Next scan is    : #1

Door_issue1671_1 [6]: ascan mot33 0 1 1 0.1
Operation will be saved in /tmp/scan.h5 (HDF5::NXscan from NXscanH5_FileRecorder)
Operation will be saved in /tmp/scan.dat (Spec from SPEC_FileRecorder)
Scan #1 started at Fri Jul 30 07:17:45 2021. It will take at least 0:00:00.765685
 #Pt No    mot33      ct02     oned09    twod09      dt   
   0         0        0.1     (1024,)   (1024, 1024)  0.306592
   1         1        0.1     (1024,)   (1024, 1024)  0.752308
Operation saved in /tmp/scan.h5 (HDF5::NXscan)
Operation saved in /tmp/scan.dat (Spec)
Scan #1 ended at Fri Jul 30 07:17:46 2021, taking 0:00:00.903216. Dead time 77.3% (setup time 0.5%, motion dead time 64.9%)

From the traceback you attached it looks like the output recorder receives data of some strange type: https://github.com/sardana-org/sardana/blob/f43b6fce6b629d1194f47b7f60fede1684603aff/src/sardana/macroserver/recorders/output.py#L269

On the server-side I use a standalone newly created Sardana server and I use the latest develop branch (hence the difference in the line numbers between your traceback and the code I point above).