|
NeXus 1
|
Wrapper for the NeXus shared library. More...
Classes | |
| class | _NXlink |
| class | NeXusError |
| NeXus Error. More... | |
| class | NeXus |
Functions | |
| def | open |
| Returns a NeXus file object. | |
Variables | |
| list | __all__ |
| tuple | c_void_pp = ctypes.POINTER(c_void_p) |
| tuple | c_int_p = ctypes.POINTER(c_int) |
| tuple | c_int64_p = ctypes.POINTER(c_int64) |
| tuple | c_NXlink_p = ctypes.POINTER(_NXlink) |
| tuple | _nxopen_mode = dict(r=1,rw=2,w=3,w4=4,w5=5,wx=6) |
| int | NOSTRIP = 128 |
| int | UNLIMITED = 1 |
| int | MAXRANK = 32 |
| int | MAXNAMELEN = 64 |
| int | MAXPATHLEN = 1024 |
| list | H4SKIP |
| tuple | _nxtype_code |
| tuple | _pytype_code = (lambda : dict([(v,k) for (k,v) in _nxtype_code.iteritems()])) |
| tuple | _compression_code |
| tuple | nxlib = _init() |
| string | __id__ = "$ID$" |
Wrapper for the NeXus shared library.
Use this interface when converting code from other languages which do not support the natural view of the hierarchy.
Library Location ================
This wrapper needs the location of the libNeXus precompiled binary. It looks in the following places in order::
os.environ['NEXUSLIB'] - All
directory containing nxs.py - All
os.environ['NEXUSDIR']\\bin - Windows
os.environ['LD_LIBRARY_PATH'] - Unix
os.environ['DYLD_LIBRARY_PATH'] - Darwin
PREFIX/lib - Unix and Darwin
/usr/local/lib - Unix and Darwin
/usr/lib - Unix and Darwin
The import will raise an OSError exception if the library wasn't found or couldn't be loaded. Note that on Windows in particular this may be because the supporting HDF5 dlls were not available in the usual places.
If you are extracting the nexus library from a bundle at runtime, set os.environ['NEXUSLIB'] to the path where it is extracted before the first import of nxs.
Example =======
import nxs file = nxs.open('filename.nxs','rw') file.opengroup('entry1') file.opendata('definition') print file.getdata() file.close()
See
Interface =========
When converting code to python from other languages you do not necessarily want to redo the file handling code. The nxs provides an interface which more closely follows the NeXus application programming interface (NAPI_).
This wrapper differs from NAPI in several respects::
File open modes can be constants or strings::
nxs.ACC_READ 'r' nxs.ACC_RDWR 'rw' nxs.ACC_CREATE 'w' nxs.ACC_CREATE4 'w4' nxs.ACC_CREATE5 'w5' nxs.ACC_CREATEXML 'wx'
Dimension constants::
Data types are strings corresponding to the numpy data types::
'float32' 'float64' 'int8' 'int16' 'int32' 'int64' 'uint8' 'uint16' 'uint32' 'uint64'
Use 'char' for string data.
You can use the numpy A.dtype attribute for the type of array A.
Dimensions are lists of integers or numpy arrays. You can use the numpy A.shape attribute for the dimensions of array A.
Compression codes are::
'none' 'lzw' 'rle' 'huffman'
As of this writing NeXus only supports 'none' and 'lzw'.
Miscellaneous constants::
Caveats =======
NOSTRIP constant is probably not handled properly,
Embedded nulls in strings is not supported
| def nxs.napi.open | ( | filename, | |
mode = 'r' |
|||
| ) |
| list nxs::napi.__all__ |
| string nxs::napi.__id__ = "$ID$" |
| tuple nxs::napi._nxopen_mode = dict(r=1,rw=2,w=3,w4=4,w5=5,wx=6) |
| tuple nxs::napi._nxtype_code |
| tuple nxs::napi._pytype_code = (lambda : dict([(v,k) for (k,v) in _nxtype_code.iteritems()])) |
| tuple nxs::napi.c_int64_p = ctypes.POINTER(c_int64) |
| tuple nxs::napi.c_int_p = ctypes.POINTER(c_int) |
| tuple nxs::napi.c_NXlink_p = ctypes.POINTER(_NXlink) |
| tuple nxs::napi.c_void_pp = ctypes.POINTER(c_void_p) |
| list nxs::napi.H4SKIP |
| int nxs::napi.MAXNAMELEN = 64 |
| int nxs::napi.MAXPATHLEN = 1024 |
| int nxs::napi.MAXRANK = 32 |
| int nxs::napi.NOSTRIP = 128 |
| tuple nxs::napi.nxlib = _init() |
| int nxs::napi.UNLIMITED = 1 |
1.7.4