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.4.tar.gz (199.2 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.4-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: moreniius-0.8.4.tar.gz
  • Upload date:
  • Size: 199.2 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.4.tar.gz
Algorithm Hash digest
SHA256 27040c04d2f9f2ee6369177297c2dcb30ec16a73e3f5a4b724e0982616767404
MD5 c03791bd78054165475cdf00467ab58e
BLAKE2b-256 e64ab18c6212ec81dd9133dac96ad3525ebb5355b9194b65e510fcdb84e8ffde

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: moreniius-0.8.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e13cbaebc332024f27f9273116af1e7bde8323a64360410d606afbf631aeb419
MD5 9109dd8581584fc9d1593c87a5e88f71
BLAKE2b-256 bb9b945e362fcf2a9cd0789fcbc7fbb308806ccfdcb5eb17c7d34b1953f27aee

See more details on using hashes here.

Provenance

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