Skip to content

Commit

Permalink
Define data type before saving into h5 for DataMakers
Browse files Browse the repository at this point in the history
Prevents crash when data contain value 0.000"
  • Loading branch information
feranick committed Oct 7, 2024
1 parent 01c611a commit c75e9b8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Utilities/GenericDataMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* GenericDataMaker
* Adds spectra to single file for classification
* File must be in TXT format
* version: v2023.12.15.1
* version: v2024.10.07.1
* By: Nicola Ferralis <[email protected]>
**************************************************
'''
Expand Down Expand Up @@ -193,7 +193,7 @@ def saveLearningFile(M, learnFileRoot):
else:
learnFile = learnFileRoot+'.h5'
with h5py.File(learnFile, 'w') as hf:
hf.create_dataset("M", data=M)
hf.create_dataset("M", data=M.astype(np.float64))
print(" Saving new training file (hdf5) in: "+learnFile+"\n")

#************************************
Expand Down
4 changes: 2 additions & 2 deletions Utilities/RandomCrossValidMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
***********************************************
* Create Random Cross Validation Datasets
* Train + Test
* version: v2023.12.19.1
* version: v2024.10.07.1
* By: Nicola Ferralis <[email protected]>
***********************************************
'''
Expand Down Expand Up @@ -129,7 +129,7 @@ def writeFile(File, En, A, Cl):
np.savetxt(f, newMatrix, delimiter='\t', fmt='%10.6f')
else:
with h5py.File(File, 'w') as hf:
hf.create_dataset("M", data=newMatrix)
hf.create_dataset("M", data=newMatrix.astype(np.float64))

#************************************
''' Main initialization routine '''
Expand Down
4 changes: 2 additions & 2 deletions Utilities/RruffDataMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* RRuffDataMaker
* Adds spectra to single file for classification
* File must be in RRuFF
* version: v2023.12.15.1
* version: v2024.10.07.1
* By: Nicola Ferralis <[email protected]>
*************************************************
'''
Expand Down Expand Up @@ -174,7 +174,7 @@ def saveLearningFile(M, learnFileRoot):
else:
learnFile = learnFileRoot+'.h5'
with h5py.File(learnFile, 'w') as hf:
hf.create_dataset("M", data=M)
hf.create_dataset("M", data=M.astype(np.float64))
print(" Saving new training file (hdf5) in: "+learnFile+"\n")

#************************************
Expand Down
4 changes: 2 additions & 2 deletions Utilities/XmuDataMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* XmuDataMaker
* Adds spectra to single file for classification
* File must be in Xmu
* version: v2023.12.15.1
* version: v2024.10.07.1
* By: Nicola Ferralis <[email protected]>
*************************************************
'''
Expand Down Expand Up @@ -171,7 +171,7 @@ def saveLearningFile(M, learnFileRoot):
else:
learnFile = learnFileRoot+'.h5'
with h5py.File(learnFile, 'w') as hf:
hf.create_dataset("M", data=M)
hf.create_dataset("M", data=M.astype(np.float64))
print(" Saving new training file (hdf5) in: "+learnFile+"\n")

#************************************
Expand Down

0 comments on commit c75e9b8

Please sign in to comment.