Changeset 1803 for trunk/bindings/python
- Timestamp:
- 17/01/12 16:14:47 (4 months ago)
- File:
-
- 1 edited
-
trunk/bindings/python/nxs/tree.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bindings/python/nxs/tree.py
r1801 r1803 92 92 >>> root.save('example.nxs') 93 93 94 NXfield objects have much of the functionality of Numpy arrays. They may be used 95 in simple arithmetic expressions with other NXfields, Numpy arrays or scalar 96 values and will be cast as ndarray objects if used as arguments in Numpy 97 modules. 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 108 If the arithmetic operation is assigned to a NeXus group attribute, it will be 109 automatically cast as a valid NXfield object with the type and shape determined 110 by 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 94 119 NeXus Objects 95 120 ------------- … … 257 282 read/write slabs without the overhead of moving the file cursor each time. 258 283 The NXdata objects in the returned tree hold the object values. 259 260 Subclasses can provide methods for individual NeXus classes such261 as NXbeam or NXdata. Brave users can also specialize NXgroup,262 NXattr, NXfield and NXlink methods.263 284 """ 264 285 … … 419 440 return [(path, data._target)] 420 441 421 # Finally some data, but don't read it if it is big422 # Instead record the location, type and size423 442 #If the array size is too large, their product needs a long integer 424 443 if np.prod(shape) > 10000 or np.prod(shape) < 0: … … 2842 2861 2843 2862 #Definition for when there are name clashes with Numpy 2844 read = load2845 __all__.append(' read')2863 nxload = load 2864 __all__.append('nxload') 2846 2865 2847 2866 def save(filename, group, format='w5'):
Note: See TracChangeset
for help on using the changeset viewer.
