#!/usr/bin/env python

import argparse
from soxs import write_image

parser = argparse.ArgumentParser(description='Make a FITS image from a SOXS event file.')
parser.add_argument("event_file", type=str, help="The event file to use to make the image.")
parser.add_argument("out_file", type=str, help='The file to write the image to.')
parser.add_argument("--coord_type", type=str, default="sky",
                    help="The type of coordinate to bin into the image. Can be 'sky' "
                         "or 'det'. Default: 'sky'")
parser.add_argument("--emin", help="The minimum energy of the photons to put in the "
                                    "image, in keV.")
parser.add_argument("--emax", help="The maximum energy of the photons to put in the "
                                   "image, in keV.")
parser.add_argument("--overwrite", action='store_true',
                    help='Overwrite an existing file with the same name.')
parser.add_argument("--expmap_file", type=str, 
                    help="Supply an exposure map file to divide this image by "
                         "to get a flux map.")
parser.add_argument("--reblock", type=int, default=1, 
                    help="Change this value to reblock the image to larger "
                         "pixel sizes (reblock >= 1). Only supported for sky "
                         "coordinates. Default: 1")

args = parser.parse_args()

write_image(args.event_file, args.out_file, coord_type=args.coord_type, 
            emin=args.emin, emax=args.emax, overwrite=args.overwrite,
            expmap_file=args.expmap_file, reblock=args.reblock)
