Ignore:
Timestamp:
Sep 22, 2017 2:01:32 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
34d7b35
Parents:
9706d88
Message:

convert sascalc to python 2/3 syntax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/tiff_reader.py

    r959eb01 r574adc7  
    22#This software was developed by the University of Tennessee as part of the 
    33#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 #project funded by the US National Science Foundation.  
     4#project funded by the US National Science Foundation. 
    55#See the license text in license.txt 
    66#copyright 2008, University of Tennessee 
     
    3131    ## Extension 
    3232    ext = ['.tif', '.tiff'] 
    33          
     33 
    3434    def read(self, filename=None): 
    3535        """ 
    3636        Open and read the data in a file 
    37          
     37 
    3838        :param file: path of the file 
    3939        """ 
     
    4444        except: 
    4545            msg = "tiff_reader: could not load file. Missing Image module." 
    46             raise RuntimeError, msg 
    47          
     46            raise RuntimeError(msg) 
     47 
    4848        # Instantiate data object 
    4949        output = Data2D() 
    5050        output.filename = os.path.basename(filename) 
    51              
     51 
    5252        # Read in the image 
    5353        try: 
    5454            im = Image.open(filename) 
    5555        except: 
    56             raise  RuntimeError, "cannot open %s"%(filename) 
     56            raise  RuntimeError("cannot open %s"%(filename)) 
    5757        data = im.getdata() 
    5858 
     
    6161        output.err_data = np.zeros([im.size[0], im.size[1]]) 
    6262        output.mask = np.ones([im.size[0], im.size[1]], dtype=bool) 
    63          
     63 
    6464        # Initialize 
    6565        x_vals = [] 
     
    6969        for i_x in range(im.size[0]): 
    7070            x_vals.append(i_x) 
    71              
     71 
    7272        itot = 0 
    7373        for i_y in range(im.size[1]): 
     
    8080                logger.error("tiff_reader: had to skip a non-float point") 
    8181                continue 
    82              
     82 
    8383            # Get bin number 
    8484            if math.fmod(itot, im.size[0]) == 0: 
     
    8787            else: 
    8888                i_x += 1 
    89                  
     89 
    9090            output.data[im.size[1] - 1 - i_y][i_x] = value 
    91              
     91 
    9292            itot += 1 
    93                  
     93 
    9494        output.xbins = im.size[0] 
    9595        output.ybins = im.size[1] 
     
    102102        output.ymin = 0 
    103103        output.ymax = im.size[0] - 1 
    104          
     104 
    105105        # Store loading process information 
    106106        output.meta_data['loader'] = self.type_name 
Note: See TracChangeset for help on using the changeset viewer.