From 02d155c01f4fd23a8c295496f6e4037e44d6ae7e Mon Sep 17 00:00:00 2001 From: Thomas Gastine Date: Wed, 26 Feb 2025 15:45:38 +0100 Subject: [PATCH] bugfix in movie2vtk.py --- python/magic/movie2vtk.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/python/magic/movie2vtk.py b/python/magic/movie2vtk.py index 2644790c..0d4ba5c6 100644 --- a/python/magic/movie2vtk.py +++ b/python/magic/movie2vtk.py @@ -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') @@ -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) @@ -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 @@ -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