Changes between Version 3 and Version 4 of CSMLReadMethods
- Timestamp:
- 24/07/06 15:27:26 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CSMLReadMethods
v3 v4 91 91 92 92 === CDMS: openFile === 93 {{{ 94 #!python 95 96 def openFile(self, filename): 97 self.file=cdms.open(filename) 98 }}} 93 99 94 100 === NAPPY: openFile === 101 {{{ 102 #!python 103 def openFile(self, filename): 104 self.file=nappy.openNAFile(filename) 105 }}} 106 107 The set axis method differs for the two interfaces. The cdunif method is straightforward and grabs an axis object direct from the file whereas the NAPPY method stores the name of the axis in a variable called self.axisstub for reference later - however to do this it has to get all the axes and then strip the units from them. This is confusing detail but the basic idea is to store 'something' that will give you a handle back to the axis. This something will be internal to the XYZInterface class. 95 108 96 109 97 110 === CDMS: setAxis === 111 {{{ 112 #!python 113 def setAxis(self,axis): 114 self.axisobj=self.file.getAxis(axis) 115 }}} 116 === NAPPY: setAxis === 117 {{{ 118 #!python 119 def __stripunits(self,listtostrip): 120 #strips units of measure from list 121 #eg ['Universal time (hours)', 'Altitude (km)', 'Latitude (degrees)', 'Longitude (degrees)'] 122 #becomes ['Universal time', 'Altitude', 'Latitude', 'Longitude'] 123 cleanlist = [] 124 for item in listtostrip: 125 openbracket=string.find(item,'(') 126 if openbracket != -1: 127 #if brackets exist, strip units. 128 item=item[:openbracket-1] 129 cleanlist.append(item) 130 return cleanlist 98 131 99 === NAPPY: setAxis === 132 133 def __getListOfAxes(self): 134 axes=self.file.XNAME 135 axes=self.__stripunits(axes) 136 return axes 137 138 def setAxis(self,axis): 139 axes = self.__getListOfAxes() 140 self.axisstub=axes.index(axis) 141 }}} 142 100 143 101 144 === CDMS: getDataForAxis === 102 145 {{{ 146 #!python 147 }}} 103 148 === NAPPY: getDataForAxis === 149 {{{ 150 #!python 151 }}} 104 152 105 153 === CDMS: setVariable === 154 {{{ 155 #!python 156 }}} 106 157 107 158 === NAPPY: setVariable === 159 {{{ 160 #!python 161 }}} 108 162 109 163 === CDMS: getDataForVariable === 164 {{{ 165 #!python 166 }}} 110 167 111 168 === NAPPY: getDataForVariable === 169 {{{ 170 #!python 171 }}} 112 172 113 173 === CDMS: getSubsetOfDataForVariable === 174 {{{ 175 #!python 176 }}} 114 177 115 178 === NAPPY: getSubsetOfDataForVariable === 179 {{{ 180 #!python 181 }}} 116 182 117 183 === CDMS: closeFile === 184 {{{ 185 #!python 186 }}} 118 187 119 188 === NAPPY: closeFile === 189 {{{ 190 #!python 191 }}} 120 192 121 193 122 123