import numpy as np

try:
    import importlib.resources as pkg_resources
except ImportError:
    # Try backported to PY<37 'importlib_resources'
    import importlib_resources as pkg_resources

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)
		else:
			with pkg_resources.path('ObservationSim.Instrument.data', 'mirror_ccdnote.txt') as optEffCurve_path:
				self.efficiency = self._get_efficiency(optEffCurve_path)

	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