Reading headers from fits files in python -
i'm trying read headers specific fits files in directory. don't want obtain headers every file, specify. here code have far:
import os astropy.io import fits pyfits def mycode(files): fits = [] headers = [] in files: fits.append(i) j in fits: if 'rf' in j: hdulist = pyfits.open(j) header = hdulist[0].header['headername'] headers.append(header) return headers pathway = 'the directory' dirs = os.listdir(pathway) print mycode(dirs)
however, when run that, says "no such file or directory" , gives name of 1 of files trying access. appreciate help!
when use pyfits.open(j), python understands file in current directory (the 1 script is). since names of files directory, python doesn`t find them. 1 solution attach directory beginning of every file.
Comments
Post a Comment