Changeset 8475d16 in sasview for src/sas/sascalc/dataloader
- Timestamp:
- Dec 22, 2017 11:37:19 AM (7 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- cc62607
- Parents:
- 0a88623
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/file_reader_base_class.py
r3053a4a r8475d16 7 7 import os 8 8 import sys 9 import re9 import math 10 10 import logging 11 11 from abc import abstractmethod … … 102 102 self.current_dataset = None 103 103 self.filepath = None 104 self.ind = None 104 105 self.output = [] 105 106 … … 158 159 data.y_unit = self.format_unit(data.y_unit) 159 160 # Sort data by increasing x and remove 1st point 160 ind = np.lexsort((data.y, data.x))161 data.x = np.asarray([data.x[i] for i in ind]).astype(np.float64)162 data.y = np.asarray([data.y[i] for i in ind]).astype(np.float64)161 self.ind = np.lexsort((data.y, data.x)) 162 data.x = self.sort_1d_array(data.x) 163 data.y = self.sort_1d_array(data.y) 163 164 if data.dx is not None: 164 165 if len(data.dx) == 0: 165 166 data.dx = None 166 167 continue 167 data.dx = np.asarray([data.dx[i] for i in ind]).astype(np.float64)168 data.dx = self.sort_1d_array(data.dx) 168 169 if data.dxl is not None: 169 data.dxl = np.asarray([data.dxl[i] for i in ind]).astype(np.float64)170 data.dxl = self.sort_1d_array(data.dxl) 170 171 if data.dxw is not None: 171 data.dxw = np.asarray([data.dxw[i] for i in ind]).astype(np.float64)172 data.dxw = self.sort_1d_array(data.dxw) 172 173 if data.dy is not None: 173 174 if len(data.dy) == 0: 174 175 data.dy = None 175 176 continue 176 data.dy = np.asarray([data.dy[i] for i in ind]).astype(np.float64)177 data.dy = self.sort_1d_array(data.dy) 177 178 if data.lam is not None: 178 data.lam = np.asarray([data.lam[i] for i in ind]).astype(np.float64)179 data.lam = self.sort_1d_array(data.lam) 179 180 if data.dlam is not None: 180 data.dlam = np.asarray([data.dlam[i] for i in ind]).astype(np.float64)181 data.dlam = self.sort_1d_array(data.dlam) 181 182 if len(data.x) > 0: 182 183 data.xmin = np.min(data.x) … … 184 185 data.ymin = np.min(data.y) 185 186 data.ymax = np.max(data.y) 187 188 def sort_1d_array(self, array=[]): 189 if array.any(): 190 for i in self.ind: 191 if math.isnan(array[i]): 192 array[i] = 0 193 array = np.asarray([array[i] for i in self.ind]).astype(np.float64) 194 return array 186 195 187 196 def sort_two_d_data(self):
Note: See TracChangeset
for help on using the changeset viewer.