hedit/hselect boolean query on imagetyp field
Roland Roberts wrote on Sep 28, 2006
I'm stuck trying to select a set of images based on imagetyp which need to have their imagetyp changed. I've tried about every permutation of comparison I can think of but consistently get this error in every case:
I've tried
and probably some others. The actual field in the headers reads
Can someone give me a clue on how to select these?
ERROR: Impossible type conversion when accessing image header parameter (imagetype)
I've tried
hselect 0*.fit $I "imagetyp ?= '*DARK*'"
hselect 0*.fit $I "imagetyp == DARK"
hselect 0*.fit $I "imagetyp ?= DARK"
hselect 0*.fit $I "imagetyp = DARK"
hselect 0*.fit $I "imagetyp == 'DARK'"
and probably some others. The actual field in the headers reads
IMAGETYP = DARKCan someone give me a clue on how to select these?
Mike Fitzpatrick wrote on Sep 28, 2006
Try
The '?=' is the string-equality operator and the value needs to be in a single quote.
-Mike
hselect *.fits $I "imagetyp ?= 'DARK'"The '?=' is the string-equality operator and the value needs to be in a single quote.
-Mike
Roland Roberts wrote on Sep 28, 2006
How is that different from my first example which should have matched anything with DARK in it? It gives the same error, as does the one you suggest. I'm baffled....
NB: I also realized I mistyped some of the examples, which I have now corrected; they said "imagetype" instead of "imagetyp".
regards,
roland
NB: I also realized I mistyped some of the examples, which I have now corrected; they said "imagetype" instead of "imagetyp".
regards,
roland
Mike Fitzpatrick wrote on Sep 28, 2006
How is that different from my first example which should have matched anything with DARK in it? It gives the same error, as does the one you suggest. I'm baffled....
The answer is in how you listed the value of the IMAGETYP keyword itself, i.e.
IMAGETYP = DARKThe DARK is meant to be a string value and should be in quotes, i.e.
IMAGETYPE = 'DARK'In that case your first example would have worked.
-Mike
Roland Roberts wrote on Sep 28, 2006
Hmm, okay, so that creates a bit of a problem. If they should have said 'DARK', how can I select them to change them to say 'DARK'?
Mike Fitzpatrick wrote on Sep 28, 2006
You can use the HFIX task to run an arbitrary command over all the image headers and edit only those that match "DARK", e.g.
The various backslashes are escapes needed for the quotes, but basically you're using 'sed' to edit the headers.
-Mike
hfix *.fits command="!cat $fname | sed -e \"s/DARK/\\'DARK\\'/g\" > _z ; mv _z $fname"The various backslashes are escapes needed for the quotes, but basically you're using 'sed' to edit the headers.
-Mike
Last post on Sep 28, 2006