IDL save result of procedure to file [message #84751] |
Fri, 07 June 2013 10:18  |
quincyaflint
Messages: 6 Registered: June 2013
|
Junior Member |
|
|
Hello,
I am trying to write and IDL procedure that will compute the difference image of two photographs from FITS files. The procedure will take the name of a folder, then loop through to compute the difference image of consecutive files within that folder. Then I want it to, once it has done the difference imaging, save the resulting image in a new destination of my choice. Currently I am able to make the image pop up in a new window using the tv,xxx command. I am unsure on how to (1) give the procedure a FOLDER that it will go through all the files and (2) I don't know how to save the resulting image in a new destination. I would greatly appreciate any help!
Thanks
|
|
|
|
Re: IDL save result of procedure to file [message #84755 is a reply to message #84754] |
Fri, 07 June 2013 11:44   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
quincyaflint@gmail.com writes:
> I'm trying to use printf, but I'm not sure in what format this will save my image
Well, you don't want that one, for sure.:-)
It is a text format. Not at all what you want. What format were you
hoping for?
For your other questions, you want to look up File_Search and
Dialog_Pickfile.
If you are new to programming, I would recommend Ken Bowman's book, An
Introduction to Programming with IDL. It will get you started on these
basic programming concepts.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
Re: IDL save result of procedure to file [message #84756 is a reply to message #84755] |
Fri, 07 June 2013 11:49   |
Andy Sayer
Messages: 127 Registered: February 2009
|
Senior Member |
|
|
You can use the 'save' procedure to save the data to an IDL .sav file.
The printf command will write data to a file in the format you specify. You probably want to be using save rather than printf, if I undertstand your posts correctly. See: http://www.exelisvis.com/docs/SAVE.html
If you're talking about saving an actual plot, rather than the data in it, that's a different question. If you want a jpeg or png then IDL has routines for that, e.g.: http://www.exelisvis.com/docs/WRITE_PNG.html (you'll also need to use tvrd before.)
If you want eps/pdf output then that involves a little more typing but is also pretty straightforward.
As to looping over files, you can do something like:
files=file_search(my_folder+'*.myformat',count=nfiles)
if nfiles gt 0 then begin
for i=0l,nfiles-1 do begin
(do your stuff here)
endfor
endif
Hope this helps,
Andy
On Friday, June 7, 2013 2:44:26 PM UTC-4, David Fanning wrote:
> quincyaflint@gmail.com writes:
>
>
>
>> I'm trying to use printf, but I'm not sure in what format this will save my image
>
>
>
> Well, you don't want that one, for sure.:-)
>
>
>
> It is a text format. Not at all what you want. What format were you
>
> hoping for?
>
>
>
> For your other questions, you want to look up File_Search and
>
> Dialog_Pickfile.
>
>
>
> If you are new to programming, I would recommend Ken Bowman's book, An
>
> Introduction to Programming with IDL. It will get you started on these
>
> basic programming concepts.
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|
|
Re: IDL save result of procedure to file [message #84759 is a reply to message #84755] |
Fri, 07 June 2013 12:00   |
quincyaflint
Messages: 6 Registered: June 2013
|
Junior Member |
|
|
This is what I ended up doing:
fit1 = '~quincy/Documents/19900103..rpb.vig.fts/19900103.214411.mk3 0.rpb.vig.fts'
fit2 = '~quincy/Documents/19900103..rpb.vig.fts/19900103.213500.mk3 0.rpb.vig.fts'
img1 = LASCO_READFITS(fit1,hr1)
img2 = LASCO_READFITS(fit2,hr2)
diff = img1 - img2
img_diff = bytscl(diff,max=1200,min=-1200)
img_395 = congrid(img_diff,395,395)
openw,1,'qtest19900103.214411.mk30.rpb.vig.fts'
printf,1,img_395
close,1
|
|
|
|
|