Skip to content

Commit

Permalink
bugfix in movie2vtk.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tgastine committed Feb 26, 2025
1 parent 4a1ab24 commit 02d155c
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions python/magic/movie2vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ def __init__(self, file=None, step=1, lastvar=None, nvar='all', fluct=False,
b = tPattern.search(ff[1]+'_'+ff[2]).groups()[1]
self.thetaCut = float(a+'.'+b)

# Get the version
self._get_version(os.path.join(datadir, filename))

# Read the movie file
infile = npfile(os.path.join(datadir, filename), endian='B')

Expand All @@ -132,7 +135,7 @@ def __init__(self, file=None, step=1, lastvar=None, nvar='all', fluct=False,
self.theta = np.linspace(0., np.pi, self.n_theta_max)

# Get the number of lines
self._get_nlines(datadir, filename, nvar, lastar)
self._get_nlines(datadir, filename, nvar, lastvar)

# Determine the shape of the data
self._get_data_shape(precision, allocate=False)
Expand All @@ -145,7 +148,7 @@ def __init__(self, file=None, step=1, lastvar=None, nvar='all', fluct=False,
prefix = 'AV_mov'
elif 'T' in field:
prefix = 'ATmov'
elif 'C' in field:
elif 'C' in field or 'XI' in field:
prefix = 'ACmov'
tag = filename.split('.')[-1]
av_mov = prefix + '.' + tag
Expand Down Expand Up @@ -245,6 +248,23 @@ def __init__(self, file=None, step=1, lastvar=None, nvar='all', fluct=False,

infile.close()

def _get_version(self, filename):
"""
This routine determines the version of the movie files
:param filename: name of the movie file
:type filename: str
"""
with open(filename, 'rb') as fi:
rm = np.fromfile(fi, np.float32, count=1) # record marker
self.version = np.fromfile(fi, '>i4', count=1)[0]
rm = np.fromfile(fi, np.float32, count=1)
if abs(self.version) > 100:
fi = npfile(filename, endian='B')
version = fi.fort_read('|S64')[0].decode().rstrip()
self.version = int(version[-1])
fi.close()

def scal3D2vtk(self, fname, data, name):
"""
This routine transforms a 3-D scalar field of dimension
Expand Down

0 comments on commit 02d155c

Please sign in to comment.