0

我终于(有点)让这个脚本工作了,除了现在我收到一条新的错误消息。. 在“提取目录并识别中央星系”之后似乎失败了。

代码:

def objmask(inimgs, inwhts, thresh1='20.0', thresh2='2.0', tfdel=True, 
            xceng=65., yceng=65., outdir='.', tmpdir='tmp'):
    print np.size(inimgs)
# initial detection of main galaxy with SExtractor for re-centering purposes
    if outdir!='.':
        if not os.path.exists(outdir):
            os.makedirs(outdir)

    if not os.path.exists(tmpdir):
        os.makedirs(tmpdir)
    for c in range(np.size(inimgs)):
        print 'Creating Aperture Run:', c
        subprocess.call(['sex',inimgs[c],'-c','gccg.sex',
                         '-CATALOG_NAME','_tmp_seobj'+str(c)+'.cat',
                         '-PARAMETERS_NAME','gccg_ell.param',
                         '-FILTER_NAME','gccg.conv',
                         '-STARNNW_NAME','gccg.nnw',
                        # '-CHECKIMAGE_TYPE','APERTURES',
                         '-VERBOSE_TYPE','QUIET',
                         '-DETECT_THRESH',thresh1,
                         '-ANALYSIS_THRESH',thresh2,
                         '-WEIGHT_IMAGE',inwhts[c]],
                         )

# extract catalog and identify central galaxy
        secat=asciitable.read('_tmp_seobj'+str(c)+'.cat',
                              names=['flux','ferr','xmin','ymin','xmax','ymax',
                                     'xc','yc','cxx','cyy','cxy'])
        robj = np.sqrt((secat['xc']-xceng)**2.0+(secat['yc']-yceng)**2.0)
        rmin = (robj==np.min(robj))
        wrmin = np.where(robj==np.min(robj))
        xc_min,yc_min = secat['xc'][rmin],secat['yc'][rmin]
        print 'extract catalog complete'

# shift images and masks to a common center
        hdu=pf.open(inimgs[c])
        img=hdu[0].data

        xdel=xceng-xc_min
        ydel=yceng-yc_min
        img_sh=shift(img,[ydel,xdel])

        hdu2=pf.open(inwhts[c])
        mask=hdu2[0].data
        mask_sh=shift(mask,[yceng-yc_min,xceng-xc_min])

        xmin=np.delete(secat['xmin']+xdel,wrmin)
        xmax=np.delete(secat['xmax']+xdel,wrmin)
        xcen=np.delete(secat['xc']+xdel,wrmin)
        ymin=np.delete(secat['ymin']+ydel,wrmin)
        ymax=np.delete(secat['ymax']+ydel,wrmin)
        ycen=np.delete(secat['yc']+ydel,wrmin)
    print 'shift complete'

# mask detected objects and write mask file
        #retgen.pbar ((float(c)*ncols+1.0)/18.0)
        omask=tgen.semask(img.shape,xmin,xmax,ymin,ymax,xcen,ycen,
                          np.delete(secat['cxx'],wrmin),
                          np.delete(secat['cyy'],wrmin),
                          np.delete(secat['cxy'],wrmin),2.0)

        hdimsh=pf.PrimaryHDU(img_sh)
        hdmsh=pf.PrimaryHDU(omask)
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            hdimsh.writeto(outdir+'/sh_img_'+str(c)+'.fits',
                           clobber=True)
            hdmsh.writeto(tmpdir+'/_omask.fits',clobber=True)
    print 'mask file complete'



# write combined g+r+i image and mask
        if c==2:
            cimg/=3.0
            csub/=3.0
            cmask/=3.0
            hdcim_out=pf.PrimaryHDU(cimg)
            hdmod_out=pf.PrimaryHDU(csub)
            hdcm_out=pf.PrimaryHDU(cmask)
            with warnings.catch_warnings():
                warnings.simplefilter('ignore')
                hdcim_out.writeto(outdir+'/im_comb.fits',
                                  clobber=True)
                hdmod_out.writeto(tmpdir+'/_im-mod_comb.fits',clobber=True)
                hdcm_out.writeto(tmpdir+'/_comb_mask.fits',clobber=True)

错误:

In [15]: fetch_swarp4.objmask(['sciPHOTOf105w7.fits'],['whtPHOTOf105w7.fits'],thresh1='20.0',thresh2='2.0',tfdel=True,xceng=65.,yceng=65.,outdir='.',tmpdir='tmp')
1
Creating Aperture Run: 0
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/vidur/se_files/<ipython-input-15-92433178d837> in <module>()
----> 1 fetch_swarp4.objmask(['sciPHOTOf105w7.fits'],['whtPHOTOf105w7.fits'],thresh1='20.0',thresh2='2.0',tfdel=True,xceng=65.,yceng=65.,outdir='.',tmpdir='tmp')

/home/vidur/se_files/fetch_swarp4.pyc in objmask(inimgs, inwhts, thresh1, thresh2, tfdel, xceng, yceng, outdir, tmpdir)
     33                                      'xc','yc','cxx','cyy','cxy'])
     34         robj = np.sqrt((secat['xc']-xceng)**2.0+(secat['yc']-yceng)**2.0)
---> 35         rmin = (robj==np.min(robj))
     36         wrmin = np.where(robj==np.min(robj))
     37         xc_min,yc_min = secat['xc'][rmin],secat['yc'][rmin]

/usr/lib/python2.7/dist-packages/numpy/core/fromnumeric.pyc in amin(a, axis, out)
   1893     except AttributeError:
   1894         return _wrapit(a, 'min', axis, out)
-> 1895     return amin(axis, out)
   1896 
   1897 

ValueError: zero-size array to minimum.reduce without identity

坦率地说,我完全不知道发生了什么,我完全迷失了。它在 rmin 失败,但我不知道错误是什么意思,也不知道为什么会这样。

PS 文件类型是“适合”文件,用于天文学。它基本上是一个可以用来推断大量天文数据的数组。

4

0 回答 0