Skip to content

Changed local median signal calculation to global median#1630

Open
ttsan2521 wants to merge 1 commit into
simonsobs:masterfrom
ttsan2521:debug_offset_fix
Open

Changed local median signal calculation to global median#1630
ttsan2521 wants to merge 1 commit into
simonsobs:masterfrom
ttsan2521:debug_offset_fix

Conversation

@ttsan2521
Copy link
Copy Markdown

In sim_mumux_crosstalk.py, changed the local median signal calculation when evaluating dPhi0/dT to a global median calculation. In the original script, it calculates the median of the input signal after an MPI distribution, which put all the detectors into bins or ranks where each rank has a subset of the sample. So all the detectors inside a rank only see a portion of the scan, and the calculated median within each rank may differ from rank to rank, which can cause a scan-like pattern as the crosstalk operator is implemented. A way to go about this is to take the median before the distribution or a global median.

@ttsan2521 ttsan2521 requested review from keskitalo and tpsatt May 8, 2026 00:42
from toast.timing import function_timer, Timer
from toast.traits import Bool, Int, Unicode, trait_docs
from toast.utils import Environment, Logger, unit_conversion
from toast.mpi import MPI #added this import- Tran
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can leave out the comment here. If we need to figure out who added which line, there is always git blame.

## Calculate a global median
local_good = signal[row][good]
if obs.comm.comm_group is not None:
all_good = obs.comm.comm_group.gather(local_good, root=0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This gets the job done but can be slow if there are lots of detectors and processes. It would be more expedient to compute and store the medians in the beginning of exec() before the data are redistributed.

Since I am not running this operator myself, I leave it up to Tran and Toby to decide if they want to develop the more efficient computation.

# Propagate flags
obs.detdata[self.det_flags][det] |= temp_obs.detdata[self.det_flags][det]


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like an extra line change.

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