FSBoyden |
11/23/2006 09:14AM (Read 4737 times)
|
|
|
Status: offline
Registered: 06/07/2006
Posts: 95
|
Hi allI am trying to fix image headers, and have looked at hedit, hselect, hfix, as to what they say. The thing is that I want to do it in a batch mode.Full story: For some of our datasets there are no airmass, RA, dec, ... values/fields in the headers, while in others some of the fields are there. Thus I would like to check if a certain field exists in the image header or not, and if not then I would like to add the field as well as a user defined value. (Trying to put together a script for the batch)From what I understand of hedit, heselect, hfix ... they search for a field value, not a field???? If the field does not exist a "parameter does not exist" is returned. If it does, it query's for an update or not???I am not very familiar with hedit, ... tasks protocalsIf someone can please help me as to how I can tackle this problem, would be appreciated.Regards
Pat
|
|
|
|
fitz |
11/23/2006 09:14AM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
Pat,See the description of the 'addonly' parameter to HEDIT, this will cause the field to be added only if it doesn't already exist in the header (i.e. add a new value, don't overwrite an existing one). Tasks like SETAIRMASS can add some of what you're after, but it sounds like you want a script that loops over a list of values for each image and then just calls HEDIT. See also the HFIX task as a way of running some arbitrary program (e.g. an awk or perl script) over a header. Hope this helps.Cheers,
-Mike
|
|
|
|
FSBoyden |
11/23/2006 09:14AM
|
|
|
Status: offline
Registered: 06/07/2006
Posts: 95
|
Hi MikeHedit and addonly works. But :wink: it still gives me to many massages about fields existing or not, and if wrong value was entered I have to change addonly to add to fix it. (Have boolean variables for add, addonly, show, verify)What I thought might work was if I used hselect to select a field, and the field doesn't exist then it would return a "zero" value. Thing is it doesn't seem to be possible to equate the value to a variable, can only write it to file and then read the value FROM file.[code:1:279a3f1816]hselect (img, field, yes, == s1) # NO!!!
s1 = hselect (img, field, yes) #NO!!!
if (hselect(img, field, yes) == "") #NO!!!
enc ...
[/code:1:279a3f1816]What is working is
[code:1:279a3f1816]txtfile = mktemp ("tmp$txt")
hselect (img,field,yes, >txtfile)
txtlist = txtfile
while (fscan (txtlist, s1) != EOF) {
if (s1 == "") {
hedit (.......
}
else {
print ("Nothing to do")
}
}
delete (txtfile, ver-, >& "dev$null")
[/code:1:279a3f1816]Which is a bit bulky, and don't like the idee of making and deleting tempfiles so many time's. If it were possible to equate the value directly to a variable then it would solve the problem.P.S. Somthing else I picked up was that if I repeat the code below, i.e. first check FILTER value, then check OBSERVAT value, the code seems to keep s1's value.Thus if s1 == "V" for the first check, but s1 == "" for the second, it still keeps s1 == "V" during the second check, and thus returns the wrong value. It doesn't seem to overwrite the s1 variable. Overgame the problem by seting s1 = "" at the top of each check.Hope you understand what I am trying to explain. Comment would be helpfullRegards
Pat
|
|
|
|
fitz |
11/23/2006 09:14AM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
Pat, What I thought might work was if I used hselect to select a field, and the field doesn't exist then it would return a "zero" value. Thing is it doesn't seem to be possible to equate the value to a variable, can only write it to file and then read the value FROM file.[/code]
A new 'missing' parameter was recently added to HSELECT just for this purpose, i.e. to have the task print out something predictable when a keyword isnt present. This is actually available in the Nov22 macintel binary release but unfortunately not yet for other platforms.
[quote:b3e947730b]Which is a bit bulky, and don't like the idee of making and deleting tempfiles so many time's. ......[/quote:b3e947730b]
This is exactly what "scan from pipe" is for, i.e.
1:B3E947730B Formatted Code hselect(img, field, yes) | scan (s1)
if (nscan() == 0)
hedit (...)
else
.....
[/code:1:b3e947730b]
Note we use the nscan() function to test whether anything was read to avoid the problem with s1 not being changed from a earlier read. Hope this helps.
Cheers,
-Mike
|
|
|
|
FSBoyden |
11/23/2006 09:14AM
|
|
|
Status: offline
Registered: 06/07/2006
Posts: 95
|
Hi MikeIt most definitely helped!!! I still have a lot to learn, but I am getting there. Thanx for the help.Regards
PatP.S. To all a merry xmas, and happy new year! :wink:
Cheers
|
|
|
|
| |
|