Ignore:
Timestamp:
Nov 28, 2018 10:01:20 AM (5 years ago)
Author:
Jeff Krzywon <jkrzywon@…>
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
Message:

Load and save mask from NXcanSAS properly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py

    r9220e89c rc7c8143  
    567567        # Type cast data arrays to float64 and find min/max as appropriate 
    568568        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 = zeros 
    576569            # Calculate the actual Q matrix 
    577570            try: 
     
    585578 
    586579            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()) 
    602582                dataset.data = dataset.data.flatten() 
    603583                dataset.qx_data = dataset.qx_data.flatten() 
    604584                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) 
    605591            self.current_dataset = dataset 
    606592            self.send_to_output() 
Note: See TracChangeset for help on using the changeset viewer.