Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99459084
mockimgs_fits_compute_area
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
Fri, Jan 24, 18:30
Size
2 KB
Mime Type
text/x-python
Expires
Sun, Jan 26, 18:30 (1 d, 18 h)
Engine
blob
Format
Raw Data
Handle
23797976
Attached To
rARRAKIHS ARRAKIHS
mockimgs_fits_compute_area
View Options
#!/usr/bin/env python3
import numpy as np
from astropy.io import fits
from astropy import constants as cte
from astropy import units as u
import argparse
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
from pNbody import *
from pNbody import ic
import pickle
####################################################################
# option parser
####################################################################
description=""
epilog =""""""
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='a file name')
parser.add_argument("-o",
action="store",
type=str,
dest="outputfilename",
default=None,
help="Name of the output file")
####################################################################
# main
####################################################################
cs = plt.cm.get_cmap('jet')
nmagbins = 50
magmin = 26
magmax = 33
magbins = np.linspace(magmin,magmax,nmagbins)
if __name__ == '__main__':
opt = parser.parse_args()
n = len(opt.files)
for j,f in enumerate(opt.files):
hdu = fits.open(f)
data = np.ravel(hdu[0].data)
data = np.compress(data<100,data)
data0 = data
Npix = np.zeros(nmagbins)
for i in tqdm(range(nmagbins)):
data = np.where(data0<magbins[i],1,0)
Npix[i] = np.ravel(data).sum()
label = os.path.basename(f)
label = label[label.find("_")+1:]
label = label[:-4]
plt.plot(magbins,Npix,color=cs(int(255*j/n)),label=r"$%s$"%label,lw=2)
plt.legend()
plt.xlabel(r"$\rm{VIS}\,\,\rm{magnitude}$")
plt.ylabel(r"$\rm{Area\,\,\rm{pixels}}$")
if opt.outputfilename is None:
plt.show()
else:
plt.savefig(opt.outputfilename)
Event Timeline
Log In to Comment