Data read and written now with respect to actual AcReal properties. This will save space in the future.
This commit is contained in:
@@ -21,14 +21,27 @@
|
||||
|
||||
import numpy as np
|
||||
|
||||
def set_dtype(endian, AcRealSize):
|
||||
if endian == 0:
|
||||
en = '>'
|
||||
elif endian == 1:
|
||||
en = '<'
|
||||
type_instruction = en + 'f' + str(AcRealSize)
|
||||
print("type_instruction", type_instruction)
|
||||
my_dtype = np.dtype(type_instruction)
|
||||
return my_dtype
|
||||
|
||||
def read_bin(fname, fdir, fnum, minfo, numtype=np.longdouble):
|
||||
'''Read in a floating point array'''
|
||||
filename = fdir + fname + '_' + fnum + '.mesh'
|
||||
datas = np.DataSource()
|
||||
read_ok = datas.exists(filename)
|
||||
|
||||
my_dtype = set_dtype(minfo.contents['endian'], minfo.contents['AcRealSize'])
|
||||
|
||||
if read_ok:
|
||||
print(filename)
|
||||
array = np.fromfile(filename, dtype=numtype)
|
||||
array = np.fromfile(filename, dtype=my_dtype)
|
||||
|
||||
timestamp = array[0]
|
||||
|
||||
@@ -52,6 +65,9 @@ def read_meshtxt(fdir, fname):
|
||||
if line[0] == 'int':
|
||||
contents[line[1]] = np.int(line[2])
|
||||
print(line[1], contents[line[1]])
|
||||
elif line[0] == 'size_t':
|
||||
contents[line[1]] = np.int(line[2])
|
||||
print(line[1], contents[line[1]])
|
||||
elif line[0] == 'int3':
|
||||
contents[line[1]] = [np.int(line[2]), np.int(line[3]), np.int(line[4])]
|
||||
print(line[1], contents[line[1]])
|
||||
|
@@ -63,7 +63,7 @@ write_mesh_info(const AcMeshInfo* config)
|
||||
// Determine endianness
|
||||
unsigned int EE = 1;
|
||||
char *CC = (char*) &EE;
|
||||
const int endianness = (int) *C;
|
||||
const int endianness = (int) *CC;
|
||||
// endianness = 0 -> big endian
|
||||
// endianness = 1 -> little endian
|
||||
|
||||
|
Reference in New Issue
Block a user