-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtdsat_telescope.py
457 lines (319 loc) · 11.3 KB
/
tdsat_telescope.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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
def load_telescope_parameters(version, **kwargs):
"""
Utility script to load the telescope parameters
version = 0: Pre-design version (to compare with Rick's stuff)
version = 1: 210 mm design
version = 2: 300 mm design
version = 3: 350 mm design
version = 4: 400 mm design
###
### Version 2:
Syntax:
diameter, qe, psf_fwhm, pixel_size, efficiency = load_telescope_parameters(version)
---
Note, going to depreicate versions < 4 eventually since those assume that
the pixels are 0.5 * pixel size
To be done: Remove QE from this method and put it somewhere else.
---
"""
import astropy.units as ur
from numpy import pi
diag = kwargs.pop('diag', True)
name = ''
# Eventually depricate these things
if version == 0:
qe = 0.8 # To be improved later.
diameter = 30*ur.cm
psf_fwhm = 10*ur.arcsec
pixel_size = psf_fwhm * 0.5
efficiency = 0.87 # Ultrasat spec
if version == 1:
qe = 0.8
efficiency = 0.54 # Reported from Mike
diameter = 21 * ur.cm
psf_fwhm = 4 * ur.arcsec
pixel_size = psf_fwhm * 0.5
if version == 2:
qe = 0.8
efficiency = 0.65 # Reported from Mike
diameter = 30 * ur.cm
psf_fwhm = 9*ur.arcsec
pixel_size = psf_fwhm * 0.5
if version == 3:
qe = 0.8
diameter = 35*ur.cm
efficiency = 0.67 # Reported from Mike
psf_fwhm = 18*ur.arcsec
pixel_size = psf_fwhm * 0.5
if version == 4:
qe = 0.8
diameter = 40*ur.cm
efficiency = 0.70 # Reported from Mike
psf_fwhm = 23*ur.arcsec
pixel_size = psf_fwhm * 0.5
# Versions below here allow the PSF and the pixel to be decoupled
# "Big Schmidt" w/ 6k x 6k array
if version == 5:
name = 'Big Schmidt'
qe = 0.7
diameter = 33.0*ur.cm
eff_diam = 29.1*ur.cm
efficiency = (eff_diam/diameter)**2
plate_scale = 0.43 # arcsec per micron
psf_fwhm_um = 21.6 # microns
psf_fwhm = plate_scale * psf_fwhm_um * ur.arcsec
pixel_size = plate_scale * 10 * ur.arcsec
# Smaller Schmidts (same focal length?) each with 6k x 6k focal plane array
if version == 6:
name = 'Two mini Big Schmidts'
qe = 0.7
diameter = 21.0*ur.cm
eff_diam = 15.1*ur.cm
efficiency = (eff_diam/diameter)**2
plate_scale = 0.43 # arcsec per micron
psf_fwhm_um = 6.7 # microns
psf_fwhm = plate_scale * psf_fwhm_um * ur.arcsec
pixel_size = plate_scale * 10 * ur.arcsec
# Medium Schmidt (same focal length?) each with 6k x 6k focal plane array
if version == 7:
name = 'Medium Schmidt'
qe = 0.7
diameter = 24.0*ur.cm
eff_diam = 19.1*ur.cm
efficiency = (eff_diam/diameter)**2
plate_scale = 0.43 # arcsec per micron
psf_fwhm_um = 7.6 # microns
psf_fwhm = plate_scale * psf_fwhm_um * ur.arcsec
pixel_size = plate_scale * 10 * ur.arcsec
# Smaller Medium Schmidts (same focal length?) each with 6k x 6k focal plane array
if version == 8:
name = 'Two Small "Medium" Schmidts'
qe = 0.7
diameter = 14.0*ur.cm
eff_diam = 6.3*ur.cm
efficiency = (eff_diam/diameter)**2
plate_scale = 0.43 # arcsec per micron
psf_fwhm_um = 8.6 # microns
psf_fwhm = plate_scale * psf_fwhm_um * ur.arcsec
pixel_size = plate_scale * 10 * ur.arcsec
# Fast Medium Schmidts (same focal length?) each with 6k x 6k focal plane array
if version == 9:
name = 'Fast Schmidt'
qe = 0.7
diameter = 32.0*ur.cm
eff_diam = 29.89*ur.cm
efficiency = (eff_diam/diameter)**2
plate_scale = 0.64 # arcsec per micron
psf_fwhm_um = 44.3 # microns
psf_fwhm = plate_scale * psf_fwhm_um * ur.arcsec
pixel_size = plate_scale * 10 * ur.arcsec
# Mini-fast Schmidts
if version == 10:
name="Mini Fast Schmidts"
qe = 0.7
diameter = 22.0*ur.cm
eff_diam = 19.2*ur.cm
efficiency = (eff_diam/diameter)**2
plate_scale = 0.64 # arcsec per micron
psf_fwhm_um = 14.1 # microns
psf_fwhm = plate_scale * psf_fwhm_um * ur.arcsec
pixel_size = plate_scale * 10 * ur.arcsec
##### Second round of telescope designs
if version == 11:
name="Small Focal Plane CMOS"
qe = 0.6
diameter = 26.0*ur.cm
eff_diam = 23.1*ur.cm
efficiency = (eff_diam/diameter)**2
plate_scale = 6.4/10. # arcsec per micron
psf_fwhm_um = 6.7 # microns
psf_fwhm = plate_scale * psf_fwhm_um * ur.arcsec
pixel_size = plate_scale * 10 * ur.arcsec
if version == 12:
name="Swiss Cross CMOS"
qe = 0.6
diameter = 30.*ur.cm
eff_diam = 21.7*ur.cm
eff_diam = 24.7*ur.cm
efficiency = (eff_diam/diameter)**2
plate_scale = 4.0/10. # arcsec per micron
psf_fwhm_um = 7.2 # microns
psf_fwhm = plate_scale * psf_fwhm_um * ur.arcsec
pixel_size = plate_scale * 10. * ur.arcsec
if version == 13:
name="Swiss Cross CCD"
qe = 0.6
diameter = 30.*ur.cm
eff_diam = 20.2*ur.cm
efficiency = (eff_diam/diameter)**2
plate_scale = 5.4/13. # arcsec per micron
psf_fwhm_um = 16.1 # microns
psf_fwhm = plate_scale * psf_fwhm_um * ur.arcsec
pixel_size = plate_scale * 13 * ur.arcsec
if version == 14:
name="Medium Focal Plane (CMOS 6k x 6k)"
qe = 0.6
diameter = 30.*ur.cm
eff_diam = 0.7*27.3*ur.cm
efficiency = (eff_diam/diameter)**2
plate_scale = 4.3/10. # arcsec per micron
psf_fwhm_um = 7.1 # microns
psf_fwhm = plate_scale * psf_fwhm_um * ur.arcsec
pixel_size = plate_scale * 10 * ur.arcsec
######
if version == 15:
name="25 cm primary"
qe = 0.6
diameter = 20.*ur.cm
eff_diam = 17*ur.cm
efficiency = (eff_diam/diameter)**2
plate_scale = 6.4/10. # arcsec per micron
psf_fwhm_um = 10.3 # microns
psf_fwhm = plate_scale * psf_fwhm_um * ur.arcsec
pixel_size = plate_scale * 10 * ur.arcsec
if diag:
print('Telescope Configuration {}'.format(version))
print('Name: {}'.format(name))
print('Entrance Pupil diameter {}'.format(diameter))
print('Optical Efficiency {}'.format(efficiency))
print('PSF FWHM {}'.format(psf_fwhm))
print('Pixel size {}'.format(pixel_size))
print('Effective Aperture {}'.format(diameter*(efficiency)**0.5))
print('Effective Area {}'.format( efficiency * pi * (0.5*diameter)**2))
return diameter, qe, psf_fwhm, pixel_size, efficiency
def load_qe(**kwargs):
"""
Loads the detector QE and returns the values.
band = 1 (default, 180-220 nm)
band = 2 (260-320 nm)
band = 3 (340-380 nm)
Syntax:
wave, qe = load_qe(band = 1)
"""
import astropy.units as ur
import numpy as np
band = kwargs.pop('band', 1)
diag = kwargs.pop('diag', False)
indir = 'input_data/'
if band == 1:
infile = indir+'detector_180_220nm.csv'
if band == 2:
infile = indir+'detector_260_300nm.csv'
if band == 3:
infile = indir+'detector_340_380nm.csv'
f = open(infile, 'r')
header = True
qe = {}
set = False
for line in f:
if header:
header = False
continue
fields = line.split(',')
if not set:
wave = float(fields[0])
qe = float(fields[3])
set = True
else:
wave = np.append(wave, float(fields[0]))
qe = np.append(qe, float(fields[3]))
f.close()
# Give wavelength a unit
wave *= ur.nm
if diag:
print('Detector Q.E. loader')
print('Band {} has input file {}'.format(band, infile))
return wave, qe / 100.
def load_reflectivity(**kwargs):
"""
Loads the optics reflectivity and returns the values.
Syntax:
wave, reflectivity = load_reflectivity()
"""
import astropy.units as ur
import numpy as np
diag = kwargs.pop('diag', False)
indir = 'input_data/'
infile = indir+'al_mgf2_mirror_coatings.csv'
f = open(infile, 'r')
header = True
qe = {}
set = False
for line in f:
if header:
header = False
continue
fields = line.split(',')
if not set:
wave = float(fields[0])
reflectivity = float(fields[1])
set = True
else:
wave = np.append(wave, float(fields[0]))
reflectivity = np.append(reflectivity, float(fields[1]))
f.close()
# Give wavelength a unit
wave *= ur.nm
if diag:
print('Optics reflectivity loader')
print('Input file {}'.format(infile))
return wave, reflectivity
def load_redfilter(**kwargs):
"""
Loads the detector QE and returns the values.
band = 1 (default, 180-220 nm)
band = 2 (260-320 nm)
Syntax:
wave, transmission = load_redfilter(band=1)
"""
import astropy.units as ur
import numpy as np
band = kwargs.pop('band', 1)
diag = kwargs.pop('diag', False)
light = kwargs.pop('light', True)
indir = 'input_data/'
if light:
infile = indir+'duet{}_filter_light.csv'.format(band)
else:
infile = indir+'duet{}_filter.csv'.format(band)
f = open(infile, 'r')
header = True
qe = {}
set = False
for line in f:
if header:
if (line.startswith('Wavelength')) or ('%T' in line):
header = False
continue
fields = line.split(',')
if not set:
wave = float(fields[0])
transmission = float(fields[1])
set = True
else:
wave = np.append(wave, float(fields[0]))
transmission = np.append(transmission, float(fields[1]))
f.close()
# Give wavelength a unit
wave *= ur.nm
if diag:
print('Red filter loader')
print('Band {} has input file {}'.format(band, infile))
return wave, transmission / 100.
def apply_filters(wave, spec, **kwargs):
"""
Loads the detector QE and returns the values.
band = 1 (default, 180-220 nm)
band = 2 (260-320 nm)
Syntax:
wave, transmission = load_redfilter(band=1)
"""
from apply_transmission import apply_trans
# Load filters
ref_wave, reflectivity = load_reflectivity(**kwargs)
qe_wave, qe = load_qe(**kwargs)
red_wave, red_trans = load_redfilter(**kwargs)
ref_flux = apply_trans(wave, spec, ref_wave, reflectivity/100.)
qe_flux = apply_trans(wave, ref_flux, qe_wave, qe)
band_flux = apply_trans(wave, qe_flux, red_wave, red_trans)
return band_flux