Exemplo n.º 1
0
    def loadEA(self, instrument = "VERITAS", **pars):

        '''                    - Instruments - 
        
        These are the currently avaialble instruments.

        'VERITAS': this is an array of IACTs located in Southern
        Arizona and sensitive from about 100 GeV to tens of TeV.  You
        can choose a variety of zenith angles (0 is pointing straight
        up) and noise levels (ie. night sky background), and expected
        source spectrum.  The default noise level is adequate for most
        fields and the default expected source spectrum (-4) is
        adequate for most sources at VHE.

        'HESS': This is an array of IACTs located in Nambia and
        sensitive from about 100 GeV to tens of TeV.  You can choose
        three zenith angles (20, 45 and 60).  The effective areas are
        from A&A 457, 899 (2006), Figure 13.  The threshold is set to
        150 GeV.

        'HAWC': This is a water Cherenkov experiment located in
        Mexico.  The effective areas are from APh 35, 6412 (2012),
        Figure 2.  You can choose from a high trigger rate (nHit > 70)
        or a low trigger rate (nHit > 30).  You can also choose from
        four zenith angle rages.

        'CTA': this is a future IACT observatory that will be an order
        of magnitude more sensitive then the current generation.  The
        Effective Area curve is from "Monte Carlo design studies for
        the Cherenkov Telescope Array", Bernlohr et
        al. arXiv:1210.3503, Figure 15 and assume the baseline/MPIK
        curve.  Note that this is for demonstration purposes only and
        there are no modifiers for zenith angle, noise level or
        anything else.  The safe energy range is hardcoded from 100
        GeV to 100 TeV and the threshold is set to 100 GeV.

        '''


        EAParamTemplates = {"VERITAS" : {"zenith":20, "azimuth":0, "noise":4.07},
                            "CTA" : {"zenith":0, "azimuth":0, "noise":0},
                            "HESS" : {"zenith":20, "azimuth":0, "noise":0},
                            "HAWC" : {"zenith":20, "azimuth":0, "noise":0}}
        EffectiveAreas = {"VERITAS": self.loadVERITASEA,
                          "CTA": self.loadCTAEA,
                          "HESS": self.loadHESSEA,
                          "HAWC": self.loadHAWCEA}

        try:
            checkParams(EAParamTemplates[instrument],pars, self.logger)
        except KeyError:
            self.logger.critical("Unsupported instrument.")
            return

        try:
            self.EASummary,self.EACurve,self.SensCurve,self.EAFile,self.EATable,self.crabRate = EffectiveAreas[instrument](**pars)
        except KeyError:
            self.logger.critical("Unsupported instrument.")
            return
Exemplo n.º 2
0
    def loadEA(self, instrument="VERITAS", **pars):
        '''                    - Instruments - 
        
        These are the currently avaialble instruments.

        'VERITAS': this is an array of IACTs located in Southern
        Arizona and sensitive from about 100 GeV to tens of TeV.  You
        can choose a variety of zenith angles (0 is pointing straight
        up) and noise levels (ie. night sky background), and expected
        source spectrum.  The default noise level is adequate for most
        fields and the default expected source spectrum (-4) is
        adequate for most sources at VHE.

        'HESS': This is an array of IACTs located in Nambia and
        sensitive from about 100 GeV to tens of TeV.  You can choose
        three zenith angles (20, 45 and 60).  The effective areas are
        from A&A 457, 899 (2006), Figure 13.  The threshold is set to
        150 GeV.

        'HAWC': This is a water Cherenkov experiment located in
        Mexico.  The effective areas are from APh 35, 6412 (2012),
        Figure 2.  You can choose from a high trigger rate (nHit > 70)
        or a low trigger rate (nHit > 30).  You can also choose from
        four zenith angle rages.

        'CTA': this is a future IACT observatory that will be an order
        of magnitude more sensitive then the current generation.  The
        Effective Area curve is from "Monte Carlo design studies for
        the Cherenkov Telescope Array", Bernlohr et
        al. arXiv:1210.3503, Figure 15 and assume the baseline/MPIK
        curve.  Note that this is for demonstration purposes only and
        there are no modifiers for zenith angle, noise level or
        anything else.  The safe energy range is hardcoded from 100
        GeV to 100 TeV and the threshold is set to 100 GeV.

        '''

        EAParamTemplates = {
            "VERITAS": {
                "zenith": 20,
                "azimuth": 0,
                "noise": 4.07
            },
            "CTA": {
                "zenith": 0,
                "azimuth": 0,
                "noise": 0
            },
            "HESS": {
                "zenith": 20,
                "azimuth": 0,
                "noise": 0
            },
            "HESS2": {
                "zenith": 0,
                "azimuth": 0,
                "noise": 0
            },
            "HAWC": {
                "zenith": 20
            }
        }
        EffectiveAreas = {
            "VERITAS": self.loadVERITASEA,
            "CTA": self.loadCTAEA,
            "HESS": self.loadHESSEA,
            "HESS2": self.loadHESS2EA,
            "HAWC": self.loadHAWCEA
        }

        try:
            checkParams(EAParamTemplates[instrument], pars, self.logger)
        except KeyError:
            self.logger.critical("Unsupported instrument.")
            return

        try:
            self.EASummary, self.EACurve, self.SensCurve, self.EAFile, self.EATable, self.crabRate = EffectiveAreas[
                instrument](**pars)
        except KeyError:
            self.logger.critical("Unsupported instrument.")
            return
