-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_Av_hist.py
More file actions
executable file
·54 lines (51 loc) · 1.48 KB
/
Copy pathplot_Av_hist.py
File metadata and controls
executable file
·54 lines (51 loc) · 1.48 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
#!/usr/bin/python3
'''
Abstract:
This is a program for ploting Av histogram
Usage:
plot_Av_hist.py [Av table]
Editor:
Jacob975
##################################
# Python3 #
# This code is made in python3 #
##################################
20180814
####################################
update log
20180814 version alpha 1
1. The code works
'''
import time
import numpy as np
import matplotlib.pyplot as plt
from sys import argv
#--------------------------------------------
# main code
if __name__ == "__main__":
VERBOSE = 0
# measure time
start_time = time.time()
#-----------------------------------
# Load argv
if len(argv) != 2:
print ("Wrong numbers of arguments.")
print ("Usage: plot_Av_hist.py [Av table]")
exit(1)
Av_table_name = argv[1]
#-----------------------------------
# Load table
Av_table = np.loadtxt(Av_table_name)
#-----------------------------------
# plot
Av_hist = np.histogram(Av_table[:,0], np.arange(-10, 30))
Av_hist_plot = plt.figure("Av histogram")
plt.title("Av histogram of file '{0}'".format(Av_table_name))
plt.xlabel("Av")
plt.ylabel("# of sources")
plt.bar(np.arange(-9.5, 29.5, 1), Av_hist[0])
Av_hist_plot.savefig("{0}_hist.png".format(Av_table_name[:-4]))
#-----------------------------------
# measure time
elapsed_time = time.time() - start_time
print ("Exiting Main Program, spending ", elapsed_time, "seconds.")