Skip to content
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

Mss003 tuning #1080

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions sotodlib/toast/ops/mlmapmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def _wrap_obs(self, ob, dets, passinfo):
axobs.wrap("timestamps", ob.shared[self.times], axis_map=[(0, axsamps)])
axobs.wrap(
"signal",
ob.detdata[self.det_data][dets, :],
np.vstack(ob.detdata[self.det_data][dets, :]),
axis_map=[(0, axdets), (1, axsamps)],
)
axobs.wrap("boresight", axbore)
Expand Down Expand Up @@ -453,6 +453,21 @@ def _wrap_obs(self, ob, dets, passinfo):

return axobs

@function_timer
def _add_obs(self, mapmaker, axobs, nmat, name):
""" Add data to the mapmaker

Singled out for more granular timing
"""
mapmaker.add_obs(
name,
axobs,
deslope=self.deslope,
noise_model=nmat,
signal_estimate=None,
)
return

@function_timer
def _init_mapmaker(
self, mapmaker, signal_map, mapmaker_prev, x_prev, comm, gcomm, prefix,
Expand Down Expand Up @@ -655,13 +670,7 @@ def _exec(self, data, detectors=None, **kwargs):
nmat, nmat_file = self._load_noise_model(ob, npass, ipass, gcomm)

axobs = self._wrap_obs(ob, dets, passinfo)
mapmaker.add_obs(
ob.name,
axobs,
deslope=self.deslope,
noise_model=nmat,
signal_estimate=None,
)
self._add_obs(mapmaker, axobs, nmat, ob.name)
del axobs

self._save_noise_model(mapmaker, nmat, nmat_file, gcomm)
Expand Down
35 changes: 35 additions & 0 deletions sotodlib/toast/workflows/sim_observe.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ def setup_simulate_observing(parser, operators):
help="Realization index",
type=int,
)
parser.add_argument(
"--pwv_limit",
required=False,
type=float,
help="If set, discard observations with simulated PWV "
"higher than the limit [mm]",
)

operators.append(
toast.ops.SimGround(
Expand Down Expand Up @@ -230,6 +237,34 @@ def simulate_observing(job, otherargs, runargs, comm):
job_ops.mem_count.prefix = "After Scan Simulation"
job_ops.mem_count.apply(data)

if otherargs.pwv_limit is not None:
iobs = 0
ngood = 0
nbad = 0
while iobs < len(data.obs):
pwv = data.obs[iobs].telescope.site.weather.pwv.to_value(u.mm)
if pwv <= otherargs.pwv_limit:
ngood += 1
iobs += 1
else:
nbad += 1
del data.obs[iobs]
if len(data.obs) == 0:
msg = (
f"PWV limit = {otherargs.pwv_limit} mm rejected all "
f"{nbad} observations assigned to this process"
)
raise RuntimeError(msg)
if toast_comm.comm_group_rank is not None:
nbad = toast_comm.comm_group_rank.allreduce(nbad)
ngood = toast_comm.comm_group_rank.allreduce(ngood)
log.info_rank(
f" Discarded {nbad} / {ngood + nbad} observations "
f"with PWV > {otherargs.pwv_limit} mm in",
comm=comm,
timer=timer,
)

# Apply LAT co-rotation
if job_ops.corotate_lat.enabled:
log.info_rank(" Running simulated LAT corotation...", comm=comm)
Expand Down
Loading