Пример #1
0
    def turn_on_board(self, board):
        log.info(f"Turnon of board {board}")
        turnon_proc = TurnOnOffProcedure(waittime_s=1.0, turnon=True)

        for _, pol_idx, pol_name in polarimeter_iterator(boards=board):
            turnon_proc.set_board_horn_polarimeter(new_board=board,
                                                   new_horn=pol_name,
                                                   new_pol=None)
            turnon_proc.run()

        return turnon_proc.get_command_list()
Пример #2
0
    def run(self):
        calibr = CalibrationTables()

        for cur_board in STRIP_BOARD_NAMES:
            # Append the sequence of commands to turnon this board to
            # the JSON object
            self.command_emitter.command_list += self.turn_on_board(cur_board)

            # Wait a while after having turned on the board
            self.wait(seconds=5)

        # Verification step
        wait_with_tag(conn=self.command_emitter,
                      name="PINCHOFF_VERIFICATION_1",
                      seconds=300)

        for cur_board in STRIP_BOARD_NAMES:
            # Now run the pinch-off procedure for each board
            with StripTag(conn=self.command_emitter,
                          name=f"PINCHOFF_TILE_{cur_board}"):
                for _, pol_idx, pol_name in polarimeter_iterator(
                        boards=cur_board):
                    self.conn.enable_electronics(polarimeter=pol_name,
                                                 pol_mode=5)

                    for id_value_muA in (100, 4_000, 8_000, 12_000):
                        for cur_lna in ("HA3", "HA2", "HA1", "HB3", "HB2",
                                        "HB1"):
                            # Convert the current (μA) in ADU
                            adu = calibr.physical_units_to_adu(
                                polarimeter=pol_name,
                                hk="idrain",
                                component=cur_lna,
                                value=id_value_muA,
                            )
                            self.conn.set_id(pol_name, cur_lna, value_adu=adu)

                            wait_with_tag(
                                conn=self.command_emitter,
                                name=
                                f"PINCHOFF_IDSET_{pol_name}_{cur_lna}_{id_value_muA:.0f}muA",
                                seconds=18,
                            )
