Skip to content

Commit

Permalink
Fix reading ODT files when using the magnetoelastic extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
stibus committed Jul 4, 2021
1 parent 17b9a97 commit 81e8044
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 0 additions & 4 deletions ubermagtable/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,7 @@ def fromfile(cls, filename, /, x=None, rename=True):
>>> table = ut.Table.fromfile(odtfile, x='t')
"""
# MagnetoElastic OOMMF extension adds energy twice to data. The
# following lines are just a way to fix that in the data.
cols = uu.columns(filename, rename=rename)
if 'MEL_E' in cols:
cols.insert(cols.index('E'), 'E')

return cls(data=pd.DataFrame(uu.data(filename), columns=cols),
units=uu.units(filename, rename=rename), x=x)
Expand Down
6 changes: 3 additions & 3 deletions ubermagtable/util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
'CGEvolve::Cycle count': 'cycle_count',
'CGEvolve::Cycle sub count': 'cycle_sub_count',
'CGEvolve::Energy calc count': 'energy_calc_count',
'CGEvolve:evolver:Energy calc count YY_FixedMEL::Energy':
'MEL_E',
'FixedMEL::Energy': 'MEL_E',
'FixedMEL:magnetoelastic:Energy': 'MEL_E',
'SpinTEvolve:evolver:Total energy': 'E',
'SpinTEvolve:evolver:Energy calc count': 'E_calc_count',
'SpinTEvolve:evolver:Max dm/dt': 'max_dmdt',
Expand Down Expand Up @@ -195,7 +195,7 @@ def columns(filename, rename=True):

if lines[0].startswith('# ODT'): # OOMMF odt file
cline = list(filter(lambda l: l.startswith('# Columns:'), lines))[0]
cline = re.split(r'Oxs_|Anv_|Southampton_|My_|UHH_|Xf_', cline)[1:]
cline = re.split(r'Oxs_|Anv_|Southampton_|My_|YY_|UHH_|Xf_', cline)[1:]
cline = list(map(lambda col: re.sub(r'[{}]', '', col), cline))
cols = list(map(lambda s: s.strip(), cline))
cols_dict = oommf_dict
Expand Down

0 comments on commit 81e8044

Please sign in to comment.