Closed robnagler closed 6 years ago
If you unpack the contents of the archive with the magnetic measurement files to the current dir, you have to specify
['und_mdir', 's', './', 'name of magnetic measurements sub-folder'],
instead of
['und_mdir', 's', '', 'name of magnetic measurements sub-folder'],
Earlier I met this problem. The logic in SRW is a bit complicated - https://github.com/radiasoft/SRW-light/blob/master/env/work/srw_python/srwl_bl.py#L1381:
#---setup magnetic field: undulator, tabulated (e.g. measured) magnetic field
magnMeasDirExists = False
if hasattr(_v, 'und_mdir'):
self.dir_magn_meas = _v.und_mdir
if(len(self.dir_magn_meas) > 0): magnMeasDirExists = True
magnMeasSumFileExists = False
if hasattr(_v, 'und_mfs'):
self.fn_magn_meas_sum = _v.und_mfs
if(magnMeasDirExists):
testPath = os.path.join(os.getcwd(), self.dir_main, self.dir_magn_meas, self.fn_magn_meas_sum)
magnMeasSumFileExists = os.path.exists(testPath)
The length of the magnMeasDirExists
variable should be non-zero so that the magnMeasSumFileExists
flag is set to True
.
I think this should work "out of the box", that is, when the archive is unpacked, the example should run in the mode it was intended (with the file).
That's a good expectation :-). Which archive are you talking about? The packed magnetic measurements are not supported by SRW - it currently requires a separate set of unpacked files.
I can update srwlib.py
to process the case of the files without an additional folder und_mdir
correctly.
I think the exported Python should do whatever template.srw.MagnMeasZip does.
I don't see this as a priority, just wanted to get it documented.
Yes, that's a good point. I'll suggest to include it to SRW.
We could also just embed some code in the python source that's output.
That's a good temporary solution before the related code is ported from Sirepo to SRW in case the tabulated undulator is used (it should not be there in case it's an ideal undulator or a gaussian beam).
This was fixed with b3c7f8f.
Running the run.py from the archive results in:
Attached is the example I used.
Tabulated Undulator Example.zip