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.10.0.tar.gz (143.8 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.10.0-py3-none-any.whl (33.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for moreniius-0.10.0.tar.gz
Algorithm Hash digest
SHA256 887da4d2226e904887b82b3c5449bc7565122e1cd14c3008209b6f83d8e94dc8
MD5 1af92aa70c8791ce05466554435b9b5c
BLAKE2b-256 7841f83c74add25a88cc547d489e34fc9322dfb02d9cddac3f795d82091d5348

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for moreniius-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d9c26ad66f8628cd00c8499bddc4373638d87047fc76a5e63ba214f6fd29296
MD5 394c4eddd1489026b1322e1761096fc1
BLAKE2b-256 b7517a189da84634650d77a144e5c91ecfeec361908df133f9e387ecc25c02da

See more details on using hashes here.

Provenance

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