comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Fuzzy searching of FITS header
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Fuzzy searching of FITS header [message #74116 is a reply to message #74109] Wed, 22 December 2010 05:45 Go to previous messageGo to previous message
Gray is currently offline  Gray
Messages: 253
Registered: February 2010
Senior Member
On Dec 22, 8:40 am, Gray <grayliketheco...@gmail.com> wrote:
> On Dec 22, 8:06 am, wlandsman <wlands...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>> On Tuesday, December 21, 2010 10:49:30 PM UTC-5, Marc Buie wrote:
>>> Wayne -
>
>>> Why can't this be handled with
>
>>> dexp=sxpar(hdr,'D*DEXP')
>
>>> sxpar already handles
>
>>> naxis=sxpar(hdr,'NAXIS*')
>
>>> It seems to me that this is a simple extension of what sxpar already does.  
>
>> Well, there is a FITS convention for reserved keyword names followed by sequential integers (e.g. NAXIS1, NAXIS2, NAXIS3... ), where (with one exception) you can be sure that the returned values will all be of the same type (in this case integers).   But for a general wildcard (e.g. 'D*EXP') the returned values might be a mixture of strings, integers and floats.    That is why Paulo's list/hash approach seems preferable this case.   --Wayne
>
>> P.S. The one exception for reserved keyword names is TSCALi for converting 16 bit integers in a binary table to double/float.    In some cases TSCALi returns a float and in other cases it returns a double.    That is why MRDFITS currently has a limitation of requiring either all conversions to float or all conversions to double.    In some other FITS routines I get around this limitation by using pointers, but it is a pain.   It is a nice application for the new LIST datatype.  
>
> Here's a very basic writeup using lists and hashes and FXPAR() (since
> I didn't feel like re-writing the keyword parsing rules).
>
> FUNCTION hdregex, header, search
>   n = n_elements(search)
>   keys = strmid(header,0,8)
>   if (n lt 2) then begin
>     this = where(stregex(keys,search,/fold,/bool),count)
>     if (count eq 0) then return, !null
>     out = hash(keys[this])
>     for i=0,count-1 do out[keys[this[i]]] = $
>       fxpar(header,keys[this[i]],start=this[i],precheck=0)
>   endif else begin
>     out = list(length=n)
>     foreach key,search,i do begin
>       this = where(stregex(keys,search,/fold,/bool),count)
>       if (count eq 0) then continue
>       temp = hash(keys[this])
>       for j=0,count-1 do out[keys[this[j]]] = $
>         fxpar(header,keys[this[j]],start=this[j],precheck=0)
>       out[i] = temp
>     endforeach
>   endelse
>   return, out
> end

Oops, typos (that's what I get for copy/paste):

FUNCTION hdregex, header, search
n = n_elements(search)
keys = strmid(header,0,8)
if (n lt 2) then begin
this = where(stregex(keys,search,/fold,/bool),count)
if (count eq 0) then return, !null
out = hash(keys[this])
for i=0,count-1 do out[keys[this[i]]] = $
fxpar(header,keys[this[i]],start=this[i],precheck=0)
endif else begin
out = list(length=n)
foreach key,search,i do begin
this = where(stregex(keys,key,/fold,/bool),count)
if (count eq 0) then continue
temp = hash(keys[this])
for j=0,count-1 do temp[keys[this[j]]] = $
fxpar(header,keys[this[j]],start=this[j],precheck=0)
out[i] = temp
endforeach
endelse
return, out
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: idlgrtext fixed-width font
Next Topic: Re: idlgrtext fixed-width font

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 22:40:21 PDT 2025

Total time taken to generate the page: 1.20002 seconds