From 1245ec7d94a7b2c69763393b406f8fcf40b607b6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 4 Dec 2023 22:25:28 +0100 Subject: [PATCH] grouped --- python/damask/_result.py | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index a3a9a9de5..8bf4638c5 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -1940,7 +1940,7 @@ class Result: The DREAM3D file is based on HDF5 file format. Without any regridding. Considers the original grid from DAMASK. - Needs orientation data, O, present in the file. + Needs orientation data, 'O', present in the file. Parameters ---------- @@ -1999,25 +1999,19 @@ class Result: o.create_group(g) data_container = create_and_open(o,'DataContainers/SyntheticVolumeDataContainer') + cell = create_and_open(data_container,'CellData') - - cell['Phases'] = np.reshape(phase_ID_array,tuple(np.flip(self.cells))+(1,)) - cell['EulerAngles'] = cell_orientation.reshape(tuple(np.flip(self.cells))+(3,)) - add_attribute(cell,'AttributeMatrixType',np.array([3],np.uint32)) add_attribute(cell,'TupleDimensions', np.array(self.cells,np.uint64)) - # Common Attributes for groups in CellData + cell['Phases'] = np.reshape(phase_ID_array,tuple(np.flip(self.cells))+(1,)) + cell['EulerAngles'] = cell_orientation.reshape(tuple(np.flip(self.cells))+(3,)) for dataset in ['Phases','EulerAngles']: add_attribute(cell[dataset],'DataArrayVersion',np.array([2],np.int32)) add_attribute(cell[dataset],'Tuple Axis Dimensions','x={},y={},z={}'.format(*np.array(self.cells))) add_attribute(cell[dataset],'TupleDimensions', np.array(self.cells,np.uint64)) - - # phase attributes add_attribute(cell['Phases'], 'ComponentDimensions', np.array([1],np.uint64)) add_attribute(cell['Phases'], 'ObjectType', 'DataArray') - - # Eulers attributes add_attribute(cell['EulerAngles'], 'ComponentDimensions', np.array([3],np.uint64)) add_attribute(cell['EulerAngles'], 'ObjectType', 'DataArray') @@ -2046,18 +2040,15 @@ class Result: cell_ensemble.attrs['TupleDimensions'] = np.array([len(self.phases) + 1], np.uint64) # Attributes for data in Ensemble matrix - for group in ['CrystalStructures','PhaseTypes']: - add_attribute(cell_ensemble[group], 'ComponentDimensions', np.array([1],np.uint64)) + for group in ['CrystalStructures','PhaseTypes','PhaseName']: + add_attribute(cell_ensemble[group], 'ComponentDimensions', np.array([1],np.uint64)) add_attribute(cell_ensemble[group], 'Tuple Axis Dimensions', f'x={len(self.phases)+1}') - add_attribute(cell_ensemble[group], 'DataArrayVersion', np.array([2],np.int32)) - add_attribute(cell_ensemble[group], 'ObjectType', 'DataArray') - add_attribute(cell_ensemble[group], 'TupleDimensions', np.array([len(self.phases) + 1],np.uint64)) + add_attribute(cell_ensemble[group], 'DataArrayVersion', np.array([2],np.int32)) + add_attribute(cell_ensemble[group], 'TupleDimensions', np.array([len(self.phases) + 1],np.uint64)) - add_attribute(cell_ensemble['PhaseName'], 'ComponentDimensions', np.array([1],np.uint64)) - add_attribute(cell_ensemble['PhaseName'], 'Tuple Axis Dimensions', f'x={len(self.phases)+1}') - add_attribute(cell_ensemble['PhaseName'], 'DataArrayVersion', np.array([2],np.int32)) - add_attribute(cell_ensemble['PhaseName'], 'ObjectType', 'StringDataArray') - add_attribute(cell_ensemble['PhaseName'], 'TupleDimensions', np.array([len(self.phases) + 1],np.uint64)) + for group in ['CrystalStructures','PhaseTypes']: + add_attribute(cell_ensemble[group], 'ObjectType', 'DataArray') + add_attribute(cell_ensemble['PhaseName'], 'ObjectType', 'StringDataArray') # Create geometry info geom = create_and_open(data_container,'_SIMPL_GEOMETRY') @@ -2066,11 +2057,10 @@ class Result: geom['ORIGIN'] = np.float32(np.zeros(3)) geom['SPACING'] = np.float32(dx) - add_attribute(geom, 'GeometryName', 'ImageGeometry') - add_attribute(geom, 'GeometryTypeName', 'ImageGeometry') - add_attribute(geom, 'GeometryType', np.array([0],np.uint32)) - add_attribute(geom, 'SpatialDimensionality', np.array([3],np.uint32)) - add_attribute(geom, 'UnitDimensionality', np.array([3],np.uint32)) + names = ['GeometryName', 'GeometryTypeName','GeometryType','SpatialDimensionality','UnitDimensionality'] + values = ['ImageGeometry','ImageGeometry',np.array([0],np.uint32),np.array([3],np.uint32),np.array([3],np.uint32)] + for name,value in zip(names,values): + add_attribute(geom,name,value) def export_DADF5(self,