-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_lightcurve.py
94 lines (81 loc) · 2.51 KB
/
plot_lightcurve.py
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
86
87
88
89
90
91
92
93
94
#===================================================================
#
# PLOTTING LIGHT CURVES
#
# This script is used to plot light curves from photometry ouput data.
#
# VERSION: 24 Sep 2020
# AUTHOER: QIANG CHEN chen@camk.edu.pl
#
# PYTHON ENVIRONMENT REQUIREMENT:
# -
#
# REFERENCE:
# -
#===================================================================
import os
import numpy as np
import matplotlib.pyplot as plt
PATH = '/work/chuck/chen/obs'
folder,name,deblending = '20190822','stars',False
folder,name,deblending = '20190823','ap',False
folder,name,deblending = '20190827','ap',False
folder,name,deblending = '20190822','ap',False
filters = ['V','U','B','I']
try:
print('deleting old data')
os.system(f'rm {PATH}/{folder}/reduced/sorted_{name}_*.png')
except:
pass
for filt in filters:
print('SORTING STARS BY EVERY FILTER TYPE:',filt)
for i in range(200):
try:
f = open(f'{PATH}/{folder}/reduced/sorted_{name}_{filt}{i}.dat','r')
data = np.array([[float(data) for data in line.split()] for line in f.readlines()])
f.close()
except:
continue
row,col = data.shape
if (row<10):
continue
print(' filter',filt,'i',i)
if (name=='stars'):
x = data[:,1]
y = data[:,2]
Julian = data[:,-3]
#intJul = [int(x) for x in Julian]
#intJul = int(np.mean(intJul))
flux = data[:,-5]
elif(name=='ap' and deblending):
x = data[:,4]
y = data[:,5]
Julian = data[:,-1]
#intJul = [int(x) for x in Julian]
#intJul = int(np.mean(intJul))
flux = data[:,6]
elif(name=='ap'):
x = data[:,1]
y = data[:,2]
Julian = data[:,-3]
#intJul = [int(x) for x in Julian]
#intJul = int(np.mean(intJul))
flux = data[:,-4]
#threshold = np.mean(flux)*0.1
#flux = np.ma.masked_where(flux < threshold, flux)
plt.clf()
rows = 1
cols = 1
plt.gcf().set_size_inches(8*cols,4*rows)
plt.subplot(rows,cols,1,title=f'Data: {folder}, Filter: {filt}, ID: {i}, Pixel Coor: ({round(np.mean(x),2)}, {round(np.mean(y),2)})')
plt.scatter(Julian-int(Julian[0]), flux)
plt.ylabel('flux')
plt.xlabel(f'Julian Date -{int(Julian[0])}')
#plt.ylim(np.mean(flux)-50,np.mean(flux)+50)
#plt.ylim(0,100)
#plt.xlim(0.305, 0.40)
plt.grid(c='0.5',ls=':')
plt.tick_params(which='both', direction='in', top='true', right='true')
plt.tight_layout()
plt.savefig(f'{PATH}/{folder}/reduced/sorted_{name}_{filt}{i}.png',format='png')
#plt.show()