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.9.0.tar.gz (140.7 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.9.0-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for moreniius-0.9.0.tar.gz
Algorithm Hash digest
SHA256 cf9c5f764ab9034ffaf5d47e9690ca683179f08ba08646eb970a10e812e20f62
MD5 1c6109274c4fac962cc09a1c7450e5f2
BLAKE2b-256 e6b933b1bbc41d281643b85efbb7b378319cbdded21733af6a3dd9c3f5f3e375

See more details on using hashes here.

Provenance

The following attestation bundles were made for moreniius-0.9.0.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.9.0-py3-none-any.whl.

File metadata

  • Download URL: moreniius-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 32.3 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.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d03973886b63f41f50a11049d108c18f7e869fa1ad686744991cb1e6d884682a
MD5 2cb06c57bd654bd5ad56e2936012b929
BLAKE2b-256 abf39bd5ab25cfe764bcf7bf8c2bdd6ac02d33e70d6fdc4c90f12aa5efa50db1

See more details on using hashes here.

Provenance

The following attestation bundles were made for moreniius-0.9.0-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