BCDA-APS / bdp_controls

APS-U Beam line Data Pipelines - experiment controls with EPICS and Bluesky
Other
0 stars 1 forks source link

Configure adsimdet to bundle metadata into the PVA image pv #21

Closed prjemian closed 2 years ago

prjemian commented 2 years ago

Write an attributes.xml file and load it into the adsimdet object.

prjemian commented 2 years ago

example attributes.xml file:

<?xml version="1.0" standalone="no" ?>

<Attributes
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://epics.aps.anl.gov/areaDetector/attributes ../attributes.xsd"
    >

    <!-- EPICS PVs -->

    <Attribute
        name="m1"
        description="m1 position"
        source="gp:m1.RBV"
        type="EPICS_PV"
        dbrtype="DBR_NATIVE"
    />
    <Attribute
        name="gp_UPTIME"
        description="elapsed time since gp: started"
        source="gp:UPTIME"
        type="EPICS_PV"
        dbrtype="DBR_STRING"
    />

    <!-- Params -->

    <Attribute name="Manufacturer"       type="PARAM"    source="MANUFACTURER"                  datatype="STRING"        description="Camera manufacturer"/>
    <Attribute name="Model"              type="PARAM"    source="MODEL"                         datatype="STRING"        description="Camera model"/>
    <Attribute name="MaxSizeX"           type="PARAM"    source="MAX_SIZE_X"                    datatype="INT"           description="Detector X size"/>
    <Attribute name="MaxSizeY"           type="PARAM"    source="MAX_SIZE_Y"                    datatype="INT"           description="Detector Y size"/>
    <Attribute name="ImageCounter"       type="PARAM"    source="ARRAY_COUNTER"                 datatype="INT"           description="Image counter"/>
    <Attribute name="DriverFileName"     type="PARAM"    source="FULL_FILE_NAME"                datatype="STRING"        description="Driver full file name"/>
    <Attribute name="FileName"           type="PARAM"    source="FILE_NAME"                     datatype="STRING"        description="Driver file name"/>
    <Attribute name="AttributesFile"     type="PARAM"    source="ND_ATTRIBUTES_FILE"            datatype="STRING"        description="Attributes file name"/>
    <Attribute name="ADCoreVersion"      type="PARAM"    source="ADCORE_VERSION"                datatype="STRING"        description="ADCore version number"/>

</Attributes>

acquisition with this file shows this structure in the HDF5 file:

In [3]: !punx tree /tmp/docker_ioc/iocad/tmp/adsimdet/2022/03/30/2d4f0e13-ef31-4fd1-b067_000.h5

!!! WARNING: this program is not ready for distribution.

