From 1da8eaa3ef57c4b46216a2b36357ec9ca494000e Mon Sep 17 00:00:00 2001 From: Reijo Keskitalo Date: Thu, 10 Dec 2020 08:34:28 -0800 Subject: [PATCH] add TOAST MapMaker and FilterBin support to toast_so_sim.py --- pipelines/toast_so_sim.py | 119 +++++++++++++----- sotodlib/toast/pipeline_tools/crosslinking.py | 1 + sotodlib/toast/pipeline_tools/hardware.py | 3 +- 3 files changed, 92 insertions(+), 31 deletions(-) diff --git a/pipelines/toast_so_sim.py b/pipelines/toast_so_sim.py index 409a798db..96bb44f7f 100755 --- a/pipelines/toast_so_sim.py +++ b/pipelines/toast_so_sim.py @@ -77,6 +77,8 @@ def parse_arguments(comm): toast_tools.add_noise_args(parser) toast_tools.add_gainscrambler_args(parser) toast_tools.add_madam_args(parser) + toast_tools.add_mapmaker_args(parser) + toast_tools.add_filterbin_args(parser) toast_tools.add_sky_map_args(parser) toast_tools.add_sss_args(parser) toast_tools.add_tidas_args(parser) @@ -104,6 +106,22 @@ def parse_arguments(comm): "--outdir", required=False, default="out", help="Output directory" ) + parser.add_argument( + "--madam", + required=False, + action="store_true", + help="Use libmadam for map-making", + dest="use_madam", + ) + parser.add_argument( + "--no-madam", + required=False, + action="store_false", + help="Do not use libmadam for map-making [default]", + dest="use_madam", + ) + parser.set_defaults(use_madam=True) + try: args = parser.parse_args() except SystemExit as e: @@ -165,9 +183,9 @@ def main(): args, comm = parse_arguments(comm) - # Initialize madam parameters - - madampars = toast_tools.setup_madam(args) + if args.use_madam: + # Initialize madam parameters + madampars = toast_tools.setup_madam(args) if args.import_dir is not None: schedules = None @@ -320,20 +338,47 @@ def main(): # Bin and destripe maps - toast_tools.apply_madam( - args, - comm, - data, - madampars, - outpath, - detweights, - totalname, - time_comms=time_comms, - telescope_data=telescope_data, - first_call=(mc == firstmc), - ) + if args.use_madam: + toast_tools.apply_madam( + args, + comm, + data, + madampars, + outpath, + detweights, + totalname, + time_comms=time_comms, + telescope_data=telescope_data, + first_call=(mc == firstmc), + ) + else: + toast_tools.apply_mapmaker( + args, + comm, + data, + outpath, + totalname, + time_comms=time_comms, + telescope_data=telescope_data, + first_call=(mc == firstmc), + ) - memreport("after madam", comm.comm_world) + memreport("after destriper", comm.comm_world) + + if ( + args.filterbin_ground_order is not None + or args.filterbin_poly_order is not None + ): + toast_tools.apply_filterbin( + args, + comm, + data, + outpath, + totalname, + time_comms=time_comms, + telescope_data=telescope_data, + first_call=(mc == firstmc), + ) if args.apply_polyfilter or args.apply_groundfilter or args.demodulate: @@ -357,20 +402,34 @@ def main(): # Bin maps - toast_tools.apply_madam( - args, - comm, - data, - madampars, - outpath, - detweights, - totalname, - time_comms=time_comms, - telescope_data=telescope_data, - first_call=args.demodulate, - extra_prefix="filtered", - bin_only=True, - ) + if args.use_madam: + toast_tools.apply_madam( + args, + comm, + data, + madampars, + outpath, + detweights, + totalname, + time_comms=time_comms, + telescope_data=telescope_data, + first_call=args.demodulate, + extra_prefix="filtered", + bin_only=True, + ) + else: + toast_tools.apply_mapmaker( + args, + comm, + data, + outpath, + totalname, + time_comms=time_comms, + telescope_data=telescope_data, + first_call=False, + extra_prefix="filtered", + bin_only=True, + ) memreport("after filter & bin", comm.comm_world) diff --git a/sotodlib/toast/pipeline_tools/crosslinking.py b/sotodlib/toast/pipeline_tools/crosslinking.py index a6b0df8ec..72a529abb 100644 --- a/sotodlib/toast/pipeline_tools/crosslinking.py +++ b/sotodlib/toast/pipeline_tools/crosslinking.py @@ -1,6 +1,7 @@ # Copyright (c) 2020 Simons Observatory. # Full license can be found in the top level "LICENSE" file. +import argparse import numpy as np diff --git a/sotodlib/toast/pipeline_tools/hardware.py b/sotodlib/toast/pipeline_tools/hardware.py index 6a42d7a85..480c62791 100644 --- a/sotodlib/toast/pipeline_tools/hardware.py +++ b/sotodlib/toast/pipeline_tools/hardware.py @@ -59,7 +59,8 @@ def add_hw_args(parser): "--tube_slots", required=True, help="Comma-separated list of optics tube slots: c1 (UHF), i5 (UHF), " - " i6 (MF), i1 (MF), i3 (MF), i4 (MF), o6 (LF). " + " i6 (MF), i1 (MF), i3 (MF), i4 (MF), o6 (LF)," + " ST1 (MF), ST2 (MF), ST3 (UHF), ST4 (LF)." "Length of list must equal --bands", ) return