Пример #1
0
    def getExpByName(self,src_names,egy_axis,cth_axis=None,weights=None):

        exph = None
        cat = Catalog.get()
        for s in src_names:

            if s == 'ridge':
                
                glon = np.linspace(0,360.,30.)
                glat = np.zeros(30)
                ra,dec = eq2gal(glon,glat)

                for i in range(30):
#                    print i, ra[i], dec[i]
                    h = self.eval2(ra[i],dec[i],egy_axis,
                                   cth_axis,wfn=weights)
       
                    if exph is None: exph = h
                    else: exph += h
            else:
                src = cat.get_source_by_name(s) 
                h = self.eval2(src['RAJ2000'], src['DEJ2000'],egy_axis,
                               cth_axis,wfn=weights)
       
                if exph is None: exph = h
                else: exph += h

        exph /= float(len(src_names))        
        return exph
Пример #2
0
    def get_hlat_ltcube(self):

        
        import healpy
        
        

        nbin = 400

        ra_edge = np.linspace(0,2*np.pi,nbin+1)
        dec_edge = np.linspace(-1,1,nbin+1)

        ra_center = 0.5*(ra_edge[1:] + ra_edge[:-1])
        dec_center = 0.5*(dec_edge[1:] + dec_edge[:-1])
        
        dec, ra = np.meshgrid(np.arcsin(dec_center),ra_center)

        lthist = pHist([ra_edge,dec_edge,self._cth_edges])
        
        srcs = np.loadtxt('src.txt',unpack=False)
        ipix = healpy.ang2pix(64,np.ravel(np.pi/2. - dec),
                              np.ravel(ra),nest=True)

        lt = self._ltmap[ipix,::-1]
        
        (l, b) = eq2gal(np.degrees(ra),np.degrees(dec))

        gal_msk = (np.abs(b) > 40.) & (np.abs(b) < 80.)
        eq_msk = (np.abs(np.degrees(dec)) < 79.9)

        msk = gal_msk & eq_msk
        for i in range(len(srcs)):
            msk &= get_src_mask(np.radians(srcs[i]),ra,dec,5.0)

        lt = lt.reshape((nbin,nbin,40))
        lt[msk==False,:] = 0
        
        
        lthist._counts = lt
        
        self._omega_tot = float(len(msk[msk==True]))/(nbin**2)*4*np.pi
        self._domega_bin = 4*np.pi/(nbin**2)
        
        h0 = lthist.slice([2],[0])
        h1 = lthist.slice([2],[20])
        h2 = lthist.slice([2],[30])
        
        
        plt.figure()
        h0.plot()
        plt.figure()
        h1.plot()
        plt.figure()
        h2.plot()
        
        plt.show()
Пример #3
0
    def plot(self,im,src_color='k',marker_threshold=0,
             label_threshold=20., ax=None,radius_deg=10.0,**kwargs):

        if ax is None: ax = plt.gca()
        
        if im.axis(0)._coordsys == 'gal':
            ra, dec = gal2eq(im.lon,im.lat)
        else:
            ra, dec = im.lon, im.lat

        #srcs = cat.get_source_by_position(ra,dec,self._roi_radius_deg)
        # Try to determine the search radius from the input file
        srcs = self.get_source_by_position(ra,dec,radius_deg)

        src_lon = []
        src_lat = []

        labels = []
        signif_avg = []
        
        for s in srcs:
            
#            print s['RAJ2000'], s['DEJ2000'], s['GLON'], s['GLAT']
            src_lon.append(s['RAJ2000'])
            src_lat.append(s['DEJ2000'])
            labels.append(s['Source_Name'])
            signif_avg.append(s['Signif_Avg'])
        
        if im.axis(0)._coordsys == 'gal':
            src_lon, src_lat = eq2gal(src_lon,src_lat)
            
            
#        pixcrd = im.wcs.wcs_sky2pix(src_lon,src_lat, 0)
        pixcrd = im.wcs.wcs_world2pix(src_lon,src_lat, 0)

#        ax.autoscale(enable=False, axis='both')
#        ax.set_autoscale_on(False)

        for i in range(len(labels)):

            if signif_avg[i] > label_threshold:             
                ax.text(pixcrd[0][i]+2.0,pixcrd[1][i]+2.0,labels[i],
                        color=src_color,size=8,clip_on=True)

            if signif_avg[i] > marker_threshold:      
                ax.plot(pixcrd[0][i],pixcrd[1][i],
                        linestyle='None',marker='+',
                        color='g', markerfacecolor = 'None',
                        markeredgecolor=src_color,clip_on=True)
        
        plt.gca().set_xlim(im.axis(0).lims())
        plt.gca().set_ylim(im.axis(1).lims())
