0

I'm very new to scripting and have a relatively simple problem that I'm hoping someone can help with.

So I have a FITS image file and I'm basically copying small subsections of it using this function called imcopy within iraf:

http://stsdas.stsci.edu/cgi-bin/gethelp.cgi?imcopy

The function requires me to provide the two x inputs and two y inputs, so something like this:

imcopy image.fits[x1:x2,y1:y2] output.fits

But I have about 300 of these x1,x2,x3,x4 input rows in a text file and I'm wondering if it would be possible to feed this text file using a python script somehow.

I imagine a loop in pyraf (which uses the python language) that runs the above function for every row may be a possibility but I'm only just starting to learn python so I'm not very familiar with it yet.

Any help would be greatly appreciated.

Unknown
  • 1
  • 2
  • If you want to run a function on every object in array - http://stackoverflow.com/questions/10973766/understanding-the-map-function-python If you want to read file - http://stackoverflow.com/questions/3277503/python-read-file-line-by-line-into-array – m9_psy Aug 10 '15 at 13:35

1 Answers1

0

With pyraf you could do something like this:

from pyraf import iraf
file_list = ['image1.fits', 'image2.fits']
for f in file_list:
    iraf.imcopy(input = f + '[x1:x2,y1:y2]', output = f.split('.fits')[0]  + '_out')
VinceP
  • 2,058
  • 2
  • 19
  • 29