Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add h5 loader #2

Open
Haydnspass opened this issue Mar 15, 2024 · 0 comments
Open

Add h5 loader #2

Haydnspass opened this issue Mar 15, 2024 · 0 comments
Assignees

Comments

@Haydnspass
Copy link
Member

Do it similarly like this, such that we can load decode emittersets.
Convert to nm if xyz was in px units.

def load_h5(path) -> Tuple[dict, dict, dict]:
    """
    Loads a hdf5 file and returns data, metadata and decode meta.

    Returns:
        (dict, dict, dict): Tuple of dicts containing

            - **emitter_data** (*dict*): core emitter data
            - **emitter_meta** (*dict*): emitter meta information
            - **decode_meta** (*dict*): decode meta information

    """
    with h5py.File(path, "r") as h5:
        data = {
            k: torch.from_numpy(v[:])
            for k, v in h5["data"].items()
            if v.shape is not None
        }
        data.update(
            {  # add the None ones
                k: None for k, v in h5["data"].items() if v.shape is None
            }
        )

        meta_data = dict(h5["meta"].attrs)
        meta_decode = dict(h5["decode"].attrs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants