/usr/share/gnudatalanguage/astrolib/tenv.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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | FUNCTION tenv,dd,mm,ss
;+
; NAME:
; TENV()
; PURPOSE:
; Converts sexagesimal number or string vector to decimal.
; EXPLANATION:
; Like TEN() but allows vector input.
;
; CALLING SEQUENCES:
; Result = TENV( dd, mm ) ; result = dd + mm/60.
; Result = TENV( dd, mm, ss) ; result = dd + mm/60. + ss/3600.
; or
; Result = TENV(ddmmss_string)
; INPUTS:
; dd - sexagesimal element(s) corresponding to hours or degrees
; mm - sexagesimal element(s) corresponding to minutes
; ss - sexagesimal element(s) corresponding to seconds (optional)
; The input parameters can be scalars or vectors. However, the
; number of elements in each parameter must be the same.
;
; HRMNSC_STRING - String scalar or vector giving sexagesmal quantity
; separated by spaces or colons e.g. "10 23 34" or "-3:23:45.2"
; Any negative values should begin with a minus sign.
; OUTPUTS:
; Result - double, decimal equivalent of input sexagesimal
; quantities. Same number of elements as the input parameters.
; If the nth element in any of the input parameters is negative
; then the nth element in Result will also be negative.
;
; EXAMPLE:
; If dd = [60,60,0], and mm = [30,-30,-30], then
;
; IDL> Result = TENV(dd,mm) ====> Result = [60.5,-60.5,-0.5]
;
; Alternatively, the input could be written as the string vector
; IDL> str = ['60:30','-60:30','-0:30']
; IDL> print,tenv(str) ====> Result = [60.5,-60.5,-0.5]
;
; WARNING:
; TENV() will recognize floating point values of -0.0 as negative numbers.
; However, there is no distinction in the binary representation of -0
; and 0 (integer values), and so TENV will treat both values as positive.
; PROCEDURES USED:
; GETTOK(), REPCHR() for string processing.
; PROCEDURE:
; Mostly involves checking arguments and setting the sign.
;
; MODIFICATION HISTORY:
; Written by W.B. Landsman April, 1991
; Recognize -0.0 W. Landsman/B. Stecklum Dec 2005
; Work with string input W. Landsman Feb 2009
; Accept comma separator in string input W. Landsman May 2017
;
;-
compile_opt idl2
npar = N_params()
npts = N_elements(dd)
if npts EQ 0 then begin
print,'Syntax - RESULT = TENV( dd, mm, ss)'
return, 0.0d
endif
if ( npar EQ 1 ) then begin
if size(dd,/TNAME) EQ 'STRING' then begin
temp = strtrim(dd,2)
temp = repchr(temp,':',' ')
temp = repchr(temp,',',' ')
neg = where( strmid(temp,0,1) EQ '-', Nneg)
value = abs(double(gettok(temp,' ')))
mm = double(gettok(temp,' '))
decimal = value + mm/60. + double(temp)/3600.0d
if Nneg GT 0 then decimal[neg] = -decimal[neg]
return,decimal
endif else return,double( dd ) ;No need to check for neg values.
endif
value = double( abs(dd) )
if ( npar GT 1 ) then begin ;Add minutes/60., check for <0
if N_elements(mm) NE npts then $
message,'ERROR - Number of elements in each parameter must be equal'
nd=(strpos(string(dd),'-') ge 0)
nm=(strpos(string(mm),'-') ge 0)
neg = nd OR nm
value = value + abs(mm)/60.0d
endif
if ( npar GT 2 ) then begin ;Add sec/3600., check for <0
if N_elements(ss) NE npts then $
message,'ERROR - Number of elements in each parameter must be equal'
ns=(strpos(string(ss),'-') ge 0)
neg = neg OR ns
value = value + abs(ss)/3600.0d
endif
neg = where( neg, Nfound ) ;Account for negative values
if ( Nfound GT 0 ) then value[neg] = -value[neg]
return,value
end
|