0

我需要帮助理解此错误消息和/或它的来源。我非常困惑,就我而言,我无法确定错误是什么。

这是我要运行的代码:

def objmask(inimgs, inwhts, thresh1='20.0', thresh2='2.0', tfdel=True, 
            xceng=3001., yceng=3001., outdir='.', tmpdir='tmp'):
# 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','./se_files/gccg.sex',
                         '-CATALOG_NAME','./se_files/_tmp_seobj'+str(c)+'.cat',
                         '-PARAMETERS_NAME','./se_files/gccg_ell.param',
                         '-FILTER_NAME','./se_files/gccg.conv',
                         '-STARNNW_NAME','./se_files/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('./se_files/_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'

这是我通过终端运行它时收到的错误消息:

>>> fetch_swarp2.objmask(['sciPHOTOf105w0.fits'],['whtPHOTOf105w0.fits'])
Creating Aperture Run: 0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "fetch_swarp2.py", line 110, in objmask
    '-WEIGHT_IMAGE',inwhts[c]],
  File "/usr/lib/python2.7/subprocess.py", line 493, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

所以 。. . 问题出在哪里,我该如何解决?

4

2 回答 2

0

subprocess.call使用shell=True关键字参数调用。

    subprocess.call([...], shell=True)

或指定完整路径sex

subprocess.call(['/path/to/sex', ...], shell=True)
于 2013-07-13T06:09:52.720 回答
0

该代码运行一个以sex一些参数命名的命令。Python 找不到那个命令;确保您已安装它。该评论似乎表明该命令由SExtractor提供。

于 2013-07-13T06:10:42.090 回答