Conversation
…strument-centered pointing
This change was implemented with Claude Code (Opus 5.5).
Motivation
----------
The projection engine always combines boresight and detector
quaternions as q_bore[t] * q_det[d]. Instrument-centered coordinates
(the position of a source such as the Moon or Sun relative to each
detector, on axes fixed to the telescope structure) need
q[d,t] = A[d] * X[t]
A[d] = q_to_eq * Rz(roll0) * q_det[d]^-1 * Rz(-roll0)
X[t] = Rz(roll[t]) * q_bore[t]^-1 * q_src[t]
where the per-detector factor sits on the LEFT of the per-sample one,
so it cannot be expressed in the existing q_bore * q_det form. Rather
than transposing the problem (which would give [nsamp, ndet] outputs
and require transposed signal, cuts, threads and responses), this adds
an opt-in flag that reverses the order of the product, so everything
else (all projections, tiling, bilinear interpolation, HEALPix,
threads, cuts, weights, [ndet, nsamp] layout) works unchanged.
C++ (src/Projection.cxx, include/Projection.h)
----------------------------------------------
- Pointer<CoordSys> gets a constructor Pointer(bool det_left=false)
and a private generic helper GetQdet(i_time, dofs), which reads the
boresight quaternion and returns q_ofs * q_bore if det_left is set,
q_bore * q_ofs otherwise.
- The seven GetCoords specializations that combine quaternions
(ProjQuat, ARC, SIN, TAN, ZEA, CEA, CAR) now call GetQdet instead of
each duplicating the read-and-multiply block. The decoding of the
combined quaternion into projection coordinates is unchanged.
ProjFlat is untouched.
- ProjectionEngine gets a private _det_left member (default false)
with get_det_left/set_det_left, and passes it to every Pointer it
constructs (coords, pixels, pointing_matrix, pixel_ranges, tile_hits,
tile_ranges, from_map, to_map, to_weight_map).
- EXPORT_ENGINE exposes it as the read/write Python property
"det_left" on every ProjEng class, including the HEALPix engines.
The default is False, so existing behaviour is unchanged.
Python (python/proj/)
---------------------
- Assembly has a det_left attribute:
Assembly.attach(sight, fplane, det_left=False).
- _ProjectionistBase.get_ProjEng(..., det_left=False) sets the
property on the engine instance.
- New _ProjectionistBase._get_pointing(assembly) returns
(q_bore, q_det, det_left) and is used by every projection method
(get_pixels, get_pointing_matrix, get_coords, get_planar, to_map,
to_weights, from_map, assign_threads, assign_threads_from_map,
get_active_tiles, and ProjectionistHealpix.get_coords). The
celestial-to-native rotation of the map must multiply the leftmost
factor: normally it is applied to the boresight (cached q_native as
before); with det_left it is applied to the detector quaternions.
- assign_threads(method='domdir') falls back to 'simple' for a
det_left Assembly, since the domdir algorithm assumes the normal
ordering.
Tests (test/test_proj_eng.py)
-----------------------------
- test_40_det_left_engine: raw engine output with det_left off/on
against numpy q_bore*q_ofs and q_ofs*q_bore.
- test_41_det_left_projectionist: a det_left Assembly gives the same
pixels, coords, to_map and from_map results as an equivalent normal
Assembly built per detector, on tiled and untiled TAN maps, and
with the simple/domdir thread assignments.
WARNING
-------
This is intended ONLY for projecting a temperature ("T only") mask
into sample space in order to flag samples (e.g. Moon/Sun sidelobe
cuts, see the companion sotodlib change). It must NOT be used to make
maps in instrument-centered coordinates: the polarization angle is
not meaningful in this mode (sotodlib builds the detector quaternions
with gamma = 0 and only allows comps='T'), and mapmaking in these
coordinates has not been designed or validated. That needs a future
implementation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Claude code session https://claude.ai/code/session_01TEzk2tan4q5HizPzkiqHqe |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change was implemented with Claude Code (Opus 5.5).
Motivation
The projection engine always combines boresight and detector quaternions as q_bore[t] * q_det[d]. Instrument-centered coordinates (the position of a source such as the Moon or Sun relative to each detector, on axes fixed to the telescope structure) need
where the per-detector factor sits on the LEFT of the per-sample one, so it cannot be expressed in the existing q_bore * q_det form. Rather than transposing the problem (which would give [nsamp, ndet] outputs and require transposed signal, cuts, threads and responses), this adds an opt-in flag that reverses the order of the product, so everything else (all projections, tiling, bilinear interpolation, HEALPix, threads, cuts, weights, [ndet, nsamp] layout) works unchanged.
C++ (src/Projection.cxx, include/Projection.h)
Python (python/proj/)
Tests (test/test_proj_eng.py)
WARNING
This is intended ONLY for projecting a temperature ("T only") mask into sample space in order to flag samples (e.g. Moon/Sun sidelobe cuts, see the companion sotodlib change). It must NOT be used to make maps in instrument-centered coordinates: the polarization angle is not meaningful in this mode (sotodlib builds the detector quaternions with gamma = 0 and only allows comps='T'), and mapmaking in these coordinates has not been designed or validated. That needs a future implementation.