Example #1
0
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
 def BolometerPropertiesInjector(frame):
     if frame.type == core.G3FrameType.Wiring:
         nchan = len(frame['WiringMap'].keys())
         core.log_notice("Collecting data from %d mapped channels." % (nchan),
                         unit='Data Acquisition')
         bpm = os.path.join(os.path.dirname(args.hardware_map), 'nominal_online_cal.g3')
         try:
             if not os.path.exists(bpm):
                 raise IOError('Missing file %s' % bpm)
             fr = list(core.G3File(bpm))[0]
             return [frame, fr]
         except Exception as e:
             core.log_warn('Error loading BolometerPropertiesMap: %s' % (str(e)),
                           unit='Data Acquisition')
Example #3
0
    def trim_wiring_map(fr):
        if fr.type != core.G3FrameType.Wiring:
            return

        fr['OriginalWiringMap'] = fr['WiringMap']
        del fr['WiringMap']
        keys_to_keep = set()
        for item in args.pathstring:
            keys_to_keep |= set(
                fnmatch.filter(fr['OriginalWiringMap'].keys(), item))
        new_wiring = dfmux.DfMuxWiringMap()
        for k in keys_to_keep:
            new_wiring[k] = fr['OriginalWiringMap'][k]
        fr['WiringMap'] = new_wiring
        core.log_notice('Taking data from %d/%d detectors' %
                        (len(keys_to_keep), len(fr['OriginalWiringMap'])),
                        unit='TeeLedgerman')
Example #4
0
 def CheckWiring(frame):
     if frame.type == core.G3FrameType.Wiring:
         nchan = len(frame['WiringMap'].keys())
         core.log_notice("Collecting data from %d mapped channels." %
                         (nchan),
                         unit='Data Acquisition')
Example #5
0
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')
Example #6
0
    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

else:
    # Otherwise assume the input is a list of board serials
    core.log_notice('Acquiring hardware map information from boards',
                    unit='Data Acquisition')
    hwm = None
    boards = ['%04d' % (int(b)) for b in args.boards]

core.log_notice('Beginning data acquisition', unit='Data Acquisition')
# Set up DfMux consumer
Example #7
0
                    help='Only record channels that match channel path string,'
                    ' e.g. 005/5/2/3/* saves data for all bolometers on crate'
                    ' 005, slot 5, mezzanine 2, module 3.')
parser.add_argument('-b',
                    dest='state',
                    action='store',
                    default=[],
                    nargs='+',
                    help='Only record bolometers that have a state that'
                    ' matches the supplied string(s), e.g. overbiased tuned')
args = parser.parse_args()

# Import pydfmux later since it can take a while
import pydfmux

core.log_notice('Initializing hardware map and boards', unit='Ledgerman')
hwm = pydfmux.load_session(open(args.hardware_map, 'r'))['hardware_map']
if hwm.query(pydfmux.IceCrate).count() > 0:
    hwm.query(pydfmux.IceCrate).resolve()

# make sure that the hardware map is consistent with what's on the IceBoards
if args.state:
    hwm.query(pydfmux.Bolometer).load_bolo_states()

if args.align:
    core.log_notice(
        'Aligning board sampling, this will break any existing DAN loops!',
        unit='Ledgerman')
    hwm.query(pydfmux.IceBoard).set_fir_stage(6)
    hwm.query(pydfmux.IceBoard).align_sampling()
Example #8
0
                    'mezzanine 2, module 3. When used with a remote hardware '
                    'map, applied as a glob to the stored bolometer names.')
parser.add_argument('-b',
                    dest='state',
                    action='store',
                    default=[],
                    nargs='+',
                    help='Only record bolometers that have a state that'
                    ' matches the supplied string(s), e.g. overbiased tuned')
args = parser.parse_args()

if args.hardware_map is not None:
    # Import pydfmux later since it can take a while
    import pydfmux

    core.log_notice('Initializing hardware map and boards',
                    unit='TeeLedgerman')
    hwm = pydfmux.load_session(open(args.hardware_map, 'r'))['hardware_map']
    if hwm.query(pydfmux.IceCrate).count() > 0:
        hwm.query(pydfmux.IceCrate).resolve()

    # Retrieve pydfmux state
    # Make sure the hardware map is consistent with what's on the IceBoards
    if args.state:
        hwm.query(pydfmux.Bolometer).load_bolo_states()

core.log_notice('Beginning data acquisition', unit='TeeLedgerman')

# Set up DfMux consumer
pipe = core.G3Pipeline()
pipe.Add(core.G3Reader, filename='tcp://' + args.server + ':' + str(args.port))