Пример #3
0
    def run(self):
        turnon_proc = TurnOnOffProcedure(waittime_s=1.0, turnon=True)
        turnoff_proc = TurnOnOffProcedure(waittime_s=1.0, turnon=False)

        for cur_board, pol_idx, polname in polarimeter_iterator(args.board):
            self.conn.log(
                message=f"turning on {polname} for reference procedure 1…")
            with StripTag(conn=self.command_emitter,
                          name=f"ref1_turnon_pol{polname}"):

                turnon_proc.set_board_horn_polarimeter(
                    new_board=cur_board,
                    new_horn=polname,
                    new_pol=None,
                )
                turnon_proc.run()
                self.command_emitter.command_list += turnon_proc.get_command_list(
                )
                turnon_proc.clear_command_list()

            self.conn.log(
                message=f"{polname} is now on, start the reference procedure")
            proc_1(self, polname, cur_board, 1, wait_time_s=self.wait_time_s)

            self.conn.log(
                message=
                f"reference procedure 1 for {polname} has been completed, turning {polname} off…"
            )

            with StripTag(conn=self.command_emitter,
                          name=f"ref1_turnoff_pol{polname}"):
                # turn off polarimeter
                turnoff_proc.set_board_horn_polarimeter(
                    new_board=cur_board,
                    new_horn=polname,
                    new_pol=None,
                )
                turnoff_proc.run()
                self.command_emitter.command_list += turnoff_proc.get_command_list(
                )
                turnoff_proc.clear_command_list()
    def run(self):
        # turn on polarimeter
        turnon_proc = TurnOnOffProcedure(waittime_s=1.0, turnon=True)
        for cur_board, pol_idx, polname in polarimeter_iterator(args.board):
            with StripTag(conn=self.command_emitter,
                          name=f"ref2_turnon_pol_{polname}"):

                turnon_proc.set_board_horn_polarimeter(
                    new_board=cur_board,
                    new_horn=polname,
                    new_pol=None,
                )
                turnon_proc.run()
                self.command_emitter.command_list += turnon_proc.get_command_list(
                )
                turnon_proc.clear_command_list()

            proc_1(self, polname, cur_board, 2, wait_time_s=self.wait_time_s)

            self.conn.log(message="ref2_set phsw state to default bias")
            # set phsw modulation to default bias
            with StripTag(
                    conn=self.command_emitter,
                    name=f"ref2_set_pol{polname}_phsw_default_end",
            ):
                for h in range(4):
                    self.conn.set_phsw_status(
                        polarimeter=polname,
                        phsw_index=h,
                        status=PhswPinMode.DEFAULT_STATE,
                    )

            self.conn.set_hk_scan(boards=cur_board,
                                  allboards=False,
                                  time_ms=500)
            wait_with_tag(
                conn=self.conn,
                seconds=self.wait_time_s,
                name=f"ref2_acquisition_pol{polname}_phsw_default_end",
            )
    def run(self):
        if self.turn_on_polarimeters:
            # turn on polarimeter
            turnon_proc = TurnOnOffProcedure(waittime_s=1.0, turnon=True)
            for cur_board, pol_idx, polname in polarimeter_iterator(args.board):
                with StripTag(
                    conn=self.command_emitter, name=f"ref4_turnon_pol_{polname}"
                ):

                    turnon_proc.set_board_horn_polarimeter(
                        new_board=cur_board,
                        new_horn=polname,
                        new_pol=None,
                    )
                    turnon_proc.run()
                    self.command_emitter.command_list += turnon_proc.get_command_list()
                    turnon_proc.clear_command_list()

                proc_1(self, polname, cur_board, 4)

                self.conn.log(message="ref4_set phsw state to default bias")
                # set phsw modulation to default bias
                for h in range(4):
                    with StripTag(
                        conn=self.command_emitter,
                        name=f"ref4_set_pol{polname}_phsw_default_end",
                    ):
                        self.conn.set_phsw_status(
                            polarimeter=polname,
                            phsw_index=h,
                            status=PhswPinMode.DEFAULT_STATE,
                        )

                self.conn.set_hk_scan(boards=cur_board, allboards=False, time_ms=500)
                wait_with_tag(
                    conn=self.conn,
                    seconds=self.wait_time_s,
                    name=f"ref4_acquisition_pol{polname}_phsw_default_end",
                )

        ####################################################################################################################
        # -------------------------------------------------------------------------------------------------------------------
        # Procedura 4
        # -------------------------------------------------------------------------------------------------------------------

        # STATE 1
        for cur_board, pol_idx, polname in polarimeter_iterator(args.board):
            with StripTag(
                conn=self.command_emitter,
                name=f"ref4_set_pol{polname}_phsw_unsw0101",
            ):
                for h, s in enumerate(
                    [
                        PhswPinMode.STILL_SIGNAL,
                        PhswPinMode.STILL_NO_SIGNAL,
                        PhswPinMode.STILL_SIGNAL,
                        PhswPinMode.STILL_NO_SIGNAL,
                    ]
                ):
                    self.conn.set_phsw_status(
                        polarimeter=polname, phsw_index=h, status=s
                    )

        wait_with_tag(
            conn=self.conn,
            seconds=self.long_wait_time_s,
            name="ref4_acquisition_phsw_unsw0101",
        )

        # STATE 2
        for cur_board, pol_idx, polname in polarimeter_iterator(args.board):
            with StripTag(
                conn=self.command_emitter,
                name=f"ref4_set_pol{polname}_phsw_unsw1010",
            ):
                for h, s in enumerate(
                    [
                        PhswPinMode.STILL_NO_SIGNAL,
                        PhswPinMode.STILL_SIGNAL,
                        PhswPinMode.STILL_NO_SIGNAL,
                        PhswPinMode.STILL_SIGNAL,
                    ]
                ):
                    self.conn.set_phsw_status(
                        polarimeter=polname, phsw_index=h, status=s
                    )

        wait_with_tag(
            conn=self.conn,
            seconds=self.long_wait_time_s,
            name="ref4_acquisition_phsw_unsw1010",
        )

        # STATE 3
        for cur_board, pol_idx, polname in polarimeter_iterator(args.board):
            with StripTag(
                conn=self.command_emitter,
                name=f"ref4_set_pol{polname}_phsw_unsw1001",
            ):
                for h, s in enumerate(
                    [
                        PhswPinMode.STILL_NO_SIGNAL,
                        PhswPinMode.STILL_SIGNAL,
                        PhswPinMode.STILL_SIGNAL,
                        PhswPinMode.STILL_NO_SIGNAL,
                    ]
                ):
                    self.conn.set_phsw_status(
                        polarimeter=polname, phsw_index=h, status=s
                    )

        wait_with_tag(
            conn=self.conn,
            seconds=self.long_wait_time_s,
            name="ref4_acquisition_phsw_unsw1001",
        )

        # STATE 4
        for cur_board, pol_idx, polname in polarimeter_iterator(args.board):
            with StripTag(
                conn=self.command_emitter,
                name=f"ref4_set_pol_{polname}_phsw_unsw0110",
            ):
                for h, s in enumerate(
                    [
                        PhswPinMode.STILL_SIGNAL,
                        PhswPinMode.STILL_NO_SIGNAL,
                        PhswPinMode.STILL_NO_SIGNAL,
                        PhswPinMode.STILL_SIGNAL,
                    ]
                ):
                    self.conn.set_phsw_status(
                        polarimeter=polname, phsw_index=h, status=s
                    )

        wait_with_tag(
            conn=self.conn,
            seconds=self.long_wait_time_s,
            name="ref4_acquisition_phsw_unsw0110",
        )
