- Timestamp:
- Jan 3, 2018 9:43:28 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:
- db5196d
- Parents:
- e3133dc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/file_reader_base_class.py
re3133dc rf02a0c6 180 180 if data.dlam is not None: 181 181 data.dlam = self._reorder_1d_array(data.dlam, ind) 182 data = self._remove_nans_in_ 1d_data(data)182 data = self._remove_nans_in_data(data) 183 183 if len(data.x) > 0: 184 184 data.xmin = np.min(data.x) … … 199 199 200 200 @staticmethod 201 def _remove_nans_in_ 1d_data(data):201 def _remove_nans_in_data(data): 202 202 """ 203 203 Remove data points where nan is loaded … … 205 205 :return: data with mask=0 for any value of nan in data .x, .y, .dx, .dy 206 206 """ 207 mask = np.ones(len(data.x)) 208 data_list = [data.x, data.y, data.dx, data.dy, data.dxl, data.dxw] 207 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] 210 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] 214 else: 215 mask = np.ones(0) 216 data_list = [] 209 217 for array in data_list: 210 218 if array is not None: … … 214 222 nans = np.where(mask == 0)[0] 215 223 if len(nans) > 0: 216 data.x = np.delete(data.x, nans) 217 data.y = np.delete(data.y, nans) 218 if data.dx is not None: 219 data.dx = np.delete(data.dx, nans) 220 if data.dxl is not None: 221 data.dxl = np.delete(data.dxl, nans) 222 if data.dxw is not None: 223 data.dxw = np.delete(data.dxw, nans) 224 if data.dy is not None: 225 data.dy = np.delete(data.dy, nans) 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) 226 249 return data 227 250 … … 255 278 dataset.x_bins = dataset.qx_data[:int(n_cols)] 256 279 dataset.data = dataset.data.flatten() 280 dataset = self._remove_nans_in_data(dataset) 257 281 if len(dataset.data) > 0: 258 282 dataset.xmin = np.min(dataset.qx_data)
Note: See TracChangeset
for help on using the changeset viewer.