Ignore:
Timestamp:
Apr 18, 2017 12:56:03 PM (7 years ago)
Author:
krzywon
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:
080d88e
Parents:
da8bb53
git-author:
Jeff Krzywon <krzywon@…> (04/18/17 12:56:03)
git-committer:
krzywon <krzywon@…> (04/18/17 12:56:03)
Message:

ABS reader converted to new system.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/file_reader_base_class.py

    rda8bb53 rad92c5a  
    5252                # Try to load the file, but raise an error if unable to. 
    5353                try: 
    54                     self.load_unit_converter() 
    5554                    self.f_open = open(filepath, 'rb') 
    5655                    self.get_file_contents() 
     
    9493        self.output.append(data_obj) 
    9594 
    96     def load_unit_converter(self): 
    97         """ 
    98         Generic unit conversion import  
    99         """ 
    100         # Check whether we have a converter available 
    101         self.has_converter = True 
    102         try: 
    103             from sas.sascalc.data_util.nxsunit import Converter 
    104         except: 
    105             self.has_converter = False 
    106  
    10795    def sort_one_d_data(self): 
    10896        """ 
     
    138126        self.output = [] 
    139127 
     128    def remove_empty_q_values(self, has_error_dx=False, has_error_dy=False): 
     129        """ 
     130        Remove any point where Q == 0 
     131        """ 
     132        x = self.current_dataset.x 
     133        self.current_dataset.x = self.current_dataset.x[x != 0] 
     134        self.current_dataset.y = self.current_dataset.y[x != 0] 
     135        self.current_dataset.dy = self.current_dataset.dy[x != 0] if \ 
     136            has_error_dy else np.zeros(len(self.current_dataset.y)) 
     137        self.current_dataset.dx = self.current_dataset.dx[x != 0] if \ 
     138            has_error_dx else np.zeros(len(self.current_dataset.x)) 
     139 
     140    def reset_data_list(self, no_lines=0): 
     141        """ 
     142        Reset the plottable_1D object 
     143        """ 
     144        # Initialize data sets with arrays the maximum possible size 
     145        x = np.zeros(no_lines) 
     146        y = np.zeros(no_lines) 
     147        dy = np.zeros(no_lines) 
     148        dx = np.zeros(no_lines) 
     149        self.current_dataset = plottable_1D(x, y, dx, dy) 
     150 
    140151    @staticmethod 
    141152    def splitline(line): 
     
    158169    def get_file_contents(self): 
    159170        """ 
     171        Reader specific class to access the contents of the file 
    160172        All reader classes that inherit from FileReader must implement 
    161173        """ 
Note: See TracChangeset for help on using the changeset viewer.