forked from IPKM/nmreval
basic FC reading is working for different script version
This commit is contained in:
parent
e5563d55d5
commit
99bb196e5c
@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from nmreval.lib.logger import logger
|
||||||
from nmreval.lib.colors import available_cycles
|
from nmreval.lib.colors import available_cycles
|
||||||
|
|
||||||
from .properties import PropWidget
|
from .properties import PropWidget
|
||||||
@ -356,7 +357,10 @@ class DataTree(QtWidgets.QTreeWidget):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
idx = self.invisibleRootItem().indexOfChild(item)
|
idx = self.invisibleRootItem().indexOfChild(item)
|
||||||
self.invisibleRootItem().takeChild(idx)
|
self.invisibleRootItem().takeChild(idx)
|
||||||
self._checked_graphs.remove(_id)
|
try:
|
||||||
|
self._checked_graphs.remove(_id)
|
||||||
|
except KeyError:
|
||||||
|
logger.warn(f'Graph {_id} already removed, skip')
|
||||||
|
|
||||||
iterator += 1
|
iterator += 1
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ class QFCReader(QtWidgets.QDialog, Ui_FCEval_dialog):
|
|||||||
infiles = QtWidgets.QFileDialog.getExistingDirectory(caption='Select input directory',
|
infiles = QtWidgets.QFileDialog.getExistingDirectory(caption='Select input directory',
|
||||||
directory=str(self.path),
|
directory=str(self.path),
|
||||||
options=QtWidgets.QFileDialog.ShowDirsOnly)
|
options=QtWidgets.QFileDialog.ShowDirsOnly)
|
||||||
|
infiles = [infiles] if infiles else infiles
|
||||||
|
|
||||||
if infiles:
|
if infiles:
|
||||||
self.listWidget.addItems(infiles)
|
self.listWidget.addItems(infiles)
|
||||||
|
@ -15,7 +15,6 @@ from nmreval.utils.utils import get_temperature, roundrobin
|
|||||||
|
|
||||||
class FCReader:
|
class FCReader:
|
||||||
def __init__(self, fname: (list | str | pathlib.Path)):
|
def __init__(self, fname: (list | str | pathlib.Path)):
|
||||||
print('Hello')
|
|
||||||
if isinstance(fname, (str, pathlib.Path)):
|
if isinstance(fname, (str, pathlib.Path)):
|
||||||
self.fnames = [fname]
|
self.fnames = [fname]
|
||||||
else:
|
else:
|
||||||
@ -78,15 +77,15 @@ class FCReader:
|
|||||||
_temp = {}
|
_temp = {}
|
||||||
reader = HdfReader(filename)
|
reader = HdfReader(filename)
|
||||||
|
|
||||||
mag_directory = 'Magnetization'
|
mag_directory = None
|
||||||
for m in ['Magnetization', 'mag']:
|
for m in ['Magnetization', 'mag']:
|
||||||
try:
|
if m in reader:
|
||||||
mag_directory = m
|
mag_directory = m
|
||||||
except KeyError:
|
break
|
||||||
continue
|
|
||||||
|
|
||||||
for mag in reader.get_selected(mag_directory, dtype='points'):
|
if m is not None:
|
||||||
_temp[mag.value] = mag
|
for mag in reader.get_selected(mag_directory, dtype='points'):
|
||||||
|
_temp[mag.value] = mag
|
||||||
|
|
||||||
return _temp
|
return _temp
|
||||||
|
|
||||||
@ -122,14 +121,19 @@ class FCReader:
|
|||||||
|
|
||||||
_temp = {}
|
_temp = {}
|
||||||
bevo_groups = reader['data'].children
|
bevo_groups = reader['data'].children
|
||||||
|
no_bevo = False
|
||||||
for grp in bevo_groups.values():
|
for grp in bevo_groups.values():
|
||||||
for k in grp.data():
|
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)':
|
if str(k.parent) != 'ACC_ABS_FID_sig (group)':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print(k.path, k, k.parent, k.parameter['bevo'], k.parameter['tevo'])
|
|
||||||
bevo = k.parameter['bevo']
|
|
||||||
tevo = k.parameter['tevo']
|
tevo = k.parameter['tevo']
|
||||||
|
|
||||||
s = reader.make_signal(k, flag='fid', value='tevo', group='bevo')
|
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]))
|
_temp[bevo].append((tevo, *[pp[1] for pp in pts]))
|
||||||
|
|
||||||
# sig = reader.get_selected('/data/B=*/ACC_ABS_FID*', dtype='signal')
|
if no_bevo:
|
||||||
# _temp = {}
|
break
|
||||||
# for s in sig:
|
|
||||||
# pts = s.points([region])
|
if no_bevo:
|
||||||
# b = s.group
|
# hopefully only for old scripts
|
||||||
# if b not in _temp:
|
sig = reader.get_selected('/data/B=*/ACC_ABS_FID*', dtype='signal')
|
||||||
# _temp[b] = []
|
_temp = {}
|
||||||
#
|
for s in sig:
|
||||||
# _temp[b].append([s.value, *[pp[1] for pp in pts]])
|
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()):
|
for b, m in sorted(_temp.items()):
|
||||||
m = np.array(m)
|
m = np.array(m)
|
||||||
@ -410,12 +419,3 @@ class FCReader:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def kww(x, m0, off, t1, beta):
|
def kww(x, m0, off, t1, beta):
|
||||||
return m0 * np.exp(-(x/t1)**beta) + off
|
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)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user