StellarCartography / pydis

DEPRECATED: Check out PyKOSMOS!
https://github.com/jradavenport/pykosmos
MIT License
43 stars 27 forks source link

Problem in interactive mode with HeNeAr_fit #81

Closed iskren-y-g closed 5 years ago

iskren-y-g commented 5 years ago

Hi guys,

I think that there is a problem with the InteracWave() class when running interactively HeNeAr_fit. For me (MacOS with python 3.6.9 and everything updated), it never enters in the OnClick() event and it exits immediately with the message that I paste below. I guess that it has something to do with the connect/disconnect instance? Is there an easy fix to this?

Cheers, Iskren

Using INTERACTIVE HeNeAr_fit mode:

1) Click on HeNeAr lines in plot window 2) Enter corresponding wavelength in terminal and press If mis-click or unsure, just press leave blank and press 3) To delete an entry, click on label, enter "d" in terminal, press 4) Close plot window when finished You have identified 0 lines

TypeError Traceback (most recent call last)

in 1 pydis.HeNeAr_fit(lamp_file,fmask=fmask_out,linelist='apohenear.dat',\ ----> 2 trim=False,interac=True,mode='poly',fit_order=5) ~/Installs/miniconda3/lib/python3.6/site-packages/pydis-1.2.dev244-py3.6.egg/pydis/pydis.py in HeNeAr_fit(calimage, linelist, interac, trim, fmask, display, outputlines, tol, fit_order, previous, mode, rowcenter, second_pass) 1531 # coeff = np.polyfit(pcent-len(slice)/2, wcent, fit_order) 1532 xpix = np.arange(len(slice)) -> 1533 coeff = np.polyfit(pcent, wcent, fit_order) 1534 wtemp = np.polyval(coeff, xpix) 1535 ~/Installs/miniconda3/lib/python3.6/site-packages/numpy/lib/polynomial.py in polyfit(x, y, deg, rcond, full, w, cov) 596 raise TypeError("expected 1D vector for x") 597 if x.size == 0: --> 598 raise TypeError("expected non-empty vector for x") 599 if y.ndim < 1 or y.ndim > 2: 600 raise TypeError("expected 1D or 2D array for y") TypeError: expected non-empty vector for x
iskren-y-g commented 5 years ago

I found out that this occurs only if I run it within ipython or in a notebook. It is not crashing if I run it in a terminal from script, e.g. python my_pydis_script.py

jradavenport commented 5 years ago

Well that's interested! I haven't tried the interactive stuff out in the Notebook environment, but it doesn't surprise me that breaks, given how clumsy it was to develop originally.!

It does make me wonder if we should be supporting the notebook explicitly as the "best" data reduction environment... especially since some of the interactive programming can be easier using the web browser...

iskren-y-g commented 5 years ago

If I get the time to dig into this, I'd try to make it work, unless you guys are on it before. It is super useful to have it run in ipython or in a jupyter notebook, because it's easy to teach and share ...

It is really nice what you've done so far. With a bit of tweaking, it can become a really nice tool.