source: python/example.py @ 9796d0a

Revision 9796d0a, 2.2 KB checked in by Hal Finkel <hfinkel@…>, 7 years ago (diff)

Add support for float4 (and similar) to Python bindings

  • Property mode set to 100644
Line 
1#                    Copyright (C) 2015, UChicago Argonne, LLC
2#                               All Rights Reserved
3#
4#                               Generic IO (ANL-15-066)
5#                     Hal Finkel, Argonne National Laboratory
6#
7#                              OPEN SOURCE LICENSE
8#
9# Under the terms of Contract No. DE-AC02-06CH11357 with UChicago Argonne,
10# LLC, the U.S. Government retains certain rights in this software.
11#
12# Redistribution and use in source and binary forms, with or without
13# modification, are permitted provided that the following conditions are met:
14#
15#   1. Redistributions of source code must retain the above copyright notice,
16#      this list of conditions and the following disclaimer.
17#
18#   2. Redistributions in binary form must reproduce the above copyright
19#      notice, this list of conditions and the following disclaimer in the
20#      documentation and/or other materials provided with the distribution.
21#
22#   3. Neither the names of UChicago Argonne, LLC or the Department of Energy
23#      nor the names of its contributors may be used to endorse or promote
24#      products derived from this software without specific prior written
25#      permission.
26#
27# *****************************************************************************
28#
29#                                  DISCLAIMER
30# THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY OF ANY KIND.  NEITHER THE
31# UNTED STATES GOVERNMENT, NOR THE UNITED STATES DEPARTMENT OF ENERGY, NOR
32# UCHICAGO ARGONNE, LLC, NOR ANY OF THEIR EMPLOYEES, MAKES ANY WARRANTY,
33# EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE
34# ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, DATA, APPARATUS,
35# PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE
36# PRIVATELY OWNED RIGHTS.
37#
38# *****************************************************************************
39
40import sys
41import numpy as np
42import genericio as gio
43
44name = sys.argv[1]
45gio.gio_inspect(name)
46
47if gio.gio_has_variable(name, "x"):
48  x = gio.gio_read(name, "x")
49  y = gio.gio_read(name, "y")
50  z = gio.gio_read(name, "z")
51  print np.column_stack((x, y, z))
52else:
53  pos = gio.gio_read(name, "pos")
54  print pos
55
Note: See TracBrowser for help on using the repository browser.