to read and to save multiple fits format files at a time [message #69988] |
Thu, 04 March 2010 04:41  |
sid
Messages: 50 Registered: January 1995
|
Member |
|
|
HI,
My data is in fits format, I am having 22 fits file and all the 22
files should be subtracted by single fits file individually, and I
should save it separately after subtraction. So please help me how to
read all these 22 files at a single stretch and subtract all the 22
files separately with one fits file and save the subtracted ones.
regards
sid
|
|
|
Re: to read and to save multiple fits format files at a time [message #70064 is a reply to message #69988] |
Thu, 04 March 2010 23:45  |
thoeger
Messages: 4 Registered: February 2010
|
Junior Member |
|
|
On Mar 4, 7:41 am, sid <gunvicsi...@gmail.com> wrote:
> HI,
> My data is in fits format, I am having 22 fits file and all the 22
> files should be subtracted by single fits file individually, and I
> should save it separately after subtraction. So please help me how to
> read all these 22 files at a single stretch and subtract all the 22
> files separately with one fits file and save the subtracted ones.
> regards
> sid
Yep, I'd do something in the vein of naming the files appropriately so
they can be found in an automated search/filtering quite easily, then:
files = file_search('pattern_to_search_for*.fits')
subtraction_file = 'filename_of_that_file.fits'
subtraction-data = readfits(subtraction_file)
for i = 0, n_elements(files) do begin
imgdata = readfits(files(i), hdr)
imgdata = imgdata-subtraction_data
outputfile = 'output_'+strtrim(i, 2)+'.fits'
writefits, outputfile, data, hdr
endfor
Cheers;
Emil
|
|
|