示例#1
0
def main():
    try:
        parser = argparse.ArgumentParser(
            description=__doc__,
            formatter_class=argparse.RawDescriptionHelpFormatter,
            parents=[util.parent_parser()],
        )
        parser.add_argument(
            "-o", "--output", required=False, default=".bitunflip.cub"
        )
        parser.add_argument("cube", help="ISIS Cube file.")

        args = parser.parse_args()

        util.set_logger(args.verbose, args.logfile, args.log)

        out_p = util.path_w_suffix(args.output, args.cube)

        unflip(Path(args.cube), out_p, keep=args.keep)

    except subprocess.CalledProcessError as err:
        print("Had an ISIS error:", file=sys.stderr)
        print(" ".join(err.cmd), file=sys.stderr)
        print(err.stdout, file=sys.stderr)
        print(err.stderr, file=sys.stderr)
示例#2
0
def arg_parser():
    parser = argparse.ArgumentParser(description=__doc__,
                                     parents=[util.parent_parser()])
    parser.add_argument("-c",
                        "--color",
                        action="store_true",
                        help="Perform Color processing.")
    parser.add_argument(
        "-p",
        "--precision",
        action="store_true",
        help="Perform HiPrecision processing to result "
        "in NOPROJ.cub that might be processed through "
        "HiJACK.",
    )
    parser.add_argument(
        "-j",
        "--jack",
        action="store_true",
        help="Do not test if HiJACK is needed, but force HiJACK to run.",
    )
    parser.add_argument(
        "img",
        metavar="some.img-file",
        nargs="+",
        help="More than one can be listed here.",
    )
    parser.add_argument(
        "--conf_dir",
        required=False,
        type=Path,
        default=Path(pkg_resources.resource_filename(__name__, 'data/')),
    )
    return parser
示例#3
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__,
        parents=[util.parent_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter
    )
    parser.add_argument(
        "-o", "--output",
        required=False,
        default=".EDR_Stats.cub",
        help="Output filename.  Optionally, if it starts with a '.' it is "
             "considered a suffix and will be swapped with the input"
             "file's suffix to determine the file to write. "
             "Default: %(default)s"
    )
    parser.add_argument(
        "--db",
        required=False,
        default=".HiCat.json",
        help="The .json file to output.  Optionally, if it "
        "starts with a '.' it is considered a suffix and "
        "will be swapped with the input file's suffix to "
        "determine the file to write. Default: %(default)s",
    )
    parser.add_argument(
        "--histmin",
        required=False,
        default=0.01,
        help="The minimum percentage above which DN are counted.  This only "
             "affects the value of STD_DN_LEVELS in the output .json file. "
             "If it is lower, more DN will be counted. Default: %(default)s"
    )
    parser.add_argument(
        "--histmax",
        required=False,
        default=99.99,
        help="The minimum percentage below which DN are counted. See --histmin "
             "for more information. Default: %(default)s"
    )
    parser.add_argument(
        "-g",
        "--gains",
        required=False,
        type=argparse.FileType('r'),
        default=pkg_resources.resource_stream(
            __name__,
            'data/EDR_Stats_gains_config.pvl'
        ),
        help="Path to the gains config PVL file.  Defaults to "
             "EDR_Stats_gains_config.pvl distributed with the library.",
    )
    parser.add_argument(
        "img",
        metavar="some.img-file",
        nargs="+",
        help="More than one can be listed here.",
    )
    return parser
示例#4
0
def arg_parser():
    parser = argparse.ArgumentParser(description=__doc__,
                                     parents=[util.parent_parser()])
    parser.add_argument("-p",
                        "--plot",
                        action="store_true",
                        help="Display plots")
    parser.add_argument("slithertxts", metavar="slither.txt files", nargs="+")
    return parser
