Manage the effective area calculation

class EffectiveArea[source]

EffectiveArea(irf:IRF to use='P8R2_SOURCE_V6', file_path:folder to find the AEFF file=None, CALDB:path to override environment variable=None, use_phidep:use azmithual dependence for effective area=False)

manage the effective area calculation from a CALDB FITS file

Must specify either a file_path, or a value for CALDB, or that the CALDB environment varable is set

EffectiveArea.__call__[source]

EffectiveArea.__call__(e, c, phi=None, event_class=-1, bilinear=True)

Return bilinear (or nearest-neighbour) interpolation.

Input: e -- bin energy; potentially array c -- bin cos(theta); potentially array

NB -- if e and c are both arrays, they must be of the same size; in other words, no outer product is taken

Test/demo

Simple creation, evaluation

    def tabulate(self, ctstep=0.05,  logestep=0.25, ctmin=0.4):
        """
        Create a table in bins of front/back, log10e, cos theta

        - ctstep [0.05] step size from ctmin [0.4] to 1
        - logestep [0.25] log10 energy step from 2 (100 MeV) to 6 (1 TeV)
        """

        binvals = lambda a,b,d: np.arange(a+d/2, b, d)
    
        ctvals = binvals(ctmin, 1.0, ctstep)
        ee = np.power(10, binvals(2,6, logestep))
        A = np.zeros( (2, len(ee), len(ctvals)) )
        for i, ct in enumerate(ctvals):
            f,b =  self(ee, ct)
            A[0,:,i] = f
            A[1,:,i] = b
        return A