No phase name for generic datasets

This commit is contained in:
Vitesh Shah 2019-12-13 09:53:47 +01:00
parent 19bc686327
commit 186605610d
2 changed files with 8 additions and 2 deletions

View File

@ -2,6 +2,7 @@
import os import os
import argparse import argparse
import re
import h5py import h5py
import numpy as np import numpy as np
@ -89,10 +90,12 @@ for filename in options.filenames:
x = results.get_dataset_location(label) x = results.get_dataset_location(label)
if len(x) == 0: if len(x) == 0:
continue continue
ph_name = re.compile(r'(\/[1-9])_([A-Z][a-z]*)_(([a-z]*)|([A-Z]*))') #looking for phase name in dataset name
array = results.read_dataset(x,0) array = results.read_dataset(x,0)
shape = [array.shape[0],np.product(array.shape[1:])] shape = [array.shape[0],np.product(array.shape[1:])]
vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape),deep=True,array_type= vtk.VTK_DOUBLE)) vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape),deep=True,array_type= vtk.VTK_DOUBLE))
vtk_data[-1].SetName('1_'+x[0].split('/',1)[1]) dset_name = '1_' + re.sub(ph_name,r'',x[0].split('/',1)[1]) #removing phase name from generic dataset
vtk_data[-1].SetName(dset_name)
grid.GetCellData().AddArray(vtk_data[-1]) grid.GetCellData().AddArray(vtk_data[-1])
results.set_visible('constituents', False) results.set_visible('constituents', False)

View File

@ -2,6 +2,7 @@
import os import os
import argparse import argparse
import re
import numpy as np import numpy as np
import vtk import vtk
@ -76,10 +77,12 @@ for filename in options.filenames:
x = results.get_dataset_location(label) x = results.get_dataset_location(label)
if len(x) == 0: if len(x) == 0:
continue continue
ph_name = re.compile(r'(\/[1-9])_([A-Z][a-z]*)_(([a-z]*)|([A-Z]*))') #looking for phase name in dataset name
array = results.read_dataset(x,0) array = results.read_dataset(x,0)
shape = [array.shape[0],np.product(array.shape[1:])] shape = [array.shape[0],np.product(array.shape[1:])]
vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape),deep=True,array_type= vtk.VTK_DOUBLE)) vtk_data.append(numpy_support.numpy_to_vtk(num_array=array.reshape(shape),deep=True,array_type= vtk.VTK_DOUBLE))
vtk_data[-1].SetName('1_'+x[0].split('/',1)[1]) dset_name = '1_' + re.sub(ph_name,r'',x[0].split('/',1)[1]) #removing phase name from generic dataset
vtk_data[-1].SetName(dset_name)
Polydata.GetCellData().AddArray(vtk_data[-1]) Polydata.GetCellData().AddArray(vtk_data[-1])
results.set_visible('constituents', False) results.set_visible('constituents', False)