Exemplo n.º 3
0
    def Spectrum(self,spectralModel, EnergyBins, **pars):

        '''                       - Spectral Functions - 
        
        The VOT code uses a spectrum (dN/dE) given an input array of
        energy bins (in GeV).  There are several available types
        avaialble and these are the only ones you can use to create a
        'custom' source.  The parameters given must match the
        parameters and units shown below.  Most of these functions are
        based on the functions in the Fermi LAT catalog except as
        noted.

        PowerLaw: a simple power law with normalization ('N0', cm^-2
        s^-1 GeV^-1), index ('index', negative), pivot energy ("E0",
        GeV).

        PowerLaw2: same as the PowerLaw but defined by the integral
        flux and not the differential flux.  Parameters are the
        integral flux ('N', cm^-2 s^-1 GeV^-1), index ('index',
        negative), lower energy limit ('E1', GeV) and upper energy
        limit ('E2', GeV).

        BrokenPowerLaw: two component power law with normalization
        ('N0', cm^-2 s^-1 GeV^-1), low energy spectral index
        ('index1', negative), high energy spectral index ('index2',
        negative) and break energy ('Eb', GeV).

        LogParabola: curving function used to model blazars with
        parameters Normalization ('N0', cm^-2 s^-1 GeV^-1), spectral
        index ('alpha', negative), index ('beta, negative) and break
        energy ('Eb', GeV).

        HESSExpCutoff: power law with a cutoff used by the HESS
        collaboration to model the Crab Nebula's spectrum.  The
        parameters are the normalization ('N0', cm^-2 s^-1 GeV^-1),
        index ('index', negative), pivot energy ('E0', GeV) and cutoff
        energy ('EC', GeV).

        Band: basic band function used to model GRBs.  The parameters
        are the normalization ('N0', cm^-2 s^-1 GeV^-1), alpha
        ('alpha', negative), beta ('beta', negative) and the peak
        energy ('Ep', GeV).

        '''

        spectralParameterTemplates = {"PowerLaw": {"N0":1e-9,"index":-2,"E0":700},
                                      "PowerLaw2": {"N":1e-6,"index":-2,"E1":1,"E2":100},
                                      "BrokenPowerLaw": {"N0":1e-9,"index1":-2,"index2":-1.5,"Eb":700},
                                      "LogParabola": {"N0":1e-9,"alpha":-1.0,"beta":-2.0,"Eb":700},
                                      "HESSExpCutoff": {"N0":1e-9, "index":-2, "E0":1000, "EC":14000},
                                      "Band": {"N0":1e-9, "alpha":-1.5,"beta":-2.5,"Ep":0.001},
                                      }
    
        if (spectralModel == "PowerLaw2"):
            '''Assumes a 1GeV Decorrelation energy and energies in GeV.'''
            pars["E0"] = 1.0
            X1 = pars["E1"]/pars["E0"]
            X2 = pars["E2"]/pars["E0"]
            pars["N0"] = (pars["N"]*(1 + pars["index"])/pars["E0"])/(X2**(1 + pars["index"]) - X1**(1 + pars["index"]))
            spectralModel = "PowerLaw"
            self.logger.warn("Calculated normalization: " + str(pars["N0"]) + " s^-1 cm^-2 GeV^-1")

        spectralFunction = {"PowerLaw": lambda x: pars["N0"]*((x/pars["E0"])**pars["index"]),
                            "PowerLaw2": lambda x: ((pars["index"] + 1)*pars["N"]*x**pars["index"])/\
                                (pars["E2"]**(pars["index"]+1) - pars["E1"]**(pars["index"]+1)),
                            "BrokenPowerLaw": lambda x: x < pars["Eb"] and pars["N0"]*((x/pars["Eb"])**pars["index1"])\
                                or pars["N0"]*((x/pars["Eb"])**pars["index2"]),
                            "LogParabola": lambda x: pars["N0"]*((x/pars["Eb"])**(pars["alpha"]+pars["beta"]*np.log(x/pars["Eb"]))),
                            "HESSExpCutoff":lambda x: pars["N0"]*((x/pars["E0"])**pars["index"])*np.exp(-x/pars["EC"]),
                            "Band": lambda x: x < pars["Ep"]*(pars["alpha"]-pars["beta"])/(pars["alpha"]+2)\
                                and (x/0.1)**pars["alpha"]*np.exp(-(x/pars["Ep"])*(pars["alpha"]+2))\
                                or (x/0.1)**pars["beta"]*((pars["Ep"]/0.1)*(pars["alpha"]-pars["beta"])/(pars["alpha"]+2))**(pars["alpha"]-pars["beta"])*np.exp(pars["beta"]-pars["alpha"]),
                            "Band1": lambda x: (x/0.1)**pars["beta"]*((pars["Ep"]/0.1)*(pars["alpha"]-pars["beta"])/(pars["alpha"]+2))**(pars["alpha"]-pars["beta"])*np.exp(pars["beta"]-pars["alpha"]),
                            }
    
        try:
            checkParams(spectralParameterTemplates[spectralModel],pars, self.logger)
        except KeyError:
            return

        dNdE = []

        try:
            for energy in EnergyBins:
                dNdE.append(spectralFunction[spectralModel](energy))
            return dNdE
        except KeyError:
            self.logger.critical("No such model.")
