Opened 6 months ago

Closed 3 months ago

#1220 closed defect (fixed)

log scale 2D data with zeros and negative values not plotted correctly

Reported by: pkienzle Owned by: GitHub <noreply@…>
Priority: major Milestone: SasView 4.3.0
Component: SasView Keywords:
Cc: Work Package: McSAS Integration Project

Description

Sasview 4.2

Zero and negative values not plotted appropriately in log scale for 2D data.

Plotter should add invalid values to the mask.

Could instead use a transform something like the following:

data = data.copy()
zmin = min(data[data>0])/2 if (data>0).any() else 1
data[data<=zmin] = zmin
return log10(data)

If you know it is counts data, then log10(data+1) is good enough for visualization.

You may still have a problem with spurious cancellation, for example when looking at background subtracted data, where you might end up with values like 1e-100 while the majority of the values are much higher. Setting the cutoff for masking at ½ the 5th percentile, np.quantile(data[data>0], 0.05)/2, instead of min(data[data>0])/2 would be better.

Change History (3)

comment:1 Changed 6 months ago by krzywon

In sasgui/plottools/PlotPanel.py, lines 1460 and 1469 that handle negative values for log plotting are commented out. Removing the comments makes the plots look much better.

The percentile suggestion will take some extra work to handle values between 0 and 1 (log10(1<n<0) is a negative number).

comment:2 Changed 5 months ago by pkienzle

See sasview PR #202.

This uses the min(data>0) as the cutoff rather than the 5th percentile, but it includes a note on how to change from one to the other.

comment:3 Changed 3 months ago by GitHub <noreply@…>

  • Owner set to GitHub <noreply@…>
  • Resolution set to fixed
  • Status changed from new to closed

In 0a924c6e6f8f8cc1aa158646b7939c1045aba95d/sasview:

Merge pull request #202 from SasView?/ticket-1220

fix 2D log-scale plotting range when data contains zeros and negative values

as agreed at today's meeting
fixes #1220

Note: See TracTickets for help on using tickets.