Commit dd569452 authored by Hal Finkel's avatar Hal Finkel
Browse files

import uint16 fix by Biwer, Christopher Michael <cmbiwer@lanl.gov>

parent 22c1c0ab
...@@ -56,6 +56,9 @@ libpygio.get_variable_type.argtypes=[ct.c_char_p,ct.c_char_p] ...@@ -56,6 +56,9 @@ libpygio.get_variable_type.argtypes=[ct.c_char_p,ct.c_char_p]
libpygio.get_variable_field_count.restype=ct.c_int libpygio.get_variable_field_count.restype=ct.c_int
libpygio.get_variable_field_count.argtypes=[ct.c_char_p,ct.c_char_p] libpygio.get_variable_field_count.argtypes=[ct.c_char_p,ct.c_char_p]
libpygio.read_gio_uint16.restype=None
libpygio.read_gio_uint16.argtypes=[ct.c_char_p,ct.c_char_p,ct.POINTER(ct.c_uint16),ct.c_int]
libpygio.read_gio_int32.restype=None libpygio.read_gio_int32.restype=None
libpygio.read_gio_int32.argtypes=[ct.c_char_p,ct.c_char_p,ct.POINTER(ct.c_int),ct.c_int] libpygio.read_gio_int32.argtypes=[ct.c_char_p,ct.c_char_p,ct.POINTER(ct.c_int),ct.c_int]
...@@ -82,7 +85,7 @@ def gio_read(file_name,var_name): ...@@ -82,7 +85,7 @@ def gio_read(file_name,var_name):
print("Variable not found") print("Variable not found")
return return
elif(var_type==9): elif(var_type==9):
print("variable type not known (not int32/int64/float/double)") print("variable type not known (not uint16/int32/int64/float/double)")
elif(var_type==0): elif(var_type==0):
#float #float
result = np.ndarray((var_size,field_count),dtype=np.float32) result = np.ndarray((var_size,field_count),dtype=np.float32)
...@@ -103,6 +106,11 @@ def gio_read(file_name,var_name): ...@@ -103,6 +106,11 @@ def gio_read(file_name,var_name):
result = np.ndarray((var_size,field_count),dtype=np.int64) result = np.ndarray((var_size,field_count),dtype=np.int64)
libpygio.read_gio_int64(file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_int64)),field_count) libpygio.read_gio_int64(file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_int64)),field_count)
return result return result
elif(var_type==4):
#uint16
result = np.ndarray((var_size,field_count),dtype=np.uint16)
libpygio.read_gio_uint16(file_name,var_name,result.ctypes.data_as(ct.POINTER(ct.c_uint16)),field_count)
return result
def gio_has_variable(file_name,var_name): def gio_has_variable(file_name,var_name):
if sys.version_info[0] == 3: if sys.version_info[0] == 3:
......
...@@ -48,6 +48,9 @@ ...@@ -48,6 +48,9 @@
void read_gio_double(char* file_name, char* var_name, double* data, int field_count){ void read_gio_double(char* file_name, char* var_name, double* data, int field_count){
read_gio<double>(file_name,var_name,data,field_count); read_gio<double>(file_name,var_name,data,field_count);
} }
void read_gio_uint16(char* file_name, char* var_name, uint16_t* data, int field_count){
read_gio<uint16_t>(file_name,var_name,data,field_count);
}
void read_gio_int32(char* file_name, char* var_name, int* data, int field_count){ void read_gio_int32(char* file_name, char* var_name, int* data, int field_count){
read_gio<int>(file_name,var_name,data,field_count); read_gio<int>(file_name,var_name,data,field_count);
} }
...@@ -80,6 +83,8 @@ ...@@ -80,6 +83,8 @@
return float_type; return float_type;
else if(vinfo.IsFloat && vinfo.ElementSize == 8) else if(vinfo.IsFloat && vinfo.ElementSize == 8)
return double_type; return double_type;
else if(!vinfo.IsFloat && vinfo.ElementSize == 2)
return uint16_type;
else if(!vinfo.IsFloat && vinfo.ElementSize == 4) else if(!vinfo.IsFloat && vinfo.ElementSize == 4)
return int32_type; return int32_type;
else if(!vinfo.IsFloat && vinfo.ElementSize == 8) else if(!vinfo.IsFloat && vinfo.ElementSize == 8)
......
...@@ -72,6 +72,7 @@ extern "C" int64_t get_elem_num(char* file_name); ...@@ -72,6 +72,7 @@ extern "C" int64_t get_elem_num(char* file_name);
extern "C" void read_gio_float (char* file_name, char* var_name, float* data, int field_count); extern "C" void read_gio_float (char* file_name, char* var_name, float* data, int field_count);
extern "C" void read_gio_double(char* file_name, char* var_name, double* data, int field_count); extern "C" void read_gio_double(char* file_name, char* var_name, double* data, int field_count);
extern "C" void read_gio_uint16 (char* file_name, char* var_name, uint16_t* data, int field_count);
extern "C" void read_gio_int32 (char* file_name, char* var_name, int* data, int field_count); extern "C" void read_gio_int32 (char* file_name, char* var_name, int* data, int field_count);
extern "C" void read_gio_int64 (char* file_name, char* var_name, int64_t* data, int field_count); extern "C" void read_gio_int64 (char* file_name, char* var_name, int64_t* data, int field_count);
enum var_type{ enum var_type{
...@@ -79,6 +80,7 @@ enum var_type{ ...@@ -79,6 +80,7 @@ enum var_type{
double_type=1, double_type=1,
int32_type=2, int32_type=2,
int64_type=3, int64_type=3,
uint16_type=4,
type_not_found=9, type_not_found=9,
var_not_found=10 var_not_found=10
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment