Пример #1
0
def edr_cal(
    img: os.PathLike,
    out_edr: os.PathLike,
    out: os.PathLike,
    edr_conf: dict,
    hical_conf: dict,
    hical_conf_path: os.PathLike,
    bitflipwidth=0,
    lis_tolerance=1.0,
    keep=False,
) -> dict:
    # EDR_Stats
    db = EDR_Stats.EDR_Stats(
        img,
        out_edr,
        edr_conf,
        keep=keep,
    )

    # HiCal
    return HiCal.HiCal(
        out_edr,
        out,
        db,
        hical_conf,
        hical_conf_path,
        None,
        None,
        bitflipwidth,
        lis_tolerance,
        keep=keep,
    )
Пример #2
0
 def test_HiCal(self):
     outcube = Path("test_HiCal-out.cub")
     # ccdchan = (self.pid.get_ccd(), self.pid.channel)
     db = hc.HiCal(
         self.cube,
         outcube,
         self.db,
         self.conf,
         conf_path,
         bin2=False,
         bin4=False,
         keep=False,
     )
     print(db)
     self.assertAlmostEqual(
         db["HIGH_PASS_FILTER_CORRECTION_STANDARD_DEVIATION"],
         0.00204738,
     )
     self.assertIsNone(db["DESTRIPED_DIFFERENCE_STANDARD_DEVIATION"])
     self.assertFalse(db["zapped"])
     self.assertEqual(db["hical_status"], "Standard")
     outcube.unlink()
Пример #3
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