spacetelescope / imexam

imexam is a python tool for simple image examination, and plotting, with similar functionality to IRAF's imexamine
http://imexam.readthedocs.io
BSD 3-Clause "New" or "Revised" License
74 stars 45 forks source link

Plotting charts in DS9 #175

Open mrepasky3 opened 5 years ago

mrepasky3 commented 5 years ago

I've been trying to use imexam to plot radial profiles in DS9. I apologize, I'm sort of new to Linux/Ubuntu but I will try to be as detailed as possible.

I open DS9 using the viewer=imexam.connect() command in ipython in the terminal. When I load an image in DS9, I then run viewer.imexam() and the correct thing comes up in the terminal, listing all the buttons and their functionalities.

However, when I actually go to plot a radial profile of a star in DS9, as soon as I tap r, a black window opens where the plot should be. I wait for this plot to load, and before it does, a window pops up (multiple times) saying that it is not responding. I tap wait, and eventually it loads. Once it finally loads, I look at the terminal, and after the normal things that go with with radial plot are displayed, this is what follows:


ValueError Traceback (most recent call last)

in ----> 1 viewer.imexam() ~/anaconda3/lib/python3.7/site-packages/imexam/connect.py in imexam(self) 150 self._run_event_imexam() 151 else: --> 152 self._run_imexam() 153 else: 154 warnings.warn("No valid image loaded in viewer") ~/anaconda3/lib/python3.7/site-packages/imexam/connect.py in _run_imexam(self) 243 # interface. 244 try: --> 245 x, y, current_key = self.readcursor() 246 if current_key in ["Left", "Right", "Up", "Down"]: 247 if current_key == "Left": ~/anaconda3/lib/python3.7/site-packages/imexam/connect.py in readcursor(self) 310 in the form of x,y,str with array offset 311 """ --> 312 return self.window.readcursor() 313 314 def alignwcs(self, **kwargs): ~/anaconda3/lib/python3.7/site-packages/imexam/ds9_viewer.py in readcursor(self) 710 raise ValueError("Outside of data range") 711 --> 712 k, x, y = xpa_string.split() 713 714 # ds9 is returning 1 based array, set to 0-based since ValueError: not enough values to unpack (expected 3, got 0) -------------------------------------------------------------------------------- I have no idea how to interpret this, or what to do to fix it. Would appreciate help. Is it just that my machine is too slow/old (only has 4 gigs of RAM)? edit: I will add that after this, it kicks me out of the viewer.imexam() mode and back to the ipython command line.
sosey commented 5 years ago

It's probably the matplotlib backend that is running. Let me know what version of matplotlib you are running, and which backend it is using? This is usu set in the matplotlibrc file, or you can see what is loaded by default by issuing the following command matplotlib.get_backend()

mrepasky3 commented 5 years ago

Let me know what version of matplotlib you are running, and which backend it is using

Matplotlib version 3.0.3 backend version Qt5Agg

mrepasky3 commented 5 years ago

Update: I've since tried to change the backend version for matplotlib. My computer has three files called matplotlibrc, but all three of them already had the backend set to 'Qt4Agg.' When I import matplotlib on ipython, however, I run matplotlib.get_backend() and it returns 'Qt5Agg.' I don't know why it would be doing this, but when this happens I just run matplotlib.use('Qt4Agg'). Sometimes this gives an error, but sometimes it works and the command matplotlib.get_backend() does return 'Qt4Agg.' Going through the same process that I did before, then, imexam still crashes at the same point. It actually takes longer to load, and instead of just sitting as a black screen the whole time, the graph window gives an error popup throughout the wait time. When it does finally load, it still crashes imexam like before.

sosey commented 5 years ago

oof. There may be different packages picking it up from different places in your system. There may be conflicting installs in your conda, one in your base and one in your active environement. You might check that, I'll try and get back to this soon.

RoeePartoush commented 4 years ago

Hi, just started trying to use imexam today, and I'm getting the same problem too: when I run some function (I tried "a" - Aperture sum, with radius region_size), I'm getting the expected print: xc=2068.2089 yc=1205.4838 x y radius flux mag(zpt=2.5e+01) sky/pix fwhm(x,y) 2069.00 1205.00 5 9.6e+05 1e+01 1150.915 2.95,2.70 2068.208872357787 1205.4837533152536 24.0

and also the expected plot, but the plot figure immediately freezes for about a minute and then an error: "ValueError: not enough values to unpack (expected 3, got 0)" with the traceback ending in the same line as the source of the error: 701 k, x, y = xpa_string.split()

By the way, I never actively installed XPA or XPANS (to be honest I don't really understand what these things are), I'm just using imexam as a package in an Anaconda environment (I followed installation instructions from the AstroConda channel)

I would very much like to know about any solution you may find, including any suggestion to reinstalling imexam in some other way. Thanks!

MacDaddy1660B commented 1 year ago

Good morning, I'm also having this same issue. I'm using DS9 as the image viewer.

Problem presents after calling viewer.imexam()

Imexam v0.9.1, matplotlib v3.7.2, pyqt v5.15.7. MacOS v13.3.1 Ventura.

MacDaddy1660B commented 1 year ago

I notice in ds9_viewer.py: line 693: xpa_string = self.get("imexam any coordinate image")

If I'm interpreting this correctly, this command will attempt to get the cursor position from a ds9 instance called imexam, but my ds9 instance is called imexam690568134.4728224, which will cause self.get to return an empty string, I think.