legend-exp / legend-pydataobj

LEGEND Python Data Objects
https://legend-pydataobj.readthedocs.io
GNU General Public License v3.0
1 stars 9 forks source link

Syntactic sugar to read LH5 data directly into third-party formats #61

Closed gipert closed 9 months ago

gipert commented 9 months ago

Proposal:

from lgdo import lh5, LH5Store

# old way
lh5.load_nda("file.lh5", "object")

# current way
store = LH5Store()
store.read("object", "file.lh5")[0].view_as("np")

# shortcut?
def read_as(name, file, library, **kwargs):
    store = LH5Store()
    obj, _ = store.read(name, file, **kwargs)
    return obj.view_as(library)

# such that?
lh5.read_as("object", "file.lh5", library="np")