Changeset 9d4e502 in sasview for DataLoader/readers


Ignore:
Timestamp:
Apr 1, 2009 3:55:03 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:
de5c813
Parents:
1328e03
Message:

removed Imag2D class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/readers/tiff_reader.py

    rded92e4 r9d4e502  
    1616import math, logging, os 
    1717import numpy 
    18 from DataLoader.data_info import Image2D 
     18from DataLoader.data_info import Data2D 
    1919     
    2020class Reader: 
     
    5151         
    5252        # Instantiate data object 
    53         output = Image2D() 
     53        output = Data2D() 
    5454        output.filename = os.path.basename(filename) 
    5555             
     
    5959        except : 
    6060            raise  RuntimeError,"cannot open %s"%(filename) 
    61         data = im.load() 
     61        predata = im.load() 
    6262 
    6363        x_range = im.size[0] 
     
    6565         
    6666        # Initiazed the output data object 
    67         output.image = numpy.zeros([y_range,x_range]) 
    68  
     67        output.data = numpy.zeros([y_range,x_range]) 
     68        output.err_data = numpy.zeros([y_range,x_range]) 
    6969        # Initialize  
    7070        x_vals = [] 
     
    8383             
    8484                try: 
    85                     if data[i_x,i_y].__class__.__name__=="tuple":                      
     85                    if predata[i_x,i_y].__class__.__name__=="tuple":                      
    8686                         
    87                         if len(data[i_x,i_y]) == 3:    
    88                             R,G,B= data[i_x,i_y] 
    89                             #Converting to L Mode: uses the ITU-R 601-2 luma transform. 
    90                             value = float(R * 299/1000 + G * 587/1000 + B * 114/1000)  
     87                        if len(predata[i_x,i_y]) == 3:    
     88                            R,G,B= predata[i_x,i_y] 
     89                        elif len(predata[i_x,i_y]) == 4:    
     90                            R,G,B,I = predata[i_x,i_y] 
     91                        #Converting to L Mode: uses the ITU-R 601-2 luma transform. 
     92                        value = float(R * 299/1000 + G * 587/1000 + B * 114/1000)  
    9193                          
    92                         elif len(data[i_x,i_y]) == 4:    
    93                             R,G,B,I = data[i_x,i_y] 
    94                             #Take only I  
    95                             value = float(R * 299/1000 + G * 587/1000 + B * 114/1000)+float(I) 
    9694                    else: 
    9795                        #Take it as Intensity 
    98                         value = float(data[i_x,i_y]) 
     96                        value = float(predata[i_x,i_y]) 
    9997                except: 
    10098                    logging.error("tiff_reader: had to skip a non-float point") 
     
    102100                 
    103101                   
    104                 output.image[y_range-i_y-1,i_x] = value 
     102                output.data[y_range-i_y-1,i_x] = value 
    105103         
    106104        output.xbins      = x_range 
     
    109107        output.y_bins     = y_vals 
    110108        output.xmin       = 0 
    111         output.xmax       = x_range 
     109        output.xmax       = x_range-1 
    112110        output.ymin       = 0 
    113         output.ymax       = y_range 
     111        output.ymax       = y_range-1 
    114112         
    115113        return output 
    116114         
    117  
    118  
Note: See TracChangeset for help on using the changeset viewer.