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

General HDF5 Reader #30

Merged
merged 26 commits into from Mar 22, 2021
Merged

General HDF5 Reader #30

merged 26 commits into from Mar 22, 2021

Conversation

janssenhenning
Copy link
Contributor

@janssenhenning janssenhenning commented Mar 19, 2021

This PR implements a generic HDF5Reader heavily inspired by the one on the studenproject18ws branch.

It can be used with filepaths and file handles and reads and transformed the data according to a given recipe dictionary.
For an example see masci_tools.io.parsers.hdf5.recipes.FleurDOS.

The data is always returned in a python dict. The possible transformations are implemented using the masci_tools.io.parsers.hdf5.transforms.hdf5_transformation decorator, which works in the exact same way as the conversion_function decorator in the outxml_parser

Basic Usage with filepath:

    from masci_tools.io.parsers.hdf5 import HDF5Reader
     
     with HDF5Reader('/path/to/hdf/file.hdf') as reader:
          data = reader.read(recipe)

Basic Usage with file handle:

     from masci_tools.io.parsers.hdf5 import HDF5Reader
     
     with open('/path/to/hdf/file.hdf', 'rb') as file: 
         with HDF5Reader(file) as reader:
              data = reader.read(recipe)

…ta according to recipes (dictionaries see `masci_tools/io/parsers/hdf5/recipes.py`).

Based on the reader from the `studentproject18ws` branch. Simplified and stripped down to always return a dict
Transformations are implemented with a decorator (equivalent to conversion_function decorator for the fleur outxml_parser)
@janssenhenning janssenhenning changed the title Implemented basic general HDF5reader, which can read and transform da… General HDF5 reader Mar 19, 2021
@janssenhenning janssenhenning changed the title General HDF5 reader General HDF5 Reader Mar 19, 2021
@codecov
Copy link

codecov bot commented Mar 19, 2021

Codecov Report

Merging #30 (6837ba8) into develop (49a0b1d) will increase coverage by 0.65%.
The diff coverage is 75.21%.

@@             Coverage Diff             @@
##           develop      #30      +/-   ##
===========================================
+ Coverage    68.43%   69.09%   +0.65%     
===========================================
  Files           64       69       +5     
  Lines        10367    10699     +332     
===========================================
+ Hits          7095     7392     +297     
- Misses        3272     3307      +35     

…eaders output. This makes it easier to create recipes which can just be plugged into a pandas dataframe for example

Also fixed one wrong import in `transforms`
…om weights are missing atm)

For this a couple of extensions had to be made to the transformation system.

Added explicit and recursive move_to_memory and conversion to string

entries in datasets can now call transformation functions using a value from the attributes (not datasets)
At the moment there is only a multiply function for example for multiplying kpoints with the reciprocal_cell matrix

More matrix manipulation was added:
   -multiplication (both orders) and multiply each element in list with matrix
   -calculating norm of list of vectors or distances between neighbours in the list
   -calculate the cumulative sum of an array

Some entries will be in the form of a dict after processing (if for example you use the get_all_child_dataset transformation).
Now there is an additional option to unpack the keys into the root dictionary after all transformations
…n pattern. Could make a fixed version of this. At the moment it is used to create the total atom sums and so is formatted according to the atom types
…d them up

This file contains:
   -Something similar to h5dump for seeing the structure of a hdf file
   -A simple hdf reader that just builds up a nested dictionary with numpy arrays, which mirrors the exact filestructure of the hdf file

Also removed the really old hdf reading routine for the `banddos.hdf` file
…tion

made some names of transformations more consistent and added errors for currently not implemented cases for transformations
For this I copied the PERIODIC_TABLE_ELEMENTS from the move_aiida_fleur_methods branch
@janssenhenning janssenhenning marked this pull request as ready for review March 21, 2021 11:10
@janssenhenning janssenhenning merged commit 45346ea into develop Mar 22, 2021
@janssenhenning janssenhenning deleted the hdf5_reader branch March 22, 2021 11:59
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

Successfully merging this pull request may close these issues.

None yet

1 participant