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, )
def setUp(self): self.cube = imgs[0].with_suffix(".TestHiCal.cub") self.pid = hirise.get_ChannelID_fromfile(self.cube) self.db = edr.EDR_Stats(imgs[0], self.cube, gains) self.binning = int(isis.getkey_k(self.cube, "Instrument", "Summing")) self.conf = conf # self.conf['HiGainFx'] = pvl.load(str(hgf_conf))['HiGainFx'] self.conf["NoiseFilter"] = nf_conf["NoiseFilter"]
def test_lut_check(self): histats = edr.parse_histat(isis.histat(self.hicube).stdout) self.assertIsNone(edr.lut_check(self.hicube, histats))
def test_calc_snr(self): histats = edr.parse_histat(isis.histat(self.hicube).stdout) histats["BINNING"] = isis.getkey_k(self.hicube, "Instrument", "Summing") s = edr.calc_snr(self.hicube, pvl.load(gains), histats) self.assertAlmostEqual(s, 291.80442197)
def test_get_dncnt(self): c = edr.get_dncnt(self.hicube) self.assertEqual(c, 80)
def test_parse_histat(self): h = edr.parse_histat(isis.histat(self.hicube).stdout) self.assertIsInstance(h, dict)
def test_EDR_stats(self): h = edr.EDR_Stats(img, self.outfile, pvl.load(gains)) self.assertIsInstance(h, dict)
def test_check(self): self.assertEqual(edr.check_lut(img), 316)
def test_tdi_bin_check(self): histats = edr.parse_histat(isis.histat(self.hicube).stdout) self.assertIsNone(edr.tdi_bin_check(self.hicube, histats)) histats["PRODUCT_ID"] = "bogus id" self.assertIsNone(edr.tdi_bin_check(self.hicube, histats))
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