Changeset 9d786e5 in sasview for src/sas/sascalc/dataloader/readers
- Timestamp:
- Jul 27, 2017 11:08:18 AM (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, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 8dec7e7
- Parents:
- 0b79323
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
r7f75a3f r9d786e5 14 14 from sas.sascalc.dataloader.data_info import combine_data_info_with_plottable 15 15 from sas.sascalc.dataloader.loader_exceptions import FileContentsException 16 17 18 class Reader(): 16 from sas.sascalc.dataloader.file_reader_base_class import FileReader 17 18 19 class Reader(FileReader): 19 20 """ 20 21 A class for reading in CanSAS v2.0 data files. The existing iteration opens … … 41 42 # Raw file contents to be processed 42 43 raw_data = None 43 # Data info currently being read in44 current_datainfo = None45 # SASdata set currently being read in46 current_dataset = None47 44 # List of plottable1D objects that should be linked to the current_datainfo 48 45 data1d = None … … 57 54 # Flag to bypass extension check 58 55 allow_all = True 59 # List of files to return 60 output = None 61 62 def read(self, filename): 56 57 def get_file_contents(self): 63 58 """ 64 59 This is the general read method that all SasView data_loaders must have. … … 69 64 # Reinitialize when loading a new data file to reset all class variables 70 65 self.reset_class_variables() 66 67 filename = self.f_open.name 68 self.f_open.close() # IO handled by h5py 69 71 70 # Check that the file exists 72 71 if os.path.isfile(filename): … … 431 430 Data1D and Data2D objects 432 431 """ 433 434 432 # Type cast data arrays to float64 435 433 if len(self.current_datainfo.trans_spectrum) > 0: … … 455 453 # Type cast data arrays to float64 and find min/max as appropriate 456 454 for dataset in self.data2d: 457 dataset.data = dataset.data.astype(np.float64)458 dataset.err_data = dataset.err_data.astype(np.float64)459 if dataset.qx_data is not None:460 dataset.xmin = np.min(dataset.qx_data)461 dataset.xmax = np.max(dataset.qx_data)462 dataset.qx_data = dataset.qx_data.astype(np.float64)463 if dataset.dqx_data is not None:464 dataset.dqx_data = dataset.dqx_data.astype(np.float64)465 if dataset.qy_data is not None:466 dataset.ymin = np.min(dataset.qy_data)467 dataset.ymax = np.max(dataset.qy_data)468 dataset.qy_data = dataset.qy_data.astype(np.float64)469 if dataset.dqy_data is not None:470 dataset.dqy_data = dataset.dqy_data.astype(np.float64)471 if dataset.q_data is not None:472 dataset.q_data = dataset.q_data.astype(np.float64)473 455 zeros = np.ones(dataset.data.size, dtype=bool) 474 456 try: … … 493 475 dataset.x_bins = dataset.qx_data[:n_cols] 494 476 dataset.data = dataset.data.flatten() 495 496 final_dataset = combine_data_info_with_plottable( 497 dataset, self.current_datainfo) 498 self.output.append(final_dataset) 477 self.current_dataset = dataset 478 self.send_to_output() 499 479 500 480 for dataset in self.data1d: 501 if dataset.x is not None: 502 dataset.x = dataset.x.astype(np.float64) 503 dataset.xmin = np.min(dataset.x) 504 dataset.xmax = np.max(dataset.x) 505 if dataset.y is not None: 506 dataset.y = dataset.y.astype(np.float64) 507 dataset.ymin = np.min(dataset.y) 508 dataset.ymax = np.max(dataset.y) 509 if dataset.dx is not None: 510 dataset.dx = dataset.dx.astype(np.float64) 511 if dataset.dxl is not None: 512 dataset.dxl = dataset.dxl.astype(np.float64) 513 if dataset.dxw is not None: 514 dataset.dxw = dataset.dxw.astype(np.float64) 515 if dataset.dy is not None: 516 dataset.dy = dataset.dy.astype(np.float64) 517 final_dataset = combine_data_info_with_plottable( 518 dataset, self.current_datainfo) 519 self.output.append(final_dataset) 481 self.current_dataset = dataset 482 self.send_to_output() 520 483 521 484 def add_data_set(self, key=""):
Note: See TracChangeset
for help on using the changeset viewer.