Пример #1
0
def PyDfMuxBolometerPropertiesInjector(frame, pydfmux_hwm=None, angle_per_mm = 4.186*core.G3Units.deg/1000):
    '''
    Insert a calibration frame following any wiring frame containing a
    BolometerPropertiesMap named "NominalBolometerProperties" that has
    the properties of each bolometer as defined by the given pydfmux 
    hardware map.
    '''

    if frame.type != core.G3FrameType.Wiring:
        return

    from spt3g import calibration
    from pydfmux.core import dfmux as pydfmux

    cal = core.G3Frame(core.G3FrameType.Calibration)
    bpm = calibration.BolometerPropertiesMap()

    for bolo in pydfmux_hwm.query(pydfmux.Bolometer):
        bp = calibration.BolometerProperties()
        if hasattr(bolo, 'physical_name'):
            bp.physical_name = str(bolo.wafer.name) + '_' + str(bolo.physical_name)
        if hasattr(bolo, 'x_mm') and bolo.x_mm is not None:
            bp.x_offset = bolo.x_mm * angle_per_mm
        if hasattr(bolo, 'y_mm') and bolo.y_mm is not None:
            bp.y_offset = bolo.y_mm * angle_per_mm
        if bolo.wafer is not None:
            bp.wafer_id = str(bolo.wafer.name)
        if hasattr(bolo, 'pixel') and bolo.pixel is not None:
            bp.pixel_id = str(bolo.pixel)
        if hasattr(bolo, 'pixel_type') and bolo.pixel_type is not None:
            bp.pixel_type = str(bolo.pixel_type)
        if hasattr(bolo, 'observing_band') and bolo.observing_band is not None:
            bp.band = float(bolo.observing_band)*core.G3Units.GHz
        if hasattr(bolo, 'polarization_angle') and bolo.polarization_angle is not None:
            bp.pol_angle = float(bolo.polarization_angle)*core.G3Units.deg
            bp.pol_efficiency = 1.0
        if hasattr(bolo, 'coupling') and bolo.coupling is not None:
            if bolo.coupling == "optical":
                bp.coupling = calibration.BolometerCouplingType.Optical
            elif bolo.coupling == "dark_tres":
                bp.coupling = calibration.BolometerCouplingType.DarkTermination
            elif bolo.coupling == "dark_xover":
                bp.coupling = calibration.BolometerCouplingType.DarkCrossover
            elif bolo.coupling == "resistor":
                bp.coupling = calibration.BolometerCouplingType.Resistor
            else:
                raise ValueError("Unrecognized coupling type %s" % bolo.coupling)

        bpm[str(bolo.name)] = bp

    cal['NominalBolometerProperties'] = bpm
    from pydfmux import current_transferfunction
    cal['DfMuxTransferFunction'] = current_transferfunction

    return [frame, cal]
Пример #2
0
def PyDfMuxBolometerPropertiesInjector(frame,
                                       pydfmux_hwm=None,
                                       angle_per_mm=4.186 * core.G3Units.deg /
                                       1000):
    '''
    Insert a calibration frame following any wiring frame containing a
    BolometerPropertiesMap named "NominalBolometerProperties" that has
    the properties of each bolometer as defined by the given pydfmux 
    hardware map.
    '''

    if frame.type != core.G3FrameType.Wiring:
        return

    from spt3g import calibration
    from pydfmux.core import dfmux as pydfmux

    cal = core.G3Frame(core.G3FrameType.Calibration)
    bpm = calibration.BolometerPropertiesMap()

    for bolo in pydfmux_hwm.query(pydfmux.Bolometer):
        bp = calibration.BolometerProperties()
        if hasattr(bolo, 'physical_name'):
            bp.physical_name = str(bolo.wafer.name) + '_' + str(
                bolo.physical_name)
        if hasattr(bolo, 'x_mm') and bolo.x_mm is not None:
            bp.x_offset = bolo.x_mm * angle_per_mm
        if hasattr(bolo, 'y_mm') and bolo.y_mm is not None:
            bp.y_offset = bolo.y_mm * angle_per_mm
        if bolo.wafer is not None:
            bp.wafer_id = str(bolo.wafer.name)
        if hasattr(bolo, 'pixel') and bolo.pixel is not None:
            bp.pixel_id = str(bolo.pixel)
        if hasattr(bolo, 'observing_band') and bolo.observing_band is not None:
            bp.band = float(bolo.observing_band) * core.G3Units.GHz
        if hasattr(
                bolo,
                'polarization_angle') and bolo.polarization_angle is not None:
            bp.pol_angle = float(bolo.polarization_angle) * core.G3Units.deg
            bp.pol_efficiency = 1.0

        bpm[str(bolo.name)] = bp

    cal['NominalBolometerProperties'] = bpm

    return [frame, cal]
