Changeset b204004 in sasview for src/sas/sascalc
- Timestamp:
- Oct 17, 2018 4:20:16 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
- Children:
- 845144e
- Parents:
- b1ec23d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
r926ece5 rb204004 104 104 self.errors = set() 105 105 self.logging = [] 106 self.q_name = []106 self.q_names = [] 107 107 self.mask_name = u'' 108 108 self.i_name = u'' 109 109 self.i_node = u'' 110 self. q_uncertainties = None111 self.q_ resolutions = None112 self. i_uncertainties = u''110 self.i_uncertainties_name = u'' 111 self.q_uncertainty_names = [] 112 self.q_resolution_names = [] 113 113 self.parent_class = u'' 114 114 self.detector = Detector() … … 240 240 self.current_dataset.y = data_set.flatten() 241 241 self.current_dataset.yaxis("Intensity", unit) 242 elif key == self.i_uncertainties :242 elif key == self.i_uncertainties_name: 243 243 self.current_dataset.dy = data_set.flatten() 244 elif key in self.q_name :244 elif key in self.q_names: 245 245 self.current_dataset.xaxis("Q", unit) 246 246 self.current_dataset.x = data_set.flatten() 247 elif key in self.q_ uncertainties or key in self.q_resolutions:248 if (len(self.q_resolution s) > 1249 and np.where(self.q_resolution s == key)[0] == 0):247 elif key in self.q_resolution_names: 248 if (len(self.q_resolution_names) > 1 249 and np.where(self.q_resolution_names == key)[0] == 0): 250 250 self.current_dataset.dxw = data_set.flatten() 251 elif (len(self.q_resolutions) > 1 252 and np.where(self.q_resolutions == key)[0] == 1): 251 elif (len(self.q_resolution_names) > 1 252 and np.where(self.q_resolution_names == key)[0] == 1): 253 self.current_dataset.dxl = data_set.flatten() 254 else: 255 self.current_dataset.dx = data_set.flatten() 256 elif key in self.q_uncertainty_names: 257 if (len(self.q_uncertainty_names) > 1 258 and np.where(self.q_uncertainty_names == key)[0] == 0): 259 self.current_dataset.dxw = data_set.flatten() 260 elif (len(self.q_uncertainty_names) > 1 261 and np.where(self.q_uncertainty_names == key)[0] == 1): 253 262 self.current_dataset.dxl = data_set.flatten() 254 263 else: … … 264 273 self.current_dataset.data = data_set 265 274 self.current_dataset.zaxis("Intensity", unit) 266 elif key == self.i_uncertainties :275 elif key == self.i_uncertainties_name: 267 276 self.current_dataset.err_data = data_set.flatten() 268 elif key in self.q_name :277 elif key in self.q_names: 269 278 self.current_dataset.xaxis("Q_x", unit) 270 279 self.current_dataset.yaxis("Q_y", unit) 271 if self.q_name [0] == self.q_name[1]:280 if self.q_names[0] == self.q_names[1]: 272 281 # All q data in a single array 273 282 self.current_dataset.qx_data = data_set[0] 274 283 self.current_dataset.qy_data = data_set[1] 275 elif self.q_name .index(key) == 0:284 elif self.q_names.index(key) == 0: 276 285 self.current_dataset.qx_data = data_set 277 elif self.q_name .index(key) == 1:286 elif self.q_names.index(key) == 1: 278 287 self.current_dataset.qy_data = data_set 279 elif key in self.q_uncertaint ies or key in self.q_resolutions:280 if ((self.q_uncertaint ies[0] == self.q_uncertainties[1]) or281 (self.q_resolution s[0] == self.q_resolutions[1])):288 elif key in self.q_uncertainty_names or key in self.q_resolution_names: 289 if ((self.q_uncertainty_names[0] == self.q_uncertainty_names[1]) or 290 (self.q_resolution_names[0] == self.q_resolution_names[1])): 282 291 # All q data in a single array 283 292 self.current_dataset.dqx_data = data_set[0].flatten() 284 293 self.current_dataset.dqy_data = data_set[1].flatten() 285 elif (self.q_uncertaint ies.index(key) == 0 or286 self.q_resolution s.index(key) == 0):294 elif (self.q_uncertainty_names.index(key) == 0 or 295 self.q_resolution_names.index(key) == 0): 287 296 self.current_dataset.dqx_data = data_set.flatten() 288 elif (self.q_uncertaint ies.index(key) == 1 or289 self.q_resolution s.index(key) == 1):297 elif (self.q_uncertainty_names.index(key) == 1 or 298 self.q_resolution_names.index(key) == 1): 290 299 self.current_dataset.dqy_data = data_set.flatten() 291 300 self.current_dataset.yaxis("Q_y", unit) … … 541 550 (n_rows, n_cols) = dataset.data.shape 542 551 flat_qy = dataset.qy_data[0::n_cols].flatten() 552 # For 2D arrays of Qx and Qy, the Q value should be constant 553 # along each row -OR- each column. The direction is not 554 # specified in the NXcanSAS standard. 543 555 if flat_qy[0] == flat_qy[1]: 544 556 flat_qy = np.transpose(dataset.qy_data)[0::n_cols].flatten() 545 557 dataset.y_bins = np.unique(flat_qy) 546 558 flat_qx = dataset.qx_data[0::n_rows].flatten() 559 # For 2D arrays of Qx and Qy, the Q value should be constant 560 # along each row -OR- each column. The direction is not 561 # specified in the NXcanSAS standard. 547 562 if flat_qx[0] == flat_qx[1]: 548 563 flat_qx = np.transpose(dataset.qx_data)[0::n_rows].flatten() … … 588 603 self.current_dataset = plottable_1D(x, y) 589 604 self.current_datainfo.filename = self.raw_data.filename 590 self.mask_name = ""591 self.i_name = ""592 self.i_node = ""593 self. q_name = []594 self.q_ uncertainties = []595 self.q_ resolutions = []596 self. i_uncertainties = ""605 self.mask_name = u'' 606 self.i_name = u'' 607 self.i_node = u'' 608 self.i_uncertainties_name = u'' 609 self.q_names = [] 610 self.q_uncertainty_names = [] 611 self.q_resolution_names = [] 597 612 598 613 @staticmethod … … 622 637 self.mask_name = attrs.get("mask") 623 638 for val in q_indices: 624 self.q_name .append(i_axes[val])639 self.q_names.append(i_axes[val]) 625 640 self.i_name = signal 626 641 self.i_node = value.get(self.i_name) 627 for item in self.q_name :642 for item in self.q_names: 628 643 if item in keys: 629 644 q_vals = value.get(item) 630 645 if q_vals.attrs.get("uncertainties") is not None: 631 self.q_uncertaint ies = q_vals.attrs.get("uncertainties")646 self.q_uncertainty_names = q_vals.attrs.get("uncertainties") 632 647 elif q_vals.attrs.get("uncertainty") is not None: 633 self.q_uncertaint ies = q_vals.attrs.get("uncertainty")634 if isinstance(self.q_uncertaint ies, basestring):635 self.q_uncertaint ies = self.q_uncertainties.split(",")648 self.q_uncertainty_names = q_vals.attrs.get("uncertainty") 649 if isinstance(self.q_uncertainty_names, basestring): 650 self.q_uncertainty_names = self.q_uncertainty_names.split(",") 636 651 if q_vals.attrs.get("resolutions") is not None: 637 self.q_resolution s = q_vals.attrs.get("resolutions")638 if isinstance(self.q_resolution s, basestring):639 self.q_resolution s = self.q_resolutions.split(",")652 self.q_resolution_names = q_vals.attrs.get("resolutions") 653 if isinstance(self.q_resolution_names, basestring): 654 self.q_resolution_names = self.q_resolution_names.split(",") 640 655 if self.i_name in keys: 641 656 i_vals = value.get(self.i_name) 642 self.i_uncertainties = i_vals.attrs.get("uncertainties")643 if self.i_uncertainties is None:644 self.i_uncertainties = i_vals.attrs.get("uncertainty")657 self.i_uncertainties_name = i_vals.attrs.get("uncertainties") 658 if self.i_uncertainties_name is None: 659 self.i_uncertainties_name = i_vals.attrs.get("uncertainty") 645 660 646 661 def _is2d(self, value, basename="I"):
Note: See TracChangeset
for help on using the changeset viewer.