Giter Club home page Giter Club logo

Comments (2)

prjemian avatar prjemian commented on August 22, 2024

From a recent conversation (involving master & ExternalLink file sets):

The NXWriter has a newer templates feature. Here's a quick demo in a bluesky plan:

templates = [
    ["/entry/full_file_name=", adsimdet.hdf1.full_file_name.get()],
]
md = {"title": "APS POLAR", nxwriter.template_key: json.dumps(templates)}

def outer(detectors, motors, **md):
    _md = {}
    _md.update(md)

    nxwriter.file_name = "polar_templates.hdf5"
    print(f"{md=!r}")
    print(f"{_md=!r}")

    @bpp.subs_decorator(nxwriter.receiver)  # collect the data
    @bpp.stage_decorator(list(detectors) + motors)
    @bpp.run_decorator(md=_md)
    def inner():
        # assume adsimdet has already collected its image file
        yield from bps.null()

    yield from inner()
    print(f"{nxwriter.file_path=!r}")
    print(f"{nxwriter.file_name=!r}")


RE(outer([adsimdet], [m1, m2], **md))

Here's what the first part of the HDF5 file looks like:

.../polar_templates.hdf5 : NeXus data file
  @HDF5_Version = "1.14.0"
  @NeXus_version = "v2020.1"
  @creator = "NXWriter"
  @default = "entry"
  @file_name = "polar_templates.hdf5"
  @file_time = "2024-06-03T17:41:42.483911"
  @h5py_version = "3.9.0"
  entry:NXentry
    @NX_class = "NXentry"
    @target = "/entry"
    duration:NX_FLOAT64[] = 
      @units = "s"
    end_time:NX_CHAR = b'2024-06-03T17:41:42.482846'
    entry_identifier --> /entry/instrument/bluesky/metadata/run_start_uid
    full_file_name:NX_CHAR = b'/tmp/adsimdet/2024/06/03/58c46161-22eb-43e3-a3bf_000000.h5'
      @target = "/entry/full_file_name"
    plan_name --> /entry/instrument/bluesky/metadata/plan_name
    program_name:NX_CHAR = b'bluesky'
    start_time:NX_CHAR = b'2024-06-03T17:41:42.479564'

from apstools.

prjemian avatar prjemian commented on August 22, 2024

polar.ipynb.zip

Update to the NXwriter local modifications. This update repositions the external links to image and fast positioners data, according to the NeXus schema

def write_entry(self):
        """Called after stop document has been received."""
        nxentry = super().write_entry()
        print(f"{nxentry=!r}")
        nxinstrument = nxentry["instrument"]
      
        if self.ad_file_name is not None:
            # https://manual.nexusformat.org/classes/base_classes/NXdetector.html
            nxdetector = nxinstrument.create_group("detector")
            nxdetector.attrs["NX_class"] = "NXdetector"
            nxdetector["data"] = h5py.ExternalLink(
                str(self.ad_file_name),
                "/entry/data",  # link to the data group with the image dataset
            )
            nxdetector["data_file"] = adsimdet.hdf1.full_file_name.get()
      
        if self.position_file_name is not None:
            # https://manual.nexusformat.org/classes/base_classes/NXcollection.html
            group = nxinstrument.create_group("fast_positions")
            group.attrs["NX_class"] = "NXcollection"
            group["root"] = h5py.ExternalLink(
                str(self.position_file_name),
                "/",  # link to the root of the file
            )

from apstools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.