ejeschke / ginga

The Ginga astronomical FITS file viewer
BSD 3-Clause "New" or "Revised" License
121 stars 77 forks source link

Question about slit feature in Cuts #456

Closed pllim closed 7 years ago

pllim commented 7 years ago

I see some similar controls between "slit" in Cuts and LineProfile. When do I use "slit" and when do I use LineProfile? Why aren't they in the same plugin?

Also, starting Cuts with "slit" enabled, I see the following:

Error making callback 'value-changed': 'Cuts' object has no attribute 'save_slit'
Traceback:
  File ".../ginga/misc/Callback.py", line 123, in make_callback
    res = method(*cb_args, **cb_kwdargs)

  File ".../ginga/rv/plugins/Cuts.py", line 978, in width_radius_changed_cb
    self.replot_all()

  File ".../ginga/rv/plugins/Cuts.py", line 675, in replot_all
    self.save_slit.set_enabled(False)

Then, while using it, I see more:

Error making callback 'value-changed': wrapped C/C++ object of type QPushButton has been deleted
Traceback:
  File ".../ginga/misc/Callback.py", line 123, in make_callback
    res = method(*cb_args, **cb_kwdargs)

  File ".../ginga/rv/plugins/Cuts.py", line 978, in width_radius_changed_cb
    self.replot_all()

  File ".../ginga/rv/plugins/Cuts.py", line 675, in replot_all
    self.save_slit.set_enabled(False)

  File ".../ginga/qtw/Widgets.py", line 47, in set_enabled
    self.widget.setEnabled(tf)
Error making callback 'activated': 'New Cut'
Traceback:
  File ".../ginga/misc/Callback.py", line 123, in make_callback
    res = method(*cb_args, **cb_kwdargs)

  File ".../ginga/rv/plugins/Cuts.py", line 370, in <lambda>
    lambda w, tf: self.axis_toggle_cb(w, tf, pos))

  File ".../ginga/rv/plugins/Cuts.py", line 1032, in axis_toggle_cb
    self._plot_slit()

  File ".../ginga/rv/plugins/Cuts.py", line 649, in _plot_slit
    obj = self.canvas.get_object_by_tag(self.cutstag)

  File ".../ginga/canvas/CanvasMixin.py", line 93, in get_object_by_tag
    obj = self.tags[tag]
ejeschke commented 7 years ago

@pllim, could you try commit f472cb8b7ccedd080085d6ba3ff7b1ae001fa49a ?

This should at least fix the issue with the "set_enabled" error.

ejeschke commented 7 years ago

I think LineProfile also is not currently playing well with MultiDim. Loading a cube and exercising the NAXIS controls it is constantly clearing the selection of the axis, which forces a popup error of "Please select an axis".

pllim commented 7 years ago

Thanks for the quick fix; indeed the "set_enabled" error is gone.

The "self.tags[tag]" error appears when I choose NAXIS3 but "New Cut" is set.

Not exactly sure what caused the "QPushButton has been deleted" error. I was doing a bunch of stuff but I was paying attention to LineProfile, not this plugin. If I see it again, I'll add more notes.

pllim commented 7 years ago

forces a popup error of "Please select an axis"

Yes, that is so annoying that I removed it in #455.

ejeschke commented 7 years ago

Yes, that is so annoying that I removed it in #455.

But I think the main issue is that the checkbox for the selected axis is getting cleared. LineProfile needs to check whether the mddata attribute of the new image is the same as for the old image, and only redo the selection checkboxes if this has actually changed. Instread, I think it is rebuilding it on every redo().

pllim commented 7 years ago

You are right. It is not very efficient. I am currently gutting it inside out to implement region selection anyway, I'll make a note to check the mddata. Is a == sufficient or is there some special Ginga function to compare mddata?

ejeschke commented 7 years ago

Actually, can you rebase on master I just pushed? It has the fix, and also fixes the annoying pop up message if the user has not selected an axis.

ejeschke commented 7 years ago

Thank you for polishing up this plugin, @pllim!

pllim commented 7 years ago

an you rebase on master I just pushed?

Hmm. I'll try. There might be conflict but I'll figure it out. Thanks!

ejeschke commented 7 years ago

