Changeset fe498b83 in sasview for src/sas/sascalc/file_converter


Ignore:
Timestamp:
Aug 19, 2016 5:20:16 AM (8 years ago)
Author:
lewis
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.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
edf0e06
Parents:
ac370c5
Message:

Refactor to make use of x_bins and y_bins

Location:
src/sas/sascalc/file_converter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/file_converter/bsl_loader.py

    rd889d80 rfe498b83  
    11from sas.sascalc.file_converter.core.bsl_loader import CLoader 
     2from sas.sascalc.dataloader.data_info import Data2D 
    23from copy import deepcopy 
    34import os 
     
    7980            data_info['pixels'], data_info['rasters'], data_info['swap_bytes']) 
    8081 
     82    def load_frames(self, frames): 
     83        frame_data = [] 
     84        # Prepare axis values (arbitrary scale) 
     85        x = self.n_rasters * range(1, self.n_pixels+1) 
     86        y = [self.n_pixels * [i] for i in range(1, self.n_rasters+1)] 
     87        y = np.reshape(y, (1, self.n_pixels*self.n_rasters))[0] 
     88        x_bins = x[:self.n_pixels] 
     89        y_bins = y[0::self.n_pixels] 
     90 
     91        for frame in frames: 
     92            self.frame = frame 
     93            raw_frame_data = self.load_data() 
     94            data2d = Data2D(data=raw_frame_data, qx_data=x, qy_data=y) 
     95            data2d.x_bins = x_bins 
     96            data2d.y_bins = y_bins 
     97            frame_data.append(data2d) 
     98 
     99        return frame_data 
     100 
     101 
    81102    def __setattr__(self, name, value): 
    82103        if name == 'filename': 
  • src/sas/sascalc/file_converter/nxcansas_writer.py

    rafbd172 rfe498b83  
    2222    """ 
    2323 
    24     def write(self, dataset, filename, dimensions=[]): 
     24    def write(self, dataset, filename): 
    2525        """ 
    2626        Write an array of Data1d or Data2D objects to an NXcanSAS file, as 
     
    7979                self._write_1d_data(data_obj, data_entry) 
    8080            elif isinstance(data_obj, Data2D): 
    81                 self._write_2d_data(data_obj, data_entry, dimensions) 
     81                self._write_2d_data(data_obj, data_entry) 
    8282            i += 1 
    8383 
     
    158158        data_entry.create_dataset('Idev', data=data_obj.dy) 
    159159 
    160     def _write_2d_data(self, data, data_entry, dimensions): 
     160    def _write_2d_data(self, data, data_entry): 
    161161        """ 
    162162        Writes the contents of a Data2D object to a SASdata h5py Group 
     
    170170        data_entry.attrs['Q_indicies'] = [0,1] 
    171171 
    172         (n_rows, n_cols) = (None, None) 
    173         try: 
    174             (n_rows, n_cols) = dimensions.pop(0) 
    175         except: 
    176             pass 
     172        (n_rows, n_cols) = (len(data.y_bins), len(data.x_bins)) 
    177173 
    178         if n_rows == None and n_cols == None: 
     174        if n_rows == 0 and n_cols == 0: 
    179175            # Calculate rows and columns, assuming detector is square 
    180176            # Same logic as used in PlotPanel.py _get_bins 
Note: See TracChangeset for help on using the changeset viewer.