McCode
McCode copied to clipboard
mcrun issue when scanning: 0-bin "0D" monitors and scans in Monitor_nD crash the scan
When performing a mcrun scan (e.g. mcrun -c ILL_SALSA.instr mono_rock=-4,4 -N9) on an instrument containing a Monitor_nD instance without "axes", i.e.
options = "per cm2, capture, slit",
Makes the mcsimdetectors() function in optimisation.py fail, due to silently requiring a filename:
*** TRACE end ***
Detector: GuideOut_xy_I=9.55988e+08 GuideOut_xy_ERR=6.63668e+06 GuideOut_xy_N=87354 "GuideOut_xy_1706023253.x_y"
Detector: GuideOut_dxdy_I=9.56116e+08 GuideOut_dxdy_ERR=6.63696e+06 GuideOut_dxdy_N=87342 "GuideOut_dxdy_1706023253.hd_vd"
Detector: GuideOut_Phic_I=9.32522e+08 GuideOut_Phic_ERR=6.14248e+06 GuideOut_Phic_N=87354 "GuideOut_Phic"
Detector: GuideOut_L_I=9.55988e+08 GuideOut_L_ERR=6.63668e+06 GuideOut_L_N=87354 "GuideOut_L_1706023253.L"
Detector: Beam_entrance_monitor_I=9.69927e+08 Beam_entrance_monitor_ERR=5.6184e+07 Beam_entrance_monitor_N=989 "beam_ent_mon.dat"
Detector: middle_I=2.94344e+07 middle_ERR=9.53658e+06 middle_N=22 "middle.dat"
Detector: middle2_I=2.94344e+07 middle2_ERR=9.53658e+06 middle2_N=22 "middle2.dat"
Detector: monitor_after_collimator_I=1.32713e+06 monitor_after_collimator_ERR=1.32713e+06 monitor_after_collimator_N=1 "monitor_after_collimator.dat"
Detector: monitor_after_collimator2_I=1.32713e+06 monitor_after_collimator2_ERR=1.32713e+06 monitor_after_collimator2_N=1 "monitor_after_collimator2.dat"
Detector: logger_space_zx_I=122517 logger_space_zx_ERR=94351.3 logger_space_zx_N=2 "logger_zx.dat"
Detector: logger_space_zy_I=122517 logger_space_zy_ERR=94351.3 logger_space_zy_N=2 "logger_zy.dat"
Detector: final_monitor_I=0 final_monitor_ERR=0 final_monitor_N=0 "final_mon.dat"
INFO: Finish running step, get detectors
Traceback (most recent call last):
File "/Applications/McStas-3.4.app/Contents/Resources/mcstas/3.4/tools/Python/mcrun/mcrun.py", line 562, in <module>
main()
File "/Applications/McStas-3.4.app/Contents/Resources/mcstas/3.4/tools/Python/mcrun/mcrun.py", line 531, in main
scanner.run() # in optimisation.py
^^^^^^^^^^^^^
File "/Applications/McStas-3.4.app/Contents/Resources/mcstas/3.4/tools/Python/mcrun/optimisation.py", line 259, in run
detectors = mcsimdetectors(current_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/McStas-3.4.app/Contents/Resources/mcstas/3.4/tools/Python/mcrun/optimisation.py", line 169, in mcsimdetectors
return [Detector(d['component'], *d['values'].split(), d['filename']) for d in blocks]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/McStas-3.4.app/Contents/Resources/mcstas/3.4/tools/Python/mcrun/optimisation.py", line 169, in <listcomp>
return [Detector(d['component'], *d['values'].split(), d['filename']) for d in blocks]
~^^^^^^^^^^^^
KeyError: 'filename'
A workaround is to add "something" to measure across in there options string:
options = "x y per cm2, capture, slit",
( Likely, a similar issue could occur if one uses the classical Monitor.comp... - Will check )