Skip to main content

No project description provided

Project description

moreniius

A project to contain custom components required to use eniius to produce NeXus Structure JSON from mccode-antlr simulated instruments. Simply, more eniius.

Features

Path-based Navigation for NeXus Structure JSON

The NexusStructureNavigator class provides convenient path-based access to NeXus Structure JSON objects, which have a verbose hierarchical format. It supports both path-based access and chainable navigation.

Without Navigator (verbose)

from moreniius import to_nexus_structure, load_instr

structure = to_nexus_structure(load_instr('instrument.instr'))
# Access requires nested dictionary lookups
component = structure['children'][0]['children'][0]['children'][12]

# Accessing attributes is even more verbose
attrs = structure['children'][0]['attributes']
nx_class = next(a for a in attrs if a['name'] == 'NX_class')

With Navigator (clean and chainable)

from moreniius import to_nexus_structure, load_instr, NexusStructureNavigator

structure = to_nexus_structure(load_instr('instrument.instr'))
nav = NexusStructureNavigator(structure)

# Path-based access (returns Navigator for groups)
component = nav['/entry/instrument/component_name']
field = nav['/entry/instrument/component_name/field']

# Chainable navigation - each group access returns a new Navigator!
component = nav['entry']['instrument']['component_name']

# Get the underlying dictionary
raw_dict = component.dict()  # or component.structure

# Access attributes with '@' prefix (returns raw dict)
nx_class = nav['/entry/@NX_class']
vector = nav['/entry/instrument/something/@vector']

# Attributes can also be accessed from Navigator objects
nx_class = nav['entry']['instrument']['mon0']['@NX_class']

# Check if paths exist
if nav.exists('/entry/instrument/mon0'):
    mon0 = nav['/entry/instrument/mon0']

# Get with default value
result = nav.get('/entry/instrument/missing', default=None)

# Find all elements with a given name
monitors = nav.find_all('mon0')

# Find all attributes with a given name
all_nx_classes = nav.find_all('NX_class', include_attributes=True)

# Reverse lookup - get path to an element (requires raw dict)
path = nav.get_path(component.structure)  # Returns '/entry/instrument/component_name'
attr_path = nav.get_path(nx_class)  # Returns '/entry/@NX_class'

Key behaviors:

  • Accessing a group (has children) returns a NexusStructureNavigator for chaining
  • Accessing an attribute (with @), dataset, or link returns the raw dictionary
  • Use .dict() or .structure to get the underlying dictionary from a Navigator

See examples/path_navigator_demo.py for a complete working example.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moreniius-0.8.3.tar.gz (198.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moreniius-0.8.3-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file moreniius-0.8.3.tar.gz.

File metadata

  • Download URL: moreniius-0.8.3.tar.gz
  • Upload date:
  • Size: 198.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for moreniius-0.8.3.tar.gz
Algorithm Hash digest
SHA256 5d492bb6bb4641861c18cb8ac6840937b4f2644c7f12eff486ff7615ce936080
MD5 49ebce6f965ee2cb702deaf3d67b8949
BLAKE2b-256 fa24d144bd954232e0132e4227fff75b88afe2fb411d48c4eb375af7f76892b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for moreniius-0.8.3.tar.gz:

Publisher: wheels.yml on g5t/moreniius

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file moreniius-0.8.3-py3-none-any.whl.

File metadata

  • Download URL: moreniius-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for moreniius-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2a53f18a009de2075028c5643c8f96ff40a6020d78571e19dca632307153ae10
MD5 25bd21c3ed9cffd3edd343955e99ca8c
BLAKE2b-256 311d21ccc9b784e45543aaae2605802c5eeee37dfd2acce609066dce2522285e

See more details on using hashes here.

Provenance

The following attestation bundles were made for moreniius-0.8.3-py3-none-any.whl:

Publisher: wheels.yml on g5t/moreniius

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page