Data read and written now with respect to actual AcReal properties. This will save space in the future.

This commit is contained in:
Miikka Vaisala
2019-09-24 16:54:04 +08:00
parent d2e13d0139
commit d7bd92ed1b
2 changed files with 18 additions and 2 deletions

View File

@@ -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]])

View File

@@ -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