I've done the following for the "Slit" feature in Cuts:

pllim commented 7 years ago

Did you try using Slit on the nrc image I passed along to you from NIRCam? It works for 4D cube but I don't know what I am looking at.

ejeschke commented 7 years ago

Back to the question at hand...

I see some similar controls between "slit" in Cuts and LineProfile. When do I use "slit" and when do I use LineProfile? Why aren't they in the same plugin?

That is a good question. @rupak0577 implemented both the "Slit" addition to Cuts and also the LineProfile plugin. I think @nabobalis was supervising this and I believe also @Cadair had some input. Maybe we could get a good explanation of the differences?

It works for 4D cube but I don't know what I am looking at.

I think we need one of these fine gentlemen to give us the 1000 meter view...

nabobalis commented 7 years ago

The orignal idea was that a slit would be a spatial cut that outputs a space/time image and the line profile would see how wavelength varies at a single pixel.

I think the orignal plan was to make slit able to cut arbitrary axes to produce any possible combination required by the user, but I can not remember if we got to that. So LineProfile was born to achieve the second aim.

rupak0577 commented 7 years ago

make slit able to cut arbitrary axes to produce any possible combination required by the user

If I remember correctly, we did discuss on whether all the axes would be shown or not and the plugin does show all the axes of the image but I think only two of them can be selected?

@ejeschke @pllim Thank you both for fixing it!

pllim commented 7 years ago

@nabobalis @rupak0577

So when I have the following NAXIS in my 4D cube:

When I draw a line and select NAXIS3, what am I really seeing in "Slit" image? What about when I select NAXIS4? The axis label does not really tell me anything.

pllim commented 7 years ago

@ejeschke , the following case needs to be handled properly as well:

  1. Open a cube.
  2. Start Cuts.
  3. Draw a line on image.
  4. Switch to Slit tab.
  5. Check NAXIS3 box (while "Cut" is still set to "New Cut")
Error making callback 'activated': 'New Cut'
Traceback:
  File ".../ginga/misc/Callback.py", line 123, in make_callback
    res = method(*cb_args, **cb_kwdargs)

  File ".../ginga/rv/plugins/Cuts.py", line 379, in <lambda>
    lambda w, tf: self.axis_toggle_cb(w, tf, pos))

  File ".../ginga/rv/plugins/Cuts.py", line 1052, in axis_toggle_cb
    self._plot_slit()

  File ".../ginga/rv/plugins/Cuts.py", line 654, in _plot_slit
    obj = self.canvas.get_object_by_tag(self.cutstag)

  File ".../ginga/canvas/CanvasMixin.py", line 93, in get_object_by_tag
    obj = self.tags[tag]

One of the sessions also resulted in core dump when I quit Ginga but I can't reproduce it now.

ejeschke commented 7 years ago

@pllim, I believe this is fixed in commit 8b7a1d0696a6c7d8bcb6c8d28b8d1ef70a38b7c8.

pllim commented 7 years ago

Indeed it is fixed. Thanks for the quick response!

ejeschke commented 7 years ago

Can we close this issue then?

pllim commented 7 years ago

My question at https://github.com/ejeschke/ginga/issues/456#issuecomment-299247180 is still unanswered.

nabobalis commented 7 years ago

@pllim Sorry, I clearly missed that question.

With this setup: NAXIS1 = 2048 NAXIS2 = 2048 NAXIS3 = 10 NAXIS4 = 2

If we select NAXIS 3, we would end up with a NAXIS3-distance diagram. For the data I use it, NAXIS3 is wavelength, so I should end up with a 2D spectra (like an IRIS raster image) where one axis is distance along slit and the other wavelength. This would be at a fixed NAXIS4 position but I can not recall what one it uses. In my case, NAXIS4 is time, so we would end up with a time-distance diagram at a fixed NAXIS3 value.

Some people might want to vary the fixed third axis value, so you could see the spectra change through time for example. I am not sure if this answers your question though.

pllim commented 7 years ago

Some people might want to vary the fixed third axis value

Thanks! Do you do that through MultiDim?

nabobalis commented 7 years ago

Yeah.

pllim commented 7 years ago

Okay, that's good to know. Thank you!