Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Buehlmann
GenericIO
Commits
dd569452
Commit
dd569452
authored
Oct 30, 2018
by
Hal Finkel
Browse files
import uint16 fix by Biwer, Christopher Michael <cmbiwer@lanl.gov>
parent
22c1c0ab
Changes
3
Show whitespace changes
Inline
Side-by-side
python/genericio.py
View file @
dd569452
...
...
@@ -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
.
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
.
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):
print
(
"Variable not found"
)
return
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
):
#float
result
=
np
.
ndarray
((
var_size
,
field_count
),
dtype
=
np
.
float32
)
...
...
@@ -103,6 +106,11 @@ def gio_read(file_name,var_name):
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
)
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
):
if
sys
.
version_info
[
0
]
==
3
:
...
...
python/lib/gio.cxx
View file @
dd569452
...
...
@@ -48,6 +48,9 @@
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
);
}
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
){
read_gio
<
int
>
(
file_name
,
var_name
,
data
,
field_count
);
}
...
...
@@ -80,6 +83,8 @@
return
float_type
;
else
if
(
vinfo
.
IsFloat
&&
vinfo
.
ElementSize
==
8
)
return
double_type
;
else
if
(
!
vinfo
.
IsFloat
&&
vinfo
.
ElementSize
==
2
)
return
uint16_type
;
else
if
(
!
vinfo
.
IsFloat
&&
vinfo
.
ElementSize
==
4
)
return
int32_type
;
else
if
(
!
vinfo
.
IsFloat
&&
vinfo
.
ElementSize
==
8
)
...
...
python/lib/gio.h
View file @
dd569452
...
...
@@ -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_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_int64
(
char
*
file_name
,
char
*
var_name
,
int64_t
*
data
,
int
field_count
);
enum
var_type
{
...
...
@@ -79,6 +80,7 @@ enum var_type{
double_type
=
1
,
int32_type
=
2
,
int64_type
=
3
,
uint16_type
=
4
,
type_not_found
=
9
,
var_not_found
=
10
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment