From 6f0308844ff00133ae16ce2b2413a35e9d261d62 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 12 Apr 2013 10:47:44 +0000 Subject: [PATCH] geom packing/unpacking won't throw away unknown header information any more (might contain comments) --- processing/pre/geom_pack.py | 19 ++----------------- processing/pre/geom_unpack.py | 17 ++--------------- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/processing/pre/geom_pack.py b/processing/pre/geom_pack.py index 4c914d2bd..804bb5834 100755 --- a/processing/pre/geom_pack.py +++ b/processing/pre/geom_pack.py @@ -75,7 +75,7 @@ for file in files: m = re.search('(\d+)\s*head', firstline.lower()) if m: headerlines = int(m.group(1)) - headers = [firstline]+[file['input'].readline() for i in range(headerlines)] + headers = [file['input'].readline() for i in range(headerlines)] else: headerlines = 1 headers = firstline @@ -102,6 +102,7 @@ for file in files: mappings[headitems[0]](headitems[headitems.index(identifiers[headitems[0]][i])+1]) else: info[headitems[0]] = mappings[headitems[0]](headitems[1]) + new_header.append(header) if info['grid'] == [0,0,0]: file['croak'].write('no grid info found.\n') @@ -115,22 +116,6 @@ for file in files: 'origin x y z: %s\n'%(' : '.join(map(str,info['origin']))) + \ 'homogenization: %i\n'%info['homogenization'] + \ 'microstructures: %i\n'%info['microstructures']) - - new_header.append("grid\ta %i\tb %i\tc %i\n"%( - info['grid'][0], - info['grid'][1], - info['grid'][2],)) - new_header.append("size\tx %f\ty %f\tz %f\n"%( - info['size'][0], - info['size'][1], - info['size'][2])) - new_header.append("origin\tx %f\ty %f\tz %f\n"%( - info['origin'][0], - info['origin'][1], - info['origin'][2])) - new_header.append("homogenization\t%i\n"%info['homogenization']) - if info['microstructures'] > 0: - new_header.append("microstructures\t%i\n"%info['microstructures']) # ------------------------------------------ assemble header --------------------------------------- diff --git a/processing/pre/geom_unpack.py b/processing/pre/geom_unpack.py index 840345eb5..eec7ee200 100755 --- a/processing/pre/geom_unpack.py +++ b/processing/pre/geom_unpack.py @@ -81,7 +81,7 @@ for file in files: m = re.search('(\d+)\s*head', firstline.lower()) if m: headerlines = int(m.group(1)) - headers = [firstline]+[file['input'].readline() for i in range(headerlines)] + headers = [file['input'].readline() for i in range(headerlines)] else: headerlines = 1 headers = firstline @@ -108,6 +108,7 @@ for file in files: mappings[headitems[0]](headitems[headitems.index(identifiers[headitems[0]][i])+1]) else: info[headitems[0]] = mappings[headitems[0]](headitems[1]) + new_header.append(header) if info['grid'] == [0,0,0]: file['croak'].write('no grid info found.\n') @@ -125,21 +126,7 @@ for file in files: 'homogenization: %i\n'%info['homogenization'] + \ 'microstructures: %i\n'%info['microstructures']) - new_header.append("grid\ta %i\tb %i\tc %i\n"%( - info['grid'][0], - info['grid'][1], - info['grid'][2],)) - new_header.append("size\tx %f\ty %f\tz %f\n"%( - info['size'][0], - info['size'][1], - info['size'][2])) - new_header.append("origin\tx %f\ty %f\tz %f\n"%( - info['origin'][0], - info['origin'][1], - info['origin'][2])) - new_header.append("homogenization\t%i\n"%info['homogenization']) if info['microstructures'] > 0: - new_header.append("microstructures\t%i\n"%info['microstructures']) digits = 1+int(math.log10(int(info['microstructures']))) else: digits = 1+int(math.log10(int(info['grid'][0]*info['grid'][1]*info['grid'][2])))