Example #1
0
 def __init__(self, name='normshell2d'):
     self.xpos = Parameter(name, 'xpos', 0)
     self.ypos = Parameter(name, 'ypos', 0)
     self.ampl = Parameter(name, 'ampl', 1) # misnomer ... this is really the integral
     self.r0 = Parameter(name, 'r0', 1, 0)
     self.width = Parameter(name, 'width', 0.1, 0)
     ArithmeticModel.__init__(self, name, (self.xpos, self.ypos, self.ampl, self.r0, self.width))
Example #2
0
 def __init__(self, name='mygauss'):
     self.sigma = Parameter(name, 'sigma', 10, min=0, max=10)
     self.pos = Parameter(name, 'pos', 0, min=-10, max=10)
     self.ampl = Parameter(name, 'ampl', 5)
     self.counter = 0
     ArithmeticModel.__init__(self, name,
                              (self.sigma, self.pos, self.ampl))
Example #3
0
 def __init__(self, name='delta2dint'):
     # Gauss source parameters
     self.xpos = Parameter(name, 'xpos', 0)  # p[0]
     self.ypos = Parameter(name, 'ypos', 0)  # p[1]
     self.ampl = Parameter(name, 'ampl', 1)  # p[2]
     self.shape = sau.get_data().shape
     ArithmeticModel.__init__(self, name, (self.xpos, self.ypos, self.ampl))
Example #4
0
 def __init__(self, name='disk2d'):
     self.xpos = Parameter(name, 'xpos', 0)  # p[0]
     self.ypos = Parameter(name, 'ypos', 0)  # p[1]
     self.ampl = Parameter(name, 'ampl', 1)  # p[2]
     self.r0 = Parameter(name, 'r0', 1, 0)  # p[3]
     ArithmeticModel.__init__(self, name,
                              (self.xpos, self.ypos, self.ampl, self.r0))
Example #5
0
    def __init__(self, wcs, name='UniformGaussianPlane'):
        """ Default initialization 
       """
        self.__name__ = name
        self.wcs = pywcs.WCS()
        self.binsize = 1.0
        self.coordsys = "galactic"  # default
        #self.ampl = Parameter(name,'ampl',1.0,0.0,1e6)
        #self.thick = Parameter(name,'thick',0.4,0.,1.0)
        #self.ypos = Parameter(name,'ypos',0.0,-1.5,1.5)
        """
       self.ampl = Parameter(name,'ampl',1.0,0.0,1e6)
       self.thick = Parameter(name,'thick',15,0.,50)
       self.ypos = Parameter(name,'ypos',200,125,275)
       """
        #import IPython; IPython.embed()
        self.binsize_deg = np.abs(wcs.wcs.cdelt[0])
        res = wcs.wcs_world2pix(np.array([0., 0], ndmin=2), 1)
        xpix, ypix = res[0]
        #self.binsize_deg=0.02
        #ypix=202.81000059
        self.ampl = Parameter(name, 'ampl', 1.0, 0.0, 1e6)
        self.thick = Parameter(name, 'thick', 0.3 / self.binsize_deg, 0.,
                               1 / self.binsize_deg)
        self.ypos = Parameter(name, 'ypos', ypix,
                              ypix - (1.5 / self.binsize_deg),
                              ypix + (1.5 / self.binsize_deg))

        ArithmeticModel.__init__(self, name,
                                 (self.ypos, self.thick, self.ampl))
Example #6
0
    def __init__(self, name='normal'):

        self.sigma = Parameter(name, 'sigma', 1., alwaysfrozen=True)
        self.x0 = Parameter(name, 'x0', 1., alwaysfrozen=True)
        self.norm = Parameter(name, 'norm', 1., alwaysfrozen=True)

        ArithmeticModel.__init__(self, name, (self.sigma, self.x0, self.norm))
  def __init__(self, name='simple_overfilling'):
	  self.C0 = Parameter(name, 'C0', c0, min=0)
	  self.C1 = Parameter(name, 'C1', 1, min=0)
	  self.C2 = Parameter(name, 'C2', 1, min=0)
	  # self.C3 = Parameter(name, 'C3', 0)
	  # ArithmeticModel.__init__(self, name, (self.C0, self.C1, self.C2, self.C3))
          ArithmeticModel.__init__(self, name, (self.C0, self.C1, self.C2))
