hselect difficulty
Andrew Staunton wrote on Jul 22, 2011
hello
I want to use hselect to parse out all images of a given filter.. the relevant header keyword used in these images is FILTER but unfortunately the value assigned to this keyword has an apostrophe as in:
FILTER = u'
FILTER = g'
FILTER = i'
etc.
so when I use what would be the correct command to parse out the images with u filter, the apostrophe creates an error. - command is:
error returned is:
is there an escape character that can be used to get hselect to recognise the apostrophe?
I want to use hselect to parse out all images of a given filter.. the relevant header keyword used in these images is FILTER but unfortunately the value assigned to this keyword has an apostrophe as in:
FILTER = u'
FILTER = g'
FILTER = i'
etc.
so when I use what would be the correct command to parse out the images with u filter, the apostrophe creates an error. - command is:
hselect @list.txt $I "(FILTER ?= 'r'')"
error returned is:
ERROR: missing closing quote in string constant
is there an escape character that can be used to get hselect to recognise the apostrophe?
Mike Fitzpatrick wrote on Jul 22, 2011
Assuming the apostrophe is done properly in the header (i.e. that a value like "O'Hara" is written as "O''Hara"), the you can use either the same double-apostrophe trick or a '\' to escape the value. For example
Note that the "?=" string comparison operator does a substring search, so a simple "filter?='r'" would also work (so long as it is unique).
ecl> hselect dpix.fits $I,FILTER '(filter?="r''")'
dpix.fits " r'"
ecl> hselect dpix.fits $I,FILTER '(filter?="r\'")'
dpix.fits " r'"
Note that the "?=" string comparison operator does a substring search, so a simple "filter?='r'" would also work (so long as it is unique).
Andrew Staunton wrote on Jul 22, 2011
thanks for your reply - although I realise now that it is not necessary to include the apostrophe....simply:
is sufficient to parse out all images with:
[QOUTE]
FILTER = r'
[/QOUTE]
But the problem that was causing this in the first place is that some images in list.txt do not have the keyword FILTER and so when hselect encounters one of these images it returns the error:
hedit is obviously the task to do remedy this but I am having trouble getting to grips with what each of its parameters actually does..
for example I thought the following command would add a keyword value FILTER with dummy value X to any image who's header currently does not contain the keyword FILTER:
however, the output returned suggested that not only did hselect add keyword FILTER with value X to images that currently did not have that keyword but it also changed the keyword value for all other images that already had the keyword FILTER, here is a sample of the output returned to me:
first off, I only wanted wanted it to add the keyword FILTER if it didn't exist, not to update it if it did already exist!! - that was probably down to my misunderstanding what each of the parameters actually does....
But more surprising than that is that despite the output of hedit as quoted above, if after running hedit I then check the keyword FILTER of any of the images that it supposedly updated, the value for FILTER remains at its old value or if the keyword FILTER did not exist for a particular image it will still not exist although the output of hedit suggests otherwise. For example, from the above output, if I were to check the keyword FILTER of
DATE/nov21/full_moon_089.fit, it would still be FILTER = u'...or if I check FILTER value for DATE/nov21/bias_116.fit, the keyword FILTER will still not exist for this image..
Why is this?
(and apologies for longwinded post!)
hselect @list.txt $I "(FILTER ?= 'r')"
is sufficient to parse out all images with:
[QOUTE]
FILTER = r'
[/QOUTE]
But the problem that was causing this in the first place is that some images in list.txt do not have the keyword FILTER and so when hselect encounters one of these images it returns the error:
ERROR: Image header parameter not found (FILTER)
hedit is obviously the task to do remedy this but I am having trouble getting to grips with what each of its parameters actually does..
for example I thought the following command would add a keyword value FILTER with dummy value X to any image who's header currently does not contain the keyword FILTER:
hedit @list.txt FILTER add+ addonly+ verify- update-
however, the output returned suggested that not only did hselect add keyword FILTER with value X to images that currently did not have that keyword but it also changed the keyword value for all other images that already had the keyword FILTER, here is a sample of the output returned to me:
.........
DATE/nov21/full_moon_033.fit,FILTER: u' -> X
add DATE/nov21/bias_001.fit,FILTER = X
add DATE/nov21/bias_050.fit,FILTER = X
DATE/nov21/full_moon_083.fit,FILTER: u' -> X
DATE/nov21/full_moon_015.fit,FILTER: u' -> X
add DATE/nov21/bias_110.fit,FILTER = X
DATE/nov21/full_moon_089.fit,FILTER: u' -> X
add DATE/nov21/bias_134.fit,FILTER = X
add DATE/nov21/bias_158.fit,FILTER = X
add DATE/nov21/bias_116.fit,FILTER = X
....and so on
first off, I only wanted wanted it to add the keyword FILTER if it didn't exist, not to update it if it did already exist!! - that was probably down to my misunderstanding what each of the parameters actually does....
But more surprising than that is that despite the output of hedit as quoted above, if after running hedit I then check the keyword FILTER of any of the images that it supposedly updated, the value for FILTER remains at its old value or if the keyword FILTER did not exist for a particular image it will still not exist although the output of hedit suggests otherwise. For example, from the above output, if I were to check the keyword FILTER of
DATE/nov21/full_moon_089.fit, it would still be FILTER = u'...or if I check FILTER value for DATE/nov21/bias_116.fit, the keyword FILTER will still not exist for this image..
Why is this?
(and apologies for longwinded post!)
Mike Fitzpatrick wrote on Jul 22, 2011
I think the magic combination of parameters you need is
The 'add+' will override the 'addonly' param and change the value for existing params, otherwise the 'addonly' is used as the only toggle.
cl> hedit ...... add- addonly+The 'add+' will override the 'addonly' param and change the value for existing params, otherwise the 'addonly' is used as the only toggle.
Last post on Jul 22, 2011