Esempio n. 1
0
def EDR_Stats(
    img: os.PathLike,
    out_path: os.PathLike,
    gainsinfo: dict,
    histmin=0.01,
    histmax=99.99,
    keep=False,
) -> dict:
    logger.info(f"EDR_Stats start: {img}")
    try:
        logger.info("The LUT for this file is: " + str(check_lut(img)))
    except KeyError as err:
        logger.error("The LUT header area is either corrupted or has a gap.")
        raise err

    # Convert to .cub
    isis.hi2isis(img, to=out_path)

    histat_complete = isis.histat(
        out_path,
        useoffsets=True,
        leftimage=0,
        rightimage=1,
        leftcalbuffer=3,
        rightcalbuffer=1,
        leftcaldark=3,
        rightcaldark=1,
        leftbuffer=3,
        rightbuffer=1,
        leftdark=3,
        rightdark=1,
    )
    histats = parse_histat(histat_complete.stdout)

    # Get some info from the new cube:
    histats["PRODUCT_ID"] = isis.getkey_k(out_path, "Archive", "ProductId")
    histats["IMAGE_LINES"] = int(
        isis.getkey_k(out_path, "Dimensions", "Lines")
    )
    histats["LINE_SAMPLES"] = int(
        isis.getkey_k(out_path, "Dimensions", "Samples")
    )
    histats["BINNING"] = int(isis.getkey_k(out_path, "Instrument", "Summing"))

    histats["STD_DN_LEVELS"] = get_dncnt(out_path, histmin, histmax, keep=keep)
    histats["IMAGE_SIGNAL_TO_NOISE_RATIO"] = calc_snr(
        out_path, gainsinfo, histats
    )
    histats["GAP_PIXELS_PERCENT"] = (
        histats["GAP_PIXELS"]
        / (int(histats["IMAGE_LINES"]) * int(histats["LINE_SAMPLES"]))
    ) * 100.0

    tdi_bin_check(out_path, histats)
    lut_check(out_path, histats)

    logger.info(f"EDR_Stats done: {out_path}")
    return histats
Esempio n. 2
0
 def test_lut_check(self):
     histats = edr.parse_histat(isis.histat(self.hicube).stdout)
     self.assertIsNone(edr.lut_check(self.hicube, histats))
Esempio n. 3
0
 def test_parse_histat(self):
     h = edr.parse_histat(isis.histat(self.hicube).stdout)
     self.assertIsInstance(h, dict)
Esempio n. 4
0
 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)
Esempio n. 5
0
 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))