Changeset 9a39657 in sasview
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader.py
r4597637 r9a39657 220 220 multipleEntries = True 221 221 222 for setupNode in sasNode[0]: 223 # Iterating through the tags in the unit node, getting their tag name and respective unit 224 setupTagName = setupNode.tag.replace(self.base_ns, "") 225 units = setupNode.attrib.get("unit", "") 226 227 # Creating our data array first, if there's only one dataNode we will handle this... 228 startArray = np.fromstring(setupNode.text, dtype=float, sep=",") 229 230 if multipleEntries == True: 231 setupArray = np.zeros((len(sasNode), len(startArray))) 232 setupArray[0] = startArray 233 else: 234 setupArray = startArray 235 236 # Now put this into the relevant location 237 if setupTagName == "I": 238 self.current_dataset.yaxis("Intensity", units) 239 self.current_dataset.y = setupArray 240 elif setupTagName == "Q": 241 self.current_dataset.xaxis("Q", units) 242 self.current_dataset.x = setupArray 243 244 elif setupTagName == "Idev": 245 self.current_dataset.dy = setupArray 246 elif setupTagName == "Qdev": 247 self.current_dataset.dx = setupArray 248 249 elif setupTagName == "Qx": 250 self.current_dataset.xaxis("Qx", units) 251 self.current_dataset.qx_data = setupArray 252 elif setupTagName == "Qy": 253 self.current_dataset.yaxis("Qy", units) 254 self.current_dataset.qy_data = setupArray 255 elif setupTagName == "Qxdev": 256 self.current_dataset.xaxis("Qxdev", units) 257 self.current_dataset.dqx_data = setupArray 258 elif setupTagName == "Qydev": 259 self.current_dataset.yaxis("Qydev", units) 260 self.current_dataset.dqy_data = setupArray 261 elif setupTagName == "dQw": 262 self.current_dataset.dxw = setupArray 263 elif setupTagName == "dQl": 264 self.current_dataset.dxl = setupArray 265 266 elif setupTagName == "Mask": 267 self.current_dataset.mask = np.ndarray.astype(setupArray, dtype=bool) 268 elif setupTagName == "Sesans": 269 self.current_datainfo.isSesans = bool(setupNode.text) 270 271 elif setupTagName == "yacceptance": 272 self.current_datainfo.sample.yacceptance = (setupNode.text, units) 273 elif setupTagName == "zacceptance": 274 self.current_datainfo.sample.zacceptance = (setupNode.text, units) 275 elif setupTagName == "Qmean": 276 pass 277 elif setupTagName == "Shadowfactor": 278 pass 279 280 # If there's more data present, let's deal with that too 281 for loopIter in range(1, len(sasNode)): 282 for dataNode in sasNode[loopIter]: 222 if sasNode[0].text is not None: 223 for setupNode in sasNode[0]: 283 224 # Iterating through the tags in the unit node, getting their tag name and respective unit 284 dataTagName = dataNode.tag.replace(self.base_ns, "") 285 # Creating our data array first 286 dataArray = np.fromstring(dataNode.text, dtype=float, sep=",") 287 288 if dataTagName == "I": 289 self.current_dataset.y[loopIter] = dataArray 290 elif dataTagName == "Q": 291 self.current_dataset.x[loopIter] = dataArray 292 elif dataTagName == "Idev": 293 self.current_dataset.dy[loopIter] = dataArray 294 elif dataTagName == "Qdev": 295 self.current_dataset.dx[loopIter] = dataArray 296 elif dataTagName == "Qx": 297 self.current_dataset.qx_data[loopIter] = dataArray 298 elif dataTagName == "Qy": 299 self.current_dataset.qy_data[loopIter] = dataArray 300 elif dataTagName == "Qxdev": 301 self.current_dataset.dqx_data[loopIter] = dataArray 302 elif dataTagName == "Qydev": 303 self.current_dataset.dqy_data[loopIter] = dataArray 304 elif dataTagName == "dQw": 305 self.current_dataset.dxw[loopIter] = dataArray 306 elif dataTagName == "dQl": 307 self.current_dataset.dxl[loopIter] = dataArray 308 309 self._check_for_empty_resolution() 310 self.data.append(self.current_dataset) 225 setupTagName = setupNode.tag.replace(self.base_ns, "") 226 units = setupNode.attrib.get("unit", "") 227 228 # Creating our data array first, if there's only one dataNode we will handle this... 229 startArray = np.fromstring(setupNode.text, dtype=float, sep=",") 230 231 if multipleEntries == True: 232 setupArray = np.zeros((len(sasNode), len(startArray))) 233 setupArray[0] = startArray 234 else: 235 setupArray = startArray 236 237 # Now put this into the relevant location 238 if setupTagName == "I": 239 self.current_dataset.yaxis("Intensity", units) 240 self.current_dataset.y = setupArray 241 elif setupTagName == "Q": 242 self.current_dataset.xaxis("Q", units) 243 self.current_dataset.x = setupArray 244 245 elif setupTagName == "Idev": 246 self.current_dataset.dy = setupArray 247 elif setupTagName == "Qdev": 248 self.current_dataset.dx = setupArray 249 250 elif setupTagName == "Qx": 251 self.current_dataset.xaxis("Qx", units) 252 self.current_dataset.qx_data = setupArray 253 elif setupTagName == "Qy": 254 self.current_dataset.yaxis("Qy", units) 255 self.current_dataset.qy_data = setupArray 256 elif setupTagName == "Qxdev": 257 self.current_dataset.xaxis("Qxdev", units) 258 self.current_dataset.dqx_data = setupArray 259 elif setupTagName == "Qydev": 260 self.current_dataset.yaxis("Qydev", units) 261 self.current_dataset.dqy_data = setupArray 262 elif setupTagName == "dQw": 263 self.current_dataset.dxw = setupArray 264 elif setupTagName == "dQl": 265 self.current_dataset.dxl = setupArray 266 267 elif setupTagName == "Mask": 268 self.current_dataset.mask = np.ndarray.astype(setupArray, dtype=bool) 269 elif setupTagName == "Sesans": 270 self.current_datainfo.isSesans = bool(setupNode.text) 271 272 elif setupTagName == "yacceptance": 273 self.current_datainfo.sample.yacceptance = (setupNode.text, units) 274 elif setupTagName == "zacceptance": 275 self.current_datainfo.sample.zacceptance = (setupNode.text, units) 276 elif setupTagName == "Qmean": 277 pass 278 elif setupTagName == "Shadowfactor": 279 pass 280 281 # If there's more data present, let's deal with that too 282 for loopIter in range(1, len(sasNode)): 283 for dataNode in sasNode[loopIter]: 284 # Iterating through the tags in the unit node, getting their tag name and respective unit 285 dataTagName = dataNode.tag.replace(self.base_ns, "") 286 # Creating our data array first 287 dataArray = np.fromstring(dataNode.text, dtype=float, sep=",") 288 289 if dataTagName == "I": 290 self.current_dataset.y[loopIter] = dataArray 291 elif dataTagName == "Q": 292 self.current_dataset.x[loopIter] = dataArray 293 elif dataTagName == "Idev": 294 self.current_dataset.dy[loopIter] = dataArray 295 elif dataTagName == "Qdev": 296 self.current_dataset.dx[loopIter] = dataArray 297 elif dataTagName == "Qx": 298 self.current_dataset.qx_data[loopIter] = dataArray 299 elif dataTagName == "Qy": 300 self.current_dataset.qy_data[loopIter] = dataArray 301 elif dataTagName == "Qxdev": 302 self.current_dataset.dqx_data[loopIter] = dataArray 303 elif dataTagName == "Qydev": 304 self.current_dataset.dqy_data[loopIter] = dataArray 305 elif dataTagName == "dQw": 306 self.current_dataset.dxw[loopIter] = dataArray 307 elif dataTagName == "dQl": 308 self.current_dataset.dxl[loopIter] = dataArray 309 310 self._check_for_empty_resolution() 311 self.data.append(self.current_dataset) 311 312 312 313 # If it's not data, let's check for other tags starting with skippable ones... … … 573 574 elif currentTagName == "SASprocess": 574 575 for processNode in sasNode: 575 setupTagName = setupNode.tag.replace(self.base_ns, "")576 processTagName = setupNode.tag.replace(self.base_ns, "") 576 577 units = setupNode.attrib.get("unit", "") 577 578 … … 608 609 # If we're dealing with a transmission data node 609 610 elif currentTagName == "Tdata": 610 for transmissionDataNode in sasNode:611 transmissionDataTagName = transmissionDataNode.tag.replace(self.base_ns, "")612 transmissionDataUnits = transmissionDataNode.attrib.get("unit", "")613 transmissionDataData = transmissionDataNode.text614 615 611 # Are there multiple entries here? 616 612 if len(sasNode) <= 1: … … 619 615 multipleEntries == True 620 616 621 for setupNode in sasNode[0]: 622 # Iterating through the tags in the unit node, getting their tag name and respective unit 623 setupTagName = setupNode.tag.replace(self.base_ns, "") 624 transmissionDataUnits = setupNode.attrib.get("unit", "") 625 626 # Creating our data array first, if there's only one dataNode we will handle this... 627 startArray = np.fromstring(setupNode.text, dtype=float, sep=",") 628 629 if multipleEntries == True: 630 setupArray = np.zeros((len(sasNode), len(startArray))) 631 setupArray[0] = startArray 632 else: 633 setupArray = startArray 634 635 ## Transmission Spectrum 636 if setupTagName == "T": 637 self.transspectrum.transmission = setupArray 638 self.transspectrum.transmission_unit = transmissionDataUnits 639 elif setupTagName == "Tdev": 640 self.transspectrum.transmission_deviation = setupArray 641 self.transspectrum.transmission_deviation_unit = transmissionDataUnits 642 elif setupTagName == "Lambda": 643 self.transspectrum.wavelength = setupArray 644 self.transspectrum.wavelength_unit = transmissionDataUnits 645 646 # If there's more data present, let's deal with that too 647 for loopIter in range(1, len(sasNode)): 648 for dataNode in sasNode[loopIter]: 649 dataTagName = dataNode.tag.replace(self.base_ns, "") 650 dataArray = np.fromstring(dataNode.text, dtype=float, sep=",") 651 652 if dataTagName == "T": 653 self.transspectrum.transmission[loopIter] = setupArray 654 elif dataTagName == "Tdev": 655 self.transspectrum.transmission_deviation[loopIter] = setupArray 656 elif dataTagName == "Lambda": 657 self.transspectrum.wavelength[loopIter] = setupArray 658 659 self.current_datainfo.trans_spectrum.append(self.transspectrum) 660 self.transspectrum = TransmissionSpectrum() 617 if sasNode[0].text is not None: 618 for setupNode in sasNode[0]: 619 # Iterating through the tags in the unit node, getting their tag name and respective unit 620 setupTagName = setupNode.tag.replace(self.base_ns, "") 621 transmissionDataUnits = setupNode.attrib.get("unit", "") 622 623 # Creating our data array first, if there's only one dataNode we will handle this... 624 startArray = np.fromstring(setupNode.text, dtype=float, sep=",") 625 626 if multipleEntries == True: 627 setupArray = np.zeros((len(sasNode), len(startArray))) 628 setupArray[0] = startArray 629 else: 630 setupArray = startArray 631 632 ## Transmission Spectrum 633 if setupTagName == "T": 634 self.transspectrum.transmission = setupArray 635 self.transspectrum.transmission_unit = transmissionDataUnits 636 elif setupTagName == "Tdev": 637 self.transspectrum.transmission_deviation = setupArray 638 self.transspectrum.transmission_deviation_unit = transmissionDataUnits 639 elif setupTagName == "Lambda": 640 self.transspectrum.wavelength = setupArray 641 self.transspectrum.wavelength_unit = transmissionDataUnits 642 643 # If there's more data present, let's deal with that too 644 for loopIter in range(1, len(sasNode)): 645 for dataNode in sasNode[loopIter]: 646 dataTagName = dataNode.tag.replace(self.base_ns, "") 647 dataArray = np.fromstring(dataNode.text, dtype=float, sep=",") 648 649 if dataTagName == "T": 650 self.transspectrum.transmission[loopIter] = dataArray 651 elif dataTagName == "Tdev": 652 self.transspectrum.transmission_deviation[loopIter] = dataArray 653 elif dataTagName == "Lambda": 654 self.transspectrum.wavelength[loopIter] = dataArray 655 656 self.current_datainfo.trans_spectrum.append(self.transspectrum) 657 self.transspectrum = TransmissionSpectrum() 661 658 662 659
Note: See TracChangeset
for help on using the changeset viewer.