Пример #6
0
def main():
    parser = ArgumentParser()

    parser.add_argument(
        "--use-mjd",
        "-m",
        default=False,
        action="store_true",
        help=
        "Print times and time intervals using MJD instead of date/time values",
    )

    parser.add_argument(
        "--homogeneous-units",
        "-u",
        default=False,
        action="store_true",
        help=
        """Use the same measurement unit for time intervals (seconds) instead of
        s (seconds), m (minutes), h (hours), and d (days).""",
    )

    parser.add_argument(
        "--polarimeter",
        "-p",
        default=[],
        type=str,
        action="append",
        help=
        """Name of the polarimeter to consider in the search. You can use the -p
        switch several times. Default: all""",
    )

    parser.add_argument(
        "--json",
        "-j",
        default=False,
        action="store_true",
        help=
        """Instead of printing tables, send a JSON document to stdout containing the
        results of the query""",
    )

    parser.add_argument("db_path", help="Path to the database of tests")

    args = parser.parse_args()

    if not args.polarimeter:
        args.polarimeter = list([x[2] for x in polarimeter_iterator()])

    db_path = Path(args.db_path)
    db = sqlite3.connect(db_path)

    curs = db.cursor()
    console = Console()

    intervals = {}
    for polarimeter in args.polarimeter:
        intervals[polarimeter] = process_one_polarimeter(
            cursor=curs,
            polarimeter=polarimeter,
        )

    if args.json:
        json.dump(intervals,
                  fp=sys.stdout,
                  cls=ExtendedJSONEncoder,
                  use_mjd=args.use_mjd)
    else:
        for polarimeter in args.polarimeter:
            print_intervals(
                polarimeter,
                intervals[polarimeter],
                console,
                use_mjd=args.use_mjd,
                homogeneous_units=args.homogeneous_units,
            )
    def run(self):
        # turn on polarimeter

        if self.turn_on_polarimeters:
            turnon_proc = TurnOnOffProcedure(waittime_s=1.0, turnon=True)
            for cur_board, pol_idx, polname in polarimeter_iterator(
                    args.board):
                with StripTag(conn=self.command_emitter,
                              name=f"ref3_turnon_pol_{polname}"):

                    turnon_proc.set_board_horn_polarimeter(
                        new_board=cur_board,
                        new_horn=polname,
                        new_pol=None,
                    )
                    turnon_proc.run()
                    self.command_emitter.command_list += turnon_proc.get_command_list(
                    )
                    turnon_proc.clear_command_list()

                proc_1(self,
                       polname,
                       cur_board,
                       3,
                       wait_time_s=self.wait_time_s)

                self.conn.log(message="ref3_set phsw state to default bias")
                # set phsw modulation to default bias
                for h in range(4):
                    with StripTag(
                            conn=self.command_emitter,
                            name=f"ref3_set_pol{polname}_phsw_default_end",
                    ):
                        self.conn.set_phsw_status(
                            polarimeter=polname,
                            phsw_index=h,
                            status=PhswPinMode.DEFAULT_STATE,
                        )

                self.conn.set_hk_scan(boards=cur_board,
                                      allboards=False,
                                      time_ms=500)
                wait_with_tag(
                    conn=self.conn,
                    seconds=self.wait_time_s,
                    name=f"ref3_acquisition_pol{polname}_phsw_default_end",
                )

        ####################################################################################################################
        # -------------------------------------------------------------------------------------------------------------------
        # Procedura 3
        # -------------------------------------------------------------------------------------------------------------------

        # RUN 1
        for cur_board, pol_idx, polname in polarimeter_iterator(args.board):

            for h in range(4):
                with StripTag(
                        conn=self.command_emitter,
                        name=f"ref3_set_pol_{polname}_phsw_{h}_default",
                ):
                    self.conn.set_phsw_status(
                        polarimeter=polname,
                        phsw_index=h,
                        status=PhswPinMode.DEFAULT_STATE,
                    )

        wait_with_tag(
            conn=self.conn,
            seconds=self.long_wait_time_s,
            name="ref3_acquisition_phsw_default",
        )

        # RUN 2
        for cur_board, pol_idx, polname in polarimeter_iterator(args.board):

            with StripTag(
                    conn=self.command_emitter,
                    name=f"ref3_set_pol{polname}_phsw_{h}_default_inv",
            ):
                for h, s in enumerate([
                        PhswPinMode.SLOW_SWITCHING_FORWARD,
                        PhswPinMode.SLOW_SWITCHING_REVERSE,
                        PhswPinMode.FAST_SWITCHING_FORWARD,
                        PhswPinMode.FAST_SWITCHING_REVERSE,
                ]):
                    self.conn.set_phsw_status(polarimeter=polname,
                                              phsw_index=h,
                                              status=s)

        wait_with_tag(
            conn=self.conn,
            seconds=self.long_wait_time_s,
            name="ref3_acquisition_phsw_default_inv",
        )
