Changeset 75313af in sasview


Ignore:
Timestamp:
Dec 12, 2018 1:50:57 PM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1249
Children:
1342f6a
Parents:
175b83f
Message:

fix 2D log-scale plotting; maybe broke vmin/vmax limits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/plottools/PlotPanel.py

    r2469df7 r75313af  
    14341434 
    14351435        """ 
     1436        # TODO: include mask info in plotter 
    14361437        self.data = data 
    14371438        self.qx_data = qx_data 
     
    14511452        else: 
    14521453            output = copy.deepcopy(self.data) 
    1453         # check scale 
     1454        # rescale data if necessary 
    14541455        if self.scale == 'log_{10}': 
    1455             try: 
    1456                 if  self.zmin_2D <= 0  and len(output[output > 0]) > 0: 
    1457                     zmin_temp = self.zmin_2D 
    1458                     output[output > 0] = np.log10(output[output > 0]) 
    1459                     #In log scale Negative values are not correct in general 
    1460                     #output[output<=0] = math.log(np.min(output[output>0])) 
    1461                 elif self.zmin_2D <= 0: 
    1462                     zmin_temp = self.zmin_2D 
    1463                     output[output > 0] = np.zeros(len(output)) 
    1464                     output[output <= 0] = -32 
    1465                 else: 
    1466                     zmin_temp = self.zmin_2D 
    1467                     output[output > 0] = np.log10(output[output > 0]) 
    1468                     #In log scale Negative values are not correct in general 
    1469                     #output[output<=0] = math.log(np.min(output[output>0])) 
    1470             except: 
    1471                 #Too many problems in 2D plot with scale 
    1472                 pass 
    1473  
    1474         else: 
    1475             zmin_temp = self.zmin_2D 
     1456            with np.errstate(all='ignore'): 
     1457                output = np.log10(output) 
     1458            index = np.isfinite(output) 
     1459            if not index.all(): 
     1460                cutoff = (np.min(output[index]) - np.log10(2) 
     1461                          if index.any() else 0.) 
     1462                output[~index] = cutoff 
     1463        # TODO: fix handling of zmin_2D/zmax_2D in _onToggleScale 
     1464        # For now, use default vmin/vmax from data 
     1465        #vmin, vmax = self.zmin_2D, self.zmax_2D 
     1466        vmin, vmax = None, None 
    14761467        self.cmap = cmap 
    14771468        if self.dimension != 3: 
    14781469            #Re-adjust colorbar 
    14791470            self.subplot.figure.subplots_adjust(left=0.2, right=.8, bottom=.2) 
    1480  
    14811471            im = self.subplot.imshow(output, interpolation='nearest', 
    14821472                                     origin='lower', 
    1483                                      vmin=zmin_temp, vmax=self.zmax_2D, 
     1473                                     vmin=vmin, vmax=vmax, 
    14841474                                     cmap=self.cmap, 
    14851475                                     extent=(self.xmin_2D, self.xmax_2D, 
Note: See TracChangeset for help on using the changeset viewer.