Changeset 9e6aeaf in sasview for src/sas/sascalc/dataloader/file_reader_base_class.py
- Timestamp:
- Sep 25, 2017 5:35:29 PM (7 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 3cb3a51
- Parents:
- 9efdb29 (diff), 0315b63 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/file_reader_base_class.py
r7b50f14 r9e6aeaf 197 197 dataset.x_bins = dataset.qx_data[:int(n_cols)] 198 198 dataset.data = dataset.data.flatten() 199 if len(dataset.data) > 0: 200 dataset.xmin = np.min(dataset.qx_data) 201 dataset.xmax = np.max(dataset.qx_data) 202 dataset.ymin = np.min(dataset.qy_data) 203 dataset.ymax = np.max(dataset.qx_data) 199 204 200 205 def format_unit(self, unit=None): … … 221 226 self.output = [] 222 227 223 def remove_empty_q_values(self, has_error_dx=False, has_error_dy=False, 224 has_error_dxl=False, has_error_dxw=False): 228 def data_cleanup(self): 229 """ 230 Clean up the data sets and refresh everything 231 :return: None 232 """ 233 self.remove_empty_q_values() 234 self.send_to_output() # Combine datasets with DataInfo 235 self.current_datainfo = DataInfo() # Reset DataInfo 236 237 def remove_empty_q_values(self): 225 238 """ 226 239 Remove any point where Q == 0 227 240 """ 228 x = self.current_dataset.x 229 self.current_dataset.x = self.current_dataset.x[x != 0] 230 self.current_dataset.y = self.current_dataset.y[x != 0] 231 if has_error_dy: 232 self.current_dataset.dy = self.current_dataset.dy[x != 0] 233 if has_error_dx: 234 self.current_dataset.dx = self.current_dataset.dx[x != 0] 235 if has_error_dxl: 236 self.current_dataset.dxl = self.current_dataset.dxl[x != 0] 237 if has_error_dxw: 238 self.current_dataset.dxw = self.current_dataset.dxw[x != 0] 241 if isinstance(self.current_dataset, plottable_1D): 242 # Booleans for resolutions 243 has_error_dx = self.current_dataset.dx is not None 244 has_error_dxl = self.current_dataset.dxl is not None 245 has_error_dxw = self.current_dataset.dxw is not None 246 has_error_dy = self.current_dataset.dy is not None 247 # Create arrays of zeros for non-existent resolutions 248 if has_error_dxw and not has_error_dxl: 249 array_size = self.current_dataset.dxw.size - 1 250 self.current_dataset.dxl = np.append(self.current_dataset.dxl, 251 np.zeros([array_size])) 252 has_error_dxl = True 253 elif has_error_dxl and not has_error_dxw: 254 array_size = self.current_dataset.dxl.size - 1 255 self.current_dataset.dxw = np.append(self.current_dataset.dxw, 256 np.zeros([array_size])) 257 has_error_dxw = True 258 elif not has_error_dxl and not has_error_dxw and not has_error_dx: 259 array_size = self.current_dataset.x.size - 1 260 self.current_dataset.dx = np.append(self.current_dataset.dx, 261 np.zeros([array_size])) 262 has_error_dx = True 263 if not has_error_dy: 264 array_size = self.current_dataset.y.size - 1 265 self.current_dataset.dy = np.append(self.current_dataset.dy, 266 np.zeros([array_size])) 267 has_error_dy = True 268 269 # Remove points where q = 0 270 x = self.current_dataset.x 271 self.current_dataset.x = self.current_dataset.x[x != 0] 272 self.current_dataset.y = self.current_dataset.y[x != 0] 273 if has_error_dy: 274 self.current_dataset.dy = self.current_dataset.dy[x != 0] 275 if has_error_dx: 276 self.current_dataset.dx = self.current_dataset.dx[x != 0] 277 if has_error_dxl: 278 self.current_dataset.dxl = self.current_dataset.dxl[x != 0] 279 if has_error_dxw: 280 self.current_dataset.dxw = self.current_dataset.dxw[x != 0] 281 elif isinstance(self.current_dataset, plottable_2D): 282 has_error_dqx = self.current_dataset.dqx_data is not None 283 has_error_dqy = self.current_dataset.dqy_data is not None 284 has_error_dy = self.current_dataset.err_data is not None 285 has_mask = self.current_dataset.mask is not None 286 x = self.current_dataset.qx_data 287 self.current_dataset.data = self.current_dataset.data[x != 0] 288 self.current_dataset.qx_data = self.current_dataset.qx_data[x != 0] 289 self.current_dataset.qy_data = self.current_dataset.qy_data[x != 0] 290 self.current_dataset.q_data = np.sqrt( 291 np.square(self.current_dataset.qx_data) + np.square( 292 self.current_dataset.qy_data)) 293 if has_error_dy: 294 self.current_dataset.err_data = self.current_dataset.err_data[x != 0] 295 if has_error_dqx: 296 self.current_dataset.dqx_data = self.current_dataset.dqx_data[x != 0] 297 if has_error_dqy: 298 self.current_dataset.dqy_data = self.current_dataset.dqy_data[x != 0] 299 if has_mask: 300 self.current_dataset.mask = self.current_dataset.mask[x != 0] 239 301 240 302 def reset_data_list(self, no_lines=0):
Note: See TracChangeset
for help on using the changeset viewer.