コード例 #1
0
 def test_cube_check(self, m_getkey):
     r = hci.HiColorCube("dummy/PSP_010502_2090_RED5.HiStitch.balance.cub")
     i = hci.HiColorCube(
         "dummy/PSP_010502_2090_IR11.HiStitch.balance.precolor.cub")
     b = hci.HiColorCube(
         "dummy/PSP_010502_2090_BG13.HiStitch.balance.precolor.cub")
     self.assertTrue(sli.cube_check(r, i, b))
     self.assertTrue(sli.cube_check(r, None, b))
     self.assertFalse(sli.cube_check(None, None, None))
     self.assertFalse(sli.cube_check(None, i, b))
     self.assertFalse(sli.cube_check(r, i, None))
コード例 #2
0
 def test_get_slither_path(self, m_getkey):
     c = hci.HiColorCube(
         "dummy/PSP_010502_2090_IR10.HiStitch.balance.precolor.cub")
     self.assertEqual(
         sli.get_slither_path(c),
         Path("dummy/PSP_010502_2090_IR10.slither.cub"),
     )
コード例 #3
0
 def test_make_dummy_IR(self, m_getkey, m_mask, m_editlab):
     r = hci.HiColorCube("dummy/PSP_010502_2090_RED4.HiStitch.balance.cub")
     b = hci.HiColorCube(
         "dummy/PSP_010502_2090_BG12.HiStitch.balance.precolor.cub")
     self.assertEqual(
         sli.make_dummy_IR(r, b),
         Path("dummy/PSP_010502_2090_IR10.slither.cub"),
     )
コード例 #4
0
 def test_process_set(self, m_getkey, m_sli, m_hicubeit, m_trim):
     r = hci.HiColorCube("dummy/PSP_010502_2090_RED5.HiStitch.balance.cub")
     i = hci.HiColorCube(
         "dummy/PSP_010502_2090_IR11.HiStitch.balance.precolor.cub")
     b = hci.HiColorCube(
         "dummy/PSP_010502_2090_BG13.HiStitch.balance.precolor.cub")
     self.assertEqual(
         sli.process_set(r, i, b, keep=True),
         Path("dummy/PSP_010502_2090_COLOR5.cub"),
     )
     _, trim_args = m_trim.call_args
     self.assertEqual(trim_args["left"], 3)
コード例 #5
0
 def test_run_slither(self, m_getkey, m_slither):
     c = hci.HiColorCube(
         "dummy/PSP_010502_2090_IR10.HiStitch.balance.precolor.cub")
     sli.run_slither(c)
     m_slither.called_once()
コード例 #6
0
def edr2stitch(images, conf_dir, bitflipwidth=0, lis_tolerance=1, keep=False):
    chids = list()
    for i in images:
        out_edr = util.path_w_suffix(".EDR_Stats.cub", i)

        # EDR_Stats
        db = EDR_Stats.EDR_Stats(i,
                                 out_edr,
                                 pvl.load(conf_dir /
                                          "EDR_Stats_gains_config.pvl"),
                                 keep=keep)

        # HiCal
        out_hical = util.path_w_suffix(".HiCal.cub", out_edr)

        db = HiCal.HiCal(
            out_edr,
            out_hical,
            db,
            HiCal.conf_setup(pvl.load(conf_dir / "HiCal.conf"),
                             pvl.load(conf_dir / "NoiseFilter.conf")),
            conf_dir / "HiCal.conf",
            None,
            None,
            bitflipwidth,
            lis_tolerance,
            keep=keep,
        )

        chids.append(ChannelCube(out_hical, db))

    # HiStitch
    # get Channel pairs
    cids = list()
    for chid1, chid2 in get_CCDpairs(chids):
        (db, o_path) = HiStitch.HiStitch(
            chid1.nextpath,
            chid2.nextpath,
            chid1.db,
            chid2.db,
            ".HiStitch.cub",
            pvl.load(conf_dir / "HiStitch.conf"),
            keep=keep,
        )
        cid = HiccdStitch.HiccdStitchCube(o_path)
        cid.gather_from_db(db)
        cids.append(cid)

    # HiccdStitch, makes balance cubes
    # need to separate by color:
    color_groups = get_color_groups(cids)
    for color_group in color_groups.values():
        db, out_stitch = HiccdStitch.HiccdStitch(
            color_group,
            ".HiccdStitch.cub",
            pvl.load(conf_dir / "HiccdStitch.conf"),
            sline=None,
            eline=None,
            keep=keep,
        )
    # HiColorInit
    #   takes *balance.cub
    #   creates *[IR|BG]*.balance.precolor.cub
    #   Can then run JitPlot on these *.balance.precolor.cub
    HiColorInit.HiColorInit([c.nextpath for c in cids],
                            ".precolor.cub",
                            keep=keep)

    # HiJitReg
    #   takes tmp/*balance.cub tmp/*balance.precolor.cub
    #   creates *regdef.pvl and *flat.tab files
    for_jitreg = list()
    for color, balcubes in color_groups.items():
        if color == "RED":
            for c in balcubes:
                for_jitreg.append(c.nextpath)
        else:
            for c in balcubes:
                for_jitreg.append(c.nextpath.with_suffix(".precolor.cub"))

    HiJitReg.HiJitReg(for_jitreg,
                      pvl.load(conf_dir / "HiJitReg.conf"),
                      keep=keep)

    # HiSlither
    #   takes same as HiJitReg (and assumes its products are available.
    #   creates *slither.txt, *slither.cub, and *COLOR[4|5].cub
    #   Can then run SliterStats on the *slither.txt
    HiSlither.HiSlither(for_jitreg)

    return chids
