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

Convert WaveX to PLRedNoise and DMWaveX to PLDMNoise #1694

Merged
merged 43 commits into from
Jan 26, 2024

Conversation

abhisrkckl
Copy link
Contributor

@abhisrkckl abhisrkckl commented Dec 15, 2023

WaveX and PLRedNoise are both Fourier representations of achromatic red noise. The difference is that WaveX is a deterministic model with free Fourier coefficients whereas PLRedNoise is a GP model where the Fourier coefficients have been analytically marginalized. The WaveX coefficients can be converted to PLRedNoise spectral parameters (amplitude and spectral index) by maximizing the following likelihood function:
image
Here, a_j and b_j are the WaveX coefficients, epsilon represents their measurement uncertainties, and P(f) is a power law spectrum.

This likelihood function has a different statistical interpretation than the analytically marginalized likelihood used for Bayesian analysis (it acts on timing residuals directly). Hence, its results are not expected to be fully consistent with the Bayesian results. Nevertheless, this conversion gives results fairly close to the Bayesian estimates (mostly within the 3-sigma level in the tests I have done).

The inverse PLRedNoise --> WaveX conversion without using the TOAs is not possible since PLRedNoise has less information than WaveX.

A similar relationship and conversion also apply to DMWaveX and PLDMNoise.
Please note that this does not work properly for wideband data due to bug #1660.

Also includes some sourcery refactors.

@abhisrkckl abhisrkckl changed the title WIP: Estimate spectral parameters from WaveX/DMWaveX components WIP: Convert WaveX to PLRedNoise and DMWaveX to PLDMNoise Dec 15, 2023
Copy link

codecov bot commented Dec 15, 2023

Codecov Report

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

Comparison is base (258e83c) 68.78% compared to head (4a4036a) 68.96%.

Files Patch % Lines
src/pint/utils.py 88.88% 13 Missing and 2 partials ⚠️
src/pint/models/dmwavex.py 50.00% 1 Missing and 1 partial ⚠️
src/pint/models/wavex.py 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1694      +/-   ##
==========================================
+ Coverage   68.78%   68.96%   +0.18%     
==========================================
  Files         105      105              
  Lines       24643    24696      +53     
  Branches     4409     4409              
==========================================
+ Hits        16950    17031      +81     
+ Misses       6588     6560      -28     
  Partials     1105     1105              

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

@abhisrkckl
Copy link
Contributor Author

Red noise conversion example (simulation):
image

@abhisrkckl
Copy link
Contributor Author

DM noise conversion example (simulation):
image

@abhisrkckl abhisrkckl changed the title WIP: Convert WaveX to PLRedNoise and DMWaveX to PLDMNoise Convert WaveX to PLRedNoise and DMWaveX to PLDMNoise Jan 3, 2024
src/pint/utils.py Outdated Show resolved Hide resolved
@abhisrkckl abhisrkckl added the awaiting review This PR needs someone to review it so it can be merged label Jan 17, 2024
@dlakaplan
Copy link
Contributor

This looks good, but it looks like the fit comparisons are only done in the example and not in the tests. Are additional tests possible?

@abhisrkckl
Copy link
Contributor Author

@dlakaplan I have added quantitative tests.


mlnlike = _get_wx2pl_lnlike(model, "WaveX", ignore_fyr=ignore_fyr)

gamma_val, log10_A_val = minimize(mlnlike, [4, -13], method="Nelder-Mead").x
Copy link
Contributor

Choose a reason for hiding this comment

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

are there any checks for whether or not this has actually converged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added convergence checks

@abhisrkckl
Copy link
Contributor Author

@dlakaplan Can you please merge this if it looks fine?

@dlakaplan dlakaplan merged commit fa790eb into nanograv:master Jan 26, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review This PR needs someone to review it so it can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants