Skip to content

Commit

Permalink
translate column names to column numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
teuben committed Jun 30, 2023
1 parent b35e742 commit 2884008
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions animate2
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,26 @@ import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation

# get the filenames, make sure they are sorted in time
f = glob.glob('run1/tab/LinWave*tab')
fnames='run1/tab/LinWave*tab'
f = glob.glob(fnames)
f.sort()

# 1-based columns numbers for now
xcol = 3
ycol = 5
print('DEBUG: %s has %d files' % (fnames,len(f)))


def xycols(fname, xcol, ycol):
"""
translate column names into 1-based column numbers
"""
lines = open(fname).readlines()
cols = lines[1].split()
print('DEBUG: ',cols[1:])
ixcol = cols.index(xcol)
iycol = cols.index(ycol)
print('DEBUG: ',ixcol,iycol)
return (ixcol,iycol)

# 1-based columns numbers from the column names
(xcol,ycol) = xycols(f[0],'x1v','velx')

# delay in ms
delay=100
Expand Down

0 comments on commit 2884008

Please sign in to comment.