ejeschke / ginga

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

Failure setting cuts in grc mode, problem using wavelength plugin #913

Closed jhennawi closed 3 years ago

jhennawi commented 3 years ago

Hi All,

I have encountered a pretty pernicious bug in trying to set cuts in grc mode. I'm attaching the python file here required to reproduce the bug, as well as the test images. The reason I need to attach the code in this way and the relevant images is that this bug is not that easy to reproduce. The results appear to depend on how I pass in the desired cut levels, which may be a data type issue, I'm not really sure.

There is a second bug here that I'm at a loss to understand depending on whether I pass in the wavelength image and use our wavelength plugin or not, which @ejeschke helped us create. The plugin which we are calling is located here:

https://github.com/pypeit/PypeIt/blob/develop/pypeit/display/ginga_plugins.py

The code and images required to reproduce the bug are here.

https://www.dropbox.com/sh/g5ss1w42hzada2c/AAD9TBUQIX7wUOLsahTVLg5Ya?dl=0

Please let me know if you require additional information and many thanks for your help.

Also, if you object to how we are using the grc mode or thing there is a more sensible way, we would be happy to hear feedback.

Many Thanks! Joe Hennawi

ejeschke commented 3 years ago

Hi @jhennawi!

Let's take the problems one at a time. First, the cuts issue: what kind of error message or wrong behavior do you see with the cuts?

I'm now downloading your code and samples to test it out, but it would be good to have some idea of what you are seeing...

ejeschke commented 3 years ago

I am seeing some kind of problem loading the waveimg. Is that the same error you are getting?

ejeschke commented 3 years ago

@jhennawi, the issue with passing cuts over the remote interface is due to the fact that numpy values do not have a default encoding in the marshalling of the RPC parameters over XML-RPC which is what grc is using to communicate with the main ginga RC plugin. This is not an issue for numpy arrays, because they are encoded as buffers.

I was able to work around the first blocker by changing the line that calls the cuts in ginga_bug.py from this:

    if cuts is not None:
        out = ch.cut_levels(cuts[0], cuts[1])

to this:

    if cuts is not None:
        out = ch.cut_levels(float(cuts[0]), float(cuts[1]))

Now I am getting a blocker calling the SlitWavelength plugin. Trying to diagnose that...

ejeschke commented 3 years ago

After making the following change, it works for me:

            subprocess.Popen(['ginga', '--modules=RC'])

to

            subprocess.Popen(['ginga', '--modules=RC,SlitWavelength', '--loglevel=20',
                              '--log=/tmp/ginga.log'])

NOTE: the log parameters I added so I could debug the cuts issue by looking at the log file--they are not necessary.

ejeschke commented 3 years ago

I think this may address both issues you are seeing. LMK if not.

jhennawi commented 3 years ago

Dear Eric, many thanks for your prompt reply and help with debugging this. Great, yes I figured the cuts thing was a casting issue, but I actually could not find the source code for the cut levels method.

One piece of hopefully constructive criticism: this is in my opinion the thing that makes debugging ginga very unpleasant. In i.e. a notebook or IPython, if I type ch.(tab) I cannot figure out what attributes and methods the channel object has, or where to find the source code for the cut_levels method. I end up trying to use grep, but even that is confusing. I don't understand why this is the case, but I think it has to do with how grc uses proxies for inheritance. Never knowing the methods associated with i.e. the viewer, channel, shell objects makes learning ginga seemingly impossible for an outsider.

I'll give your changes a go and report back to you. Many thanks!!!

jhennawi commented 3 years ago

Sorry about the bug in launching RC, that was a pretty serious oversight on our part!

ejeschke commented 3 years ago

@jhennawi, I understand your frustration. Sort of the same feeling I get trying to debug problems in javascript in a web browser from code running in Python. You are removed a level or two away from the context in which it happens. You are absolutely correct in that it has a lot to do with the proxies being only very loosely coupled to the Ginga execution environment. I hope that we can improve the remote interface in the future and also it's documentation. You are helping to make clear what the limitations are!

I do find that enabling a log file for the Ginga process is very helpful, you might want to consider doing so if you haven't already for pypelt.

ejeschke commented 3 years ago

@jhennawi, can we close this issue?

jhennawi commented 3 years ago

Yes thank you!!

On Tue, Dec 15, 2020 at 9:44 PM ejeschke notifications@github.com wrote:

@jhennawi https://github.com/jhennawi, can we close this issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ejeschke/ginga/issues/913#issuecomment-745556055, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACC6HI2FEIT3OUOSP6UVEI3SU7DELANCNFSM4UQYIE4A .

--

Joseph F. Hennawi Professor Department of Physics Broida Hall, UC Santa Barbara Santa Barbara, CA 93106-9530 Phone: 805-893-3503 Mobile: 805-450-8697 E-mail: joe@ joe@physics.ucsb.eduphysics.ucsb.edu http://web.physics.ucsb.edu/~joe/ enigma.physics.ucsb.edu