# Path: Plot/PlotLibrary.py
# class Spectrum:
#   def __init__(self,Parameters,Model,Emin,Emax,Representation = "e2dnde",escale = "TeV",Npt=200):
#   def CheckNumParemeters(self, Params):
#   def usage(self):
#   def MakeFluxAndError(self,Emin=0,Emax=10e10):
#   def GetModel(self,Emin=0,Emax=10e10):
#   def GetButterfly(self,Emin=0,Emax=10e10):
#   def _HandleUnit(self,ener,flux,dflux = None):
#       D = (np.power(self.Emax,1.-self.Gamma)-np.power(self.Emin,1.-self.Gamma))
#     N = 2*len(ene)+1
# 
# Path: environ.py
# VERSION_4FGL = os.environ.get("VERSION_4FGL",'')
# 
# VERSION_3FGL = os.environ.get("VERSION_3FGL",'')
# 
# VERSION_2FGL = os.environ.get("VERSION_2FGL",'')
# 
# VERSION_1FHL = os.environ.get("VERSION_1FHL",'')
# 
# VERSION_2FHL = os.environ.get("VERSION_2FHL",'')
# 
# VERSION_3FHL = os.environ.get("VERSION_3FHL",'')
# 
# FERMI_CATALOG_DIR = os.environ.get('FERMI_CATALOG_DIR', '')


import pyfits,string,numpy
import Loggin
    import Coordinates.CoordHandler as CH
from Plot import PlotLibrary
from environ import VERSION_4FGL,VERSION_3FGL,VERSION_2FGL,VERSION_1FHL,VERSION_2FHL,VERSION_3FHL,FERMI_CATALOG_DIR
from math import *
    from astropy.coordinates import ICRS, Galactic, FK4, FK5 
  def _HandleEnergyUnit(self,ener):
      fac = 1
      if self.escale == "TeV":
          fac = 1e-6
      if self.escale == "GeV":
          fac = 1e-3
      return ener*fac

  def _HandleFluxUnit(self,flux):
      fac = 1
      if self.escale == "TeV":
          fac = 1e6
      if self.escale == "GeV":
          fac = 1e3
      return fac*flux



#Side functions
def calcAngSepDeg(ra0, dec0, ra1, dec1):
    '''Return the angular separation between two objects. Use the
    special case of the Vincenty formula that is accurate for all
    distances'''
    C = numpy.pi / 180
    d0 = C * dec0
    d1 = C * dec1
    r12 = C * (ra0 - ra1)
    cd0 = numpy.cos(d0)
    sd0 = numpy.sin(d0)
    cd1 = numpy.cos(d1)

# Path: Plot/PlotLibrary.py
# class Spectrum:
#   def __init__(self,Parameters,Model,Emin,Emax,Representation = "e2dnde",escale = "TeV",Npt=200):
#   def CheckNumParemeters(self, Params):
#   def usage(self):
#   def MakeFluxAndError(self,Emin=0,Emax=10e10):
#   def GetModel(self,Emin=0,Emax=10e10):
#   def GetButterfly(self,Emin=0,Emax=10e10):
#   def _HandleUnit(self,ener,flux,dflux = None):
#       D = (np.power(self.Emax,1.-self.Gamma)-np.power(self.Emin,1.-self.Gamma))
#     N = 2*len(ene)+1
# 
# Path: environ.py
# VERSION_4FGL = os.environ.get("VERSION_4FGL",'')
# 
# VERSION_3FGL = os.environ.get("VERSION_3FGL",'')
# 
# VERSION_2FGL = os.environ.get("VERSION_2FGL",'')
# 
# VERSION_1FHL = os.environ.get("VERSION_1FHL",'')
# 
# VERSION_2FHL = os.environ.get("VERSION_2FHL",'')
# 
# VERSION_3FHL = os.environ.get("VERSION_3FHL",'')
# 
# FERMI_CATALOG_DIR = os.environ.get('FERMI_CATALOG_DIR', '')


# Path: Catalog/ReadFermiCatalog.py
import pyfits,string,numpy
import Loggin
    import Coordinates.CoordHandler as CH
from Plot import PlotLibrary
from environ import VERSION_4FGL,VERSION_3FGL,VERSION_2FGL,VERSION_1FHL,VERSION_2FHL,VERSION_3FHL,FERMI_CATALOG_DIR
from math import *
    from astropy.coordinates import ICRS, Galactic, FK4, FK5 

  def _HandleEnergyUnit(self,ener):
      fac = 1
      if self.escale == "TeV":
          fac = 1e-6
      if self.escale == "GeV":
          fac = 1e-3
      return ener*fac

  def _HandleFluxUnit(self,flux):
      fac = 1
      if self.escale == "TeV":
          fac = 1e6
      if self.escale == "GeV":
          fac = 1e3
      return fac*flux



#Side functions
def calcAngSepDeg(ra0, dec0, ra1, dec1):
    '''Return the angular separation between two objects. Use the
    special case of the Vincenty formula that is accurate for all
    distances'''
    C = numpy.pi / 180
    d0 = C * dec0
    d1 = C * dec1
    r12 = C * (ra0 - ra1)
    cd0 = numpy.cos(d0)
    sd0 = numpy.sin(d0)
    cd1 = numpy.cos(d1)

    sd1 = numpy.sin(d1)