我编写了一个需要用于多个文件的函数。当我将它用于一个文件时,它可以工作,但是当我尝试将它用于更多时,我会出错。我附上了我的代码,谁能告诉我它有什么问题?
#! /usr/bin/env python
#peice of code to find the information from a star catalog for the brightest star from each indiviual CCD
import os, sys, glob, pyfits, numpy
dr='/home/desar2.cosmology.illinois.edu+7443/DESFiles/desardata/OPS/red/20130321211637_20130106/red/DECam_00166306/catalogs/'
def meanarr(image, res=None):
"costruct code which runs over a single ccd to get the means"
a=pyfits.getdata(image).MAG_AUTO
q=numpy.mean(a)
s=pyfits.getdata(image).X2WIN_IMAGE
j=numpy.mean(s)
f=pyfits.getdata(image).Y2WIN_IMAGE
z=numpy.mean(f)
g=pyfits.getdata(image).XYWIN_IMAGE
h= numpy.mean(g)
a=[q,j,z,h]
print a
s0=''
return res
#image=dr+'DECam_00166306_01_star_catalog.fits'
#s=meanarr(image)
for arg in (sys.argv):
print arg
s=meanarr(arg)
print '---done---'
它应该只为每个输入文件打印一个包含四个数字的列表,但我认为最后四行存在问题。