Пример #4
0
    def plot(self,im,src_color='k',marker_threshold=0,
             label_threshold=20., ax=None,radius_deg=10.0,
             **kwargs):

        if ax is None: ax = plt.gca()
        min_radius_deg = kwargs.get('min_radius_deg',None)
        fontweight = kwargs.get('fontweight','normal')
        
        if im.axis(0)._coordsys == 'gal':
            ra, dec = gal2eq(im.lon,im.lat)
        else:
            ra, dec = im.lon, im.lat

        #srcs = cat.get_source_by_position(ra,dec,self._roi_radius_deg)
        # Try to determine the search radius from the input file
        srcs = self.get_source_by_position(ra,dec,radius_deg,
                                           min_radius=min_radius_deg)

        src_lon = []
        src_lat = []

        labels = []
        signif_avg = []
        
        for s in srcs:
            
#            print s['RAJ2000'], s['DEJ2000'], s['GLON'], s['GLAT']
            src_lon.append(s['RAJ2000'])
            src_lat.append(s['DEJ2000'])
            labels.append(s['Source_Name'])
            signif_avg.append(s['Signif_Avg'])
        
        if im.axis(0)._coordsys == 'gal':
            src_lon, src_lat = eq2gal(src_lon,src_lat)
            
            
#        pixcrd = im.wcs.wcs_sky2pix(src_lon,src_lat, 0)
        pixcrd = im.wcs.wcs_world2pix(src_lon,src_lat, 0)

#        ax.autoscale(enable=False, axis='both')
#        ax.set_autoscale_on(False)

        size = kwargs.get('size',8)

        for i in range(len(labels)):

            scale = (min(max(signif_avg[i],5.0),50.0)-5.0)/45.
            
            mew = 1.0 + 1.0*scale
            ms = 5.0 + 3.0*scale

            mew = 1.0
            ms = 5.0

            mew = None
            ms = None
            
            if label_threshold is not None and signif_avg[i] > label_threshold:

                ax.text(pixcrd[0][i]+2.0,pixcrd[1][i]+2.0,labels[i],
                        color=src_color,size=size,clip_on=True,
                        fontweight=fontweight)

            if marker_threshold is not None and \
                    signif_avg[i] > marker_threshold:      
                ax.plot(pixcrd[0][i],pixcrd[1][i],
                        linestyle='None',marker='+',
                        color='g', markerfacecolor = 'None',#mew=mew,ms=ms,
                        markeredgecolor=src_color,clip_on=True)
        
        plt.gca().set_xlim(im.axis(0).lims())
        plt.gca().set_ylim(im.axis(1).lims())
Пример #5
0
    def plot(self,
             im,
             src_color='k',
             marker_threshold=0,
             label_threshold=20.,
             ax=None,
             radius_deg=10.0,
             **kwargs):

        if ax is None: ax = plt.gca()
        min_radius_deg = kwargs.get('min_radius_deg', None)
        fontweight = kwargs.get('fontweight', 'normal')

        if im.axis(0)._coordsys == 'gal':
            ra, dec = gal2eq(im.lon, im.lat)
        else:
            ra, dec = im.lon, im.lat

        #srcs = cat.get_source_by_position(ra,dec,self._roi_radius_deg)
        # Try to determine the search radius from the input file
        srcs = self.get_source_by_position(ra,
                                           dec,
                                           radius_deg,
                                           min_radius=min_radius_deg)

        src_lon = []
        src_lat = []

        labels = []
        signif_avg = []

        for s in srcs:

            #            print s['RAJ2000'], s['DEJ2000'], s['GLON'], s['GLAT']
            src_lon.append(s['RAJ2000'])
            src_lat.append(s['DEJ2000'])
            labels.append(s['Source_Name'])
            signif_avg.append(s['Signif_Avg'])

        if im.axis(0)._coordsys == 'gal':
            src_lon, src_lat = eq2gal(src_lon, src_lat)


#        pixcrd = im.wcs.wcs_sky2pix(src_lon,src_lat, 0)
        pixcrd = im.wcs.wcs_world2pix(src_lon, src_lat, 0)

        #        ax.autoscale(enable=False, axis='both')
        #        ax.set_autoscale_on(False)

        for i in range(len(labels)):

            scale = (min(max(signif_avg[i], 5.0), 50.0) - 5.0) / 45.

            mew = 1.0 + 1.0 * scale
            ms = 5.0 + 3.0 * scale

            if label_threshold is not None and signif_avg[i] > label_threshold:

                ax.text(pixcrd[0][i] + 2.0,
                        pixcrd[1][i] + 2.0,
                        labels[i],
                        color=src_color,
                        size=8,
                        clip_on=True,
                        fontweight=fontweight)

            if marker_threshold is not None and \
                    signif_avg[i] > marker_threshold:
                ax.plot(pixcrd[0][i],
                        pixcrd[1][i],
                        linestyle='None',
                        marker='+',
                        color='g',
                        markerfacecolor='None',
                        mew=mew,
                        ms=ms,
                        markeredgecolor=src_color,
                        clip_on=True)

        plt.gca().set_xlim(im.axis(0).lims())
        plt.gca().set_ylim(im.axis(1).lims())