def yellanddrop(fr): global n_badpkts global n_goodpkts global logtweaked if fr.type != core.G3FrameType.Timepoint: return if len(fr['DfMux']) < nboards - 2: if n_badpkts > 0 and n_badpkts % 100 == 0: core.log_error( 'Only %d/%d boards (%s) responding for %d samples -- check for sample misalignment. Temporarily suppressing DfMuxBuilder logging and disabling data archiving.' % (len(fr['DfMux']), nboards, ', '.join( [str(k) for k in fr['DfMux'].keys()]), n_badpkts), unit='Data Acquisition') # Turn up the threshold on DfMuxBuilder to prevent flooding the console core.set_log_level(core.G3LogLevel.LOG_ERROR, 'DfMuxBuilder') logtweaked = True n_badpkts += 1 n_goodpkts = 0 return [] else: n_goodpkts += 1 if n_goodpkts > 5 and logtweaked: # Turn the threshold back down core.set_log_level(core.G3LogLevel.LOG_NOTICE, 'DfMuxBuilder') core.log_notice( 'Gross board misalignment resolved. Re-enabling DfMuxBuilder logging and data archiving.', unit='Data Acquisition') logtweaked = False n_badpkts = 0
band=str(int(band))+'GHz' bands.append(band) bad_wafers = [] for wafer in args.wafers_to_exclude: if wafer not in [None, '']: bad_wafers.append(wafer.capitalize()) good_wafers = [] for wafer in args.wafers_to_include: if wafer not in [None, '']: good_wafers.append(wafer.capitalize()) # Suppress warnings about timestream missing from scan frame if args.split_left_right: core.set_log_level(core.G3LogLevel.LOG_ERROR, 'MapBinner') # ----------------------------------------------------------------------------- # Generate map stubs for use later in pipeline. # ----------------------------------------------------------------------------- map_params = maps.FlatSkyMap( x_len = x_len, y_len = y_len, res = res, proj = proj, alpha_center = ra, delta_center = dec, pol_type = maps.MapPolType.T, coord_ref = maps.MapCoordReference.Equatorial) # Set up an empty map for point source filtering if args.mask_point_sources and args.point_source_file not in [None, '']: ps_params = maps.FlatSkyMap( x_len = x_len, y_len = y_len, res = res, proj = proj, alpha_center = ra, delta_center = dec,
action='store_false', help='Include this flag to make T-only maps') parser.add_argument('--simstub', default=False, action='store_true', help='Include this flag to produce a simstub') args = parser.parse_args() args.res *= core.G3Units.arcmin args.xlen *= core.G3Units.deg args.ylen *= core.G3Units.deg x_len = int(args.xlen / args.res) y_len = int(args.ylen / args.res) # Suppress all warnings about timestream missing from scan frame core.set_log_level(core.G3LogLevel.LOG_ERROR, 'MapBinner') def SimStub(fr, ts_key, valid_ids_key='valid_ids', flag_key='Flags', weight_key='TodWeights'): to_keep = [ valid_ids_key, flag_key, weight_key, 'DfMuxHousekeeping', 'RawBoresightAz', 'RawBoresightEl', 'OnlineBoresightAz', 'OnlineBoresightEl', 'OnlineBoresightRa', 'OnlineBoresightDec', 'OnlineRaDecRotation', 'OnlinePointingModel' ]
def WaitForWiring(frame): if frame.type == core.G3FrameType.Wiring: core.set_log_level(core.G3LogLevel.LOG_NOTICE, 'DfMuxBuilder') core.set_log_level(core.G3LogLevel.LOG_NOTICE, 'DfMuxCollector') core.log_notice('Got a wiring frame, ready for data acquisition.', unit='Data Acquisition')
help='Enable GCP watchdog ping') args = parser.parse_args() # Tee log messages to both log file and GCP socket console_logger = core.G3PrintfLogger() console_logger.timestamps = True # Make sure to get timestamps in the logs if args.syslog: import syslog core.G3Logger.global_logger = core.G3MultiLogger( [console_logger, core.G3SyslogLogger("dfmuxdaq: ", syslog.LOG_USER)]) else: core.G3Logger.global_logger = console_logger core.set_log_level(core.G3LogLevel.LOG_ERROR, 'DfMuxBuilder') core.set_log_level(core.G3LogLevel.LOG_ERROR, 'DfMuxCollector') args.hardware_map = os.path.realpath(args.hardware_map) if not len(args.boards): # If the input is a hardware map path, import the HWM and # extract the list of boards from it core.log_notice('Initializing hardware map and boards', unit='Data Acquisition') import pydfmux hwm = pydfmux.load_session(open(args.hardware_map, 'r'))['hardware_map'] boards = hwm.query(pydfmux.Dfmux) boards.resolve() boards = boards.serial
for k, v in b.data.items(): if len(v) != len(b.t): core.log_error( 'Field "%s" has %i samples but .t has %i samples.' % (k, len(v), len(b.t))) self.stats['concerns']['n_error'] += 1 if len(t_check) and abs(min(t_check) - t_this) > 60: core.log_warn( 'data frame timestamp (%.1f) does not correspond to ' 'data timestamp vectors (%s) .' % (t_this, t_check), unit='HKScanner') self.stats['concerns']['n_warning'] += 1 else: core.log_warn('Weird hkagg_type: %i' % f['hkagg_type'], unit='HKScanner') self.stats['concerns']['n_warning'] += 1 return [f] if __name__ == '__main__': # Run me on a G3File containing a Housekeeping stream. core.set_log_level(core.G3LogLevel.LOG_INFO) import sys for f in sys.argv[1:]: p = core.G3Pipeline() p.Add(core.G3Reader(f)) p.Add(HKScanner()) p.Run()