Changeset 1803 for trunk/bindings/python


Ignore:
Timestamp:
17/01/12 16:14:47 (4 months ago)
Author:
Ray Osborn
Message:

Refs #323: Added 'nxload' as an alias to 'load' for use when there are name clashes.

File:
1 edited

Legend:

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

    r1801 r1803  
    9292    >>> root.save('example.nxs') 
    9393 
     94NXfield objects have much of the functionality of Numpy arrays. They may be used 
     95in simple arithmetic expressions with other NXfields, Numpy arrays or scalar 
     96values and will be cast as ndarray objects if used as arguments in Numpy 
     97modules. 
     98 
     99    >>> x=nx.NXfield(np.linspace(0,10.0,11)) 
     100    >>> x 
     101    NXfield([  0.   1.   2. ...,   8.   9.  10.]) 
     102    >>> x + 10 
     103    NXfield([ 10.  11.  12. ...,  18.  19.  20.]) 
     104    >>> sin(x) 
     105    array([ 0.        ,  0.84147098,  0.90929743, ...,  0.98935825, 
     106        0.41211849, -0.54402111]) 
     107 
     108If the arithmetic operation is assigned to a NeXus group attribute, it will be 
     109automatically cast as a valid NXfield object with the type and shape determined 
     110by the Numpy array type and shape. 
     111 
     112    >>> entry.data.result = sin(x) 
     113    >>> entry.data.result 
     114    NXfield([ 0.          0.84147098  0.90929743 ...,  0.98935825  0.41211849 
     115     -0.54402111]) 
     116    >>> entry.data.result.dtype, entry.data.result.shape 
     117    (dtype('float64'), (11,)) 
     118 
    94119NeXus Objects 
    95120------------- 
     
    257282    read/write slabs without the overhead of moving the file cursor each time. 
    258283    The NXdata objects in the returned tree hold the object values. 
    259  
    260     Subclasses can provide methods for individual NeXus classes such 
    261     as NXbeam or NXdata.  Brave users can also specialize NXgroup,  
    262     NXattr, NXfield and NXlink methods. 
    263284    """ 
    264285 
     
    419440            return [(path, data._target)] 
    420441 
    421         # Finally some data, but don't read it if it is big 
    422         # Instead record the location, type and size 
    423442        #If the array size is too large, their product needs a long integer 
    424443        if np.prod(shape) > 10000 or np.prod(shape) < 0: 
     
    28422861 
    28432862#Definition for when there are name clashes with Numpy 
    2844 read = load 
    2845 __all__.append('read') 
     2863nxload = load 
     2864__all__.append('nxload') 
    28462865 
    28472866def save(filename, group, format='w5'): 
Note: See TracChangeset for help on using the changeset viewer.