Example #8
0
    def __init__(self, name='normal'):

        self.sigma = Parameter(name, 'sigma', 1., alwaysfrozen=True)
        self.x0 = Parameter(name, 'x0', 1., alwaysfrozen=True)
        self.norm = Parameter(name, 'norm', 1., alwaysfrozen=True)

        ArithmeticModel.__init__(self, name, (self.sigma, self.x0, self.norm))
 def __init__(self, name='simple_overfilling'):
      self.amplitude = Parameter(name, 'amplitude', c0, min=0) # p[0], calibration constant
      self.Ck = Parameter(name,'Ck', 1, min=0) # p[1], telescope efficiency parameter
      # self.b = Parameter(name, 'b', 2, min=1, max=3) # p[2], range factor
      # self.Cb = Parameter(name, 'Cb', 1) # background noise
      # ArithmeticModel.__init__(self, name, (self.amplitude, self.Ck, self.Cb))
      ArithmeticModel.__init__(self, name, (self.amplitude, self.Ck))
Example #10
0
    def __init__(self, name='myplexpcutoff'):
        self.Eo = Parameter(name, 'Eo', 1, frozen=True, units='keV')  # p[0] Normalized at 1 TeV by default
        self.beta = Parameter(name, 'beta', 1e-1, min=1e-3, max=10, units='1/TeV')  # p[1]
        self.gamma = Parameter(name, 'gamma', 2, min=-1, max=5)  # p[2]
        self.No = Parameter(name, 'No', 1e-11, min=1e-15, max=1e-5, units='1/cm^2/s/TeV')  # p[3]

        ArithmeticModel.__init__(self, name, (self.Eo, self.beta, self.gamma, self.No))
Example #11
0
    def __init__(self, coord, energies, name='cube-model', use_psf=True, exposure=None, psf=None, spatial_model=None,
                 spectral_model=None, select_region=False, index_selected_region=None):
        from scipy import signal
        self.spatial_model = spatial_model
        self.spectral_model = spectral_model
        self.use_psf = use_psf
        self.exposure = exposure
        self.psf = psf
        self._fftconvolve = signal.fftconvolve
        xx = coord.data.lon.degree
        yy = coord.data.lat.degree
        self.xx_lo = xx[0:-1, 1:]
        self.xx_hi = xx[0:-1, 0:-1]
        self.yy_lo = yy[0:-1, 0:-1]
        self.yy_hi = yy[1:, 0:-1]
        self.ee_lo = energies[:-1]
        self.ee_hi = energies[1:]
        self.select_region = select_region
        self.index_selected_region = index_selected_region

        # Fix spectral ampl parameter
        spectral_model.ampl = 1
        spectral_model.ampl.freeze()

        pars = []
        for _ in spatial_model.pars + spectral_model.pars:
            setattr(self, _.name, _)
            pars.append(_)

        self._spatial_pars = slice(0, len(spatial_model.pars))
        self._spectral_pars = slice(len(spatial_model.pars), len(pars))
        ArithmeticModel.__init__(self, name, pars)
Example #12
0
 def __init__(self, name='shell2d'):
     self.xpos = Parameter(name, 'xpos', 0)  # p[0]
     self.ypos = Parameter(name, 'ypos', 0)  # p[1]
     self.ampl = Parameter(name, 'ampl', 1)  # p[2]
     self.r0 = Parameter(name, 'r0', 1, 0)  # p[3]
     self.width = Parameter(name, 'width', 0.1, 0)
     ArithmeticModel.__init__(
         self, name, (self.xpos, self.ypos, self.ampl, self.r0, self.width))
Example #13
0
 def __init__(self, name='normdisk2d'):
     self.xpos = Parameter(name, 'xpos', 0)
     self.ypos = Parameter(name, 'ypos', 0)
     self.ampl = Parameter(name, 'ampl',
                           1)  # misnomer ... this is really the integral
     self.r0 = Parameter(name, 'r0', 1, 0)
     ArithmeticModel.__init__(self, name,
                              (self.xpos, self.ypos, self.ampl, self.r0))
Example #14
0
 def __init__(self, name='normgauss2dint'):
     # Gauss source parameters
     self.xpos = Parameter(name, 'xpos', 0)  # p[0]
     self.ypos = Parameter(name, 'ypos', 0)  # p[1]
     self.ampl = Parameter(name, 'ampl', 1)  # p[2]
     self.fwhm = Parameter(name, 'fwhm', 1)  # p[3]
     ArithmeticModel.__init__(self, name,
                              (self.xpos, self.ypos, self.ampl, self.fwhm))
Example #15
0
 def __init__(self, name='simple_overfilling'):
      # p[0]
      self.c0= Parameter(name, 'c1', 1) 
      #p[1]
      self.c1 = Parameter(name, 'c2', 1)
      #p[2]
      self.c2=Parameter(name,'c3',1) #extra parameter
      ArithmeticModel.__init__(self, name, (self.c0,self.c1,self.c2))
Example #16
0
  def __init__(self, name='simple_overfilling'):
       # p[0]
       self.amplitude= Parameter(name, 'amplitude', 1)
       self.k=Parameter(name,'k',1)
       # p[2]
       #self.Hm = Parameter(name, 'Hm', 1)

       ArithmeticModel.__init__(self, name, (self.amplitude,self.k))
  def __init__(self, name='growth_modelling'):
	  self.C0 = Parameter(name, 'C0', c0)
	  self.C1 = Parameter(name, 'C1', 0)
	  self.C2 = Parameter(name, 'C2', 0)
	  self.C3 = Parameter(name, 'C3', 0)
       	  self.C4 = Parameter(name, 'C4', 0)
	  self.b = Parameter(name, 'b', b0, min=0)
	  ArithmeticModel.__init__(self, name, (self.C0, self.C1, self.C2,
                                                self.C3, self.C4, self.b))
Example #18
0
 def __init__(self, name='ecpl'):
     self.gamma = Parameter(name, 'gamma', 2, min=-10, max=10)
     self.ref = Parameter(name, 'ref', 1, frozen=True)
     self.ampl = Parameter(name, 'ampl', 1, min=0)
     self.cutoff = Parameter(name, 'cutoff', 1, min=0, units='1/TeV')
     ArithmeticModel.__init__(self, name, (self.gamma, self.ref, self.ampl,
                                           self.cutoff))
     self._use_caching = True
     self.cache = 10
Example #19
0
 def __init__(self, name='hesssource2d'):
     # Gauss source parameters
     self.xpos = Parameter(name, 'xpos', 0)  # p[0]
     self.ypos = Parameter(name, 'ypos', 0)  # p[1]
     self.ampl = Parameter(name, 'ampl', 1)  # p[2]
     self.fwhm = Parameter(name, 'fwhm', 1)  # p[3]
     self.loadpsf('psf.json')
     ArithmeticModel.__init__(self, name,
                              (self.xpos, self.ypos, self.ampl, self.fwhm))
Example #20
0
    def __init__(self, gp_model):
        self.gp_model = gp_model
        self.parts = (self, )
        modelname = 'GP' + gp_model.__class__.__name__

        sherpa_pars = []
        for par in gp_model.parameters.parameters:
            sherpa_pars.append(par.to_sherpa(modelname=modelname))

        ArithmeticModel.__init__(self, modelname, sherpa_pars)
Example #21
0
    def __init__(self, gp_model):
        self.gp_model = gp_model
        self.parts = (self,)
        modelname = 'GP' + gp_model.__class__.__name__

        sherpa_pars = []
        for par in gp_model.parameters.parameters:
            sherpa_pars.append(par.to_sherpa())

        ArithmeticModel.__init__(self, modelname, sherpa_pars)
  def __init__(self, name='DWEL_K_d_GM'):
	  # self.C1 = Parameter(name, 'C1', 0)
	  # self.C2 = Parameter(name, 'C2', 0)
          # self.C3 = Parameter(name, 'C3', 0)
          # self.C4 = Parameter(name, 'C4', 0)
	  self.C1 = Parameter(name, 'C1', 2.33)
	  self.C2 = Parameter(name, 'C2', 0.60)
          self.C3 = Parameter(name, 'C3', 0.75)
          self.C4 = Parameter(name, 'C4', 7.13)
	  ArithmeticModel.__init__(self, name, (self.C1, self.C2, self.C3,
                                                self.C4))
Example #23
0
 def __init__(self, name='normgauss2dint'):
     # Gauss source parameters
     self.wcs = WCS.WCS()
     self.coordsys = "galactic"  # default
     self.binsize = 1.0
     self.xpos = Parameter(name, 'xpos', 0)  # p[0]
     self.ypos = Parameter(name, 'ypos', 0)  # p[1]
     self.ampl = Parameter(name, 'ampl', 1)  # p[2]
     self.fwhm = Parameter(name, 'fwhm', 1, min=0)  # p[3]
     self.shape = None
     self.n_ebins = None
     ArithmeticModel.__init__(self, name, (self.xpos, self.ypos, self.ampl, self.fwhm))
Example #24
0
 def __init__(self, name='normgauss2dint'):
     # Gauss source parameters
     self.wcs = WCS.WCS()
     self.coordsys = "galactic"  # default
     self.binsize = 1.0
     self.xpos = Parameter(name, 'xpos', 0)  # p[0]
     self.ypos = Parameter(name, 'ypos', 0)  # p[1]
     self.ampl = Parameter(name, 'ampl', 1)  # p[2]
     self.fwhm = Parameter(name, 'fwhm', 1, min=0)  # p[3]
     self.shape = None
     self.n_ebins = None
     ArithmeticModel.__init__(self, name,
                              (self.xpos, self.ypos, self.ampl, self.fwhm))
Example #25
0
    def __init__(self,
                 coord,
                 energies,
                 name='cube-model',
                 use_psf=True,
                 exposure=None,
                 psf=None,
                 spatial_model=None,
                 spectral_model=None,
                 edisp=None,
                 select_region=False,
                 index_selected_region=None):
        from scipy import signal
        self.spatial_model = spatial_model
        self.spectral_model = spectral_model
        xx = coord.data.lon.degree
        yy = coord.data.lat.degree
        self.xx_lo = xx[0:-1, 1:]
        self.xx_hi = xx[0:-1, 0:-1]
        self.yy_lo = yy[0:-1, 0:-1]
        self.yy_hi = yy[1:, 0:-1]
        self.ee_lo = energies[:-1]
        self.ee_hi = energies[1:]
        self.use_psf = use_psf
        self.exposure = exposure
        self.psf = psf
        self.edisp = edisp
        self.true_energy = EnergyBounds(self.exposure.energies("edges"))
        self.dim_x, self.dim_y, self.dim_Ereco, self.dim_Etrue = len(self.xx_lo[:, 0]), len(self.xx_lo[0, :]), \
                                                                 len(self.ee_lo), len(self.true_energy) - 1
        self._fftconvolve = signal.fftconvolve
        # The shape of the counts cube in (Ereco,x,y)
        self.shape_data = (self.dim_Ereco, self.dim_x, self.dim_y)
        # Array that will store the result after multipliying by the energy resolution in (x,y,Etrue,Ereco)
        self.convolve_edisp = np.zeros(
            (self.dim_x, self.dim_y, self.dim_Etrue, self.dim_Ereco))
        self.select_region = select_region
        self.index_selected_region = index_selected_region

        # Fix spectral ampl parameter
        spectral_model.ampl = 1
        spectral_model.ampl.freeze()

        pars = []
        for _ in spatial_model.pars + spectral_model.pars:
            setattr(self, _.name, _)
            pars.append(_)

        self._spatial_pars = slice(0, len(spatial_model.pars))
        self._spectral_pars = slice(len(spatial_model.pars), len(pars))
        ArithmeticModel.__init__(self, name, pars)
Example #26
0
    def __init__(self, name='cube-model', spatial_model=None, spectral_model=None):
        self.spatial_model = spatial_model
        self.spectral_model = spectral_model

        # Fix spectral ampl parameter
        spectral_model.ampl = 1
        spectral_model.ampl.freeze()

        pars = []
        for _ in spatial_model.pars + spectral_model.pars:
            setattr(self, _.name, _)
            pars.append(_)

        self._spatial_pars = slice(0, len(spatial_model.pars))
        self._spectral_pars = slice(len(spatial_model.pars), len(pars))
        ArithmeticModel.__init__(self, name, pars)
Example #27
0
    def __init__(self, fit):
        self.fit = fit
        
        sherpa_name = 'sherpa_model'
        par_list = list()
        for par in self.fit.model.parameters.parameters:
            sherpa_par = par.to_sherpa(modelname='source')
            #setattr(self, name, sherpa_par)
            par_list.append(sherpa_par)

        if fit.stat != 'wstat' and self.fit.background_model is not None:
            for par in self.fit.background_model.parameters.parameters:
                sherpa_par = par.to_sherpa(modelname='background')
                #setattr(self, name, sherpa_par)
                par_list.append(sherpa_par)

        ArithmeticModel.__init__(self, sherpa_name, par_list)
        self._use_caching = True
        self.cache = 10
Example #28
0
    def __init__(self,
                 coord,
                 energies,
                 name='cube-model',
                 use_psf=True,
                 exposure=None,
                 psf=None,
                 spatial_model=None,
                 spectral_model=None,
                 select_region=False,
                 index_selected_region=None):
        from scipy import signal
        self.spatial_model = spatial_model
        self.spectral_model = spectral_model
        self.use_psf = use_psf
        self.exposure = exposure
        self.psf = psf
        self._fftconvolve = signal.fftconvolve
        xx = coord.data.lon.degree
        yy = coord.data.lat.degree
        self.xx_lo = xx[0:-1, 1:]
        self.xx_hi = xx[0:-1, 0:-1]
        self.yy_lo = yy[0:-1, 0:-1]
        self.yy_hi = yy[1:, 0:-1]
        self.ee_lo = energies[:-1]
        self.ee_hi = energies[1:]
        self.select_region = select_region
        self.index_selected_region = index_selected_region

        # Fix spectral ampl parameter
        spectral_model.ampl = 1
        spectral_model.ampl.freeze()

        pars = []
        for _ in spatial_model.pars + spectral_model.pars:
            setattr(self, _.name, _)
            pars.append(_)

        self._spatial_pars = slice(0, len(spatial_model.pars))
        self._spectral_pars = slice(len(spatial_model.pars), len(pars))
        ArithmeticModel.__init__(self, name, pars)
Example #29
0
    def __init__(self, coord, energies, name='cube-model', use_psf=True, exposure=None, psf=None, spatial_model=None,
                 spectral_model=None, edisp=None, select_region=False, index_selected_region=None):
        from scipy import signal
        self.spatial_model = spatial_model
        self.spectral_model = spectral_model
        xx = coord.data.lon.degree
        yy = coord.data.lat.degree
        self.xx_lo = xx[0:-1, 1:]
        self.xx_hi = xx[0:-1, 0:-1]
        self.yy_lo = yy[0:-1, 0:-1]
        self.yy_hi = yy[1:, 0:-1]
        self.ee_lo = energies[:-1]
        self.ee_hi = energies[1:]
        self.use_psf = use_psf
        self.exposure = exposure
        self.psf = psf
        self.edisp = edisp
        self.true_energy = EnergyBounds(self.exposure.energies("edges"))
        self.dim_x, self.dim_y, self.dim_Ereco, self.dim_Etrue = len(self.xx_lo[:, 0]), len(self.xx_lo[0, :]), \
                                                                 len(self.ee_lo), len(self.true_energy) - 1
        self._fftconvolve = signal.fftconvolve
        # The shape of the counts cube in (Ereco,x,y)
        self.shape_data = (self.dim_Ereco, self.dim_x, self.dim_y)
        # Array that will store the result after multipliying by the energy resolution in (x,y,Etrue,Ereco)
        self.convolve_edisp = np.zeros(
            (self.dim_x, self.dim_y, self.dim_Etrue, self.dim_Ereco))
        self.select_region = select_region
        self.index_selected_region = index_selected_region

        # Fix spectral ampl parameter
        spectral_model.ampl = 1
        spectral_model.ampl.freeze()

        pars = []
        for _ in spatial_model.pars + spectral_model.pars:
            setattr(self, _.name, _)
            pars.append(_)

        self._spatial_pars = slice(0, len(spatial_model.pars))
        self._spectral_pars = slice(len(spatial_model.pars), len(pars))
        ArithmeticModel.__init__(self, name, pars)
