Skip to content

Adding Bdot probe diagnostic and corresponding test#3055

Open
mirfan4906 wants to merge 18 commits intoPlasmaPy:mainfrom
mirfan4906:adding-bdot-probe-diagnostics
Open

Adding Bdot probe diagnostic and corresponding test#3055
mirfan4906 wants to merge 18 commits intoPlasmaPy:mainfrom
mirfan4906:adding-bdot-probe-diagnostics

Conversation

@mirfan4906
Copy link

Implementation Details

  • Function compute_bfield is located in src/plasmapy/diagnostics/magnetic_pickup_probe.py.
  • The function performs numerical integration of the voltage signal to compute the magnetic field.

Tests

  • Added a corresponding unit test in tests/diagnostics/test_magnetic_pickup_probe.py.
  • The test inputs a sinusoidal voltage signal and verifies that the computed magnetic field waveform correctly matches the expected integral (within a small numerical tolerance).

@mirfan4906 mirfan4906 requested a review from rocco8773 as a code owner July 24, 2025 22:34
@github-actions
Copy link

Thank you for submitting this pull request (PR)! ✨

Below are checks that are being run for this PR. Click on the name of a check to learn why it didn't pass. ✅ Don't worry if something broke! We break stuff all the time. 😅

PlasmaPy's contributor guide has pages on:

Tip

📚 For a documentation preview, click on docs/readthedocs.org:plasmapy below. For cryptic documentation errors, see the documentation troubleshooting guide.

Tip

🧹 Automatically fix most pre-commit.ci failures by commenting pre-commit.ci autofix below. For other failures, please see the pre-commit troubleshooting guide.

We thank you once again! 🌌

@github-actions github-actions bot added testing plasmapy.diagnostics Related to the plasmapy.diagnostics subpackage python Pull requests that update Python code labels Jul 24, 2025
@codecov
Copy link

codecov bot commented Jul 24, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.46%. Comparing base (e4bda5d) to head (b021460).
⚠️ Report is 33 commits behind head on main.

⚠️ Current head b021460 differs from pull request most recent head 08f68ee

Please upload reports for the commit 08f68ee to get more accurate results.

Files with missing lines Patch % Lines
src/plasmapy/diagnostics/magnetic_pickup_probe.py 88.88% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3055      +/-   ##
==========================================
+ Coverage   94.71%   95.46%   +0.75%     
==========================================
  Files         108      109       +1     
  Lines        9869     9887      +18     
  Branches     1501     1502       +1     
==========================================
+ Hits         9347     9439      +92     
+ Misses        325      256      -69     
+ Partials      197      192       -5     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@namurphy namurphy self-requested a review July 28, 2025 19:35
Copy link
Member

@namurphy namurphy left a comment

Choose a reason for hiding this comment

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

Thank you so much for submitting this contribution! Given how widely used bdot probes are in experiments and as space plasma diagnostics, this is going to be very beneficial for the community.

  • I provided some thoughts and suggestions below, including several minor changes.
  • Could you add yourself as an author to CITATION.cff? That will help make sure you get credit for the contribution.
  • Could you add a changelog entry at changelog/3055.feature.rst?
  • There are a few tedious things that we need to do when adding a new .py file, which can wait until later. In #3023, I started to add a section to the contributor guide that includes a checklist of what needs to be done, but I still need to finish it. 😅 Maybe this week?

Thank you once again! We really appreciate it!

Comment on lines +34 to +35
# Use a tolerance since numerical integration introduces small errors
assert u.allclose(computed_bfield, expected_field, rtol=1e-3, atol=1e-5 * u.T)
Copy link
Member

Choose a reason for hiding this comment

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

It was a good idea here to explain the relatively high value for rtol.

Comment on lines 84 to 85
if len(bdot_voltage) != len(time_array):
raise Exception("length of time and voltage arrays in not equal\n")
Copy link
Member

Choose a reason for hiding this comment

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

Good idea to check this!

The Codecov check is showing that the code in this block is not being run during any tests. Could we add another test to make sure that this exception gets raised as appropriate? It's discussed in the testing guide, and would be along the lines of:

def test_compute_bfield_error():
    time_array = ...
    bdot_voltage = ...  # has a different number of elements than time
    with pytest.raises(ValueError):
        compute_bfield(time_array, bdot_voltage, ...)

Thank you!

Copy link
Author

Choose a reason for hiding this comment

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

I’ll review the testing guide and implement the additional test you suggested. Thank you so much for the thorough and helpful feedback. It has made me much more familiar with the format and process, which hopefully will make things smoother as I move forward with Professor Schaffner. I’ve made the other code changes and will be going through the remaining instructions as well. I'll be on the lookout for any other instructions/tasks regarding submitting a new pull request!

@mirfan4906 mirfan4906 requested a review from a team as a code owner August 12, 2025 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plasmapy.diagnostics Related to the plasmapy.diagnostics subpackage python Pull requests that update Python code testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants