コード例 #1
0
ファイル: fitters.py プロジェクト: esheldon/espy
    def set_averages(self):
        nsh=len(files.SHNUMS)
        dt=[('s2n','f8'),
            ('g1true','f8'),
            ('g2true','f8'),
            ('g1','f8'),('g1_err','f8'),
            ('g2','f8'),('g2_err','f8'),
            ('g1sens','f8'),('g1sens_err','f8'),
            ('g2sens','f8'),('g2sens_err','f8')]
        out=zeros(nsh, dtype=dt)
        for i,shnum in enumerate(files.SHNUMS):
            data=self.datadict[shnum]
            shres=stats.get_mean_shear_shstruct(data)

            wts=stats.get_weights(data['gcov'])
            out['s2n'][shnum-1],err = wmom(data[self.s2n_field], wts)

            out['g1true'][shnum-1] = cluster_step.sh1exp[shnum]
            out['g2true'][shnum-1] = cluster_step.sh2exp[shnum]

            for n in shres:
                out[n][shnum-1] = shres[n]

        self.avg=out
コード例 #2
0
ファイル: collate.py プロジェクト: esheldon/espy
    def get_matched_struct(self, pipe):
        dt=[
            ('simid','i4'),
            ('ccd','i2'),
            ('id','i4'),
            ('flags','i4'),
            ('row','f8'),
            ('col','f8'),
            ('model','S4'),
            ('s2n_w','f8'),
            ('Ts2n','f8'),
            ('s2','f8'),
            ('sratio','f8'),
            ('objtype','S4'),
            ('g','f8',2),
            ('gcov','f8',(2,2)),
            ('gsens','f8',2),
            ('Tmean','f8'),
            ('weight','f8'),
            ('use1','i2'),
            ('use2','i2'),
            ('use3','i2'),
            ('use4','i2')]

        # note this s2n min is just the limit used in the
        # shear measurement code
        wgal=pipe.get_gals(s2n_min=self.conf['shear_s2n_min'])

        gals=pipe.cat[wgal]
        output=zeros(gals.size, dtype=dt)

        print wgal.size, pipe.shear_res.size
        w,=where(gals['simid'] != pipe.shear_res['simid'])
        if w.size != 0:
            raise ValueError("gals and shear don't line up")

        mcat,mshear=match(gals['simid'], pipe.shear_res['simid'])
        if mshear.size != pipe.shear_res.size:
            mess="""not all shear objects matched
                by simid: %d %d""" % (pipe.shear_res.size,mshear.size)
            print mess
         
        # gets simid, row, col
        copy_fields(gals, output)

        output['ccd'] = pipe['ccd']

        output['flags'][:] = pipe.shear_res['flags'][:]

        output['s2n_w'][:] = pipe.shear_res['s2n_w'][:]
        output['Ts2n'][:] = pipe.shear_res['Ts2n'][:]
        output['s2'][:] = pipe.shear_res['s2'][:]
        output['sratio'][:] = sqrt(1./output['s2'][:])

        for i in xrange(output.size):
            output['objtype'][i] = pipe.shear_res['model'][i]

        output['g'][:,:] = pipe.shear_res['g'][:,:]
        output['gcov'][:,:,:] = pipe.shear_res['gcov'][:,:,:]
        output['gsens'][:,:] = pipe.shear_res['gsens'][:,:]

        output['Tmean'][:] = pipe.shear_res['Tmean'][:]
        output['model'][:] = pipe.shear_res['model'][:]


        wts=stats.get_weights(pipe.shear_res['gcov'][:,:,:])
        output['weight'][:] = wts[:]


        return output