pymodaq_data 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pymodaq_data/__init__.py +53 -0
- pymodaq_data/data.py +2901 -0
- pymodaq_data/h5modules/__init__.py +6 -0
- pymodaq_data/h5modules/backends.py +1031 -0
- pymodaq_data/h5modules/browsing.py +101 -0
- pymodaq_data/h5modules/data_saving.py +1107 -0
- pymodaq_data/h5modules/exporter.py +119 -0
- pymodaq_data/h5modules/exporters/__init__.py +0 -0
- pymodaq_data/h5modules/exporters/base.py +111 -0
- pymodaq_data/h5modules/exporters/flimj.py +63 -0
- pymodaq_data/h5modules/exporters/hyperspy.py +143 -0
- pymodaq_data/h5modules/saving.py +411 -0
- pymodaq_data/h5modules/utils.py +115 -0
- pymodaq_data/icon.ico +0 -0
- pymodaq_data/plotting/__init__.py +0 -0
- pymodaq_data/plotting/plotter/plotter.py +91 -0
- pymodaq_data/plotting/plotter/plotters/__init__.py +0 -0
- pymodaq_data/plotting/plotter/plotters/matplotlib_plotters.py +133 -0
- pymodaq_data/post_treatment/__init__.py +6 -0
- pymodaq_data/post_treatment/process_to_scalar.py +234 -0
- pymodaq_data/slicing.py +48 -0
- pymodaq_data/splash.png +0 -0
- pymodaq_data-0.0.1.dist-info/METADATA +160 -0
- pymodaq_data-0.0.1.dist-info/RECORD +26 -0
- pymodaq_data-0.0.1.dist-info/WHEEL +4 -0
- pymodaq_data-0.0.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created the 15/11/2022
|
|
4
|
+
|
|
5
|
+
@author: Sebastien Weber
|
|
6
|
+
"""
|
|
7
|
+
from typing import Tuple
|
|
8
|
+
import os
|
|
9
|
+
from collections import OrderedDict
|
|
10
|
+
from typing import List
|
|
11
|
+
import warnings
|
|
12
|
+
import logging
|
|
13
|
+
import webbrowser
|
|
14
|
+
import numpy as np
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from packaging import version as version_mod
|
|
17
|
+
|
|
18
|
+
from pymodaq_utils.logger import set_logger, get_module_name
|
|
19
|
+
from pymodaq_utils.config import Config
|
|
20
|
+
from .backends import H5Backend
|
|
21
|
+
from .exporter import ExporterFactory
|
|
22
|
+
|
|
23
|
+
config = Config()
|
|
24
|
+
logger = set_logger(get_module_name(__file__))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class H5BrowserUtil(H5Backend):
|
|
28
|
+
"""Utility object to interact and get info and data from a hdf5 file
|
|
29
|
+
|
|
30
|
+
Inherits H5Backend and all its functionalities
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
backend: str
|
|
35
|
+
The used hdf5 backend: either tables, h5py or h5pyd
|
|
36
|
+
"""
|
|
37
|
+
def __init__(self, backend='tables'):
|
|
38
|
+
super().__init__(backend=backend)
|
|
39
|
+
|
|
40
|
+
def export_data(self, node_path='/', filesavename: str = 'datafile.h5', filter=None):
|
|
41
|
+
"""Initialize the correct exporter and export the node"""
|
|
42
|
+
|
|
43
|
+
# Format the node and file type
|
|
44
|
+
filepath = Path(filesavename)
|
|
45
|
+
node = self.get_node(node_path)
|
|
46
|
+
# Separate dot from extension
|
|
47
|
+
extension = filepath.suffix[1:]
|
|
48
|
+
# Obtain the suitable exporter object
|
|
49
|
+
exporter = ExporterFactory.create_exporter(
|
|
50
|
+
extension,
|
|
51
|
+
ExporterFactory.get_format_from_filter(filter))
|
|
52
|
+
# Export the data
|
|
53
|
+
exporter.export_data(node, filepath)
|
|
54
|
+
|
|
55
|
+
def get_h5file_scans(self, where='/'):
|
|
56
|
+
"""Get the list of the scan nodes in the file
|
|
57
|
+
|
|
58
|
+
Parameters
|
|
59
|
+
----------
|
|
60
|
+
where: str
|
|
61
|
+
the path in the file
|
|
62
|
+
|
|
63
|
+
Returns
|
|
64
|
+
-------
|
|
65
|
+
list of dict
|
|
66
|
+
dict with keys: scan_name, path (within the file) and data (the live scan png image)
|
|
67
|
+
"""
|
|
68
|
+
# TODO add a test for this method
|
|
69
|
+
scan_list = []
|
|
70
|
+
where = self.get_node(where)
|
|
71
|
+
for node in self.walk_nodes(where):
|
|
72
|
+
if 'pixmap2D' in node.attrs:
|
|
73
|
+
scan_list.append(
|
|
74
|
+
dict(scan_name='{:s}_{:s}'.format(node.parent_node.name, node.name), path=node.path,
|
|
75
|
+
data=node.attrs['pixmap2D']))
|
|
76
|
+
|
|
77
|
+
return scan_list
|
|
78
|
+
|
|
79
|
+
def get_h5_attributes(self, node_path):
|
|
80
|
+
"""
|
|
81
|
+
"""
|
|
82
|
+
node = self.get_node(node_path)
|
|
83
|
+
attrs_names = node.attrs.attrs_name
|
|
84
|
+
attr_dict = OrderedDict(node.attrs.to_dict())
|
|
85
|
+
|
|
86
|
+
settings = None
|
|
87
|
+
scan_settings = None
|
|
88
|
+
if 'settings' in attrs_names:
|
|
89
|
+
if node.attrs['settings'] != '':
|
|
90
|
+
settings = node.attrs['settings']
|
|
91
|
+
|
|
92
|
+
if 'scan_settings' in attrs_names:
|
|
93
|
+
if node.attrs['scan_settings'] != '':
|
|
94
|
+
scan_settings = node.attrs['scan_settings']
|
|
95
|
+
pixmaps = []
|
|
96
|
+
for attr in attrs_names:
|
|
97
|
+
if 'pixmap' in attr:
|
|
98
|
+
pixmaps.append(node.attrs[attr])
|
|
99
|
+
|
|
100
|
+
return attr_dict, settings, scan_settings, pixmaps
|
|
101
|
+
|