/usr/share/gnudatalanguage/astrolib/hgrep.pro is in gdl-astrolib 2018.02.16+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | pro hgrep, header, substring, keepcase=keepcase, linenum=linenum
;+
; NAME:
; HGREP
;
; PURPOSE:
; Find a substring in a FITS header (or any other string array)
;
; CALLING SEQUENCE:
; HGREP, header, substring, [/KEEPCASE, /LINENUM ]
;
; INPUTS:
; header - FITS header or other string array
; substring - scalar string to find in header; if a numeric value is
; supplied, it will be converted to type string
;
; OPTIONAL INPUT KEYWORDS:
; /KEEPCASE: if set, then look for an exact match of the input substring
; Default is to ignore case .
; /LINENUM: if set, prints line number of header in which
; substring appears
;
; OUTPUTS:
; None, results are printed to screen
;
; EXAMPLE:
; Find every place in a FITS header that the word 'aperture'
; appears in lower case letters and print the element number
; of the header array:
;
; IDL> hgrep, header, 'aperture', /keepcase, /linenum
;
; HISTORY:
; Written, Wayne Landsman (Raytheon ITSS) August 1998
; Adapted from STIS version by Phil Plait/ ACC November 14, 1997
; Remove trailing spaces if a non-string is supplied W. Landsman Jun 2002
;-
if (N_params() LT 2) then begin
print,'Syntax - HGREP, header, substring, [/KEEPCASE, /LINENUM ]'
return
endif
if N_elements(header) eq 0 then begin
print,'first parameter not defined. Returning...'
return
endif
hh = strtrim(header,2)
if size(substring,/tname) NE 'STRING' then substring = strtrim(substring,2)
if keyword_set(keepcase) then $
flag = strpos(hh,substring) $
else flag = strpos(strlowcase(hh),strlowcase(substring))
g = where(flag NE -1, Ng)
if Ng GT 0 then $
if keyword_set(linenum) then $
for i = 0, Ng-1 do print, string(g[i],f='(i4)') + ': ' + hh[g[i]] $
else $
for i = 0, Ng-1 do print,hh[g[i]]
return
end
|