示例#5
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__,
        parents=[util.parent_parser()],
        conflict_handler="resolve",
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        "--db",
        required=False,
        default=".HiCat.json",
        help="The .json file to use.  Optionally, if it "
        "starts with a '.' it is considered an extension and "
        "will be swapped with the input file's extension to "
        "find the .json file to use. Default: %(default)s",
    )
    parser.add_argument(
        "--db2",
        required=False,
        default=".HiCat.json",
        help="The second .json file to use.  Optionally, if "
        "it starts with a '.' it is considered a suffix "
        "and will be swapped with the second input file's "
        "suffix to find the .json file to use. Default: %(default)s",
    )
    parser.add_argument(
        "--dbout",
        required=False,
        default=".HiCat.json",
        help="The name of the output .json file to write.  Optionally, if "
        "it starts with a '.' it is considered a suffix "
        "and will be added to the CCD ID of the observation of the "
        "input files. Default: %(default)s",
    )
    parser.add_argument(
        "-o",
        "--output",
        required=False,
        default=".HiStitch.cub",
        help="The name of the output .cub file to write.  Optionally, if "
        "it starts with a '.' it is considered a suffix"
        "and will be added to the CCD ID of the observation of the "
        "input files. Default: %(default)s",
    )
    parser.add_argument("-c",
                        "--conf",
                        required=False,
                        type=argparse.FileType('r'),
                        default=pkg_resources.resource_stream(
                            __name__, 'data/HiStitch.conf'),
                        help="Path to the HiStitch config file.  Defaults to "
                        "HiStitch.conf distributed with the library.")
    parser.add_argument("cube0", metavar="cube0.cub-file")
    parser.add_argument("cube1", metavar="cube1.cub-file", nargs="?")
    return parser
示例#6
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
        parents=[util.parent_parser()],
    )
    parser.add_argument("-o",
                        "--output",
                        required=False,
                        default=".lisfix.cub")
    parser.add_argument("file", help="ISIS Cube file.")
    return parser
示例#7
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__,
        parents=[util.parent_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        "cubes",
        metavar="RED balance.cub and color balance.precolor.cub files",
        nargs="+",
        help=r"Either one or both sets of RED .balance.cub  and IR/BG "
        r".balance.precolor.cub files. However, that's tedious to type,"
        r"so you could just type in *.balance*cub here, and the program "
        r"will sort out what it needs.")
    return parser
示例#8
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__,
        parents=[util.parent_parser()],
        conflict_handler="resolve",
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        "-o_irb",
        "--output_irb",
        required=False,
        default="_IRB.cub",
        help="The filename to be used for the output IRB cube.  If it "
        "begins with an underscore ('_') it will be assumed to be a "
        "suffix that will be appended to a name derived from the "
        "observation. Default: %(default)s")
    parser.add_argument(
        "-o_rgb",
        "--output_rgb",
        required=False,
        default="_RGB.cub",
        help="The filename to be used for the output RGB cube.  If it "
        "begins with an underscore ('_') it will be assumed to be a "
        "suffix that will be appended to a name derived from the "
        "observation. Default: %(default)s")
    parser.add_argument(
        "-c",
        "--conf",
        required=False,
        type=argparse.FileType('r'),
        default=pkg_resources.resource_stream(
            __name__,
            'data/HiBeautify.conf',
        ),
        help="Path to the HiBeautify config file.  Defaults to "
        "HiBeautify.conf distributed with the library.")
    # parser.add_argument('-f', '--frost', action='store_true',
    #                     help='Use the frost/ice color stretch, and disable '
    #                     'auto-detection of frost/ice.')
    # parser.add_argument('--nofrost', action='store_true',
    #        help='Do not use the frost/ice color stretch, and disable '
    #                     'auto-detection of frost/ice.')
    parser.add_argument(
        "cubes",
        type=Path,
        nargs=2,
        metavar="HiColorNorm-cube",
        help="The COLOR4.HiColorNorm.cub and COLOR5.HiColorNorm.cub files.")
    return parser
示例#9
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__, parents=[util.parent_parser()]
    )
    parser.add_argument(
        "-c", "--color", action="store_true", help="Perform Color processing."
    )
    parser.add_argument(
        "-p",
        "--precision",
        action="store_true",
        help="Perform HiPrecision processing to result "
        "in NOPROJ.cub that might be processed through "
        "HiJACK.",
    )
    parser.add_argument(
        "-j",
        "--jack",
        action="store_true",
        help="Do not test if HiJACK is needed, but force HiJACK to run.",
    )
    parser.add_argument(
        "--max_workers",
        default=None,
        type=int,
        help="This program uses multiprocessing to parallelize some of the "
             "work.  This multiprocessing will default to use the number of "
             "processors on the host machine.  If you want to throttle this "
             "to use less resources on your machine, indicate the number of "
             "processors you want to use."
    )
    parser.add_argument(
        "img",
        metavar="some.img-file",
        nargs="+",
        help="More than one can be listed here.",
    )
    parser.add_argument(
        "--conf_dir",
        required=False,
        type=Path,
        default=Path(pkg_resources.resource_filename(__name__, "data/")),
        help="Directory where configuration files for each of the hiproc "
             "algorithms are.  Defaults to the configuration files "
             "distributed with the library."
    )
    return parser
示例#10
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__,
        parents=[util.parent_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter
    )
    parser.add_argument(
        "-o", "--out_dir",
        required=False,
        default="./HiJACK",
        help="The directory where HiJACK output will be placed.  If it "
             "doesn't already exist, it will be created. Default: %(default)s"
    )
    parser.add_argument(
        "-c",
        "--conf_dir",
        required=False,
        type=Path,
        default=Path(pkg_resources.resource_filename(__name__, 'data/')),
        help="Directory where ResolveJitter.conf and HiJACK.conf can be "
             "found. Defaults to the directory distributed with the library.",
    )
    parser.add_argument(
        "-n",
        "--noplot",
        action="store_false",
        dest="plot",
        help="Will stop the display of before and after jitter plots.",
    )
    parser.add_argument(
        "-b", "--base_ccd_number",
        required=False,
        default=5,
        help="The CCD number that will be used in a variety of ways to set "
             "parameters for the resulting image. Default: %(default)s"
    )
    parser.add_argument(
        "cubes",
        metavar="balance.cub-files",
        nargs="+",
        help="All of the .balance.cub files created by HiccdStitch."
    )
    return parser
示例#11
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__,
        parents=[util.parent_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        "-c",
        "--conf",
        required=False,
        type=argparse.FileType('r'),
        default=pkg_resources.resource_stream(__name__,
                                              'data/HiPrecisionInit.conf'),
        help="Path to the HiPrecisionInit config file.  Defaults to "
        "HiPrecisionInit.conf distributed with the library.")
    parser.add_argument("slither_text",
                        metavar="slither.txt-files",
                        nargs="+",
                        help="The text files created by HiSlither.")
    return parser
示例#12
0
def arg_parser():
    parser = argparse.ArgumentParser(description=__doc__,
                                     parents=[util.parent_parser()])
    parser.add_argument("-c",
                        "--conf",
                        required=False,
                        type=argparse.FileType('r'),
                        default=pkg_resources.resource_stream(
                            __name__, 'data/HiJitReg.conf'),
                        help="Path to the HiJitReg config file.  Defaults to "
                        "HiJitReg.conf distributed with the library.")
    parser.add_argument(
        "cubes",
        metavar="balance.precolor.cub files",
        nargs="+",
        help="Either one or both sets of RED .balance.cub  and IR/BG "
        ".balance.precolor.cub files. However, that's tedious to type,"
        "so you could just type in *.balance*cub here, and the program "
        "will sort out what it needs.")
    return parser
示例#13
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__,
        parents=[util.parent_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        "-o",
        "--output_suffix",
        required=False,
        default=".precolor.cub",
        help="The input color (BG & IR) color cubes will have their final "
        "suffix removed, and this suffix added. Default: %(default)s")
    parser.add_argument(
        "cubes",
        metavar="balance.cub-files",
        nargs="+",
        help="Either one or both sets of RED/IR/BG .balance.cub files. "
        "However, that's tedious to type, so you could just type in "
        "*.balance.cub here, and the program will sort out what it needs.")
    return parser
