迂回的Python错误消息:零大小数组

迂回的Python错误消息:零大小数组,python,fits,Python,Fits,我终于(某种程度上)让这个脚本工作了,但现在我收到了一条新的错误消息。在“提取目录并识别中央星系”之后,它似乎失败了 代码: 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

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

代码:

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
[15]中的
fetch_swarp4.objmask(['sciPHOTOf105w7.fits',['whtPHOTOf105w7.fits',thresh1='20.0',thresh2='2.0',tfdel=True,xceng=65',yceng=65',outdir=''',tmpdir='tmp')
1.
正在创建光圈梯段:0
---------------------------------------------------------------------------
ValueError回溯(最近一次调用上次)
/home/vidur/se_文件/in()
---->1 fetch_swarp4.objmask(['sciPHOTOf105w7.fits',['whtPHOTOf105w7.fits'],thresh1='20.0',thresh2='2.0',tfdel=True,xceng=65',yceng=65',outdir=''',tmpdir='tmp')
/objmask中的home/vidur/se_files/fetch_swarp4.pyc(inimgs、inwhts、thresh1、thresh2、tfdel、xceng、yceng、outdir、tmpdir)
33'xc'、'yc'、'cxx'、'cyy'、'cxy']
34 robj=np.sqrt((秒['xc']-xceng)**2.0+(秒['yc']-yceng)**2.0)
--->35 rmin=(robj==np.min(robj))
36 wrmin=np.式中(robj==np.min(robj))
37 xc_min,yc_min=secat['xc'][rmin],secat['yc'][rmin]
/amin中的usr/lib/python2.7/dist-packages/numpy/core/fromneric.pyc(a、axis、out)
1893除属性错误外:
1894返回(a,‘最小’,轴,输出)
->1895返回amin(轴,输出)
1896
1897
ValueError:将数组大小设置为最小值。减少而不使用标识
坦白地说,我完全不知道发生了什么,我完全迷路了。它在rmin失败了,但我不知道这个错误是什么意思,也不知道它为什么要这样做


另外,文件类型为“fits”文件,用于天文学。它基本上是一个可以用来推断大量天文数据的阵列

为什么是双==?rmin=(robj==np.min(robj))这很有趣,robj是空的。我想知道这是为什么。NumPy 1.7似乎已经清除了一点错误消息,但这并不难理解。任何
reduce
/
fold
-类型的函数都需要使用非空序列,或者在给定空序列时使用起始值
minimum.reduce
amin
传递给通用reduce函数(
PyUFunc\u reduceionop
)的函数<代码>标识正是NumPy所称的起始值。所以,要么你给了amin一个在所有维度上都是0长度的数组,要么你给了它一个轴,当应用到数组时,它给出了一个在所有维度上都是0长度的子数组。