Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F116253637
mockimgs_fits_manip
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Jun 5, 20:02
Size
1 KB
Mime Type
text/x-python
Expires
Sat, Jun 7, 20:02 (2 d)
Engine
blob
Format
Raw Data
Handle
26580697
Attached To
rARRAKIHS ARRAKIHS
mockimgs_fits_manip
View Options
#!/usr/bin/python3
import argparse
from astropy.io import fits
import os
import numpy as np
####################################################################
# 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=1,
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()
hdu1 = fits.open(opt.files[0])
data = hdu1[0].data
data = np.where(data>28,100,data)
#data = np.where(data<29.5,100,data)
#data = np.where(data<26.0,100,data)
'''
dd = np.where(data>30.5,0,1)
dd = np.where(data>30.5,0,1)
print(sum(dd.ravel()))
'''
# save fits
if opt.outputfilename:
hdu = fits.PrimaryHDU(data)
if os.path.isfile(opt.outputfilename):
os.remove(opt.outputfilename)
hdu.writeto(opt.outputfilename)
Event Timeline
Log In to Comment