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

Astronomy Using Unevenly Sampled Data : GSoC 2023 #737

Merged
merged 31 commits into from
Sep 28, 2023

Conversation

pupperemeritus
Copy link
Contributor

@pupperemeritus pupperemeritus commented Jun 7, 2023

This is a work in progress. Feel free to provide critique and suggestions for any bugs that may be or incorrect behaviour. So far I have implemented the base Lomb-Scargle Cross Spectrum and Power Spectrum classes. Do mention any useful statistical functions that may be of interest to people dealing with unevenly sampled data. I have so far only completed the slow implementation. As I work on the fast implementation, tests, statistical functions and documentation, I will tack on commits to this PR as i progress.

@pupperemeritus pupperemeritus changed the title Astronomy Using Unevenly Sampled Data : GSoC 2023 Astronomy Using Unevenly Sampled Data : GSoC 2023 [WiP] Jun 8, 2023
@matteobachetti
Copy link
Member

The enable_deprecations_as_warnings issue is partially solved in commit #cc2a561bbf770fd269a82b9aa3704c303a36dc2c, feel free to cherry-pick.

@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Merging #737 (03606c8) into main (5fac201) will increase coverage by 0.71%.
Report is 5 commits behind head on main.
The diff coverage is 100.00%.

❗ Current head 03606c8 differs from pull request most recent head 01a1533. Consider uploading reports for the commit 01a1533 to get more accurate results

@@            Coverage Diff             @@
##             main     #737      +/-   ##
==========================================
+ Coverage   96.62%   97.34%   +0.71%     
==========================================
  Files          41       42       +1     
  Lines        7388     7649     +261     
==========================================
+ Hits         7139     7446     +307     
+ Misses        249      203      -46     
Files Coverage Δ
stingray/__init__.py 100.00% <100.00%> (ø)
stingray/fourier.py 99.79% <100.00%> (+0.03%) ⬆️
stingray/lightcurve.py 97.89% <ø> (ø)
stingray/lombscargle.py 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

stingray/fourier.py Outdated Show resolved Hide resolved
@pupperemeritus pupperemeritus changed the title Astronomy Using Unevenly Sampled Data : GSoC 2023 [WiP] Astronomy Using Unevenly Sampled Data : GSoC 2023 : Part 1 [WiP] Jun 21, 2023
@matteobachetti
Copy link
Member

@pupperemeritus a small suggestion: when you incorporate recent additions to main, please rebase instead of merging/pulling. This will avoid all the merge commits polluting the history.

@pupperemeritus
Copy link
Contributor Author

I will do that 👍

@pupperemeritus pupperemeritus force-pushed the LombScargle branch 2 times, most recently from 58097e6 to b5998dc Compare June 25, 2023 14:32
@pupperemeritus pupperemeritus force-pushed the LombScargle branch 2 times, most recently from f013cc8 to d2d7968 Compare August 21, 2023 08:33
@pupperemeritus pupperemeritus marked this pull request as ready for review August 21, 2023 08:34
Copy link
Member

@matteobachetti matteobachetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pupperemeritus thanks for your work!
It's overall good, I left a few comments about things that can be improved.
Phase lags should work! I added a test that shows that, at least when the time arrays are the same, phase lags should be measured correctly.

stingray/fourier.py Outdated Show resolved Hide resolved
stingray/fourier.py Outdated Show resolved Hide resolved
stingray/fourier.py Outdated Show resolved Hide resolved
stingray/fourier.py Outdated Show resolved Hide resolved
stingray/lombscargle.py Outdated Show resolved Hide resolved
stingray/lombscargle.py Show resolved Hide resolved
@pupperemeritus
Copy link
Contributor Author

I will make those changes

Copy link
Member

@matteobachetti matteobachetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pupperemeritus. Please note that the _make_crossspectrum is the legacy interface in Stingray, and that much of the checks on EventLists are currently wrong and can be simplified.
As a final change, I would like to ask you to please use the from_events, from_lightcurves, etc. functions, to uniformize to the most recent versions of AveragedCrossspectrum. When implementing from_events, you will need to create light curves internally using a given sample time dt.

):
raise TypeError("Both the events are not of type Eventlist or Lightcurve or None")

if type(data1) == type(data2):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of raising ValueError, I would just say that the lags will not be correct. The process should actually work.

if len(data1.time) != len(data2.time):
raise ValueError("data1 and data2 must have the same length")
else:
if (isinstance(data1, EventList) or isinstance(data2, EventList)) and (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here is wrong. If you have event lists, the time arrays will always be different.

if not isinstance(fullspec, bool):
raise TypeError("fullspec must be a boolean")

if np.logical_xor(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I'd say you are overcomplicating the data type selection here. You have various instances of isinstance filtering that should be simplified. What don't you like of the machinery in the standard Crossspectrum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was something along the lines of EventList, Lightcurve intermixing while accounting for mixed type with one none. I think that train of thought went quiet overcomplicated. I guess I will simplify and bring it in line with the regular crossspectrum

@pupperemeritus pupperemeritus changed the title Astronomy Using Unevenly Sampled Data : GSoC 2023 : Part 1 [WiP] Astronomy Using Unevenly Sampled Data : GSoC 2023 Sep 17, 2023
Copy link
Member

@matteobachetti matteobachetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pupperemeritus great new additions! Some parts of the code are not tested yet. I added an example test that should pass if the EventList machinery works, there should be a few more, some making the code run correctly and testing its values, some making it break in predictable ways. Please try to get the patch coverage to 100%

stingray/tests/test_lombscargle.py Show resolved Hide resolved
@matteobachetti
Copy link
Member

@astrofrog @jakevdp would the Lomb-Scargle cross spectrum be interesting to be put in astropy timeseries? @pupperemeritus's work might be useful for a more general audience than ours.

@matteobachetti
Copy link
Member

@pupperemeritus, thanks for your hard work! This makes an excellent addition to Stingray, and it will be one of the highlights of the next release.

@pupperemeritus
Copy link
Contributor Author

Thank you @matteobachetti. It was a fun working on it and a great learning experience.

@matteobachetti matteobachetti added this pull request to the merge queue Sep 28, 2023
Merged via the queue into StingraySoftware:main with commit be88264 Sep 28, 2023
5 checks passed
@pupperemeritus pupperemeritus deleted the LombScargle branch February 12, 2024 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants