RE: [MaxImDL] Read and write FITS header values


Aug 30, 2008

 


----------------------------

#33596 Aug 30, 2008

Would any one have a sample script that can read and write FITS header

keyword values?



Michael Kran



----------------------------

#33599 Aug 30, 2008

michael.kran wrote: >

> Would any one have a sample script that can read and write FITS header

> keyword values?



Set App = CreateObject("MaxIm.Application")

Set Docs = App.Documents



For Each Doc In Docs

Value = Doc.GetFITSKey ( "SomeKey" )

Doc.SetFITSKey "SomeOtherKey", Value

Next



---------------



Doug George

dgeorge@...



Diffraction Limited

Makers of Cyanogen Imaging Products

www.cyanogen.com



100 Craig Henry Dr., Suite 202

Ottawa, Ontario,

Canada, K2G 5W3



Phone: (613) 225-2732

Fax: (613) 225-9688



---------------



----------------------------

#33602 Aug 30, 2008

Thank you, Doug!



Michael Kran



_____



From: MaxImDL@yahoogroups.com [mailto:MaxImDL@yahoogroups.com] On Behalf Of

Douglas B. George

Sent: Saturday, August 30, 2008 2:14 PM

To: MaxImDL@yahoogroups.com

Subject: Re: [MaxImDL] Read and write FITS header values







michael.kran wrote: >

> Would any one have a sample script that can read and write FITS header

> keyword values?



Set App = CreateObject("MaxIm.Application")

Set Docs = App.Documents



For Each Doc In Docs

Value = Doc.GetFITSKey ( "SomeKey" )

Doc.SetFITSKey "SomeOtherKey", Value

Next



---------------



Doug George

dgeorge@cyanogen. mailto:dgeorge%40cyanogen.com> com



Diffraction Limited

Makers of Cyanogen Imaging Products

www.cyanogen www.cyanogen.com> .com



100 Craig Henry Dr., Suite 202

Ottawa, Ontario,

Canada, K2G 5W3



Phone: (613) 225-2732

Fax: (613) 225-9688



---------------











[Non-text portions of this message have been removed]



----------------------------

#33605 Aug 30, 2008

Here you go. If this gets scrambled too bad, let me know and I'll send

it directly to you as an enclosure. You are probably interested in

SubRoutine ChangeKeyWords().



Jim Jones





Option Explicit

Dim i, count, fso, f, fc, Images(750), dGain, dExp, collArgs, fl, Img,

Path, Doc(750)

Dim apps, AllDocs, j, objArgs





'**************************************************************************************

'*

KeyWordFix_Mira *

'* James L. Jones

05/01/06 *

'**************************************************************************************











'*********************************************

'* Get Collection of file Names *

'*********************************************

Set collArgs = WScript.Arguments

Set fso = CreateObject("Scripting.FileSystemObject")

Set f = fso.GetFolder(collArgs(0))

Set fc = f.Files

Call Drag_Drop()

Call MoveColl()

'WScript.Echo count

For i = 0 To count-1

'WScript.Echo count, i

Call OpenImage()

Call ChangeKeyWords()

Call CloseImages()

Next

'*********************************************

'* Drag and Drop *

'*********************************************

Sub Drag_Drop()

count = 0

If collArgs.Count = 0 Then

WScript.Echo _

"Drag a folder of FITS images to this icon to correct key words."

WScript.Quit

End If

End Sub



'*****************************************************************

'* Move collection of file names (fc) to array (Images()) *

'*****************************************************************

Sub MoveColl()

count = fc.Count

i = 0

For Each fl In fc

Images(i) = fl.name

i=i+1

Next

End Sub



'********************************

'* Subroutine OpenImage() *

'********************************

Sub OpenImage()

Set Img = CreateObject("MaxIm.Document")

Path = collArgs(0) & "\" & Images(i)

'WScript.Echo Path

Img.OpenFile (Path)

End Sub



'*********************************

'* Subroutine ChangeKeyWords() *

'*********************************

Sub ChangeKeyWords()

dGain = Img.GetFITSKey("EGAIN")

dExp = Img.GetFITSKey("EXPOSURE")

Call Img.SetFITSKey("EXPTIME", dExp)

Call Img.SetFITSKey("GAIN", dGain)

Call Img.SetFITSKey("RDNOISE", 15.0)

Call Img.SaveFile (Path,3,False,1,False)

End Sub





'******************************************

'* Subroutine CloseImages *

'******************************************

Sub CloseImages()

Img.Close

Set Img = Nothing

End Sub







michael.kran wrote: > Would any one have a sample script that can read and write FITS header

> keyword values?

>

> Michael Kran

>

>

---------------

>

> Yahoo! Groups Links

>

>

>

>

>







----------------------------

#33607 Aug 30, 2008

Thanks so much, Jim.



Just so you know why I am asking, I volunteered to help on an educational

project. During academic 2008-09, I will have about 100,000 images to stack

for use in Astrometrica. I'd like to reproduce Astrometrica's stacking

results via MaxImDL with the minimum of key strokes. It's about 2 GB of

data a night, and the desired turn about time for my step is measured in

hours. We're racing the clock to prep the image sets, get them to the kids,

see if they find an asteroid, then get a confirmatory image on a subsequent

night. And to have it all done within a week. I don't want to be the

bottleneck. :-)



Oh, and did I mention I'm not a programmer. :-0



Again thanks for your help!



Michael Kran



_____



From: MaxImDL@yahoogroups.com [mailto:MaxImDL@yahoogroups.com] On Behalf Of

Jim Jones

Sent: Saturday, August 30, 2008 3:42 PM

To: MaxImDL@yahoogroups.com

Subject: Re: [MaxImDL] Read and write FITS header values







Here you go. If this gets scrambled too bad, let me know and I'll send

it directly to you as an enclosure. You are probably interested in

SubRoutine ChangeKeyWords().



Jim Jones



Option Explicit

Dim i, count, fso, f, fc, Images(750), dGain, dExp, collArgs, fl, Img,

Path, Doc(750)

Dim apps, AllDocs, j, objArgs



'***************************************************************************

***********

'*

KeyWordFix_Mira *

'* James L. Jones

05/01/06 *

'***************************************************************************

***********



'*********************************************

'* Get Collection of file Names *

'*********************************************

Set collArgs = WScript.Arguments

Set fso = CreateObject("Scripting.FileSystemObject")

Set f = fso.GetFolder(collArgs(0))

Set fc = f.Files

Call Drag_Drop()

Call MoveColl()

'WScript.Echo count

For i = 0 To count-1

'WScript.Echo count, i

Call OpenImage()

Call ChangeKeyWords()

Call CloseImages()

Next

'*********************************************

'* Drag and Drop *

'*********************************************

Sub Drag_Drop()

count = 0

If collArgs.Count = 0 Then

WScript.Echo _

"Drag a folder of FITS images to this icon to correct key words."

WScript.Quit

End If

End Sub



'*****************************************************************

'* Move collection of file names (fc) to array (Images()) *

'*****************************************************************

Sub MoveColl()

count = fc.Count

i = 0

For Each fl In fc

Images(i) = fl.name

i=i+1

Next

End Sub



'********************************

'* Subroutine OpenImage() *

'********************************

Sub OpenImage()

Set Img = CreateObject("MaxIm.Document")

Path = collArgs(0) & "\" & Images(i)

'WScript.Echo Path

Img.OpenFile (Path)

End Sub



'*********************************

'* Subroutine ChangeKeyWords() *

'*********************************

Sub ChangeKeyWords()

dGain = Img.GetFITSKey("EGAIN")

dExp = Img.GetFITSKey("EXPOSURE")

Call Img.SetFITSKey("EXPTIME", dExp)

Call Img.SetFITSKey("GAIN", dGain)

Call Img.SetFITSKey("RDNOISE", 15.0)

Call Img.SaveFile (Path,3,False,1,False)

End Sub



'******************************************

'* Subroutine CloseImages *

'******************************************

Sub CloseImages()

Img.Close

Set Img = Nothing

End Sub



michael.kran wrote: > Would any one have a sample script that can read and write FITS header

> keyword values?

>

> Michael Kran

>

>

---------------

>

> Yahoo! Groups Links

>

>

>

>

>











[Non-text portions of this message have been removed]



----------------------------

#33608 Aug 30, 2008

Michael



If you need to change large numbers of headers, this script may be of

more interest than I thought. If you put the images in a folder and

drag and drop the folder to the script icon, it changes the headers of

all the images in the folder. Can't have anything but images in the

folder though.



Jim Jones



Michael Kran wrote: > Thanks so much, Jim.

>

> Just so you know why I am asking, I volunteered to help on an educational

> project. During academic 2008-09, I will have about 100,000 images to stack

> for use in Astrometrica. I'd like to reproduce Astrometrica's stacking

> results via MaxImDL with the minimum of key strokes. It's about 2 GB of

> data a night, and the desired turn about time for my step is measured in

