Changeset 6fd7b20 in sasview
- Timestamp:
- Jan 3, 2018 2:09:40 PM (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:
- 340291a
- Parents:
- db5196d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/file_reader_base_class.py
rf02a0c6 r6fd7b20 25 25 def decode(s): 26 26 return s.decode() if isinstance(s, bytes) else s 27 28 # Data 1D fields for iterative purposes 29 FIELDS_1D = ('x', 'y', 'dx', 'dy', 'dxl', 'dxw') 30 # Data 2D fields for iterative purposes 31 FIELDS_2D = ('data', 'qx_data', 'qy_data', 'q_data', 'err_data', 32 'dqx_data', 'dqy_data') 33 27 34 28 35 class FileReader(object): … … 206 213 """ 207 214 if isinstance(data, Data1D): 208 mask = np.ones(data.x.shape) 209 data_list = [data.x, data.y, data.dx, data.dy, data.dxl, data.dxw] 215 fields = FIELDS_1D 210 216 elif isinstance(data, Data2D): 211 mask = np.ones(data.data.shape) 212 data_list = [data.data, data.qx_data, data.qy_data, data.q_data, 213 data.err_data, data.dqx_data, data.dqy_data, data.mask] 217 fields = FIELDS_2D 214 218 else: 215 mask = np.ones(0) 216 data_list = [] 217 for array in data_list: 219 return data 220 good = np.isfinite(getattr(data, fields[0])) 221 for name in fields[1:]: 222 array = getattr(data, name) 218 223 if array is not None: 219 224 # Set mask[i] to 0 when data.<param> is nan 220 mask[np.isnan(array)] = 0 221 # Data indices to mask/remove from the data 222 nans = np.where(mask == 0)[0] 223 if len(nans) > 0: 224 if isinstance(data, Data1D): 225 data.x = np.delete(data.x, nans) 226 data.y = np.delete(data.y, nans) 227 if data.dx is not None: 228 data.dx = np.delete(data.dx, nans) 229 if data.dxl is not None: 230 data.dxl = np.delete(data.dxl, nans) 231 if data.dxw is not None: 232 data.dxw = np.delete(data.dxw, nans) 233 if data.dy is not None: 234 data.dy = np.delete(data.dy, nans) 235 elif isinstance(data, Data2D): 236 data.data = np.delete(data.data, nans) 237 data.qx_data = np.delete(data.qx_data, nans) 238 data.qy_data = np.delete(data.qy_data, nans) 239 if data.q_data is not None: 240 data.q_data = np.delete(data.q_data, nans) 241 if data.err_data is not None: 242 data.err_data = np.delete(data.err_data, nans) 243 if data.dqx_data is not None: 244 data.dqx_data = np.delete(data.dqx_data, nans) 245 if data.dqy_data is not None: 246 data.dqy_data = np.delete(data.dqy_data, nans) 247 if data.mask is not None: 248 data.mask = np.delete(data.mask, nans) 225 good &= np.isfinite(array) 226 if not np.all(good): 227 for name in fields: 228 array = getattr(data, name) 229 if array is not None: 230 setattr(data, name, array[good]) 249 231 return data 250 232
Note: See TracChangeset
for help on using the changeset viewer.