예제 #1
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())
예제 #2
0
    def get_allsky_lthist(self,lon_axis,slat_axis,coordsys='gal',cth_axis=None):

        h = HistogramND([lon_axis,slat_axis,self._cth_axis])

        if coordsys=='gal':
        
            lon, slat = np.meshgrid(h.axis(0).center,
                                    h.axis(1).center,
                                    indexing='ij')
        

            ra, dec = gal2eq(np.degrees(lon),
                             np.degrees(np.arcsin(slat)))
        
            ra = np.radians(ra)
            dec = np.radians(dec)

        else:
            ra, dec = np.meshgrid(h.axis(0).center,
                                  np.arcsin(h.axis(1).center),
                                  indexing='ij')


        theta = np.pi/2. - dec
        phi = ra
            
        ipix = healpy.ang2pix(64,np.ravel(theta),
                              np.ravel(phi),nest=True)

        lt = self._ltmap[ipix,::-1]

#        print lt.shape
#        print h.axes()[0].nbins, h.axes()[1].nbins, h.axes()[2].nbins
        
        lt = lt.reshape((h.axes()[0].nbins,
                         h.axes()[1].nbins,
                         h.axes()[2].nbins))

        h._counts = lt

        return h
예제 #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()
        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())
예제 #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)

        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())