/tmp/docker_ioc/iocad/tmp/adsimdet/2022/03/30/2d4f0e13-ef31-4fd1-b067_000.h5 : NeXus data file
  entry:NXentry
    @NX_class = "NXentry"
    data:NXdata
      @NX_class = "NXdata"
      data:NX_UINT8[1,1024,1024] = __array
        __array = [
            [
                [5, 18, 19, '...', 14]
                [18, 7, 5, '...', 21]
                [12, 22, 9, '...', 7]
                ...
                [16, 17, 19, '...', 9]
              ]
          ]
        @NDArrayDimBinning = [1 1]
        @NDArrayDimOffset = [0 0]
        @NDArrayDimReverse = [0 0]
        @NDArrayNumDims = 2
        @signal = 1
    instrument:NXinstrument
      @NX_class = "NXinstrument"
      NDAttributes:NXcollection
        @NX_class = "NXcollection"
        @hostname = "zap"
        ADCoreVersion:NX_CHAR[6] = "3.11.0"
          @NDAttrDescription = "ADCore version number"
          @NDAttrName = "ADCoreVersion"
          @NDAttrSource = "ADCORE_VERSION"
          @NDAttrSourceType = "NDAttrSourceParam"
        AttributesFile:NX_CHAR[19] = "/tmp/attributes.xml"
          @NDAttrDescription = "Attributes file name"
          @NDAttrName = "AttributesFile"
          @NDAttrSource = "ND_ATTRIBUTES_FILE"
          @NDAttrSourceType = "NDAttrSourceParam"
        DriverFileName:NX_CHAR[0] = ""
          @NDAttrDescription = "Driver full file name"
          @NDAttrName = "DriverFileName"
          @NDAttrSource = "FULL_FILE_NAME"
          @NDAttrSourceType = "NDAttrSourceParam"
        FileName:NX_CHAR[0] = ""
          @NDAttrDescription = "Driver file name"
          @NDAttrName = "FileName"
          @NDAttrSource = "FILE_NAME"
          @NDAttrSourceType = "NDAttrSourceParam"
        ImageCounter:NX_INT32 = 11135
          @NDAttrDescription = "Image counter"
          @NDAttrName = "ImageCounter"
          @NDAttrSource = "ARRAY_COUNTER"
          @NDAttrSourceType = "NDAttrSourceParam"
        Manufacturer:NX_CHAR[18] = "Simulated detector"
          @NDAttrDescription = "Camera manufacturer"
          @NDAttrName = "Manufacturer"
          @NDAttrSource = "MANUFACTURER"
          @NDAttrSourceType = "NDAttrSourceParam"
        MaxSizeX:NX_INT32 = 1024
          @NDAttrDescription = "Detector X size"
          @NDAttrName = "MaxSizeX"
          @NDAttrSource = "MAX_SIZE_X"
          @NDAttrSourceType = "NDAttrSourceParam"
        MaxSizeY:NX_INT32 = 1024
          @NDAttrDescription = "Detector Y size"
          @NDAttrName = "MaxSizeY"
          @NDAttrSource = "MAX_SIZE_Y"
          @NDAttrSourceType = "NDAttrSourceParam"
        Model:NX_CHAR[15] = "Basic simulator"
          @NDAttrDescription = "Camera model"
          @NDAttrName = "Model"
          @NDAttrSource = "MODEL"
          @NDAttrSourceType = "NDAttrSourceParam"
        NDArrayEpicsTSSec:NX_UINT32 = 1017511801
          @NDAttrDescription = "The NDArray EPICS timestamp seconds past epoch"
          @NDAttrName = "NDArrayEpicsTSSec"
          @NDAttrSource = "Driver"
          @NDAttrSourceType = "NDAttrSourceDriver"
        NDArrayEpicsTSnSec:NX_UINT32 = 52514310
          @NDAttrDescription = "The NDArray EPICS timestamp nanoseconds"
          @NDAttrName = "NDArrayEpicsTSnSec"
          @NDAttrSource = "Driver"
          @NDAttrSourceType = "NDAttrSourceDriver"
        NDArrayTimeStamp:NX_FLOAT64 = 1017511800.9523605
          @NDAttrDescription = "The timestamp of the NDArray as float64"
          @NDAttrName = "NDArrayTimeStamp"
          @NDAttrSource = "Driver"
          @NDAttrSourceType = "NDAttrSourceDriver"
        NDArrayUniqueId:NX_INT32 = 11137
          @NDAttrDescription = "The unique ID of the NDArray"
          @NDAttrName = "NDArrayUniqueId"
          @NDAttrSource = "Driver"
          @NDAttrSourceType = "NDAttrSourceDriver"
        gp_UPTIME:NX_CHAR[17] = "11 days, 02:14:29"
          @NDAttrDescription = "elapsed time since gp: started"
          @NDAttrName = "gp_UPTIME"
          @NDAttrSource = "gp:UPTIME"
          @NDAttrSourceType = "NDAttrSourceEPICSPV"
        m1:NX_FLOAT64 = -0.442
          @NDAttrDescription = "m1 position"
          @NDAttrName = "m1"
          @NDAttrSource = "gp:m1.RBV"
          @NDAttrSourceType = "NDAttrSourceEPICSPV"
      detector:NXdetector
        @NX_class = "NXdetector"
        data:NX_UINT8[1,1024,1024] = __array
          __array = [
              [
                  [5, 18, 19, '...', 14]
                  [18, 7, 5, '...', 21]
                  [12, 22, 9, '...', 7]
                  ...
                  [16, 17, 19, '...', 9]
                ]
            ]
          @NDArrayDimBinning = [1 1]
          @NDArrayDimOffset = [0 0]
          @NDArrayDimReverse = [0 0]
          @NDArrayNumDims = 2
          @signal = 1
        NDAttributes:NXcollection
          @NX_class = "NXcollection"
          ColorMode:NX_INT32 = 0
            @NDAttrDescription = "Color mode"
            @NDAttrName = "ColorMode"
            @NDAttrSource = "Driver"
            @NDAttrSourceType = "NDAttrSourceDriver"
      performance
        timestamp:NX_FLOAT64[1,5] = __array
          __array = [
              [0.05105276, 0.292471579, 1017489897.1036279, 27.35308513515428, 0.0]
            ]
prjemian commented 2 years ago

The IOC sees the file at this path:

In [21]: adsimdet.cam.nd_attributes_file.get()
Out[21]: '/tmp/attributes.xml'
prjemian commented 2 years ago

To write this file where the IOC can use it, Bluesky needs write access to a file system which the IOC can read. Need a key in the iconfig.yml file for this.