Comments (2)
From a recent conversation (involving master & ExternalLink file sets):
- https://bcda-aps.github.io/apstools/latest/api/_filewriters.html
- https://bcda-aps.github.io/apstools/latest/api/_plans.html#apstools.plans.doc_run.write_stream
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.
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)
- 4M insertion device (only 11US and 11DS)
- STI insertion device (13 devices, including two at 4ID) HOT 6
- Planar insertion device (34 devices, including 20ID) HOT 1
- Revolver insertion device (only 08US, 08DS, 34DS) HOT 15
- S29ID-IEX insertion device HOT 2
- typo: should import write_stream HOT 1
- area detector factory function HOT 6
- Is diffractometer configuration saved by NXWriter?
- Support profile move databases for ISN with ophyd HOT 1
- Add .component_names to HOWTO
- RuntimeError from listdevice()
- BusyStatus belongs with the synApps busy record support. HOT 4
- YAML Syntax error in workflow file HOT 2
- resume use of davidslusser/actions_python_ruff in CI
- BUG: capitalization problem with synApps.SaveData() device HOT 1
- SpecWriterCallback should write to file with each event document
- Eiger detector plugins need to be primed with real acquire_time
- EpicsMotorLimitsMixin: Features are now part of ophyd.EpicsMotor
- Remove Anaconda defaults channel per TOS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apstools.