-
Notifications
You must be signed in to change notification settings - Fork 15
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
Implement time-dependent quaternions and save memory when computing pointings #319
Conversation
The tests are currently not passing because of the fact that |
@paganol , @giuspugl , @sgiardie , @ggalloni , @mreineck I'm implementing the
Probably the biggest problem I have is that I do not know if we really need to load Implementing any of these solutions but the first one has a number of drawbacks, and I would like to be sure that this is really worth the effort. |
I agree that the switch to the Concerning the reading: if we have indeed not really read the observations yet, I'd vote for:
|
I agree on this, and this was what we had at the begining. The reason why we moved to two different variables was to handle more efficiently the coordinate rotation. For example in
For this I would go for the first option, only "slow" quaternions. Already with the new sims saving all the pointing is kind of unfeasable. Codes should be able to deal with quaternions by themselves, or import litebird_sim for computing pointings. |
…s `DetectorInfo`.
Hi @ziotom78, everything seems ok, but I'm still getting stupid syntax issues that are not detected locally. But, a part from that, I think we are ready for merging and the a release. |
I have fixed the syntax issue and changed the github action image for macos to |
This PR is a WIP to implement the ideas in discussion #312. It contains several changes to the code base to implement the following features:
RotQuaternion
, which encodes a rotation quaternion that can vary in timeget_pointings
work with generic time-varying quaternionsObservation.get_pointings
so that it always requires the index of the detector for which pointings are requestedHWP
so that it accepts a methodapply_hwp_to_pointings
to modify the pointings (useful to simulate some families of HWP systematics)PointingProvider
that computes pointings on the flyRotMatrix
objectsObservation.get_pointings
)PointingProvider
objectstest/test_io.py
to check that quaternions and pointings are saved correctlySimulation.prepare_pointings()
into a high-level method inSimulation
and a low-level functionprepare_pointings()
prepare_pointings()
is calledObservation.get_pointings()
hwp_sys.py
to make use of time-varying quaternionsscan_map.py
dipole.py
RotQuaternion
objects that encode periodic fluctuations around the z axisThe type
RotQuaternion
encodes a time-varying quaternion that is normalized to 1, i.e., it encodes a time-dependent rotation. The rotation is saved internally in a(N, 4)
matrix, whereN
is the number of quaternions that are sampled evenly. The typeRotQuaternion
has a fieldstart_time
and a fieldsampling_rate_hz
that encode the timet0
and the number of quaternions per second encoded in the matrix; thus, the sample cover the time range fromt0
tot0 + N / sampling_rate_hz
. You can create it by passing a(N, 4)
matrix:There is one significant breaking change in the API. In the current API for
get_pointings
, the function requires a matrix of quaternions for the parameterdetector_quats
to specify the rotation to be applied to the boresight of each detector to convert its reference frame into the RF of the focal plane; this matrix has the shape(N_det, 4)
, withN_det
the number of detectors. However, now that the code supports time-varying quaternions, the shape(N, 4)
is used to encode the value of the rotation quaternion as time passes for one detector.This means that when one spots this matrix in the parameter
detector_quats
it could either be interpreted as
Two quaternions that do not vary with time and are associated to two detectors:
One time-varying quaternion sampled at two times t0 and t1 that is associated to one detector:
To prevent ambiguities, in this PR I have implemented the following breaking change to the API: now you are expected to always pass a list of
RotQuaternion
objects to the parameterdetector_quats
:I played a bit with some “smart” conversions to avoid this breaking change, but I disliked the result because it seemed to me that they looked confusing and made the code of
RotQuaternion.__init__()
quite complex.Note that
RotMatrix
has a default constructor that creates the identity rotation (constant in time), so in the simplest cases the new API is quite readable: