1
0
forked from IPKM/nmreval

basic FC reading is working for different script version

This commit is contained in:
Dominik Demuth 2023-04-14 19:17:05 +02:00
parent e5563d55d5
commit 99bb196e5c
3 changed files with 34 additions and 29 deletions

View File

@ -1,5 +1,6 @@
from __future__ import annotations
from nmreval.lib.logger import logger
from nmreval.lib.colors import available_cycles
from .properties import PropWidget
@ -356,7 +357,10 @@ class DataTree(QtWidgets.QTreeWidget):
except AttributeError:
idx = self.invisibleRootItem().indexOfChild(item)
self.invisibleRootItem().takeChild(idx)
try:
self._checked_graphs.remove(_id)
except KeyError:
logger.warn(f'Graph {_id} already removed, skip')
iterator += 1

View File

@ -54,6 +54,7 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
infiles = QtWidgets.QFileDialog.getExistingDirectory(caption='Select input directory',
directory=str(self.path),
options=QtWidgets.QFileDialog.ShowDirsOnly)
infiles = [infiles] if infiles else infiles
if infiles:
self.listWidget.addItems(infiles)

View File

@ -15,7 +15,6 @@ from nmreval.utils.utils import get_temperature, roundrobin
class FCReader:
def __init__(self, fname: (list | str | pathlib.Path)):
print('Hello')
if isinstance(fname, (str, pathlib.Path)):
self.fnames = [fname]
else:
@ -78,13 +77,13 @@ class FCReader:
_temp = {}
reader = HdfReader(filename)
mag_directory = 'Magnetization'
mag_directory = None
for m in ['Magnetization', 'mag']:
try:
if m in reader:
mag_directory = m
except KeyError:
continue
break
if m is not None:
for mag in reader.get_selected(mag_directory, dtype='points'):
_temp[mag.value] = mag
@ -122,14 +121,19 @@ class FCReader:
_temp = {}
bevo_groups = reader['data'].children
no_bevo = False
for grp in bevo_groups.values():
for k in grp.data():
print(k)
try:
# look for parameter, should be missing in older scripts
bevo = k.parameter['bevo']
except KeyError:
no_bevo = True
break
if str(k.parent) != 'ACC_ABS_FID_sig (group)':
continue
print(k.path, k, k.parent, k.parameter['bevo'], k.parameter['tevo'])
bevo = k.parameter['bevo']
tevo = k.parameter['tevo']
s = reader.make_signal(k, flag='fid', value='tevo', group='bevo')
@ -140,15 +144,20 @@ class FCReader:
_temp[bevo].append((tevo, *[pp[1] for pp in pts]))
# sig = reader.get_selected('/data/B=*/ACC_ABS_FID*', dtype='signal')
# _temp = {}
# for s in sig:
# pts = s.points([region])
# b = s.group
# if b not in _temp:
# _temp[b] = []
#
# _temp[b].append([s.value, *[pp[1] for pp in pts]])
if no_bevo:
break
if no_bevo:
# hopefully only for old scripts
sig = reader.get_selected('/data/B=*/ACC_ABS_FID*', dtype='signal')
_temp = {}
for s in sig:
pts = s.points([region])
b = s.group
if b not in _temp:
_temp[b] = []
_temp[b].append([s.value, *[pp[1] for pp in pts]])
for b, m in sorted(_temp.items()):
m = np.array(m)
@ -410,12 +419,3 @@ class FCReader:
@staticmethod
def kww(x, m0, off, t1, beta):
return m0 * np.exp(-(x/t1)**beta) + off
if __name__ == '__main__':
test = FCReader('/autohome/dominik/nmreval/testdata/fc_test/314K_2015-09-03_1605.h5')
test.load_magnetization(region=(None, None))
# test = FCReader('/autohome/dominik/nmreval/testdata/fc_test/2023-03-16_1423.h5')
# test.load_magnetization(region=(None, None))
print(test.data)