Exemple #1
0
def survey_single():
    """
    Creates a single observation survey for test purposes.
    """
    # Allocate observation container
    obs = gammalib.GObservations()
    
    # Set single pointing at galactic centre
    pntdir = gammalib.GSkyDir()
    pntdir.lb_deg(0.0, 0.0)
    run = obsutils.set_obs(pntdir)
    obs.append(run)
    
    # Define single point source with Crab flux at galactic centre
    center = gammalib.GSkyDir()
    center.lb_deg(0.0, 0.0)
    point_spatial  = gammalib.GModelSpatialPointSource(center)
    point_spectrum = crab_spec()
    point          = gammalib.GModelSky(point_spatial, point_spectrum)
    point.name('GC source')
    
    # Create model container
    models = gammalib.GModels()
    models.append(point)
    obs.models(models)
    
    # Return observation container
    return obs
Exemple #2
0
    def set_obs(self, lpnt=0.0, bpnt=0.0, emin=0.1, emax=100.0):
        """
        Returns an observation container.
        
        Keywords:
         lpnt - Galactic longitude of pointing [deg] (default: 0.0)
         bpnt - Galactic latitude of pointing [deg] (default: 0.0)
         emin - Minimum energy [TeV] (default: 0.1)
         emax - Maximum energy [TeV] (default: 100.0)
        """
        # If an observation was provided on input then load it from XML file
        filename = self["inobs"].filename()
        if filename != "NONE" and filename != "":
            obs = self.get_observations()

        # ... otherwise allocate a single observation
        else:

            # Read relevant user parameters
            caldb    = self["caldb"].string()
            irf      = self["irf"].string()
            deadc    = self["deadc"].real()
            duration = self["duration"].real()
            rad      = self["rad"].real()

            # Allocate observation container
            obs = gammalib.GObservations()
    
            # Set single pointing
            pntdir = gammalib.GSkyDir()
            pntdir.lb_deg(lpnt, bpnt)
        
            # Create CTA observation
            run = obsutils.set_obs(pntdir, caldb=caldb, irf=irf, \
                                   duration=duration, deadc=deadc, \
                                   emin=emin, emax=emax, rad=rad)
        
            # Append observation to container
            obs.append(run)

            # Set source position
            offset     = self["offset"].real()
            pntdir.lb_deg(lpnt, bpnt+offset)
            self.m_ra  = pntdir.ra_deg()
            self.m_dec = pntdir.dec_deg()
    
        # Return observation container
        return obs
Exemple #3
0
def survey_gplane(lrange=10, lstep=2):
    """
    Creates a single observation survey for test purposes.
    
    Keywords:
     lrange - Longitude range (integer deg)
     lstep  - Longitude step size (integer deg)
    """
    # Allocate observation container
    obs = gammalib.GObservations()
    
    # Loop over longitudes
    for l in range(-lrange,lrange+lstep,lstep):
        
        # Set pointing
        pntdir = gammalib.GSkyDir()
        pntdir.lb_deg(l, 0.0)
        run = obsutils.set_obs(pntdir)
        run.id(str(l))
        obs.append(run)
    
    # Define single point source with Crab flux at galactic centre
    center = gammalib.GSkyDir()
    center.lb_deg(0.0, 0.0)
    point_spatial  = gammalib.GModelSpatialPointSource(center)
    point_spectrum = crab_spec()
    point          = gammalib.GModelSky(point_spatial, point_spectrum)
    point.name('GC source')
    
    # Create model container
    models = gammalib.GModels()
    models.append(point)
    obs.models(models)
    
    # Return observation container
    return obs