Changeset d508be9 in sasview for DataLoader/readers


Ignore:
Timestamp:
Apr 10, 2009 1:44:31 PM (15 years ago)
Author:
Jae Cho <jhjcho@…>
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, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
d0fd4c9
Parents:
88e289c
Message:

line with fewer/larger columns now considered as a header

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/readers/ascii_reader.py

    r892f246 rd508be9  
    9494                #Initialize counters for data lines and header lines. 
    9595                is_data = False #Has more than 3 lines 
    96                 mum_data_lines = 3 # More than "3" lines of data is considered as actual data unless there is only less lines of data 
    97  
    98                 i=-1  # To count # of current data candidate lines 
    99                 i1=-1 # To count total # of previous data candidate lines 
    100                 j=-1  # To count # of header lines 
    101                 j1=-1 # Helps to count # of header lines 
     96                mum_data_lines = 3 # More than "3" lines of data is considered as actual data unless that is the only data 
     97 
     98                i=-1            # To count # of current data candidate lines 
     99                i1=-1           # To count total # of previous data candidate lines 
     100                j=-1            # To count # of header lines 
     101                j1=-1           # Helps to count # of header lines 
     102                lentoks = 2     # minimum required number of columns of data; ( <= 4). 
    102103                 
    103104                for line in lines: 
     
    109110                        _y = float(toks[1]) 
    110111                         
     112                        #To reject the line when reader meets less columns of data 
     113                        if lentoks == 3: 
     114                            _dy = float(toks[2]) 
     115                        elif lentoks == 4: 
     116                            _dx = float(toks[3]) 
     117                         
    111118                        #Reset the header line counters 
    112119                        if j == j1: 
     
    116123                        if i > 1: 
    117124                            is_data = True 
    118                              
     125                         
    119126                        if data_conv_q is not None: 
    120127                            _x = data_conv_q(_x, units=output.x_unit) 
     
    161168                            has_error_dx = False if _dx == None else True 
    162169                         
     170                        #After talked with PB, we decided to take care of only 4 columns of data for now. 
     171                        #number of columns in the current line 
     172                        if len(toks)>= 4: 
     173                            new_lentoks = 4 
     174                        else: 
     175                            new_lentoks = len(toks) 
     176                         
     177                        #If the previous columns are less than the current, mark the previous as non-data and reset the dependents.   
     178                        if lentoks < new_lentoks : 
     179                            if is_data == False: 
     180                                i = -1 
     181                                i1 = 0 
     182                                j = -1 
     183                                j1 = -1 
     184                             
    163185                        #Delete the previously stored lines of data candidates if is not data. 
    164186                        if i < 0 and -1< i1 < mum_data_lines and is_data == False: 
     
    219241                                    pass                                                                                                              
    220242                            tdx = numpy.append(tdx, _dx) 
     243 
     244                        #reset i1 and flag lentoks for the next 
     245                        if lentoks < new_lentoks : 
     246                            if is_data == False: 
     247                                i1 = -1                             
     248                        if len(toks)>= 4: 
     249                            lentoks = 4 
     250                        else: 
     251                            lentoks = len(toks) 
    221252                         
    222253                        #Reset # of header lines and counts # of data candidate lines     
     
    230261                        if is_data == True: 
    231262                            break     
     263                        lentoks = 2 
    232264                        #Counting # of header lines                     
    233265                        j+=1 
     
    265297                        dx[i] = tdx[ind[i]] 
    266298                 
     299                 
    267300                #Data     
    268301                output.x = x 
     
    279312                else: 
    280313                    output.yaxis("\\rm{Intensity}","cm^{-1}") 
    281  
     314                print "output",output 
    282315                return output 
    283316             
Note: See TracChangeset for help on using the changeset viewer.