import numpy as np
import matplotlib.pyplot as plt

from simulate import simulate

class possum(simulate):
	"""
	Class for creating polarization and 
	faraday rotation spectra.

	Frequency Coverages:
		_createWSRT()
			Frequency range for the Westerbork
			Synthesis Radio Telescope 
				310 - 380 MHz
	
		_createASKAP12()
			ASKAP12 frequency coverage
				700 - 1300 MHz
				1500 - 1800 MHz

		_createASKAP36()
			ASKAP36 frequency coverage 
				1130 - 1430 MHz
	"""

	def __init__(self):
		self.__c   = 2.99e+08 	# speed of light in m/s
		self.__mhz = 1.0e+06


	def _createWSRT(self, *args):
		"""
		Create the WSRT frequency spectrum:
			310 - 380 MHz
		"""
		self.nu_ = self._createFrequency(310., 380., nchan=400)

	def _createASKAP12(self, *args):
		"""
		Create the ASKAP12 frequency range:
			700 - 1300 MHz
			1500 - 1800 MHz

		To call:
			_createASKAP12()

		Parameters:
			[None]

		Postcondition:
		"""
		band12 = self._createFrequency(700.,1300.,nchan=600)
		band3  = self._createFrequency(1500.,1800.,nchan=300)
		self.nu_ = np.concatenate((band12, band3))


	def _createASKAP36(self, *args):
		"""
		Create the ASKAP36 frequency range:
			1130 - 1430 MHZ

		To call:
			_createASKAP36()

		Parameters:
			[None]

		Postcondition:
			
		"""
		self.nu_ = self._createFrequency(1130., 1430., nchan=300)


	def _createFrequency(self, numin=700., numax=1800., nchan=100.):
		"""
		Creates an array of evenly spaced frequencies
		numin and numax are in [MHz]

		To call:
			_createFrequency(numin, numax, nchan)

		Parameters:
			numin
			numax

		Postcondition:
		"""

		# ======================================
		#	Convert MHz to Hz
		# ======================================
		numax = numax * self.__mhz
		numin = numin * self.__mhz