コード例 #7
0
def edr2stitch(
    images,
    conf_dir,
    bitflipwidth=0,
    lis_tolerance=1.0,
    max_workers=None,
    keep=False,
):
    chids = list()
    edr_conf = pvl.load(conf_dir / "EDR_Stats_gains_config.pvl")
    hical_conf = HiCal.conf_setup(
        pvl.load(conf_dir / "HiCal.conf"),
        pvl.load(conf_dir / "NoiseFilter.conf"),
    )
    with concurrent.futures.ProcessPoolExecutor(
                max_workers=max_workers
    ) as executor:
        future_dbs = dict()
        for i in images:
            out_edr = util.path_w_suffix(".EDR_Stats.cub", i)
            out_hical = util.path_w_suffix(".HiCal.cub", out_edr)

            f = executor.submit(
                edr_cal,
                i,
                out_edr,
                out_hical,
                edr_conf,
                hical_conf,
                conf_dir / "HiCal.conf",
                bitflipwidth=bitflipwidth,
                lis_tolerance=lis_tolerance,
                keep=False,
            )
            future_dbs[f] = out_hical

        for future in concurrent.futures.as_completed(future_dbs):
            out_hical = future_dbs[future]
            chids.append(ChannelCube(out_hical, future.result()))

    # HiStitch
    # get Channel pairs
    cids = list()
    stitch_conf = pvl.load(conf_dir / "HiStitch.conf")
    with concurrent.futures.ProcessPoolExecutor(
        max_workers=max_workers
    ) as executor:
        future_tuples = list()
        for chid1, chid2 in get_CCDpairs(chids):
            f = executor.submit(
                # (db, o_path) = HiStitch.HiStitch(
                HiStitch.HiStitch,
                chid1.nextpath,
                chid2.nextpath,
                chid1.db,
                chid2.db,
                ".HiStitch.cub",
                stitch_conf,
                keep=keep,
            )
            future_tuples.append(f)

        for future in concurrent.futures.as_completed(future_tuples):
            (db, o_path) = future.result()
            cid = HiccdStitch.HiccdStitchCube(o_path)
            cid.gather_from_db(db)
            cids.append(cid)

    # HiccdStitch, makes balance cubes
    # need to separate by color:
    color_groups = get_color_groups(cids)
    for color_group in color_groups.values():
        db, out_stitch = HiccdStitch.HiccdStitch(
            color_group,
            ".HiccdStitch.cub",
            pvl.load(conf_dir / "HiccdStitch.conf"),
            sline=None,
            eline=None,
            keep=keep,
        )
    # HiColorInit
    #   takes *balance.cub
    #   creates *[IR|BG]*.balance.precolor.cub
    #   Can then run JitPlot on these *.balance.precolor.cub
    HiColorInit.HiColorInit(
        [c.nextpath for c in cids], ".precolor.cub", keep=keep
    )

    # HiJitReg
    #   takes tmp/*balance.cub tmp/*balance.precolor.cub
    #   creates *regdef.pvl and *flat.tab files
    for_jitreg = list()
    for color, balcubes in color_groups.items():
        if color == "RED":
            for c in balcubes:
                for_jitreg.append(c.nextpath)
        else:
            for c in balcubes:
                for_jitreg.append(c.nextpath.with_suffix(".precolor.cub"))

    HiJitReg.HiJitReg(
        for_jitreg, pvl.load(conf_dir / "HiJitReg.conf"), keep=keep
    )

    # HiSlither
    #   takes same as HiJitReg (and assumes its products are available.
    #   creates *slither.txt, *slither.cub, and *COLOR[4|5].cub
    #   Can then run SlitherStats on the *slither.txt
    HiSlither.HiSlither(for_jitreg)

    return chids