fusion-flap / nti-wavelet-tools

NTI Wavelet Tools is a data processing toolbox. Current development language is IDL (Interactive Data Language), but some features are only available for IDL 8.5 or later and Python 2.6. Old SVN repository and issue management site: https://deep.reak.bme.hu/projects/wavelet
MIT License
2 stars 0 forks source link

Interactive Python plot for 2D plots #18

Open gergopokol opened 4 years ago

gergopokol commented 4 years ago

2D plots should be plotted preferably in new window opened from the GUI. Should be a universal plotter, and specific plotters can be children of the universal one.

First, functionality is to be discussed. Then GUI design, Implementation of auxiliary calculations. Implementation can be tested after #13

poloskeipeter commented 4 years ago

Should the FLAP plotter be considered?

gergopokol commented 4 years ago

Should the FLAP plotter be considered?

Yes. FLAP uses matplotlib routines, and so it can be parameterized as needed. In principle...

My main concern is if the interactive features would require detailed information on colour scales, etc.. that are now calculated internally in FLAP plotters and the info might not be accessible. Should be tested, I guess...

gergopokol commented 4 years ago

@poloskeipeter opened new issue for the discussion, contents of which are copied herein:

I would like to initiate a discussion about the functionality of the displayed plots. What are the crucial functionalities which should be implemented?

* different windows for stft and modenumbers
* channel selection for stft
* colorbar
* basic zooming
* filtering (IDL ones)
* saving figures (with parameters & ID)
gergopokol commented 4 years ago

Regarding the functionality

The proposal by @poloskeipeter slightly refined (can be iterated further):

  1. Different windows for plotting mode numbers and other matrixes (transforms, cross-transforms, coherences, phases, transfer functions). This is 2 different GUI-s. "Other matrix" plots should be prepared first, and they can be used to plot mode numbers, as well.
  2. "Other matrix" plots should have:
    • selection of the matrix (flap data object),
    • selection of the channel, selection of the absolute value / absolute value squared / phase (enabled and disabled based on the matrix being real or complex),
    • selection of colour scale,
    • scaling of the colour scale,
    • display of filter parameters on the plot,
    • display of version numbers on the plot,
    • basic zooming,
    • live display of value and coordinates of cursor position,
    • saving to figure.
  3. On the top of "Other matrix" plots, mode number plots should have:
    • options for filtering,
    • options for setting saturation based on the qs matrix with the corresponding colour scale,
    • options for displaying mode number fits at the selected point.
poloskeipeter commented 4 years ago

@gergopokol it is possible in QTdesign to set up a single interface with multiple "subwindows" (for modenumbers and anything else).

Although I am not 100% sure if the main plotting interface should contain options for anything else but spectrograms and modenumbers.

With other suggestions I agree, and I will create their place and their basic functionality (for spectrograms and modenumbers I think I know how).

As we don't have the calculations yet implemented, @martonvavrik would it be possible to prepare a plot-testing data set in the flap format ?

gergopokol commented 4 years ago

@martonvavrik is working on the data reader in #22. Almost ready, just debugging.

poloskeipeter commented 4 years ago

First contourplots have been added, with a function, if you click on the figure, while no tool is selected, it prints the value of the contourplot wherever the cursor was.

poloskeipeter commented 4 years ago

Current possibilities & how to test them:

  1. Open GUI and press Quick-plot to plot a "spectrogram like" contourplot
  2. If the interactive functions are NOT selected (zoom, save, pan etc.) then we can interact with the figure
  3. Left-click or right-click on the spectrogram prints the current cursor position in (t, f) and the matrix's value at the closest point.
  4. Left-click on the colorbar selects the pressed color bin on the spectrogram, reducing alpha anywhere else. (basic energy range selection) - linear descent
  5. Right-click on the colorbar re-initializes the graph
  6. Clicking outside of the plotted area does print a kind message that the user clicked outside
poloskeipeter commented 4 years ago

image

poloskeipeter commented 4 years ago

