Skip to content

Conversation

@chervias
Copy link
Member

This implements the sidelobe cutter from @amaurea sogma code. The mask is a simple enmap so it should be low-res and full sky to not be super slow. The coords module seems like the natural place, but I'm not completely sure, so open to suggestions.

@chervias chervias requested review from amaurea and mhasself November 18, 2025 12:18
@chervias chervias mentioned this pull request Jan 14, 2026
Copy link
Member

@mhasself mhasself left a comment

Choose a reason for hiding this comment

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

Very useful, thanks. I know this is ported from another codebase but I think it still needs to be reformatted to match style and standards of sotodlib.

pyproject.toml Outdated
"psycopg2-binary",
"lmfit",
"flacarray>=0.3.4",
"numpy-quaternion",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"numpy-quaternion",
"numpy-quaternion", # Required quietly by pixell.coordsys

from sotodlib import coords, mapmaking
import so3g

def sidelobe_cut(obs, args, sidelobe_cutters, object_list=None):
Copy link
Member

Choose a reason for hiding this comment

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

We prefer active function names, like "get_". Since this is already in coords.sidelobes, consider just calling it "get_cuts(...)".


Parameters
----------
obs : sotodlib.core.AxisManager
Copy link
Member

Choose a reason for hiding this comment

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

In sotodlib we use "aman" or "tod" as the principle AxisManager to operate on.

An observation axis manager.
args : dict
An argument dictionary, which must contains the path to the
masks in mask_sun and mask_moon. This is only used for these
Copy link
Member

Choose a reason for hiding this comment

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

sun_mask and moon_mask

An argument dictionary, which must contains the path to the
masks in mask_sun and mask_moon. This is only used for these
paths.
sidelobe_cutters : dict
Copy link
Member

Choose a reason for hiding this comment

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

Would be nicer if this argument were optional -- i.e. default value None, converted to {} on init. That doesn't mean you have to return the dict -- folks using this in a loop would treat it just as before by pre-instantiating the cache.

first run this should be empty and will be filled. Subsequent
runs will use these precalculated objects.
object_list : list, optional
A list of the objects we want to mask. If None, sun and moon
Copy link
Member

Choose a reason for hiding this comment

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

A list of strings (lower case) indicating the objects to mask.

cutss.append(cuts)
return cutss

def Simplecut(ndets, nsamps):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def Simplecut(ndets, nsamps):
def _simple_cut(ndets, nsamps):

And then change the two places it's called, too.

Comment on lines 95 to 96
def forward(tod, map, pmat):
pmat.from_map(dest=tod, signal_map=map, comps="T",)
Copy link
Member

Choose a reason for hiding this comment

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

This is called exactly once, so does it need to be a function? If you keep it, make it private (_forward).

Comment on lines 82 to 84
except RuntimeError:
# This happens when the interpolated pointing ends up outside the -npix:+2npix range
# that gpu_mm allows. This can happen when a detector moves too close to the north pole
Copy link
Member

Choose a reason for hiding this comment

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

The justification for this try / except is framed as a gpu_mm issue. It's not obvious that a RuntimeError raised by pmat would be due to the same cause, and thus require the same solution.

So please remove this try/except or characterize it specifically in terms of sotodlib pointing behaviors.

@chervias chervias requested a review from mhasself February 2, 2026 18:44
@chervias
Copy link
Member Author

chervias commented Feb 2, 2026

tested on a mapmaker run, good to go

Copy link
Member

@mhasself mhasself left a comment

Choose a reason for hiding this comment

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

Thanks, looks good!

@chervias chervias merged commit 8ecf215 into master Feb 3, 2026
5 checks passed
@chervias chervias deleted the sidelobecutter branch February 3, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants