Telescope.py 1.26 KB
Newer Older
Fang Yuedong's avatar
Fang Yuedong committed
1
2
import numpy as np

Fang Yuedong's avatar
Fang Yuedong committed
3
4
5
6
7
8
try:
    import importlib.resources as pkg_resources
except ImportError:
    # Try backported to PY<37 'importlib_resources'
    import importlib_resources as pkg_resources

Fang Yuedong's avatar
Fang Yuedong committed
9
10
11
12
13
14
15
16
class Telescope(object):
	def __init__(self, param=None, optEffCurve_path=None):
		self.diameter = 2.0 # in unit of meter
		if param is not None:
			self.diameter = param["diameter"]
		self.pupil_area = np.pi * (0.5 * self.diameter)**2
		if optEffCurve_path is not None:
			self.efficiency = self._get_efficiency(optEffCurve_path)
Fang Yuedong's avatar
Fang Yuedong committed
17
18
19
		else:
			with pkg_resources.path('ObservationSim.Instrument.data', 'mirror_ccdnote.txt') as optEffCurve_path:
				self.efficiency = self._get_efficiency(optEffCurve_path)
Fang Yuedong's avatar
Fang Yuedong committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

	def _get_efficiency(self, effCurve_path):
		""" Read in the efficiency of optics
			for each band
		Parameters:
			effCurve_path:	the path for efficiency file
		Returns:
			opticsEff:		a dictionary of efficiency (a scalar) for each band
		"""
		f = open(effCurve_path, 'r')
		for _ in range(2):
			header = f.readline()

		iline = 0
		opticsEff = {}
		for line in f:
			line = line.strip()
			columns = line.split()
			opticsEff[str(columns[0])] = float(columns[2])
		f.close()
		return opticsEff

	def _get_effCurve(self, effCurve_path):
		pass