else:
                if 'Maj' in r.columns:
                    tcopy=vstack((tcopy,r))

            ra=np.mean(tcopy['RA'])
            dec=np.mean(tcopy['DEC'])

            if startra==ra and startdec==dec:
                break
            iter+=1
            print iter,len(tcopy)
            if iter==10:
                break

            # now find the bounding box of the resulting collection
        ra,dec,size=find_bbox(tcopy,scale=scale)
        
        if np.isnan(size):
            ra=r['RA']
            dec=r['DEC']
            size=minsize

        if size>maxsize:
            # revert just to original
            ra,dec=r['RA'],r['DEC']
            tcopy=Table(r)
            ra,dec,size=find_bbox(tcopy,scale=scale)

        if size>maxsize:
            size=maxsize
        if size<minsize:
Example #2
0
                dist *= 1.2
                continue

            # all original components need to be in there
            tcopy = vstack([ctable, tcopy])
            ra = np.mean(tcopy['RA'])
            dec = np.mean(tcopy['DEC'])

            if startra == ra and startdec == dec:
                break
            iter += 1
            if iter == 10:
                break

        # now find the bounding box of the resulting collection
        ra, dec, size = find_bbox(tcopy)
        print tcopy, size

        if np.isnan(size):
            ra, dec = s.sd[sourcename]['RA'], s.sd[sourcename]['DEC']
            size = 60

        if size > 200:
            size = 200.0
            ra, dec = s.sd[sourcename]['RA'], s.sd[sourcename]['DEC']
        if size < 60:
            size = 60.0
        size = (int(0.5 + size / 10)) * 10

        size /= 3600.0
        initfactor = 4.0
            # include checktable
            interim=vstack((tcopy,checktable))
            # de-dupe again
            names=list(set(interim[cname]))
            print 'Names are',names
            filt=[False]*len(interim)
            for n in names:
                pos=np.argmax(interim[cname]==n)
                filt[pos]=True
            tcopy=interim[filt]
            
            ra=np.mean(tcopy['RA'])
            dec=np.mean(tcopy['DEC'])
            
            newra,newdec,size=find_bbox(tcopy)
            print '     size is',size

            if startra==ra and startdec==dec:
                break
            iter+=1
            if iter==10:
                break

        # now find the bounding box of the resulting collection
        ra,dec,size=find_bbox(tcopy)

        if np.isnan(size):
            ra=r['RA']
            dec=r['DEC']
            size=60
        sts=st[st['Source_Name']==name]
        if len(sts)==0:
            print name,'does not exist in source table, skipping'
            continue
        r2=sts[0] # corresponding row in source table
        if os.path.isfile('blend/'+name+'.txt'):
            print name,'already has a blend file'
            continue
        id=r2['Source_id'] # unique in this field!
        rgt=gt[gt['Source_id']==id]
        print 'Contains',len(rgt),'Gaussians'
        mlt=rgt[~np.isnan(rgt['lr_ra_fin'])]
        mlt['ra']=mlt['lr_ra_fin']
        mlt['dec']=mlt['lr_dec_fin']
        title=name+' (%s)' % display_mode
        ra,dec,size=find_bbox(rgt,scale=scale)
        size*=1.5
        size/=3600.0
        print 'Lofarfile is',lofarfile
        lhdu=extract_subim(lofarfile,ra,dec,size*2)
        try:
            peak==r2['Peak_flux']/1000.0
        except:
            peak=None
        pwg=gals[(np.abs(gals['ra']-ra)<size) & (np.abs(gals['dec']-dec)<size)]

        ora=r2['lr_ra_fin']
        odec=r2['lr_dec_fin']
        ga=GaussAssoc(rgt,ora,odec)

        stop=False