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

✨ Add support for pfid megacomplex #1510

Merged
merged 12 commits into from
Aug 23, 2024
Merged

Conversation

jsnel
Copy link
Member

@jsnel jsnel commented Aug 16, 2024

Add support for the modelling of perturbed free induction decay (PFID) as described in the 1995 paper by P. Hamm.

P. Hamm, “Coherent effects in femtosecond infrared spectroscopy,” Chemical Physics 200, 415–429 (1995).
DOI: 10.1016/0301-0104(95)00262-6

Change summary

  • Added PFID megacomplex

The feature will be documented as part of an upcoming publication.

Checklist

  • ✔️ Passing the tests (mandatory for all PR's)
  • 🚧 Added changes to changelog (mandatory for all PR's)
  • 🧪 Adds new tests for the feature (mandatory for ✨ feature and 🩹 bug fix PR's)

Copy link
Contributor

Binder 👈 Launch a binder notebook on branch jsnel/pyglotaran/pfid_megacomplex

@jsnel jsnel force-pushed the pfid_megacomplex branch from fbf1aa2 to cacafec Compare August 17, 2024 01:01
glotaran/typing/types.py Dismissed Show dismissed Hide dismissed
@jsnel jsnel force-pushed the pfid_megacomplex branch from 19cc2ed to c555dab Compare August 17, 2024 14:19
Copy link

codecov bot commented Aug 17, 2024

Codecov Report

Attention: Patch coverage is 89.18919% with 12 lines in your changes missing coverage. Please review.

Project coverage is 88.8%. Comparing base (2c88dce) to head (dd657e8).
Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
...ran/builtin/megacomplexes/pfid/pfid_megacomplex.py 88.7% 7 Missing and 5 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1510     +/-   ##
=======================================
+ Coverage   88.6%   88.8%   +0.1%     
=======================================
  Files        107     109      +2     
  Lines       5128    5245    +117     
  Branches     962     982     +20     
=======================================
+ Hits        4544    4658    +114     
  Misses       468     468             
- Partials     116     119      +3     

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


🚨 Try these New Features:

@jsnel jsnel marked this pull request as ready for review August 17, 2024 15:11
@jsnel jsnel requested review from joernweissenborn and a team as code owners August 17, 2024 15:11
Copy link
Contributor

sourcery-ai bot commented Aug 17, 2024

🧙 Sourcery has finished reviewing your pull request!


Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.

@jsnel
Copy link
Member Author

jsnel commented Aug 18, 2024

Removed the bugfix from this PR and into its own PR: #1512

@jsnel jsnel force-pushed the pfid_megacomplex branch from e19c83b to cfbd353 Compare August 18, 2024 18:30
@jsnel jsnel requested review from s-weigand and ism200 August 18, 2024 20:03
Copy link
Collaborator

@ism200 ism200 left a comment

Choose a reason for hiding this comment

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

ziet er wmb prima uit

hartelijk dank!

Copy link
Member

@s-weigand s-weigand left a comment

Choose a reason for hiding this comment

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

There is an inherited bug and a question I have, besides that it looks good to me 👍

@jsnel jsnel requested a review from a team as a code owner August 23, 2024 19:34
@jsnel jsnel requested a review from s-weigand August 23, 2024 19:36
jsnel added 7 commits August 23, 2024 21:39
This commit adds the `PFIDMegacomplex` class along with its dependencies and related classes.

The `PFIDMegacomplex` is a megacomplex used for fitting perturbed free induction decay as described in Hamm 1995: https://doi.org/10.1016/0301-0104(95)00262-6

Co-authored-by: Sebastian Weigand <s.weigand.phy@gmail.com>
Co-authored-by: Jörn Weißenborn <Joern.weissenborn@gmail.com>
Co-authored-by: Ivo van Stokkum <ism200@users.noreply.github.com>

✨ Refactor return argument calculate_pfid_matrix_gaussian_irf

Keep the (online) linters happy

✨ Refactor frequency conversion in PFIDMegacomplex

Postpone the frequency conversion

✨ Refactor: Update PFID megacomplex matrix initialization

The code changes in this commit refactor the initialization of the `matrix` variable in the `PFIDMegacomplex` class. Instead of setting all elements to 1, it is now initialized with all elements set to 0. Additionally, an exception is raised if the `irf` parameter is None, indicating that an IRF (Impulse Response Function) is required for PFID megacomplex calculations.

Note: The removed function `calculate_pfid_matrix_no_irf()` was not used and has been commented out.

Guard against zero standard errors for fixed parameters

alpha

fix for alpha

alpha moved to freq diff

introduced 2nd oscillation shifted by alpha[0]

pfid starting from Hamm (1995) but with excited state decaying with kd

small correction

kd=15

fixed 1 bug

call to calculate_decay_matrix_gaussian_irf_on_index
and added spectral_axis_inverted option
still problem with large times

with left_shifted_axis

thus avoiding overflows, and extending the right time range

kappa introduced

extra decay rate

cleaning

after trying several things, alpha is now unused

cleaning comments

removing the alpha related comments

new b computation

using left_shifted_axis_indices

intermediate stage

1st attempt to unify pfid with doas

after reintroducing the phase with pfid
Ran pre-commit

Commented out some unused code
In the current version of the case studies the kappa and gamma parameters is unused, this for simplicity we have removed it from the initial (simple) pfid implementation.

Non-relevant comments have been removed.
Working unit tests:
- OneOscillationWithIrf
- OneOscillationWithSequentialModel
jsnel added 5 commits August 23, 2024 21:39
By switching m1 and m2 we reliably introduce the ordering bug, which is then fixed by the fix for matrix provider.
It doesn't belong in virtual environment but should be coming from global.
@jsnel jsnel force-pushed the pfid_megacomplex branch from b680554 to dd657e8 Compare August 23, 2024 19:40
Copy link

Copy link
Member

@s-weigand s-weigand left a comment

Choose a reason for hiding this comment

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

LGTM now, also good we discovered that legacy bug 😄

@jsnel jsnel merged commit 8da51b9 into glotaran:main Aug 23, 2024
38 checks passed
@jsnel jsnel deleted the pfid_megacomplex branch August 23, 2024 20:14
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