Page MenuHomec4science

mockimgs_fits_histogram
No OneTemporary

File Metadata

Created
Mon, Dec 23, 07:07

mockimgs_fits_histogram

#!/usr/bin/python3
import argparse
from astropy.io import fits
import os
import numpy as np
import matplotlib.pyplot as plt
####################################################################
# option parser
####################################################################
description="subtract two fits files and create a new one with the difference"
epilog ="""
Examples:
--------
mockimgs_fits_substract image1.fits -o image.fits
"""
parser = argparse.ArgumentParser(description=description,epilog=epilog,formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(action="store",
dest="files",
metavar='FILE',
type=str,
default=None,
nargs="*",
help='one files')
parser.add_argument("-o",
action="store",
type=str,
dest="outputfilename",
default=None,
help="Name of the output file")
####################################################################
# main
####################################################################
if __name__ == '__main__':
opt = parser.parse_args()
for f in opt.files:
hdu = fits.open(f)
data = np.ravel(hdu[0].data)
data = np.compress(data<100,data)
bins = np.linspace(26,31.5,50)
h,bins = np.histogram(data,bins)
plt.plot(bins[1:],h,label=f)
plt.legend()
plt.show()

Event Timeline