Add HWP Jones Formalism with Band Integration#499
Conversation
assuming we will have as input the gammas for each harmonic
…tod to scan_map way
…ird/litebird_sim into add_jones_to_hwp_harmonics
…gration for jones calculus
- Change the `Calc` name into `HWPFormalism` - Move the code that loads CSV files containing Jones coefficients into a new class, `HWPJonesParams` and avoid using files explicitly (this eases the transition to IMo objects when these CSV files will be stored there) - Implement a way to load CSV files from streams and the IMo - Move the class `NonIdealHWP` in a separate file to prevent circular imports - Add typing information (partially)
ziotom78
left a comment
There was a problem hiding this comment.
Hi Miguel, I implemented the ability to load the CSV files containing Jones coefficients from the IMo. This required several changes, but now the API is much more similar to the one we use to load DetectorInfo objects and similar:
- IMo objects are associated with a dataclass (in this case,
HWPJonesParams) - A static method
.from_imo()returns the dataclass - The dataclass is passed to functions, not the file name
There is still some work to do because tests do not pass yet using ty. It should be quick to fix them.
| mueller10deg = { | ||
| "0f": np.array( | ||
| [ | ||
| [0.961, 8.83 * 1e-5, -7.87 * 1e-6], | ||
| [9.60 * 1e-5, 1.88 * 1e-4, 4.87 * 1e-4], | ||
| [4.39 * 1e-6, -4.63 * 1e-4, 7.48 * 1e-4], | ||
| ], | ||
| dtype=np.float64, | ||
| ), | ||
| "2f": np.array( | ||
| [ | ||
| [4.89 * 1e-6, 5.15 * 1e-4, 5.16 * 1e-4], | ||
| [5.43 * 1e-4, 3.10 * 1e-3, 3.28 * 1e-3], | ||
| [5.42 * 1e-4, 2.96 * 1e-3, 3.24 * 1e-3], | ||
| ], | ||
| dtype=np.float64, | ||
| ), | ||
| "4f": np.array( | ||
| [ | ||
| [1.09 * 1e-7, 9.26 * 1e-5, 9.25 * 1e-5], | ||
| [8.86 * 1e-5, 0.959, 0.959], | ||
| [8.86 * 1e-5, 0.959, 0.959], | ||
| ], | ||
| dtype=np.float64, | ||
| ), | ||
| } | ||
|
|
||
| f_factor = ( | ||
| np.sin(np.deg2rad(0.078 * Theta)) ** 2 / np.sin(np.deg2rad(0.078 * 10)) ** 2 | ||
| ) |
There was a problem hiding this comment.
These seem magic numbers… If they are the coefficients of Mueller matrices for the four frequencies 0f, 2f, and 4f, they should be read from the IMo. (The same for the magic factor 0.078.)
The LBS code is public, and we should not put data related to the instrument here.
There was a problem hiding this comment.
Hi, these are the obtained values for a hwp at Theta=10º, that we use to make the interpolation when we want to obtain the values for another Theta (according to the interpolation in https://arxiv.org/pdf/2308.00967)
However, these were done for a previous version of the HWP, where we did not have jones matrices, and for a specific frequency, so we can in fact delete them now. I doubt we'll need this interpolation with this specific values again.
| return [det_params, bpi] | ||
|
|
||
|
|
||
| def fill_tod( |
There was a problem hiding this comment.
Given that fill_tod is imported in litebird_sim/__init__.py, a more specific name would be helpful here. What do you think about fill_tod_with_hwp_harmonics?
There was a problem hiding this comment.
sure, the name is a bit long but I can't see a better option
Thanks a lot!
Ok, I will look into this so that we can merge this. |
|
@ziotom78 It is ready to merge! |
This PR should now be fully compatible with all the recent changes in the master branch. It uses the multi-frequency capabilities of HealpixMap to ease the simplification of the integration in band.
It is now possible to insert a Jones matrix, or a .csv file like the following:
Where we have a column for the frequency in GHz, then one column for each Jones element - amplitude and phase - in both 0f and 2f.
Still left to do before merging: