diff options
| author | Aaron LI <aly@aaronly.me> | 2017-09-02 10:47:42 +0800 | 
|---|---|---|
| committer | Aaron LI <aly@aaronly.me> | 2017-09-02 10:47:42 +0800 | 
| commit | a214637f11d7c8277f2127db3ff0c3731e6c6b80 (patch) | |
| tree | ab22687818c2358419d5483fcbcd7727c7072d0b /astro/fits/crop_image.py | |
| parent | 04aef0c64a49f94f0e5db9c2ccc4bed63f7b4f5d (diff) | |
| download | atoolbox-a214637f11d7c8277f2127db3ff0c3731e6c6b80.tar.bz2 | |
fits: Add {rescale,crop}_image.py for FITS image rescaling and cropping
Diffstat (limited to 'astro/fits/crop_image.py')
| -rwxr-xr-x | astro/fits/crop_image.py | 35 | 
1 files changed, 35 insertions, 0 deletions
diff --git a/astro/fits/crop_image.py b/astro/fits/crop_image.py new file mode 100755 index 0000000..9cfa7bf --- /dev/null +++ b/astro/fits/crop_image.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2017 Aaron LI <aly@aaronly.me> +# MIT license +# + +""" +Crop out the central region of specified size from the FITS image. +""" + +import argparse + +from rescale_image import FITSImage + + +def main(): +    parser = argparse.ArgumentParser( +        description="Rescale a FITS image to the desired size/resolution") +    parser.add_argument("-C", "--clobber", action="store_true", +                        help="overwrite existing output file") +    parser.add_argument("-s", "--size", type=float, required=True, +                        help="central crop box size [deg]") +    parser.add_argument("-i", "--infile", required=True, +                        help="input FITS image") +    parser.add_argument("-o", "--outfile", required=True, +                        help="output cropped FITS image") +    args = parser.parse_args() + +    fitsimage = FITSImage(args.infile) +    fitsimage.crop(size=args.size) +    fitsimage.write(args.outfile, clobber=args.clobber) + + +if __name__ == "__main__": +    main()  | 
