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

Harmonic oscillation reduction [JSB version] #313

Merged
merged 13 commits into from
Mar 9, 2023

Conversation

profjsb
Copy link
Contributor

@profjsb profjsb commented Feb 23, 2023

This is a copy of the PR #285 by @sarajamal57, that has been rebased to the current main of cesium.

It is meant to solve the overflow problem in issue #284 by:

  • normalization of the input data if opt_normalize == True
  • rescaling of the output dictionary via rescale_lomb_model()

Additional output:
The full power spectrum and associated frequencies are added in the output dictionary ("freqs_vector", "psd_vector")

@profjsb profjsb changed the title Harmonic oscillation reduction Harmonic oscillation reduction [JSB version] Feb 23, 2023
@profjsb profjsb requested a review from stefanv February 23, 2023 21:26
Copy link
Contributor

@stefanv stefanv left a comment

Choose a reason for hiding this comment

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

Thanks @profjsb. There are some small things that can be tidied up here, but none needs to block merging. Go ahead and do as much as you like, then merge on passing of tests.

nharm=8,
nfreq=3,
tone_control=5.0,
opt_normalize=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would normalize suffice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea. done.

@@ -71,6 +95,7 @@ def lomb_scargle_model(
detrend_order=1,
)
model_dict["trend"] = fit["trend_coef"][1]
#
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

norm_residual = signal - fit["model"]
signal = norm_residual

# store current estim_freq results, [**RESCALED for first fund freq]
Copy link
Contributor

Choose a reason for hiding this comment

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

If these comments are useful, should they be clarified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, done.

model_dict["freq_fits"].append(current_fit)
model_dict["freq_fits"][-1]["resid"] = norm_residual

if opt_normalize & (i == 0):
Copy link
Contributor

Choose a reason for hiding this comment

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

These two if clauses feel as if they should be combined higher up, but perhaps that's tricky.

rescaled_model = norm_model.copy()
# unchanged : 'psd', 'chi0', 'freq', 'chi2', 'trace', 'nu0', 'nu', 'npars',
# 'rel_phase', 'rel_phase_error', 'time0', 'signif'
rescaled_model["s0"] = rescaled_model["s0"] / mscale**2
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe three for-loops here?

@profjsb profjsb merged commit 2d90428 into cesium-ml:main Mar 9, 2023
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.

4 participants