Пример #3
0
    def send_off(self, frame):
        if not self.wiring_map is None and self.bolo_props is None:

            #faking the frame data
            self.bolo_props = calibration.BolometerPropertiesMap()

            n_chans = 0
            squids = {}
            for k in self.wiring_map.keys():
                wm = self.wiring_map[k]
                c = wm.channel + 1

                if c > n_chans:
                    n_chans = c
                sq = get_physical_id(wm.board_serial, 
                                         wm.crate_serial, 
                                         wm.board_slot,
                                         wm.module + 1)
                squids[sq] = 1
            n_squids = len(squids.keys())

            sq_layout = make_square_block(n_squids)
            ch_layout = make_square_block(n_chans)

            sq_x_sep = ch_layout[0] + 1
            sq_y_sep = ch_layout[1] + 1
            ch_x_sep = 1
            ch_y_sep = 1

            for i, sq in enumerate( sorted(squids.keys()) ):
                x = i % sq_layout[0]
                y = i // sq_layout[0]
                squids[sq] = (1.2 * x * ch_layout[0], 1.2* y * ch_layout[1])

            #need nsquids
            #need nbolos per squid
            for k in self.wiring_map.keys():
                wm = self.wiring_map[k]
                sq_id = get_physical_id(wm.board_serial, 
                                            wm.crate_serial, 
                                            wm.board_slot,
                                            wm.module + 1)

                w_id = get_physical_id(wm.board_serial, 
                                           wm.crate_serial, 
                                           wm.board_slot)

                sql = squids[sq_id]
                x = sql[0] + ((wm.channel) % ch_layout[0]) * ch_x_sep
                y = sql[1] + ((wm.channel) // ch_layout[0]) * ch_y_sep

                bp = calibration.BolometerProperties()
                bp.physical_name = k
                bp.band = 0
                bp.pol_angle = 0
                bp.pol_efficiency = 0
                bp.wafer_id = w_id
                bp.squid_id = sq_id
                bp.x_offset = float(x) 
                bp.y_offset = float(y) 
                self.bolo_props[k] = bp

            out_frame = core.G3Frame(core.G3FrameType.Calibration)
            out_frame['BolometerProperties'] = self.bolo_props
            out_frame['DfMuxTransferFunction'] = self.default_tf
            return [out_frame, frame]
        else:
            return frame
    'new': '34300000_new.g3'
}]

fname_nominal_boloprops = '/home/adama/SPT/hardware_maps_southpole/2018/hwm_pole_run2_include_darks_v2/nominal_online_cal.g3'
nominal_boloprops = list(core.G3File(fname_nominal_boloprops))[0]

for fnames_dict in bp_filenames:
    fname_old_boloprops = fnames_dict['old']
    old_bp = list(core.G3File(fname_old_boloprops))[0]
    old_boloprops = copy.deepcopy(old_bp)

    newframe = core.G3Frame(core.G3FrameType.Calibration)
    for field in old_boloprops:
        if field != 'BolometerProperties':
            newframe[field] = old_boloprops[field]
    newframe['BolometerProperties'] = calibration.BolometerPropertiesMap()

    print(len(old_boloprops['BolometerProperties']))

    for bolo in old_boloprops['BolometerProperties'].keys():
        if '/' in bolo:
            newbolo = bolo.split('/')[1]
        else:
            newbolo = bolo

        if newbolo in nominal_boloprops['NominalBolometerProperties'].keys():
            newframe['BolometerProperties'][bolo] = old_boloprops[
                'BolometerProperties'][bolo]
            newframe['BolometerProperties'][
                bolo].pol_angle = nominal_boloprops[
                    'NominalBolometerProperties'][newbolo].pol_angle
Пример #5
0
#!/usr/bin/env python
from spt3g import core, calibration

# Test that parts of BolometerPropertiesMap are appropriately settable

a = calibration.BolometerProperties()
a.pol_angle = 3
a.pol_angle += 3
assert (a.pol_angle == 6)
b = calibration.BolometerPropertiesMap()
b['test'] = a
assert (b['test'].pol_angle == 6)
b['test'].pol_angle += 6
print(b['test'].pol_angle)
assert (b['test'].pol_angle == 12)