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

Introduce power colors #780

Merged
merged 64 commits into from Jan 15, 2024
Merged

Introduce power colors #780

merged 64 commits into from Jan 15, 2024

Conversation

matteobachetti
Copy link
Member

@matteobachetti matteobachetti commented Nov 30, 2023

This PR introduces Power colors à la Heil et al. 2015. Now we can calculate power colors (both linear and logarithmic) and the hue, also defined according to the same paper by Heil+. I added the relevant functions in fourier.py, and tested them in test_fourier.py
Moreover, Power colors can be directly calculated from the spectra in a DynamicalCrossspectrum or DynamicalPowerspectrum, with the new methods power_colors.

In order to make power colors more usable, we also needed a simple way to combine contiguous power spectra to improve the S/N. I added a function to DynamicalCrossspectrum to combine n contiguous spectra together, regardless of their distance in time (e.g. two intervals on the opposite side of an occultation in NICER).

Demonstration here: StingraySoftware/notebooks#76

image

image

Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (cc9d575) 96.31% compared to head (83681ca) 96.40%.
Report is 37 commits behind head on main.

Files Patch % Lines
stingray/lightcurve.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #780      +/-   ##
==========================================
+ Coverage   96.31%   96.40%   +0.08%     
==========================================
  Files          43       43              
  Lines        8495     8697     +202     
==========================================
+ Hits         8182     8384     +202     
  Misses        313      313              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@dhuppenkothen dhuppenkothen left a comment

Choose a reason for hiding this comment

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

Yay! Looks great! I only have minor comments, so I'll pre-emptively approve it so that it can get merged once everything is fixed.

stingray/crossspectrum.py Outdated Show resolved Hide resolved
stingray/crossspectrum.py Outdated Show resolved Hide resolved
stingray/crossspectrum.py Outdated Show resolved Hide resolved
stingray/fourier.py Outdated Show resolved Hide resolved
stingray/crossspectrum.py Outdated Show resolved Hide resolved
stingray/crossspectrum.py Outdated Show resolved Hide resolved
stingray/fourier.py Show resolved Hide resolved
stingray/fourier.py Show resolved Hide resolved
return pc0, pc0_err, pc1, pc1_err


def hue_from_power_color(pc0, pc1, center=[4.51920, 0.453724]):
Copy link
Member

Choose a reason for hiding this comment

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

Given that there is an uncertainty on the power colours, should there also be an uncertainty on the hue?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just tricky to compute, because both error bars matter here (x and y), and I don't think people use the error bars on hues much anyway? Anyways, open to figure this out

stingray/powerspectrum.py Show resolved Hide resolved
@pep8speaks
Copy link

pep8speaks commented Jan 11, 2024

Hello @matteobachetti! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 2254:81: E203 whitespace before ':'
Line 2255:60: E203 whitespace before ':'
Line 2266:81: E203 whitespace before ':'
Line 2267:60: E203 whitespace before ':'

Line 2033:101: E501 line too long (101 > 100 characters)

Comment last updated at 2024-01-11 16:51:45 UTC

@matteobachetti matteobachetti added this pull request to the merge queue Jan 15, 2024
Merged via the queue into main with commit 1fc9b90 Jan 15, 2024
16 checks passed
@matteobachetti matteobachetti deleted the power_colors branch January 15, 2024 10:13
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.

None yet

3 participants