> hours. We're racing the clock to prep the image sets, get them to the kids,

> see if they find an asteroid, then get a confirmatory image on a subsequent

> night. And to have it all done within a week. I don't want to be the

> bottleneck. :-)

>

> Oh, and did I mention I'm not a programmer. :-0

>

> Again thanks for your help!

>

> Michael Kran

>

> _____

>

> From: MaxImDL@yahoogroups.com [mailto:MaxImDL@yahoogroups.com] On Behalf Of

> Jim Jones

> Sent: Saturday, August 30, 2008 3:42 PM

> To: MaxImDL@yahoogroups.com

> Subject: Re: [MaxImDL] Read and write FITS header values

>

>

>

> Here you go. If this gets scrambled too bad, let me know and I'll send

> it directly to you as an enclosure. You are probably interested in

> SubRoutine ChangeKeyWords().

>

> Jim Jones

>

> Option Explicit

> Dim i, count, fso, f, fc, Images(750), dGain, dExp, collArgs, fl, Img,

> Path, Doc(750)

> Dim apps, AllDocs, j, objArgs

>

> '***************************************************************************

> ***********

> '*

> KeyWordFix_Mira *

> '* James L. Jones

> 05/01/06 *

> '***************************************************************************

> ***********

>

> '*********************************************

> '* Get Collection of file Names *

> '*********************************************

> Set collArgs = WScript.Arguments

> Set fso = CreateObject("Scripting.FileSystemObject")

> Set f = fso.GetFolder(collArgs(0))

> Set fc = f.Files

> Call Drag_Drop()

> Call MoveColl()

> 'WScript.Echo count

> For i = 0 To count-1

> 'WScript.Echo count, i

> Call OpenImage()

> Call ChangeKeyWords()

> Call CloseImages()

> Next

> '*********************************************

> '* Drag and Drop *

> '*********************************************

> Sub Drag_Drop()

> count = 0

> If collArgs.Count = 0 Then

> WScript.Echo _

> "Drag a folder of FITS images to this icon to correct key words."

> WScript.Quit

> End If

> End Sub

>

> '*****************************************************************

> '* Move collection of file names (fc) to array (Images()) *

> '*****************************************************************

> Sub MoveColl()

> count = fc.Count

> i = 0

> For Each fl In fc

> Images(i) = fl.name

> i=i+1

> Next

> End Sub

>

> '********************************

> '* Subroutine OpenImage() *

> '********************************

> Sub OpenImage()

> Set Img = CreateObject("MaxIm.Document")

> Path = collArgs(0) & "\" & Images(i)

> 'WScript.Echo Path

> Img.OpenFile (Path)

> End Sub

>

> '*********************************

> '* Subroutine ChangeKeyWords() *

> '*********************************

> Sub ChangeKeyWords()

> dGain = Img.GetFITSKey("EGAIN")

> dExp = Img.GetFITSKey("EXPOSURE")

> Call Img.SetFITSKey("EXPTIME", dExp)

> Call Img.SetFITSKey("GAIN", dGain)

> Call Img.SetFITSKey("RDNOISE", 15.0)

> Call Img.SaveFile (Path,3,False,1,False)

> End Sub

>

> '******************************************

> '* Subroutine CloseImages *

> '******************************************

> Sub CloseImages()

> Img.Close

> Set Img = Nothing

> End Sub

>

> michael.kran wrote:

>

>> Would any one have a sample script that can read and write FITS header

>> keyword values?

>>

>> Michael Kran

>>

>>

---------------

>>

>> Yahoo! Groups Links

>>

>>

>>

>>

>>

>>

>

>

>

>

>

> [Non-text portions of this message have been removed]

>

>

---------------

>

> Yahoo! Groups Links

>

>

>

>

>







----------------------------

#33610 Aug 30, 2008

Jim,



That's fantastic. I changed dGain in your script to dMid. Stored the

MIDPOINT value in dMid. Then, stored it to DATE-OBS.



It worked!



I won't have had a clue what to do. Thanks so much!



Michael



_____



From: MaxImDL@yahoogroups.com [mailto:MaxImDL@yahoogroups.com] On Behalf Of

Jim Jones

Sent: Saturday, August 30, 2008 4:28 PM

To: MaxImDL@yahoogroups.com

Subject: Re: [MaxImDL] Read and write FITS header values







Michael



If you need to change large numbers of headers, this script may be of

more interest than I thought. If you put the images in a folder and

drag and drop the folder to the script icon, it changes the headers of

all the images in the folder. Can't have anything but images in the

