-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathape_heMapper.py
33 lines (24 loc) · 1.27 KB
/
ape_heMapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import json
import logging
from metadataProcessor import MetadataProcessor
from neXusReader import NeXusReader
class APE_HE_Mapper:
def __init__(self, mySchema, metadata_dict):
self.mySchema = mySchema
self.metadata_dict = metadata_dict
self.keys_path_schema = MetadataProcessor.extract_keys_from_myDict(self.mySchema)
try:
self.metadata = {tuple(key.split('/')): value for key, value in self.metadata_dict.items()}
except Exception as e:
logging.error(f"Unexpected error while transforming to tuple the metadata keys path: {e}")
self.equivalencies = {
('entry', 'sample', 'transformations', 'phi(x)'): ('entry', 'sample', 'transformations', 'phi'),
('entry', 'sample', 'transformations', 'theta(z)'): ('entry', 'sample', 'transformations', 'theta')
}
def output_the_document(self):
# Process metadata
metadata = MetadataProcessor.process_gas_flux(self.metadata)
myDict_parsed = MetadataProcessor.map_equivalencies(metadata, self.keys_path_schema, self.equivalencies)
# Generate document
myDoku = MetadataProcessor.create_metadata_document(self.mySchema, myDict_parsed)
return myDoku