Ignore:
Timestamp:
25/10/08 00:17:16 (4 years ago)
Author:
Paul Kienzle
Message:

python: make proper package (step 1) Refs #101.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bindings/python/nxs.py

    r1116 r1120  
    66Wrapper for the NeXus shared library. 
    77 
     8Use this interface when converting code from other languages which 
     9do not support the natural view of the hierarchy. 
    810 
    911Library Location 
     
    1113 
    1214This wrapper needs the location of the libNeXus precompiled binary. It 
    13 looks in the following places in order: 
     15looks in the following places in order:: 
     16 
    1417    os.environ['NEXUSLIB']                  - All 
    1518    directory containing nxs.py             - All 
     
    2124    /usr/lib                                - Unix and Darwin 
    2225 
    23 On Windows it looks for libNeXus.dll and libNeXus-0.dll; 
    24 NEXUSDIR defaults to r'C:\Program Files\NeXus Data Format' 
     26On Windows it looks for one of libNeXus.dll or libNeXus-0.dll. 
    2527On OS X it looks for libNeXus.dylib 
    2628On Unix it looks for libNeXus.so 
     29NEXUSDIR defaults to r'C:\Program Files\NeXus Data Format'. 
    2730PREFIX defaults to /usr/local, but is replaced by the value of 
    2831--prefix during configure. 
     
    3639first import of nxs. 
    3740 
     41Example 
     42======= 
     43 
     44  import nxs 
     45  file = nxs.open('filename.nxs','rw') 
     46  file.opengroup('entry1') 
     47  file.opendata('definition') 
     48  print file.getdata() 
     49  file.close() 
     50 
     51  See nxstest.py for a more complete example. 
     52 
    3853Interface 
    3954========= 
    4055 
    41 Full documentation of the NeXus API is available at nexusformat.org. 
    42  
    43 This wrapper differs from napi in several respects: 
     56When converting code to python from other languages you do not 
     57necessarily want to redo the file handling code.  The nxs 
     58provides an interface which more closely follows the 
     59NeXus application programming interface (NAPI_). 
     60 
     61This wrapper differs from NAPI in several respects:: 
     62 
    4463  - Data values are loaded/stored directly from numpy arrays. 
    4564  - Return codes are turned into exceptions. 
     
    5170  - NXmalloc/NXfree are not needed. 
    5271 
    53 Example: 
    54  
    55   import nxs 
    56   file = nxs.open('filename.nxs','rw') 
    57   file.opengroup('entry1') 
    58   file.opendata('definition') 
    59   print file.getdata() 
    60   file.close() 
    61  
    62   See nxstest.py for a more complete example. 
    63  
    64 File open modes can be constants or strings: 
     72File open modes can be constants or strings:: 
    6573 
    6674  nxs.ACC_READ      'r' 
     
    7179  nxs.ACC_CREATEXML 'wx' 
    7280 
    73 Dimension constants: 
     81Dimension constants:: 
    7482 
    7583  nxs.UNLIMITED  - for the extensible data dimension 
    7684  nxs.MAXRANK    - for the number of possible dimensions 
    7785 
    78 Data types are strings corresponding to the numpy data types: 
     86Data types are strings corresponding to the numpy data types:: 
    7987 
    8088  'float32' 'float64' 
     
    8290  'uint8' 'uint16' 'uint32' 'uint64' 
    8391 
    84   Use 'char' for strings.  You can use the numpy dtype attribute for the 
    85   data type. 
     92  Use 'char' for string data.   
     93 
     94You can use the numpy A.dtype attribute for the type of array A. 
    8695 
    8796Dimensions are lists of integers or numpy arrays.  You can use the 
    88 numpy shape attribute for the dimensions. 
    89  
    90 Compression codes are: 
     97numpy A.shape attribute for the dimensions of array A. 
     98 
     99Compression codes are:: 
    91100 
    92101 'none' 'lzw' 'rle' 'huffman' 
     
    94103  As of this writing NeXus only supports 'none' and 'lzw'. 
    95104 
    96 Miscellaneous constants: 
     105Miscellaneous constants:: 
    97106 
    98107  nxs.MAXNAMELEN  - names must be shorter than this 
     
    112121   - if I remove the open/close call in the wrapper it doesn't leak. 
    113122 
     123.. _NAPI:  http://www.nexusformat.org/Application_Program_Interface 
    114124""" 
     125__all__ = ['MAXNAMELEN','MAXPATHLEN','NeXus','open'] 
     126 
    115127import sys, os, numpy, ctypes 
    116128 
Note: See TracChangeset for help on using the changeset viewer.