Exemplo n.º 4
0
    def Spectrum(self, spectralModel, EnergyBins, **pars):
        '''                       - Spectral Functions - 
        
        The VOT code uses a spectrum (dN/dE) given an input array of
        energy bins (in GeV).  There are several available types
        avaialble and these are the only ones you can use to create a
        'custom' source.  The parameters given must match the
        parameters and units shown below.  Most of these functions are
        based on the functions in the Fermi LAT catalog except as
        noted.

        PowerLaw: a simple power law with normalization ('N0', cm^-2
        s^-1 GeV^-1), index ('index', negative), pivot energy ("E0",
        GeV).

        PowerLaw2: same as the PowerLaw but defined by the integral
        flux and not the differential flux.  Parameters are the
        integral flux ('N', cm^-2 s^-1 GeV^-1), index ('index',
        negative), lower energy limit ('E1', GeV) and upper energy
        limit ('E2', GeV).

        BrokenPowerLaw: two component power law with normalization
        ('N0', cm^-2 s^-1 GeV^-1), low energy spectral index
        ('index1', negative), high energy spectral index ('index2',
        negative) and break energy ('Eb', GeV).

        LogParabola: curving function used to model blazars with
        parameters Normalization ('N0', cm^-2 s^-1 GeV^-1), spectral
        index ('alpha', negative), index ('beta, negative) and break
        energy ('Eb', GeV).

        HESSExpCutoff: power law with a cutoff used by the HESS
        collaboration to model the Crab Nebula's spectrum.  The
        parameters are the normalization ('N0', cm^-2 s^-1 GeV^-1),
        index ('index', negative), pivot energy ('E0', GeV) and cutoff
        energy ('EC', GeV).

        Band: basic band function used to model GRBs.  The parameters
        are the normalization ('N0', cm^-2 s^-1 GeV^-1), alpha
        ('alpha', negative), beta ('beta', negative) and the peak
        energy ('Ep', GeV).

        '''

        spectralParameterTemplates = {
            "PowerLaw": {
                "N0": 1e-9,
                "index": -2,
                "E0": 700
            },
            "PowerLaw2": {
                "N": 1e-6,
                "index": -2,
                "E1": 1,
                "E2": 100
            },
            "BrokenPowerLaw": {
                "N0": 1e-9,
                "index1": -2,
                "index2": -1.5,
                "Eb": 700
            },
            "LogParabola": {
                "N0": 1e-9,
                "alpha": -1.0,
                "beta": -2.0,
                "Eb": 700
            },
            "HESSExpCutoff": {
                "N0": 1e-9,
                "index": -2,
                "E0": 1000,
                "EC": 14000
            },
            "Band": {
                "N0": 1e-9,
                "alpha": -1.5,
                "beta": -2.5,
                "Ep": 0.001
            },
        }

        if (spectralModel == "PowerLaw2"):
            '''Assumes a 1GeV Decorrelation energy and energies in GeV.'''
            pars["E0"] = 1.0
            X1 = pars["E1"] / pars["E0"]
            X2 = pars["E2"] / pars["E0"]
            pars["N0"] = (pars["N"] * (1 + pars["index"]) / pars["E0"]) / (
                X2**(1 + pars["index"]) - X1**(1 + pars["index"]))
            spectralModel = "PowerLaw"
            self.logger.info("Calculated normalization: " + str(pars["N0"]) +
                             " s^-1 cm^-2 GeV^-1")

        spectralFunction = {"PowerLaw": lambda x: pars["N0"]*((x/pars["E0"])**pars["index"]),
                            "PowerLaw2": lambda x: ((pars["index"] + 1)*pars["N"]*x**pars["index"])/\
                                (pars["E2"]**(pars["index"]+1) - pars["E1"]**(pars["index"]+1)),
                            "BrokenPowerLaw": lambda x: x < pars["Eb"] and pars["N0"]*((x/pars["Eb"])**pars["index1"])\
                                or pars["N0"]*((x/pars["Eb"])**pars["index2"]),
                            "LogParabola": lambda x: pars["N0"]*((x/pars["Eb"])**(pars["alpha"]+pars["beta"]*np.log(x/pars["Eb"]))),
                            "HESSExpCutoff":lambda x: pars["N0"]*((x/pars["E0"])**pars["index"])*np.exp(-x/pars["EC"]),
                            "Band": lambda x: x < pars["Ep"]*(pars["alpha"]-pars["beta"])/(pars["alpha"]+2)\
                                and (x/0.1)**pars["alpha"]*np.exp(-(x/pars["Ep"])*(pars["alpha"]+2))\
                                or (x/0.1)**pars["beta"]*((pars["Ep"]/0.1)*(pars["alpha"]-pars["beta"])/(pars["alpha"]+2))**(pars["alpha"]-pars["beta"])*np.exp(pars["beta"]-pars["alpha"]),
                            "Band1": lambda x: (x/0.1)**pars["beta"]*((pars["Ep"]/0.1)*(pars["alpha"]-pars["beta"])/(pars["alpha"]+2))**(pars["alpha"]-pars["beta"])*np.exp(pars["beta"]-pars["alpha"]),
                            }

        try:
            checkParams(spectralParameterTemplates[spectralModel], pars,
                        self.logger)
        except KeyError:
            return

        dNdE = []

        try:
            for energy in EnergyBins:
                dNdE.append(spectralFunction[spectralModel](energy))
            return dNdE
        except KeyError:
            self.logger.critical("No such model.")