Idea for modenumber plotting:

  1. Select color based on what color was selected (whatever modenumber it was). - was done
  2. Generate colormap with this single color, applying a linear opacity change. - see color selection
  3. Replot some qualitative measure of the selected modenumber's fit. - to be implemented
poloskeipeter commented 4 years ago

Basic plotting window funtionality is done.

There were a couple ideas from Gergo to the detailed plotting:

  1. Displaying multiple plots simultanously (use multiplot for display (121 and 122)) with 2 main options A. First plot will display spectrogram & second plot displays amplitudes (at given, clicked (t,f) -point) for different channels along specifc coordinate (like toroidal angle, radial coordinate etc.) B. First plot displays modenumber graph & secon plot displays phase-diagram at given time-frequency point.
poloskeipeter commented 4 years ago

Relevant part of help has been added

gergopokol commented 4 years ago

Interaction with the color scale seems to be a bit buggy. Tested on various sav files (e.g. AUGD_38088_Loaded-with-MTR_processed_spectrogram_smoothed.sav) with current version of the python-new-GUI branch.

  1. On spectrogram plots at lowest values of the color scale high energy modes appear. Looks like some overflow problem.
  2. On mode number plots faulty mode numbers are indicated when clicking on the color scale. Displayed (and filtered) values reach from 0 to 1.
martonvavrik commented 4 years ago

The following error was given when clicking on the colorbar (when it also produces the previous bug): Traceback (most recent call last): File "C:\Users\Marci\Anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 215, in process func(*args, **kwargs) File "E:/marci main/Fusion/nti-wavelet-tools/python/gui/main.py", line 339, in MouseClickInteraction high = self.colorbar.boundaries[int((act - lo) / step) + 1] IndexError: index 12 is out of bounds for axis 0 with size 12 Traceback (most recent call last): File "C:\Users\Marci\Anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 215, in process func(*args, **kwargs) File "E:/marci main/Fusion/nti-wavelet-tools/python/gui/main.py", line 338, in MouseClickInteraction low = self.colorbar.boundaries[int((act - lo) / step)] IndexError: index 12 is out of bounds for axis 0 with size 12 Traceback (most recent call last): File "C:\Users\Marci\Anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 215, in process func(*args, **kwargs) File "E:/marci main/Fusion/nti-wavelet-tools/python/gui/main.py", line 338, in MouseClickInteraction low = self.colorbar.boundaries[int((act - lo) / step)] IndexError: index 14 is out of bounds for axis 0 with size 12

gergopokol commented 4 years ago

Bug investigated: If the coordinate is normalized in line 336 of main.py, it works on Gergő's and Marci's laptop. Peti's laptop does need the normalization. To be investigated further.

poloskeipeter commented 4 years ago

@gergopokol @martonvavrik please check if this works for you or not

gergopokol commented 4 years ago

Position on the color scale is correctly indicated. Spectrogram filtering seems to work just fine. Modenumber filtering fails fo highlight some mode numbers, and even more if we plot on a large mode number scale, say [-20,20].

gergopokol commented 4 years ago

Despite our best attempts, mode number highlighting is still buggy.

The actually plotted colour values (checked from saved plot with GIMP) on the cloor scale (checked from saved plot with GIMP) sit just in the middle of the corresponding selectedCmap values remaining after the selection, which seems to be ok. This bug is a mistery... Also, it works differently at Peti, but still buggy.

poloskeipeter commented 4 years ago

An idea would be to explicitly state the number of colorscale elements (maximal - minimal +1), and reimplement the selection part algorithm, using a similar method as now, but without the rescaling needed.

poloskeipeter commented 4 years ago

It seems that using this method leads to a double-length (2 long) bin for the 0 modenumber instead of a 1 long. My suspicion is getting stronger around int-casting.

poloskeipeter commented 4 years ago

Pushed code seems to provide the requested plot-interaction functionality. It works both for me and @gergopokol (matplotlib 3.2.2 and matplotlib 3.1.2). Other versions were not tested.