Changeset f55af70 in sasview for DataLoader/readers


Ignore:
Timestamp:
Jan 20, 2009 9:54:56 AM (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:
fbd0bece
Parents:
d9629c53
Message:

Now it can read larger # of 2D pixels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/readers/IgorReader.py

    rb99ac227 rf55af70  
    5252        if len(output.detector)>0: print str(output.detector[0]) 
    5353        output.detector.append(detector) 
    54          
    55         size_x = 128 
    56         size_y = 128 
    57         output.data = numpy.zeros([size_x,size_y]) 
    58         output.err_data = numpy.zeros([size_x,size_y]) 
    59          
     54                 
     55        # Get content 
     56        dataStarted = False 
     57         
     58         
     59        lines = buf.split('\n') 
     60        itot = 0 
     61        x = [] 
     62        y = [] 
     63         
     64        ncounts = 0 
     65         
     66        xmin = None 
     67        xmax = None 
     68        ymin = None 
     69        ymax = None 
     70         
     71        i_x = 0 
     72        i_y = -1 
     73        i_tot_row = 0 
     74         
     75        isInfo = False 
     76        isCenter = False 
     77        
    6078        data_conv_q = None 
    6179        data_conv_i = None 
     
    7088            # Test it 
    7189            data_conv_i(1.0, output.I_unit)             
    72      
    73          
    74         # Get content 
    75         dataStarted = False 
    76          
    77          
    78         lines = buf.split('\n') 
    79         itot = 0 
    80         x = [] 
    81         y = [] 
    82          
    83         ncounts = 0 
    84          
    85         xmin = None 
    86         xmax = None 
    87         ymin = None 
    88         ymax = None 
    89          
    90         i_x = 0 
    91         i_y = -1 
    92          
    93         isInfo = False 
    94         isCenter = False 
     90          
    9591        for line in lines: 
    9692             
     
    104100                except: 
    105101                    raise ValueError,"IgorReader: can't read this file, missing wavelength" 
     102                 
     103            #Find # of bins in a row assuming the detector is square. 
     104            if dataStarted == True: 
     105                try: 
     106                    value = float(line) 
     107                except: 
     108                    # Found a non-float entry, skip it 
     109                    continue 
     110                 
     111                # Get total bin number 
     112                 
     113            i_tot_row += 1 
     114        i_tot_row=math.ceil(math.sqrt(i_tot_row))-1  
     115        #print "i_tot", i_tot_row 
     116        size_x = i_tot_row#192#128 
     117        size_y = i_tot_row#192#128 
     118        output.data = numpy.zeros([size_x,size_y]) 
     119        output.err_data = numpy.zeros([size_x,size_y]) 
     120      
     121        #Read Header and 2D data 
     122        for line in lines: 
     123            # Find setup info line 
     124            if isInfo: 
     125                isInfo = False 
     126                line_toks = line.split() 
     127                # Wavelength in Angstrom 
     128                try: 
     129                    wavelength = float(line_toks[1]) 
     130                except: 
     131                    raise ValueError,"IgorReader: can't read this file, missing wavelength" 
    106132                # Distance in meters 
    107133                try: 
     
    115141                except: 
    116142                    raise ValueError,"IgorReader: can't read this file, missing transmission" 
    117                  
     143                                             
    118144            if line.count("LAMBDA")>0: 
    119145                isInfo = True 
     
    150176                 
    151177                # Get bin number 
    152                 if math.fmod(itot, 128)==0: 
     178                if math.fmod(itot, i_tot_row)==0: 
    153179                    i_x = 0 
    154180                    i_y += 1 
Note: See TracChangeset for help on using the changeset viewer.