2013-07-13 56 views
0

我需要幫助瞭解這個錯誤信息,和/或它來自哪裏。我很困惑,至於我,我無法確定錯誤是什麼。瞭解Python錯誤消息?

這裏是我試圖運行代碼:

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 

左右。 。 。問題在哪裏,我該如何解決?

回答

0

請致電subprocess.callshell=True關鍵字參數。

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

或指定的sex完整路徑:

subprocess.call(['/path/to/sex', ...], shell=True) 
+0

在終端的哪個位置我會進行修改(在哪個步驟之後)? – vdogsandman

0

運行代碼名爲sex一些參數的命令。 Python找不到那個命令;確保你已經安裝了它。評論似乎表明該命令由SExtractor提供。