DiamondLightSource / hyperion

Unattended Data Collection using BlueSky / Ophyd
BSD 3-Clause "New" or "Revised" License
5 stars 5 forks source link

Zocalo callback to trigger zocalo fluorescence #1458

Open DominicOram opened 2 weeks ago

DominicOram commented 2 weeks ago

After capturing fluorescence data we should trigger zocalo to analyse it. To do this zocalo needs a blank recipe and the following parameters:

params = {
    "inputFile": "/dls/i24/data/2024/cm37275-3/20240617_16_03_53.dat",
    "omega": "10.1",
    "transmission": "9.879",
    "samplexyz": "(0,-1,0)",
    "acqTime": "1.0",
    "energy": "12399.7",
    "spectrumID": "15408",
    "custom_recipe": {
        "start": [[1, []]],
        "1": {
            "service": "DLS PyMca Fitter",
            "queue": "pymca.fitter",
            "parameters": {
                "inputFile": "{inputFile}",
                "omega": "{omega}",
                "transmission": "{transmission}",
                "samplexyz": "{samplexyz}",
                "acqTime": "{acqTime}",
                "energy": "{energy}",
                "xfeFluorescenceSpectrumID": "{spectrumID}",
            },
        },
    },
}

Where inputFile is the file written by the detector (Note that we will be using the HDF writer on the detector so we can read the location from that). Currently, it is not obvious what spectrumID corresponds to @pblowey is looking into it

Acceptance Criteria

pblowey commented 2 weeks ago

An update on this. I think I have found the file that GDA calls to trigger PyMCA and it is /dls_sw/apps/mx-scripts/bin/RunPyMcaZocaloAtEndOfCollect.sh. This file actually does call a recipe file that is contained within the live zocalo-configuration called pymca-fitter except for some reason, this script calls it using the file path with the -f flag, meaning that zocalo treats it as a custom-recipe (in terms of logging), which is why I thought it was running a custom-recipe. If you got hyperion to run a similar command to the one in the file with zocalo.go (except you can replace the -f .json with -r pymca-fitter, it should activate the PyMCA fitter in zocalo.

pblowey commented 2 weeks ago

spectrumID or "xfeFluorescenceSpectrumID" is not actually used by the pymca-zocalo code in any way, though, in its current state, I think it will throw an error if it is not present as it is given as a required argument to a function that doesn't use it.

DominicOram commented 2 weeks ago

Are you able to make it optional your end so that it won't give an error if we don't provide it?

pblowey commented 2 weeks ago

Ultimately, yes, I will do this. The pymca_fitter service code has not been maintained for a while and is currently running from some old zocalo environment, so it will need a bit of work before I can deploy it with this change. I'll let you know when it's done.