spacetelescope / stginga

Ginga products specific to STScI data analysis.
https://stginga.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6 stars 10 forks source link

BadPixCorr plugin might be incompatible with Ginga v4 #227

Closed pllim closed 2 years ago

pllim commented 2 years ago

stginga/plugins/BadPixCorr.py circle drawing acts weird now. To reproduce this problem:

  1. Load an image with SCI and DQ arrays and real bad pixels.
  2. Start BadPixCorr plugin.
  3. Select a bad pixel to fix by clicking on it. By default, it draws a circle and an annulus around it.

Problem: Circle has zero radius. Setting the line below from 0 to 1 has no effect.

https://github.com/spacetelescope/stginga/blob/8d0e3b02e9a0194de57245e8978e7d140b021171/stginga/plugins/BadPixCorr.py#L87

I think obj.radius comes back zero even if I try to draw a bigger circle.

https://github.com/spacetelescope/stginga/blob/8d0e3b02e9a0194de57245e8978e7d140b021171/stginga/plugins/BadPixCorr.py#L359

Suspect:

cc @ejeschke @kulpster85

ejeschke commented 2 years ago

@pllim, is this with the current (dev) version of Ginga?

pllim commented 2 years ago

Yes, current dev version I pulled from GitHub today.

ejeschke commented 2 years ago

How big should the circle normally be relative to the annulus? In the GUI for BadPixCorr, if I type a number into the box labeled "Radius:" (under "Bad Pix Attributes") and press enter, it shows a green circle of that radius (in addition to the magenta annulus). Is it possible that the field is being initialized to 0 incorrectly?

pllim commented 2 years ago

Yes, obj.radius returns zero. In your Drawing plugin, it defaults to 1. I don't understand why it does not default to 1 anymore in this plugin. 😿

ejeschke commented 2 years ago

I see that when I actually drag out a circle instead of just clicking, I get a circle of the desired radius. Not sure why the previous version should have defaulted to 1 with just a click, because it is certainly possible to draw a circle with a radius close to zero.

If change L359 from

self.radius = obj.radius

to

self.radius = max(obj.radius, 1.0)
obj.radius = self.radius

I think the plugin works like you are describing.

ejeschke commented 2 years ago

PR in #228

ejeschke commented 2 years ago

When I try the Drawing plugin, one can easily draw very tiny circles. I think the 1.0 in the 'radius:' box is not meaningful for the drawing operation itself, since the radius is determined by how far you drag the cursor while the button is held. Instead, it changes to the actual radius if you try to edit the object.

pllim commented 2 years ago

Thanks! I'll have a look tomorrow. 🙇‍♀️

pllim commented 2 years ago

Works fine. Thanks again!