/usr/share/gnudatalanguage/astrolib/ten.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 | FUNCTION ten,dd,mm,ss
;+
; NAME:
; TEN()
; PURPOSE:
; Converts a sexagesimal number or string to decimal.
; EXPLANATION:
; Inverse of the SIXTY() function.
;
; CALLING SEQUENCES:
; X = TEN( [ HOUR_OR_DEG, MIN, SEC ] )
; X = TEN( HOUR_OR_DEG, MIN, SEC )
; X = TEN( [ HOUR_OR_DEG, MIN ] )
; X = TEN( HOUR_OR_DEG, MIN )
; X = TEN( [ HOUR_OR_DEG ] ) <-- Trivial cases
; X = TEN( HOUR_OR_DEG ) <--
;
; or
; X = TEN(HRMNSC_STRING)
;
; INPUTS:
; HOUR_OR_DEG,MIN,SEC -- Scalars giving sexagesimal quantity in
; in order from largest to smallest.
; or
; HRMNSC_STRING - String giving sexagesmal quantity separated by
; spaces, commas or colons e.g. "10 23 34" or "-3:23:45.2"
; Any negative values should begin with a minus sign.
; OUTPUTS:
; Function value returned = double real scalar, decimal equivalent of
; input sexigesimal quantity. For numeric input, a minus sign on any
; nonzero element of the input vector causes all the elements to be taken
; as < 0.
;
; EXAMPLES:
; IDL> print,ten(0,-23,34)
; --> -0.39277778
; IDL> print,ten("-0,23,34")
; --> -0.39277778
; PROCEDURE:
; Mostly involves checking arguments and setting the sign.
;
; The procedure TENV can be used when dealing with a vector of
; sexigesimal quantities.
;
; MODIFICATION HISTORY:
; Written by R. S. Hill, STX, 21 April 87
; Modified to allow non-vector arguments. RSH, STX, 19-OCT-87
; Recognize -0.0 W. Landsman/B. Stecklum Dec 2005
; Work with string input W. Landsman Dec 2008
; Accept comma separator in string input W. Landsman May 2017
;-
compile_opt idl2
np = N_params()
if (np eq 1) then begin
if size(dd,/TNAME) EQ 'STRING' then begin
temp = strtrim(dd,2)
neg = strmid(dd,0,1) EQ '-'
temp = repchr(temp,':',' ')
temp = repchr(temp,',',' ')
value = abs(double(gettok(temp,' ')))
mm = double(gettok(temp,' '))
decimal = value + mm/60. + double(temp)/3600.0d
if neg then decimal = -decimal
return,decimal
endif else vector=dd
endif else begin
if (np lt 1) || (np gt 3) then goto,bad_args
vector=dblarr(3)
vector[0]=dd
vector[1]=mm
if np gt 2 then vector[2]=ss
endelse
sz = size(vector)
ndim = sz[0]
if (ndim eq 0) then return,double(vector)
facs=[1.0d0,60.0d0,3600.0d0]
nel = sz[1]
sign = +1.0d0
dummy=where(strpos(string(vector),'-') ge 0,cnt)
if cnt gt 0 then sign = -1.0d0
vector = abs(vector)
decim = double(vector[0])
i = 1
while (i le nel-1) do begin
decim = decim + double(vector[i])/facs[i]
i++
endwhile
return,decim*sign
bad_args:
print,'Argument(s) should be hours/degrees, minutes (optional),'
print,'seconds (optional) in vector or as separate arguments.'
print,'If any one number negative, all taken as negative.'
return,0.0d0
end
|