Пример #8
0
def test_iterate_polarimeters():
    pol_list = [
        x
        for x in polarimeter_iterator(
            boards="I", include_q_band=True, include_w_band=True
        )
    ]

    assert len(pol_list) == 7
    assert pol_list[0] == ("I", 0, "I0")
    assert pol_list[1] == ("I", 1, "I1")
    assert pol_list[2] == ("I", 2, "I2")
    assert pol_list[3] == ("I", 3, "I3")
    assert pol_list[4] == ("I", 4, "I4")
    assert pol_list[5] == ("I", 5, "I5")
    assert pol_list[6] == ("I", 6, "I6")

    pol_list = [
        x
        for x in polarimeter_iterator(
            boards="V", include_q_band=True, include_w_band=False
        )
    ]

    assert len(pol_list) == 7
    assert pol_list[0] == ("V", 0, "V0")
    assert pol_list[1] == ("V", 1, "V1")
    assert pol_list[2] == ("V", 2, "V2")
    assert pol_list[3] == ("V", 3, "V3")
    assert pol_list[4] == ("V", 4, "V4")
    assert pol_list[5] == ("V", 5, "V5")
    assert pol_list[6] == ("V", 6, "V6")

    pol_list = [
        x
        for x in polarimeter_iterator(
            boards="V", include_q_band=True, include_w_band=True
        )
    ]

    assert len(pol_list) == 8
    assert pol_list[0] == ("V", 0, "V0")
    assert pol_list[1] == ("V", 1, "V1")
    assert pol_list[2] == ("V", 2, "V2")
    assert pol_list[3] == ("V", 3, "V3")
    assert pol_list[4] == ("V", 4, "V4")
    assert pol_list[5] == ("V", 5, "V5")
    assert pol_list[6] == ("V", 6, "V6")
    assert pol_list[7] == ("V", 7, "W4")

    pol_list = [
        x
        for x in polarimeter_iterator(
            boards="V", include_q_band=False, include_w_band=True
        )
    ]

    assert len(pol_list) == 1
    assert pol_list[0] == ("V", 7, "W4")

    pol_list = [
        x for x in polarimeter_iterator(include_q_band=True, include_w_band=False)
    ]
    assert len(pol_list) == 49

    pol_list = [
        x for x in polarimeter_iterator(include_q_band=True, include_w_band=True)
    ]
    assert len(pol_list) == 55

    pol_list = [
        x for x in polarimeter_iterator(include_q_band=False, include_w_band=False)
    ]
    assert len(pol_list) == 0

    pol_list = [
        x for x in polarimeter_iterator(include_q_band=False, include_w_band=True)
    ]
    assert len(pol_list) == 6
