Skip to content

Commit

Permalink
Default oh5 files to OIM 9.1 specification.
Browse files Browse the repository at this point in the history
Signed-off by: David Rowenhorst <[email protected]>
  • Loading branch information
drowenhorst-nrl committed Dec 13, 2024
1 parent baa818e commit 10bacbf
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions pyebsdindex/ebsdfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,17 @@ def writeang(filename, indexer, data,

def writeoh5(filename, indexer, data,
gridtype='SqrGrid', xstep=1.0, ystep=1.0,
ncols=None, nrows=None, datasetname='Scan 1'):
ncols=None, nrows=None, datasetname='Scan 1', version='9.1'):
fpath = Path(filename).expanduser()

nphase = data.shape[0] - 1
phaseIDadd = 0
if version == '8.6':
if nphase == 1:
phaseIDadd = 1
else:
phaseIDadd = 1

with h5py.File(fpath, 'w') as f:

f.create_dataset(datasetname +'/EBSD/Header/Camera Azimuthal Angle', data=np.array([np.float64(0.0)]))
Expand Down Expand Up @@ -131,7 +139,9 @@ def writeoh5(filename, indexer, data,
f.create_dataset(datasetname + '/EBSD/Header/Pattern Center Calibration/zAdjCoeff0', data=np.array([np.float64(0.0)]))
f.create_dataset(datasetname + '/EBSD/Header/Pattern Center Calibration/zAdjCoeff1', data=np.array([np.float64(0.0)]))
f.create_dataset(datasetname + '/EBSD/Header/Pattern Center Calibration/zAdjCoeff2', data=np.array([np.float64(0.0)]))
pcount = 1


pcount = phaseIDadd
nphase = len(indexer.phaseLib)


Expand Down Expand Up @@ -223,11 +233,7 @@ def writeoh5(filename, indexer, data,


npoints = data[-1].shape[-1]
nphase = data.shape[0] - 1
if nphase == 1:
phaseIDadd = 0
else:
phaseIDadd = 1

eulers = rotlib.qu2eu(data[-1]['quat'])
phi1 = np.squeeze(eulers[:,0]).astype(np.float32)
phi = np.squeeze(eulers[:, 1]).astype(np.float32)
Expand All @@ -240,6 +246,8 @@ def writeoh5(filename, indexer, data,
f.create_dataset(datasetname + '/EBSD/Data/Phi2',
data=phi2)
f.create_dataset(datasetname + '/EBSD/Data/IQ',
data=(data[-1]['iq']).astype(np.float32))
f.create_dataset(datasetname + '/EBSD/Data/Pattern Quality',
data=(data[-1]['pq']).astype(np.float32))

f.create_dataset(datasetname + '/EBSD/Data/Fit',
Expand Down Expand Up @@ -269,9 +277,12 @@ def writeoh5(filename, indexer, data,
f.create_dataset(datasetname + '/EBSD/Data/Valid', data=np.zeros(npoints, dtype=np.int8))
f.create_dataset(datasetname + '/EBSD/Data/SEM Signal', data=np.zeros(npoints, dtype=np.int32))

version = 'OIM Analysis 8.6.103 x64 [29 Sep 2022]'
chararray = np.chararray(1, itemsize=len(version)+1)
chararray[:] = version
if version == '8.6':
versiontxt = 'OIM Analysis 8.6.103 x64 [29 Sep 2022]'
else:
versiontxt = 'OIM Analysis 9.1.0'
chararray = np.chararray(1, itemsize=len(versiontxt)+1)
chararray[:] = versiontxt
f.create_dataset('Version', data=chararray)
man = 'EDAX'
chararray = np.chararray(1, itemsize=len(man)+1 )
Expand Down

0 comments on commit 10bacbf

Please sign in to comment.