-
Notifications
You must be signed in to change notification settings - Fork 0
/
objplot.py
executable file
·346 lines (268 loc) · 9.19 KB
/
objplot.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
#!/usr/bin/env python3
# ConAn
# Constellation Analytic simulations
#
# main plot: plot the satellite density over a calendar for a given object
import numpy as np
import matplotlib
matplotlib.use('Agg') # to avoid Xdisplay issues in remote
import matplotlib.pyplot as plt
import sys
sys.path.append('/home/ohainaut/Documents/ESO/E2E/SatelliteConstellations/SIMULATIONS/')
from matplotlib import ticker
from conanplot import gyrd
# import ConAn routines
import conan as ca
import conanplot as cp
#print('ConAn:objplot -in')
def helphelp():
out = """
objplot
-r RA -d dec -n name
-T FlyEye WFI VST EFOSC FORSimg LSST HAWKI MICADO
FORSspec UVES1h 4MOST ESPRESSO
VISIR
skyMag TrailDensity SatDensity(def)
These pre-load default
extptime, FoVl, FoVw, maglim, magbloom, trailf,
telname, instrName, latitude
-l latitude*
-t exptime* -f Fovl* -m magbloom* -k trailf*
maglim: those with eff.mag fainter are not observable
those brigher create a trail
trailf: fraction of the exposure that is destroyed by trail. 1=full
magbloom: for those brighter, trailf=1=full
-s telName* -i instrName*
(*: overwrites presets)
-M BRIGHT FAINT ALL OBS EFFECT --> HARDCODED
All sats, restrict to bright/faint (wrt magbloom), convert into effect on obs.
"""
print(out)
#outpath = "/home/ohainaut/public_html/outsideWorld/"
outpath = "./"
maglimoff = 1.75 # 1.75: 1/5sig ; 1.: 2/5sig
magbloomoff = -2.5
magcutflag = 'OBS'
magcutflag = 'EFFECT' ## 4MOST
fovw = -99.
constellationsll = 'SLOWGWAK'
elevlim = 20.
telinslabel = " "
telescope = " "
overlat = 0
lon = 0.
#default for overwriting values
overtime = 0
overfovl = 0
overfovw = 0
overmagbloom = 0
overmaglim = 0
overresol = 0
overtrailf = -1
overlat = 0
overtelescope = 0
overinstrument = 0
objlabel=" "
helpme = False
if len(sys.argv) == 1:
helpme = True
for i in np.arange(0,len(sys.argv)):
if sys.argv[i] == '-r': #ra
i += 1
rao = float(sys.argv[i])
if sys.argv[i] == '-d': #delta
i += 1
deo = float(sys.argv[i])
if sys.argv[i] == '-n': #obj name
i += 1
objlabel = sys.argv[i]
if sys.argv[i] == '-l': #latitude
i += 1
overlat = float(sys.argv[i])
if sys.argv[i] == '-T': #telescope/instrument
i += 1
telinslabel = sys.argv[i]
if sys.argv[i] == '-t': #expt
i += 1
overtime = float(sys.argv[i])
if sys.argv[i] == '-f': #fieldofview
i += 1
overfovl = float(sys.argv[i])
if sys.argv[i] == '-fw': #fieldofview
i += 1
overfovw = float(sys.argv[i])
if sys.argv[i] == '-r': #resolution
i += 1
overresol = float(sys.argv[i])/3600.
if sys.argv[i] == '-m': #maglim
i += 1
overmaglim = float(sys.argv[i])
if helpme:
helphelp()
exit(0)
telescope, lat, instrument, expt, fovl, fovw, resol, maglim, magbloom, trailf = cp.findPreset(telinslabel)
if overtime:
expt = overtime
if overfovl:
fovl = overfovl
if overfovw:
fovw = overfovw
if fovw < 0:
fovw = fovl *1.
if overmagbloom:
magbloom = overmagbloom
if overmaglim:
maglim = overmaglim
if overresol:
resol = overresol
if overtrailf >= 0.:
trailf = overtrailf
if overlat:
lat = overlat
if overtelescope:
telescope = overtelescope
if overinstrument:
instrument = overinstrument
if fovw < 0:
fovw = fovl *1.
#---
#- fill in the calendar
hstep = 12 # points per hour
times = np.zeros((365,24*hstep))
for i in range(365):
for j in range(24*hstep):
times[i,j] = 2459580.5 + i + j/24./hstep - (.5 + lon/360.) # to centre midnight
# Loc ST
lst = (280.46061837 + 360.98564736629*(times -2451545.0) + lon)%360
# sun coordinates
walphas, deltas = ca.get_sun(times)
alphas = lst - walphas # alphas is the HA
elevs = ca.radec2elev(alphas,deltas,lat)
# object coordinates
hao = lst - rao
AzEl = np.array( ca.radec2azel(hao,deo,lat))
# satellites
constellationsl, constellations = cp.findConstellations(constellationsll)
consLab, consNum, consPla, consNPl, consInc, consAlt = ca.loadConstellations(constellations)
nCons = len(consLab)
densSatAll = np.zeros_like(AzEl[0])
densVelAll = np.zeros_like(AzEl[0])
densSatObs = np.zeros_like(AzEl[0])
densVelObs = np.zeros_like(AzEl[0])
densSatBloom = np.zeros_like(AzEl[0])
densVelBloom = np.zeros_like(AzEl[0])
consLab, consNum, consPla, consNPl, consInc, consAlt = ca.loadConstellations(constellations)
nCons = len(consLab)
mageffmax = -99
mageffmin = 99.
icons = 0
while icons < len(consInc):
# constellation
densSi, veli, magi = ca.modelOneConstMag(AzEl,lat,
np.reshape(alphas,alphas.shape[0]*alphas.shape[1]),
np.reshape(deltas,deltas.shape[0]*deltas.shape[1]),
consInc[icons], consAlt[icons], consNum[icons])
# all sat:
densSatAll += densSi
densVelAll += densSi * veli
# effective magnitude
mageffi = magi - 2.5*np.log10(resol/veli/expt)
mageffmax = max(mageffmax,np.amax(mageffi))
mageffmin = min(mageffmin,np.amin(mageffi))
# only observable ones
densSobsi = np.copy(densSi)
densSobsi[ mageffi > maglim] = 0.
densSatObs += densSobsi
densVelObs += densSobsi * veli
# only super bright bloomers
densSbloomi = np.copy(densSi)
densSbloomi[ mageffi > magbloom ] = 0.
densSatBloom += densSbloomi
densVelBloom += densSbloomi * veli
icons += 1
cmap = 'magma'
if magcutflag == 'ALL':
ds = densSatAll
dv = densVelAll
elif magcutflag == 'OBS':
ds = densSatObs
dv = densVelObs
labelmag = True
cblab = "Number of satellite trails per exposure"
lvmin = -2.5 # log limits for the colour scale
lvmax = 1.2 #
# lvmin = 0 # log limits for the colour scale # 4MOST
# lvmax = 2.7 # 4MOST
elif magcutflag == 'EFFECT':
ds = trailf * densSatObs + (1.-trailf)* densSatBloom
dv = trailf * densVelObs + (1.-trailf)* densVelBloom
labelmag = True
cblab = "Fraction of exposure lost"
lvmin = -3.5 # log limits for the colour scale
lvmax = 2.2 #
lvmax = .2 #
lvmin = -3.5 # log limits for the colour scale # 4MOST
#
cmap = gyrd
else:
print("valid for -M: BRIGHT OBS FAINT ALL EFFECT")
exit(1)
dens = ds* fovl*fovw + dv * fovl * expt # trailf already accounted for
#== plot
fig = plt.figure(figsize=(12,7))
plt.rc('font', size=15) #controls default text size
plt.rc('axes', titlesize=15) #fontsize of the title
plt.rc('axes', labelsize=18) #fontsize of the x and y labels
plt.rc('xtick',labelsize=15) #fontsize of the x tick labels
plt.rc('ytick',labelsize=15) #fontsize of the y tick labels
plt.rc('legend',fontsize=15) #fontsize of the legend
#plt.rcParams['figure.figsize'] = [12, 8]
ax = fig.subplots()
_ = ax.set_xticks(np.arange(0.,hstep*24, hstep*3))
_ = ax.set_xticklabels(np.concatenate((np.arange(12,24,3),np.arange(0,12,3))))
_ = ax.set_xlabel('Local Solar Time')
_ = ax.set_yticks(np.arange(0.,365,30.5))
_ = ax.set_yticklabels(['Jan.','Feb.','Mar.','Apr.','May','Jun.','Jul.','Aug.','Sep.','Oct.','Nov.','Dec.'])
_ = ax.set_ylabel('Calendar')
_ = ax.set_xlim(4*hstep, 20*hstep) # from 16h to 8h
lsat = np.log10(dens+1.e-10)
lsat = lsat + np.log( elevs < 0 )
#- fill in the satellites
csat = ax.contourf(lsat, levels=np.arange(lvmin,lvmax,.01) , cmap=cmap, extend='both')
csat.cmap.set_under('k') # below minimum -> black
#- unobservable
osat = np.nan_to_num(lsat*0) + 1000.*( AzEl[1] < elevlim )
_ = ax.contourf(osat, levels=np.arange(999.,1001.) , cmap='Greys')
#- airmass
wel = AzEl[1] *( elevs < 0 )
cobj = ax.contour(wel, levels=np.arange(elevlim,90.,10.), cmap="summer_r")
lobj = plt.clabel(cobj, fmt='%.0f$^o$')
_ = ax.contourf(elevs, levels=[0.,90.], colors='royalblue')
#- daylight
csun = ax.contour(elevs, levels=[-18.,-12.,-6.,0],
linewidths=[1.,1.,1.,5.],
linestyles='solid',
colors='b')
lsun = plt.clabel(csun, fmt='%.0f$^o$')
# color bar
cbar = fig.colorbar(csat)
cbar.set_ticks(np.log10(np.array([0.0005,0.001,0.002,0.005,0.01,0.02,0.05,0.1,0.2,0.5,1.,2.,5.,10.,20.,50.,100.,200.])))
cbar.set_ticklabels( [ "{:.2g}".format(x) for x in 10.**(cbar.get_ticks())])
cbar.set_label(cblab)
# save
_ = ax.set_title('Object: {} $\\alpha$: {:.2f}$^o$, $\\delta$: {:.2f}$^o$'.format(objlabel,rao,deo))
#ax.grid()
#_ = ax.text(0.,-28,'(b)', fontsize=14)
_ = ax.text(30.,-32,'Constellation: {} ({:.0f} sat.)'.format(constellationsl,sum(consNum)), fontsize=8, ha='left')
_ = ax.text(30,-40,'Telescope: {}, lat= {:.2f}$^o$'.format(telescope,lat),fontsize=8, ha='left')
if fovl < 1./60.:
fovll = '{:.2f}\"'.format(fovl*3600.)
elif fovl < 1./6.:
fovll = '{:.2f}\''.format(fovl*60.)
else:
fovll = '{:.2f}$^o$'.format(fovl)
_ = ax.text(30.,-48,'Instrument: {} FoV= {} Resolution= {:.1g}\" Exp.T= {:.0f}s'.format(instrument, fovll, resol*3600., expt), fontsize=8, ha='left')
outfileroot = "{}_{}_{}_{}".format(objlabel,telinslabel,constellationsll,magcutflag)
fig.tight_layout()
plt.savefig(outpath+'w.png')
plt.savefig(outpath+outfileroot+'.png')