示例#14
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__,
        parents=[util.parent_parser()],
        conflict_handler="resolve",
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        "-o",
        "--output",
        required=False,
        default="_COLOR.cub",
        help="The filename to be used for the output color cube.  If it "
        "begins with an underscore ('_') it will be assumed to be a "
        "suffix that will be appended to a name derived from the "
        "observation. Default: %(default)s")
    parser.add_argument(
        "-c",
        "--conf",
        required=False,
        type=argparse.FileType('r'),
        default=pkg_resources.resource_stream(__name__,
                                              'data/HiColorNorm.conf'),
        help="Path to the HiColorNorm config file.  Defaults to "
        "HiColorNorm.conf distributed with the library.")
    parser.add_argument(
        "-n",
        "--nounfiltered",
        action="store_false",
        dest="Make_Unfiltered",
        help="Stops creation of an unfiltered cube.",
    )
    parser.add_argument("cubes",
                        type=Path,
                        nargs=2,
                        metavar="COLOR-cube",
                        help="The COLOR4.cub and COLOR5.cub files")
    return parser
示例#15
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__,
        parents=[util.parent_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        "-o",
        "--output",
        required=False,
        default="_RED.NOPROJ.cub",
        help="The filename to be used for the output noproj cube.  If it "
        "begins with an underscore ('_') it will be assumed to be a "
        "suffix that will be appended to a name derived from the "
        "observation. Default: %(default)s")
    parser.add_argument("-c",
                        "--conf",
                        required=False,
                        type=argparse.FileType('r'),
                        default=pkg_resources.resource_stream(
                            __name__, 'data/HiNoProj.conf'),
                        help="Path to the HiNoProj config file.  Defaults to "
                        "HiNoProj.conf distributed with the library.")
    parser.add_argument(
        "-b",
        "--base_ccd_number",
        required=False,
        default=5,
        help="The CCD number that will be given to the MATCH parameter of "
        "ISIS noproj. Default: %(default)s")
    parser.add_argument(
        "cubes",
        type=Path,
        metavar="balance.cub-files",
        nargs="+",
        help="The RED .balance.cub files created by HiccdStitch.")
    return parser
示例#16
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__,
        parents=[util.parent_parser()],
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument(
        "-o",
        "--output",
        required=False,
        default=".HiccdStitch.cub",
        help="The name of the output .cub file to write.  Optionally, if "
        "it starts with a '.' it is considered a suffix"
        "and will be added to the Observation ID of the "
        "input files. Default: %(default)s",
    )
    parser.add_argument(
        "-c",
        "--conf",
        required=False,
        type=argparse.FileType('r'),
        default=pkg_resources.resource_stream(
            __name__,
            'data/HiccdStitch.conf',
        ),
        help="Path to the HiccdStitch config file.  Defaults to "
        "HiccdStitch.conf distributed with the library.")
    parser.add_argument(
        "--db",
        required=False,
        default=".HiCat.json",
        help="The .json file to output.  Optionally, if it "
        "starts with a '.' it is considered an extension "
        "and will be swapped with the output file's extension "
        "to determine the .json filename to use. Default: %(default)s",
    )
    parser.add_argument(
        "--sline",
        required=False,
        default=None,
        type=int,
        help="If given, will be used as the starting line to crop the image "
        "at in order to create a training area to use for cubenorm "
        "processing.")
    parser.add_argument(
        "--eline",
        required=False,
        default=None,
        type=int,
        help="If given, will be used as the ending line for cubenorm cropping, "
        "see --sline for more information.")
    parser.add_argument(
        "--cubenorm",
        required=False,
        nargs="+",
        type=bool,
        help="To engage cubenorm processing a list of true or false values "
        "(could be 0 or 1) that must match the number of input cubes"
        "must be given to indicate which of the input cubes should "
        "have cubenorm processing applied.  If you only had four input"
        "cubes, then ``--cubenorm 0 0 1 1`` would not run cubenorm "
        "processing on the first two cubes, but would run it on the last"
        "two, etc.  The default is not to run this processing on any.")
    parser.add_argument(
        "cubes",
        metavar="cub-file",
        nargs="+",
        help="Cubes to assemble, which are presumably the output of HiStitch. "
        "They must all be from the same detectors, so either all RED, "
        "all IR, or all BG cubes.")
    return parser
