Skip to content

Stokes parameters polarization measurement#246

Open
nmik wants to merge 33 commits intocositools:developfrom
nmik:develop
Open

Stokes parameters polarization measurement#246
nmik wants to merge 33 commits intocositools:developfrom
nmik:develop

Conversation

@nmik
Copy link
Contributor

@nmik nmik commented Oct 2, 2024

This script is the starting point to have a Stokes parameters formalism to compute the polarization from a source (with known location in the sky).

@codecov
Copy link

codecov bot commented Oct 2, 2024

Codecov Report

❌ Patch coverage is 53.57143% with 234 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.61%. Comparing base (99fdff7) to head (4659f87).
⚠️ Report is 666 commits behind head on develop.

Files with missing lines Patch % Lines
cosipy/polarization/polarization_stokes.py 53.57% 234 Missing ⚠️
Files with missing lines Coverage Δ
cosipy/polarization/polarization_stokes.py 53.57% <53.57%> (ø)

... and 37 files with indirect coverage changes

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

@nmik nmik marked this pull request as ready for review April 30, 2025 14:53
@israelmcmc
Copy link
Collaborator

Closes #209

@israelmcmc israelmcmc requested a review from eneights September 11, 2025 18:13
@israelmcmc israelmcmc added the pull-request-waiting-for-reviewer The ball is on the reviewer side. label Sep 11, 2025
@israelmcmc
Copy link
Collaborator

@eneights I think you were looking at this PR, is that correct?

@eneights
Copy link
Contributor

@israelmcmc Yes, I started looking at it and have needed to focus on other things, but it's on my to do list. Sorry for the delay!

@israelmcmc
Copy link
Collaborator

Thanks for confirming @eneights. No worries, I just wanted to make sure the assignee and status label were correct.

@israelmcmc israelmcmc added the Feature / Enhancement New functionality or improvement label Sep 15, 2025
@eneights
Copy link
Contributor

This looks good! I made some minor changes, which I'm creating a pull request for into Michela's branch once I figure out github. @nmik once that PR is merged into your branch, this PR will automatically update with those changes

For reference, this is how the results for the ASAD and Stokes methods compare:
Stokes: 81% +/- 5% at 87 +/- 2 deg with MDP = 16%
ASAD: 95% +/- 7% at 88 +/- 2 deg with MDP = 16%
Simulated: 80% at 90 deg

@eneights
Copy link
Contributor

@nmik I'm not sure what I did but I guess I pushed the changes into your branch. Can you take a look and make sure you're okay with them?

@eneights
Copy link
Contributor

The unit test was using an outdated response file. I switched it to the current polarization response in test_data, but the unit test is still failing

@JarredMRoberts JarredMRoberts self-assigned this Oct 20, 2025
@eneights
Copy link
Contributor

Hi @nmik, can you please add a way to change the ASAD bin sizes/edges? This seems to currently always default to 20 bins, but should be adjustable. The unit test is still throwing an error because there are NaNs in the ASAD, which is due to there being too many bins for the coarse unit test response. Thank you!

@nmik
Copy link
Contributor Author

nmik commented Dec 15, 2025

Hi, working on it right now. should be ready to pull in a few.
Here is the fix (it was quite easy to implement).

Changes

I now use this definition in the init method of class PolarizationStokes:
self._nbins = self._response.axes['Pol'].nbins
print('Number of azimuthal angle bins used:', self._nbins)

This variable self._nbins is now passed to

  • create_polarized_asads(), and create_unpolarized_asad() in the method 'calculate_average_mu100' (which is only used to compute the modulation factor) and simulate_unpolarized_stokes (which is not used at the moment).

Considerations

Final PD and PA predicted seems to be ok :

 PD: 84.51 +/- 5.47 %
 PA: 87.12 +/- 1.88 deg

The ASAD binning in not used to predict the Stokes-I, Stokes-U and Stokes-Q, so it doesn't change the measured values, but it does play a role in computing the modulation factor, which is used to compute the intrinsic polarization and the MDP.

Diagnostic Plots

Some diagnostic plots are attached: everything looks good.

image image Modulation PA bin 9 Modulation PA bin 10 Modulation PA bin 11 Modulation PA bin 0 Modulation PA bin 1 Modulation PA bin 2 Modulation PA bin 3 Modulation PA bin 4 Modulation PA bin 5 Modulation PA bin 6 Modulation PA bin 7 Modulation PA bin 8

@eneights
Copy link
Contributor

Thanks for making this change @nmik!

I still don't see a way for the user to specify the number of bins or bin edges, which is necessary to get the unit test to work with that extremely coarse response. There are currently empty azimuthal scattering angle bins, and it's necessary to use fewer bins in the ASAD than in the response. For example, I need to use 10 bins in my ASAD method unit test, while there are 12 in the unit test response.

A plot is still being produced automatically in the unit test, with no option to disable it. I think it comes from line 458 in polarization_stokes.py. Could you please add a show_plots flag in init() for the user to choose whether to show the plots that are generated? Maybe this can also apply for line 483.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature / Enhancement New functionality or improvement pull-request-waiting-for-reviewer The ball is on the reviewer side.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants