Changeset 1121 for trunk/bindings/python/nxs
- Timestamp:
- 25/10/08 00:34:52 (4 years ago)
- Location:
- trunk/bindings/python/nxs
- Files:
-
- 1 added
- 4 moved
-
. (added)
-
__init__.py (moved) (moved from trunk/bindings/python/__init__.py)
-
napi.py (moved) (moved from trunk/bindings/python/nxs.py) (1 diff)
-
tree.py (moved) (moved from trunk/bindings/python/nexus.py) (4 diffs)
-
unit.py (moved) (moved from trunk/bindings/python/nxsunit.py) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bindings/python/nxs/napi.py
r1120 r1121 123 123 .. _NAPI: http://www.nexusformat.org/Application_Program_Interface 124 124 """ 125 __all__ = [' MAXNAMELEN','MAXPATHLEN','NeXus','open']125 __all__ = ['UNLIMITED', 'MAXRANK', 'MAXNAMELEN','MAXPATHLEN','NeXus','open'] 126 126 127 127 import sys, os, numpy, ctypes -
trunk/bindings/python/nxs/tree.py
r1120 r1121 14 14 15 15 import nxs 16 tree = nxs. read('file.nxs') # loads a structure from a file17 nxs. write('copy.nxs', tree)# saves a structure to a file16 tree = nxs.load('file.nxs') # loads a structure from a file 17 nxs.save('copy.nxs', tree) # saves a structure to a file 18 18 nxs.dir('copy.nxs') # display the contents of a file 19 19 20 20 21 The tree returned from read() has an entry for each group, field and21 The tree returned from load() has an entry for each group, field and 22 22 attribute. You can traverse the hierarchy using the names of the 23 23 groups. For example, tree.Histogram1.instrument.detector.distance … … 68 68 retrieve them in meters using:: 69 69 entry.instrument.detector.distance.nxdata_as('m') 70 See help for nxsunitfor more details on the unit formats supported.70 See `nxs.unit` for more details on the unit formats supported. 71 71 72 72 The slab interface to field data works by opening the file handle … … 108 108 to the data group and title is the title of the NXentry, if available. 109 109 110 The read() and write() functions are implemented within a specialized 111 NeXus class which allows all the usual API functions. You can subclass 112 this with your own definitions for NXgroup(), NXattr(), SDS() and NXlink() 113 if you want to change the nature of the tree. The properties of these 114 classes are closely coupled to the behaviour of readfile/writefile so 115 refer to the source if you need to do this. 110 The load() and save() functions are implemented within 111 `nxs.tree.NeXusTree`, a subclass of `nxs.napi.NeXus` which allows 112 all the usual API functions. You can subclass NeXusTree with your 113 own version that defines, e.g., a NXmonitor() method to return an 114 NXmonitor object when an NXmonitor class is read. Your NXmonitor 115 class should probably be a subclass of NXgroup. 116 117 You can also specialize the definitions for the basic types 118 NXgroup(), NXattr(), SDS() and NXlink() if you want to make 119 radical changes to the returned structure. The properties of 120 these classes are closely coupled to the behaviour of the readfile 121 and writefile methods so refer to the source if you need to do this. 116 122 """ 117 123 __all__ = ['read', 'write', 'dir', 'NeXusTree'] … … 614 620 else: 615 621 units = None 616 self._converter = nxs unit.Converter(units)622 self._converter = nxs.unit.Converter(units) 617 623 self.nxslab = NXslab_context(file, path, self._converter) 618 624 -
trunk/bindings/python/nxs/unit.py
r1120 r1121 45 45 """ 46 46 47 __all__ = ['Converter']48 49 47 # TODO: Add udunits to NAPI rather than reimplementing it in python 50 48 # TODO: Alternatively, parse the udunits database directly … … 55 53 56 54 from __future__ import division 55 56 __all__ = ['Converter'] 57 57 58 import math 58 59
Note: See TracChangeset
for help on using the changeset viewer.
