Ejemplo n.º 1
0
    def _add_slope(self, plt, slopes):
        import biggles
        from esutil.stat import sigma_clip
        slope,slope_sig=sigma_clip(slopes)
        slope_err=slope_sig/sqrt(slopes.size)

        #slope = slopes.mean()
        #slope_err = slopes.std()/sqrt(slopes.size)

        m='<slope>: %.2g +/- %.2g' % (slope,slope_err)
        slab = biggles.PlotLabel(0.9,0.9,m,halign='right')
        plt.add(slab)
Ejemplo n.º 2
0
    def _add_to_plot(self, plt, xfield, type, w, color, doslope=False):
        """

        Add widths to plot and plot a fit line. Very broad Sigma clipping is
        performed before fitting the line

        """
        import gmix_image
        import biggles
        from esutil.stat import sigma_clip


        if type=='fw25':
            width = self.data['fw25_arcsec'][w]
        elif type=='fw50':
            width = self.data['fw50_arcsec'][w]
        elif type=='fw75':
            width = self.data['fw75_arcsec'][w]
        elif type=='fw25_em2':
            width = self.data['fw25_arcsec_em2'][w]
        elif type=='fw50_em2':
            width = self.data['fw50_arcsec_em2'][w]
        elif type=='fw75_em2':
            width = self.data['fw75_arcsec_em2'][w]
        else:
            for i,wi in enumerate(w):

                width=numpy.zeros(w.size)
                if type=='em1':
                    gmix=gmix_image.GMix(self.data['pars1'][wi,:])
                elif type=='em2':
                    gmix=gmix_image.GMix(self.data['pars2'][wi,:])
                elif type=='am':
                    gmix=gmix_image.GMix(self.data['ampars'][wi,:])
                
                T=gmix.get_T()
                width[i] = 0.265*2.3548*sqrt(T/2.)

        x=self.data[xfield][w]
        pts=biggles.Points(x, width, type='dot', color=color)

        coeffs=None
        if doslope and w.size > 20:
            crap1,crap2,wsc=sigma_clip(width, nsig=5,get_indices=True)
            if wsc.size > 20:

                if xfield == 'flux_max':
                    w2,=numpy.where((x[wsc] > 5000) & (x[wsc] < 25000) )
                    xuse=x[wsc[w2]]
                    yuse=width[wsc[w2]]
                    #xuse=x[wsc]
                    #yuse=width[wsc]
                else:
                    xuse=x[wsc]
                    yuse=width[wsc]

                if xuse.size > 20:
                    coeffs=numpy.polyfit(xuse, yuse, 1)
                    ply=numpy.poly1d(coeffs)
                    yvals=ply(xuse)
                    cv=biggles.Curve(xuse, yvals, color=color)
                    plt.add(cv)

        plt.add(pts)

        return coeffs