Example #30
0
    def __init__(self, name='proton'):
        # First precompute some quantities
        self.Ep_min = 1e-1  # TeV
        self.Ep_max = 1e5  # TeV
        self.nbins = 300
        self.lEp_min = np.log10(self.Ep_min)
        self.lEp_max = np.log10(self.Ep_max)
        self.Ep = np.logspace(self.lEp_min, self.lEp_max, self.nbins)
        self.lbsize = (self.lEp_max - self.Ep_min) / self.nbins
        self.Fgam = None
        self.EG = None
        self.EP = None
        self.ncalc = 0

        # Instantiate parameters
        self.Eo = Parameter(name, 'Eo', 10, frozen=True, units='TeV')  # p[0] Normalized at 10 TeV by default
        self.beta = Parameter(name, 'beta', 1., min=1e-3, max=1e4, units='1/PeV')  # p[1]
        self.gamma = Parameter(name, 'gamma', 2.2, min=-1, max=5)  # p[2]
        self.ampl = Parameter(name, 'ampl', 1e-11, min=1e-15, max=1e15, units='1/cm^2/s/TeV')  # p[3]
        self.Einf = Parameter(name, 'Einf', 1, frozen=True, units='TeV')  # p[4] 1 TeV by default
        self.Esup = Parameter(name, 'Esup', 100, frozen=True, units='TeV')  # p[5] 100 TeV by default

        ArithmeticModel.__init__(self, name, (self.Eo, self.beta, self.gamma, self.ampl, self.Einf, self.Esup))
Example #31
0
  def __init__(self, name='simple_overfilling'):
	  self.C0 = Parameter(name, 'C0', 1, min=1)
	  self.C1 = Parameter(name, 'C1', 1, min=1)
	  self.C2 = Parameter(name, 'C2', 1, min=0)
	  self.b = Parameter(name, 'b', 2, min=1, max=3)
	  ArithmeticModel.__init__(self, name, (self.C0, self.C1, self.C2, self.b))
Example #32
0
    def __init__(self, name='usermodel'):
        self.param1 = Parameter(name, 'param1', 1, min=0, max=100)
        self.param2 = Parameter(name, 'param2', 1, min=-100, max=100)

        ArithmeticModel.__init__(self, name, (self.param1, self.param2))
Example #33
0
 def __init__(self, name='myexp'):
     self.A = Parameter(name, 'A', 1)
     self.mylambda = Parameter(name, 'mylambda', 2)
     self.b = Parameter(name, 'b', 3)
     self.counter = 0
     ArithmeticModel.__init__(self, name, (self.A, self.mylambda, self.b))
  def __init__(self, name='DWEL_K_d'):
	  self.C1 = Parameter(name, 'C1', 3.96, min=0)
	  self.C2 = Parameter(name, 'C2', 2.614, min=0)
# values larger than one
	  ArithmeticModel.__init__(self, name, (self.C1, self.C2))
Example #35
0
 def __init__(self, name):
     self.has_25 = Parameter(name, "has_25", 0, min=0, max=1)
     ArithmeticModel.__init__(self, name, (self.has_25,))
Example #36
0
    def __init__(self, name="usermodel"):
        self.param1 = Parameter(name, "param1", 1, min=0, max=100)
        self.param2 = Parameter(name, "param2", 1, min=-100, max=100)

        ArithmeticModel.__init__(self, name, (self.param1, self.param2))
Example #37
0
 def __init__(self, name):
     self.has_25 = Parameter(name, "has_25", 0, min=0, max=1)
     ArithmeticModel.__init__(self, name, (self.has_25, ))
  def __init__(self, name='EVI_K_d'):
	  self.C1 = Parameter(name, 'C1', 1, min=1)
# values larger than one
	  ArithmeticModel.__init__(self, name, (self.C1))
Example #39
0
 def __init__(self, name='myconst1d'):
     self.c0 = Parameter(name, 'c0', 3.1)
     self.counter = 0
     ArithmeticModel.__init__(self, name, (self.c0, ))
Example #40
0
    def __init__(self, name='usermodel'):
        self.param1 = Parameter(name, 'param1', 1, min=0, max=100)
        self.param2 = Parameter(name, 'param2', 1, min=-100, max=100)

        ArithmeticModel.__init__(self, name, (self.param1,
                                              self.param2))