- Timestamp:
- Nov 28, 2018 12:01:20 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249
- Children:
- 109afbd
- Parents:
- 9220e89c
- Location:
- src/sas/sascalc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/associations.py
ra32c19c rc7c8143 23 23 ".ses": "sesans_reader", 24 24 ".h5": "cansas_reader_HDF5", 25 ".nxs": "cansas_reader_HDF5", 25 26 ".txt": "ascii_reader", 26 27 ".dat": "red2d_reader", -
src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py
r9220e89c rc7c8143 567 567 # Type cast data arrays to float64 and find min/max as appropriate 568 568 for dataset in self.data2d: 569 zeros = np.ones(dataset.data.size, dtype=bool)570 try:571 for i in range(0, dataset.mask.size - 1):572 zeros[i] = dataset.mask[i]573 except:574 self.errors.append(sys.exc_value)575 dataset.mask = zeros576 569 # Calculate the actual Q matrix 577 570 try: … … 585 578 586 579 if dataset.data.ndim == 2: 587 (n_rows, n_cols) = dataset.data.shape 588 flat_qy = dataset.qy_data[0::n_cols].flatten() 589 # For 2D arrays of Qx and Qy, the Q value should be constant 590 # along each row -OR- each column. The direction is not 591 # specified in the NXcanSAS standard. 592 if flat_qy[0] == flat_qy[1]: 593 flat_qy = np.transpose(dataset.qy_data)[0::n_cols].flatten() 594 dataset.y_bins = np.unique(flat_qy) 595 flat_qx = dataset.qx_data[0::n_rows].flatten() 596 # For 2D arrays of Qx and Qy, the Q value should be constant 597 # along each row -OR- each column. The direction is not 598 # specified in the NXcanSAS standard. 599 if flat_qx[0] == flat_qx[1]: 600 flat_qx = np.transpose(dataset.qx_data)[0::n_rows].flatten() 601 dataset.x_bins = np.unique(flat_qx) 580 dataset.y_bins = np.unique(dataset.qy_data.flatten()) 581 dataset.x_bins = np.unique(dataset.qx_data.flatten()) 602 582 dataset.data = dataset.data.flatten() 603 583 dataset.qx_data = dataset.qx_data.flatten() 604 584 dataset.qy_data = dataset.qy_data.flatten() 585 586 try: 587 iter(dataset.mask) 588 dataset.mask = np.invert(np.asarray(dataset.mask, dtype=bool)) 589 except TypeError: 590 dataset.mask = np.ones(dataset.data.shape, dtype=bool) 605 591 self.current_dataset = dataset 606 592 self.send_to_output() -
src/sas/sascalc/file_converter/nxcansas_writer.py
r9220e89c rc7c8143 328 328 (n_rows, n_cols) = (len(data.y_bins), len(data.x_bins)) 329 329 330 if n_rows == 0 and n_cols == 0: 330 if ((n_rows == 0 and n_cols == 0) 331 or (n_cols*n_rows != len(data.data.flatten()))): 331 332 # Calculate rows and columns, assuming detector is square 332 333 # Same logic as used in PlotPanel.py _get_bins … … 360 361 dqy_entry = data_entry.create_dataset('dQy', data=data.dqy_data) 361 362 dqy_entry.attrs['units'] = data.Q_unit 363 if data.mask is not None and not all(data.mask == [None]): 364 data_entry.attrs['mask'] = "mask" 365 mask = np.invert(np.asarray(data.mask, dtype=bool)) 366 data_entry.create_dataset('mask', data=mask)
Note: See TracChangeset
for help on using the changeset viewer.