Skip to content

Commit

Permalink
remove duplicate energies before interpolation in groups2csv()
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed May 15, 2024
1 parent f6fd50e commit 697ccf5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions larch/io/csvfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import numpy as np
from dateutil.parser import parse as dateparse
from larch import Group
from larch.math import interp
from larch.math import interp, remove_dups
from larch.utils import bytes2str, fix_varname, gformat

maketrans = str.maketrans
Expand All @@ -32,7 +32,6 @@ def groups2csv(grouplist, filename, delim=',',
"""
delim = delim.strip() + ' '

def get_label(grp):
'get label for group'
for attr in ('filename', 'label', 'name', 'file', '__name__'):
Expand Down Expand Up @@ -80,11 +79,10 @@ def save_group(g, delim=', ', x='energy', y='norm'):
label = get_label(g)
buff.append("# %s: %s" % (label, g.filename))
labels.append(label)
_x = getattr(g, x)
_x = remove_dups(getattr(g, x))
_y = getattr(g, y)

if ((len(_x) != npts) or (abs(_x -x0)).sum() > 1.0):
columns.append(interp(_x, _y, x0))
columns.append(interp(_x, _y, x0, kind='linear'))
else:
columns.append(_y)

Expand Down

0 comments on commit 697ccf5

Please sign in to comment.