Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

461 spectral window #463

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

461 spectral window #463

wants to merge 9 commits into from

Conversation

mpyat2
Copy link
Collaborator

@mpyat2 mpyat2 commented Dec 26, 2024

This implements the "Spectral Window" algorithm (with the results identical to the popular program Period04, http://period04.net/). The algorithm is essentially the 'classic' Discrete Fourier Transform as it is described in (Deeming 1975, bibcode 1975Ap&SS..36..137D) for a signal with unit amplitude.
Since we need DFT for this, I made the plug-in 2 in 1: DFT itself (again, identical to Period04, which uses this very algorithm) and Spectral Window. The 'Classic' DFT is the most primitive one and loses to other algorithms (for example, DC DFT) in many cases, yet why not have it for the collection?

To-do:

  1. Implement 'Create Model' functionality accessed directly from a panel with the DFT result (like in DC DFT). This button is hidden now, when I tried to use it 'as is', an error occured. It seems 'Create Model' is too tightly bound with DC DFT.
  2. Unit test
  3. Try to optimize calculations: now it is slower even as Peranso3 (where the same algorithm is implemented, too)

Side notes:

  1. This plug-in, like DC DFT and AoV ones, may open several resulting non-modal dialogs. When a new star is loaded, they lose connections between their panes. So, I decided to close all of them while loading a new star. This is implemented with the help of List<PeriodAnalysisDialog>. It is probably worth implementing such behavior in DC DFT and AoV plug-ins.
  2. Looks like there are still many places in VStar where Swing dialogs are called from threads other than EDT. This is strongly discouraged by the Java docs, strange, but it has no visible effect in the app. Nevertheless, I avoided it here with the help of SwingUtilities.invokeAndWait. Probably, this can be used in the other places in the app.

Test data: eta_Aql_2024_visual.txt
eta_Aql_2024_visual.txt

image
image

@mpyat2 mpyat2 self-assigned this Dec 26, 2024
@mpyat2 mpyat2 requested a review from dbenn December 26, 2024 18:22
@mpyat2 mpyat2 added enhancement New feature or request plug-in Plug-in Development labels Dec 26, 2024
@dbenn dbenn linked an issue Dec 27, 2024 that may be closed by this pull request
@dbenn
Copy link
Collaborator

dbenn commented Dec 27, 2024

Really cool @mpyat2! Perhaps the DFT will have issues with unevenly spaced data, which your comment may be alluding to, but this is a great addition! I am less familiar with Spectral Window, but see some references, e.g. https://encyclopediaofmath.org/wiki/Spectral_window If you have another reference you are using, could you point me to that?

As you may see from #204 I'm implementing a piecewise linear model (almost done) that will be incorporated with the AoV period search plugin for model creation as well as being standalone. Some of the other issues you see could be collaborated on if it helps.

…rovement); Math.tan(a/2) instead of sin(a), cos(a) increased performance at ~40% on my machine
@mpyat2
Copy link
Collaborator Author

mpyat2 commented Dec 27, 2024

Hi @dbenn , concerning "Spectral Window": it is implemented like in Period04, see http://period04.net/files/p04manual_v1.0.0.pdf, page 53. There is no theory (unfortunately) in the guide, but only a practical example. I'll look for a better description. Also, a very lapidary description can be found here: https://www.cbabelgium.com/peranso/UserGuideHTML/Spectralwindow.html. I also wrote a couple of words about it in the documentation for the plug-in (see DFT and Spectral Window Plug-In.pdf)

@mpyat2
Copy link
Collaborator Author

mpyat2 commented Dec 27, 2024

Side note about performance: on my mini-PC (low-performance machine, Celeron N5095A @ 2.00GHz, Windows 11) DFT calculations for the test data "eta_Aql_2024_visual.txt" (minFreq=0.0, maxFreq=2.0, resolution=0.00001) with Java 8 (1.8.0_432, last update) takes ~41s, while with Open JDK 23.0.1 it takes only ~7s (almost in 6 times faster!).

Well, recent versions of Java have done some great optimization...
image

@dbenn
Copy link
Collaborator

dbenn commented Dec 27, 2024

Recommending a new minimal version of Java of VStar may be worth considering @mpyat2.

@mpyat2
Copy link
Collaborator Author

mpyat2 commented Dec 27, 2024

Recommending a new minimal version of Java of VStar may be worth considering @mpyat2.

Well, it's probably sufficient to indicate that it it recommended to switch to the newest version available because of better optimization, performance win, etc.

@mpyat2
Copy link
Collaborator Author

mpyat2 commented Dec 27, 2024

I am less familiar with Spectral Window,

Also, the Spectral Window can be considered as a 'representation of gaps' and the finite nature of the observing interval. The Fourier spectrum of the real data is a convolution of an 'ideal' spectrum with the Fourier transform of this "gaps' function" (see this abstract https://ui.adsabs.harvard.edu/abs/1975Ap%26SS..36..137D/abstract). By the way, in the appendix to the article, a short Fortran program, which calculates both DFT and Spectral Window, is listed. Well, I noticed it now only; in fact, it is quite simple and is easy to reinvent (this is a straightforward calculation of Eq. 3 from the article).
In other words, if you calculate the spectral window (which is centered at 0), you will see all phantom structures that accompany the real spectral peaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plug-in Plug-in Development
Projects
Development

Successfully merging this pull request may close these issues.

Implement "Spectral Window" analysis tool
2 participants