示例#17
0
 def test_parent_parser(self):
     self.assertIsInstance(util.parent_parser(), argparse.ArgumentParser)
示例#18
0
def arg_parser():
    parser = argparse.ArgumentParser(
        description=__doc__, parents=[util.parent_parser()]
    )
    parser.add_argument(
        "-c",
        "--conf",
        type=argparse.FileType('r'),
        default=pkg_resources.resource_stream(
            __name__,
            'data/ResolveJitter.conf'
        ),
        help="Path to a ResolveJitter.conf file, only needed if "
        "--lineinterval isn't given.",
    )
    parser.add_argument(
        "--csv",
        action="store_true",
        help="This program writes out a fixed-width data file with extra "
        "information for plotting.  This also writes out a "
        "comma-separated version.",
    )
    parser.add_argument(
        "--lineinterval",
        type=float,
        help="The number of lines to use to set the number of Fourier "
        "transform intervals, defaults to Control_Lines in the "
        "ResolveJitter.conf file.",
    )
    parser.add_argument(
        "--outdir",
        type=Path,
        help="Output directory.  Defaults to the directory of the first "
        "input file.",
    )
    parser.add_argument(
        "--outprefix",
        help="Prefix string for output files.  If not given, will default "
        "to the Observation ID of the images.",
    )
    parser.add_argument(
        "-p", "--plot", action="store_true", help="Displays interactive plot.",
    )
    parser.add_argument(
        "--saveplot",
        nargs="?",
        default=False,
        const=True,
        help="Saves plot to a default filename in the output directory. "
        "If a filename is provided it will be used to save the plot.",
    )
    parser.add_argument(
        "--whichmatch1",
        action="store_false",
        dest="which1",
        help="If specified, the sense of the offsets for the first "
        "file will be relative to the MATCH cube, rather than the FROM "
        "cube.",
    )
    parser.add_argument(
        "--whichmatch2",
        action="store_false",
        dest="which2",
        help="If specified, the sense of the offsets for the second "
        "file will be relative to the MATCH cube, rather than the FROM "
        "cube.",
    )
    parser.add_argument(
        "--whichmatch3",
        action="store_false",
        dest="which3",
        help="If specified, the sense of the offsets for the third "
        "file will be relative to the MATCH cube, rather than the FROM "
        "cube.",
    )
    parser.add_argument(
        "files",
        nargs="*",
        help="Three flat.txt files that are the output of ISIS hijitreg.",
    )
    return parser
示例#19
0
def main():
    # Set the numpy type for elements in the main data area of the .dat file.
    float_type = np.float32

    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
        parents=[util.parent_parser()],
    )
    parser.add_argument("-o",
                        "--output",
                        required=False,
                        default=".bitflip.dat")
    parser.add_argument(
        "-w",
        "--width",
        required=False,
        default=5,
        help="The number of medstd widths for bit-flip "
        "cleaning.",
    )
    parser.add_argument(
        "-r",
        "--replacement",
        required=False,
        default=float_type(0),
        type=float_type,
        help="By default, the program will replace "
        "identified pixels with an appropriate NULL data "
        "value, but if provided this value will be used "
        "instead.",
    )
    parser.add_argument(
        "-p",
        "--plot",
        required=False,
        action="store_true",
        help="Displays plot for each area.",
    )
    parser.add_argument(
        "-n",
        "--dryrun",
        required=False,
        action="store_true",
        help="Does not produce a cleaned output file.",
    )
    parser.add_argument("file", help="A .dat file to clean.")

    args = parser.parse_args()

    util.set_logger(args.verbose, args.logfile, args.log)

    out_p = util.path_w_suffix(args.output, args.file)

    clean(
        args.file,
        out_p,
        args.replacement,
        width=args.width,
        plot=args.plot,
        dryrun=args.dryrun,
    )

    sys.exit(0)