folder though.



Jim Jones



Michael Kran wrote: > Thanks so much, Jim.

>

> Just so you know why I am asking, I volunteered to help on an educational

> project. During academic 2008-09, I will have about 100,000 images to

stack > for use in Astrometrica. I'd like to reproduce Astrometrica's stacking

> results via MaxImDL with the minimum of key strokes. It's about 2 GB of

> data a night, and the desired turn about time for my step is measured in

> hours. We're racing the clock to prep the image sets, get them to the

kids, > see if they find an asteroid, then get a confirmatory image on a

subsequent > night. And to have it all done within a week. I don't want to be the

> bottleneck. :-)

>

> Oh, and did I mention I'm not a programmer. :-0

>

> Again thanks for your help!

>

> Michael Kran

>

> _____

>

> From: MaxImDL@yahoogroups mailto:MaxImDL%40yahoogroups.com> .com

[mailto:MaxImDL@yahoogroups mailto:MaxImDL%40yahoogroups.com> .com] On

Behalf Of > Jim Jones

> Sent: Saturday, August 30, 2008 3:42 PM

> To: MaxImDL@yahoogroups mailto:MaxImDL%40yahoogroups.com> .com

> Subject: Re: [MaxImDL] Read and write FITS header values

>

>

>

> Here you go. If this gets scrambled too bad, let me know and I'll send

> it directly to you as an enclosure. You are probably interested in

> SubRoutine ChangeKeyWords().

>

> Jim Jones

>

> Option Explicit

> Dim i, count, fso, f, fc, Images(750), dGain, dExp, collArgs, fl, Img,

> Path, Doc(750)

> Dim apps, AllDocs, j, objArgs

>

>

'*************************************************************************** > ***********

> '*

> KeyWordFix_Mira *

> '* James L. Jones

> 05/01/06 *

>

'*************************************************************************** > ***********

>

> '*********************************************

> '* Get Collection of file Names *

> '*********************************************

> Set collArgs = WScript.Arguments

> Set fso = CreateObject("Scripting.FileSystemObject")

> Set f = fso.GetFolder(collArgs(0))

> Set fc = f.Files

> Call Drag_Drop()

> Call MoveColl()

> 'WScript.Echo count

> For i = 0 To count-1

> 'WScript.Echo count, i

> Call OpenImage()

> Call ChangeKeyWords()

> Call CloseImages()

> Next

> '*********************************************

> '* Drag and Drop *

> '*********************************************

> Sub Drag_Drop()

> count = 0

> If collArgs.Count = 0 Then

> WScript.Echo _

> "Drag a folder of FITS images to this icon to correct key words."

> WScript.Quit

> End If

> End Sub

>

> '*****************************************************************

> '* Move collection of file names (fc) to array (Images()) *

> '*****************************************************************

> Sub MoveColl()

> count = fc.Count

> i = 0

> For Each fl In fc

> Images(i) = fl.name

> i=i+1

> Next

> End Sub

>

> '********************************

> '* Subroutine OpenImage() *

> '********************************

> Sub OpenImage()

> Set Img = CreateObject("MaxIm.Document")

> Path = collArgs(0) & "\" & Images(i)

> 'WScript.Echo Path

> Img.OpenFile (Path)

> End Sub

>

> '*********************************

> '* Subroutine ChangeKeyWords() *

> '*********************************

> Sub ChangeKeyWords()

> dGain = Img.GetFITSKey("EGAIN")

> dExp = Img.GetFITSKey("EXPOSURE")

> Call Img.SetFITSKey("EXPTIME", dExp)

> Call Img.SetFITSKey("GAIN", dGain)

> Call Img.SetFITSKey("RDNOISE", 15.0)

> Call Img.SaveFile (Path,3,False,1,False)

> End Sub

>

> '******************************************

> '* Subroutine CloseImages *

> '******************************************

> Sub CloseImages()

> Img.Close

> Set Img = Nothing

> End Sub

>

> michael.kran wrote:

>

>> Would any one have a sample script that can read and write FITS header

>> keyword values?

>>

>> Michael Kran

>>

>>

---------------

>>

>> Yahoo! Groups Links

>>

>>

>>

>>

>>

>>

>

>

>

>

>

> [Non-text portions of this message have been removed]

>

>

---------------

>

> Yahoo! Groups Links

>

>

>

>

>











[Non-text portions of this message have been removed]







Contact Us
This Site's Privacy Policy
Google's privacy policies

S
e
n
i
o
r
T
u
b
e
.
o
r
g