-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_eg_for_human_jdg.py
More file actions
executable file
·85 lines (82 loc) · 2.41 KB
/
plot_eg_for_human_jdg.py
File metadata and controls
executable file
·85 lines (82 loc) · 2.41 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/python3
'''
Abstract:
This is a program to show the SED of human judgement examples.
Usage:
plot_eg_for_human_jdg.py [main_name of test set]
Editor:
Jacob975
##################################
# Python3 #
# This code is made in python3 #
##################################
20200221
####################################
update log
20200221 version alpha 1:
1. The code works.
'''
import numpy as np
import time
from sys import argv
import os
from matplotlib import pyplot as plt
#--------------------------------------------
# main code
if __name__ == "__main__":
VERBOSE = 0
# measure times
start_time = time.time()
#----------------------------------------
# Load argv
if len(argv) != 2:
print ("Error!\nUsage: plot_test_result.py [main_name for test set]")
exit()
main_name = argv[1]
#----------------------------------------
# Load data
print("Loading ...")
data = np.loadtxt("{0}_sed.txt".format(main_name))
coord = np.loadtxt("{0}_coord.txt".format(main_name))
print("done")
#----------------------------------------
# Ploting
print ("ploting ... ")
source_type = ['star', 'galaxy', 'YSO']
colors = ['b', 'g', 'r']
wavelength = [ 1.235,
1.662,
2.159,
3.550,
4.493,
5.731,
7.872,
24.00]
# Initialize the figure space
fig, ax = plt.subplots(figsize = (8,6))
ax.set_xlabel("Wavelength ($\mu$m)", fontsize=16)
ax.set_ylabel("Flux (m$J_{y}$)", fontsize=16)
ax.set_yscale("log")
ax.set_xscale('log')
ax.set_xticks(wavelength, minor = False)
ax.set_xticklabels(wavelength)
ax.grid(True)
# Plot the sources
for i, source in enumerate(data):
y = source[:8]
yerr = source[8:]
ax.errorbar(
x = wavelength,
y = y,
yerr = yerr,
label = r"%s at (%.7f, %.7f)" % (source_type[i], coord[i][0], coord[i][1]),
fmt='--o',
capsize=8,
c = colors[i],
)
ax.legend()
fig.savefig( "SEDs.png".format(coord[i,0], coord[i,1]))
#----------------------------------------
# measuring time
elapsed_time = time.time() - start_time
print ("Exiting Main Program, spending ", elapsed_time, "seconds.")