-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_sed_hist.py
More file actions
executable file
·57 lines (54 loc) · 1.52 KB
/
Copy pathplot_sed_hist.py
File metadata and controls
executable file
·57 lines (54 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python3
'''
Abstract:
This is a program for plotting the histogram of certain band on SED.
Usage:
plot_sed_hist.py [index band] [sed table]
Output:
1. The image of given-band histogram
Editor:
Jacob975
##################################
# Python3 #
# This code is made in python3 #
##################################
20191016
####################################
update log
20191016 version alpha 1:
1. The code works.
'''
import time
import numpy as np
from sys import argv
from matplotlib import pyplot as plt
#--------------------------------------------
# Main code
if __name__ == "__main__":
VERBOSE = 0
# Measure time
start_time = time.time()
#-----------------------------------
# Load argv
if len(argv) != 3:
print ("The number of arguments is wrong.")
print ("Usage: plot_sed_hist.py [index band ] [sed table]")
print ("The [index band] should range from 0 to 7")
exit()
ind_band = int(argv[1])
sed_table_name = argv[2]
#-----------------------------------
# Load data
print ("Loading data...")
sed_table = np.loadtxt(sed_table_name)
# Plot the result
print ("Plotting the histogram")
n, bins, patches = plt.hist(np.log10(sed_table[:,ind_band]), 50)
plt.xlim(-2, 4)
plt.yscale('log')
plt.grid()
plt.show()
#-----------------------------------
# Measure time
elapsed_time = time.time() - start_time
print("Exiting Main Program, spending ", elapsed_time, "seconds.")