Пример #9
0
    def run_proc2(self):
        calibr = CalibrationTables()

        if self.turn_on:
            turnon_proc = TurnOnOffProcedure(
                waittime_s=1.0,
                turnon=True,
                bias_file_name=self.bias_file_name,
            )
            with StripTag(conn=self.command_emitter,
                          name="phsw_proc2_turnon_pol"):
                for cur_board, pol_idx, pol_name in polarimeter_iterator(
                        args.board):

                    # turnon pol
                    turnon_proc.set_board_horn_polarimeter(
                        new_board=cur_board,
                        new_horn=pol_name,
                        new_pol=None,
                    )
                    turnon_proc.run()
                    self.command_emitter.command_list += turnon_proc.get_command_list(
                    )
                    turnon_proc.clear_command_list()

                self.conn.wait(seconds=self.pre_acquisition_time_s)

        for cur_board, pol_idx, pol_name in polarimeter_iterator(args.board):
            self._stable_acquisition(pol_name, "1111", proc_number=2)

            wait_with_tag(
                conn=self.command_emitter,
                seconds=self.pre_acquisition_time_s,
                name=f"acquisition_unsw0101_pol{pol_name}",
            )

            # curves
            test_num, unit_test_data = load_unit_level_test(
                self.pol_unittest_associations,
                pol_name,
                no_unit_level_tests=self.no_unit_level_tests,
                cryo=self.cryo,
            )

            if self.no_unit_level_tests:
                self.conn.log(
                    f"The ph/sw test #2 for polarimeter {pol_name} is *not* based on unit-level tests"
                )
            else:
                assert unit_test_data is not None

                self.conn.log(
                    f"The ph/sw test #2 for polarimeter {pol_name} is based on unit test #{test_num}"
                )

            if self.reverse_test:
                self._reverse(calibr,
                              cur_board,
                              pol_name,
                              unit_test_data,
                              proc_number=2)

            if self.forward_test:
                self._forward(calibr,
                              cur_board,
                              pol_name,
                              unit_test_data,
                              proc_number=2)

            self._restore_phsw_state(pol_name, proc_number=1)