Closed qzhang234 closed 2 years ago
@prjemian It appears that as long as I change the file format to %s%s.h5
it would look fine. However the moment I acquire again in AD_Acquire
it flips back. How do I add the file format in the staging process?
Set eiger.hdf1.stage_sigs["file_format"] = "%s%s.h5"
On Sun, May 22, 2022, 2:16 AM Qingteng Zhang @.***> wrote:
@prjemian https://github.com/prjemian It appears that as long as I change the file format to %s%s.h5 it would look fine. However the moment I acquire again in AD_Acquire it flips back. How do I add the file format in the staging process?
[image: MicrosoftTeams-image] https://user-images.githubusercontent.com/48140482/169683543-6838c0dc-7ea2-44c2-8eb4-5e83ec6b4682.png
— Reply to this email directly, view it on GitHub https://github.com/aps-8id-dys/ipython-8idiuser/issues/286#issuecomment-1133834816, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARMUMGXPJYM5JOWG52AQBTVLHNONANCNFSM5WSZ34FQ . You are receiving this because you were mentioned.Message ID: @.***>
@prjemian I added this line in the base class LocalEigerDetectorBase
and it's not working:
Looking at the variable name more closely, I realized that it should be file_template
instead of file_format
, so I tried that, but it's not working either. The error is attached in the pull down tab.
Any suggestions?
@prjemian I noticed that I can set file_format
to %s%s_%2.2d.h5
, %s%s_%3.3d.h5
, %s%s_%4.4d.h5
, and AD_Acquire
will run just fine, but I cannot set the file name to %s%s
.
Looking at the error message more closely (screenshot attached), I believe it's a requirement from
~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/apstools/devices/area_detector_support.py
Where file_template
is supposed to have a number at the end. I do not have permission to modify this file (and I probably shouldn't) and I don't think it's possible to avoid calling area_detector_support.py
in AD_Acquire
.
Any recommendations?
So, we need to outsmart that code by overriding it locally, and not including the file_number.
It's the stage()
method of AD_EpicsHdf5FileName()
in file apstools.devices.area_detector_support
.
So, after importing AD_EpicsHdf5FileName
, we make a custom class based on that and write a new version of the stage()
method that does everything except write the file_number
. Then use that custom class.
@qzhang234 : Up to the challenge of writing that code here?
@prjemian Thanks for the instructions! I have two questions:
stage()
method in AD_EpicsHdf5FileName()
and modify the behavior of filename generation so that it skips the frame number. Could you point me to stage()
in AD_EpicsHdf5FileName()
please?That's the right place to make the addition. Remove the pass
at the end of line 102 since we now provide some content. Here's the stage()
method: https://github.com/BCDA-APS/apstools/blob/1de05de8603c8a383e3604001d4c59ce2d5b3d61/apstools/devices/area_detector_support.py#L375-L415
This is the line to be changed in myHdf5EpicsIterativeWriter()
: https://github.com/BCDA-APS/apstools/blob/1de05de8603c8a383e3604001d4c59ce2d5b3d61/apstools/devices/area_detector_support.py#L406
I see. However would it work if I just copy the entire block of def stage()
and modify the line that generates file name in myHdf5EpicsIterativeWriter
?
Somehow I feel it would be too good to be true if I can modify the behavior of functions in inherited class that way. Just checking
That's the way I'd do it.
@prjemian I added the script (see code here) but I'm getting the same error. Looks like the file template is still pointing to the original one in area_detector_support.py
so the overwrite did not take into effect.
Any suggestions?
I've got to look at your code. Logging in now.
@prjemian Got it. Let me know if there's anything I can help
Logged in, looking at /home/beams/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument/devices/ad_eiger.py
now. Do not see any new code, only:
class myHdf5EpicsIterativeWriter(AD_EpicsHdf5FileName, FileStoreIterativeWrite):
pass
at lines 104-5. Where are your changes?
pearl% git grep file_format
ad_imm_plugins.py:# file_format = Component(
ad_imm_plugins.py: # # below is the old file_format to delete
ad_imm_plugins.py: # # file_format = Component(
ad_imm_plugins.py: # if plugin.file_format.get() not in (1, "IMM_Cmprs"):
ad_imm_plugins.py: # plugin.file_format,
ad_imm_plugins.py: # if plugin.file_format.get() not in (0, "IMM_Raw"):
ad_imm_plugins.py: # plugin.file_format,
@prjemian Sorry, I removed the change because I wanted to test the diagnostics for the scaler. The permalink in the previous comment should still work, and I just added the code back that overwrite the file template. Could you take a look again?
Still not seeing any change:
/home/beams/8IDIUSER/.ipython-bluesky/profile_bluesky/startup/instrument
pearl% git grep file_format
devices/ad_imm_plugins.py:# file_format = Component(
devices/ad_imm_plugins.py: # # below is the old file_format to delete
devices/ad_imm_plugins.py: # # file_format = Component(
devices/ad_imm_plugins.py: # if plugin.file_format.get() not in (1, "IMM_Cmprs"):
devices/ad_imm_plugins.py: # plugin.file_format,
devices/ad_imm_plugins.py: # if plugin.file_format.get() not in (0, "IMM_Raw"):
devices/ad_imm_plugins.py: # plugin.file_format,
Shouldn't it be file_template
?
You are correct!
Like this:
pearl% git grep file_template
devices/ad_eiger.py: template = self.file_template.get()
devices/ad_eiger.py: self.hdf1.stage_sigs["file_template"] = "%s%s.h5"
@prjemian … And this version shows the same error (see file attached). I'll comment out this part for tonight and run the long scan test tonight. Would you be able to log in again to take a look sometime tomorrow?
Closing this issue for now as it is lower-priority right now. Will reopen after the stability problem #287 is fixed.
Re-open to save for later.
@prjemian Problem solved today. Closing the issue.
All files saved by Eiger has FileNumber attached at the end, which was not included in the file name variable (see screenshot attached). There is no mentioning of the PV
dp_eiger_xrd4:HDF1:FileNumber
anywhere inad_eiger
either, so chances are this might be defined in a base library.@prjemian Any suggestions on how to edit that?