1 | ;+ |
---|
2 | ; |
---|
3 | ; ========== |
---|
4 | ; dms2dd.pro |
---|
5 | ; ========== |
---|
6 | ; |
---|
7 | ; .. function:: dms2dd(degree,minute,second) |
---|
8 | ; |
---|
9 | ; Calculate the decimal degree for a given degree minute and second |
---|
10 | ; |
---|
11 | ; :param degree: degree |
---|
12 | ; :type degree: integer |
---|
13 | ; :raise degree: required |
---|
14 | ; |
---|
15 | ; :param minute: minute |
---|
16 | ; :type minute: integer |
---|
17 | ; :raise minute: required |
---|
18 | ; |
---|
19 | ; :param second: second |
---|
20 | ; :type second: integer |
---|
21 | ; :raise second: required |
---|
22 | ; |
---|
23 | ; :returns: decimal degree or -1 if error in parameters type or dimension |
---|
24 | ; :rtype: double |
---|
25 | ; |
---|
26 | ; :examples: |
---|
27 | ; |
---|
28 | ; :: |
---|
29 | ; |
---|
30 | ; IDL> degree=45 |
---|
31 | ; IDL> minute=30 |
---|
32 | ; IDL> second=30 |
---|
33 | ; IDL> dd=dms2dd(degree,minute,second) |
---|
34 | ; IDL> print,dd |
---|
35 | ; 45.5083 |
---|
36 | ; |
---|
37 | ; :uses: |
---|
38 | ; |
---|
39 | ; :func:`report` |
---|
40 | ; |
---|
41 | ; :see also: |
---|
42 | ; |
---|
43 | ; http://www.csgnetwork.com/gpscoordconv.html |
---|
44 | ; |
---|
45 | ; :todo: |
---|
46 | ; |
---|
47 | ; authorize arrays in inputs (like :func:`julday`) |
---|
48 | ; |
---|
49 | ; :history: |
---|
50 | ; |
---|
51 | ; - fplod 20101124T140937Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
52 | ; |
---|
53 | ; * returned value type from float to double |
---|
54 | ; * Double constants in conversion |
---|
55 | ; |
---|
56 | ; - fplod 20101124T120209Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
57 | ; |
---|
58 | ; * apply http://sphinx.pocoo.org/domains.html Info field lists |
---|
59 | ; to have a nicer parameters documentation |
---|
60 | ; |
---|
61 | ; - fplod 20101122T094140Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
62 | ; |
---|
63 | ; * creation |
---|
64 | ; |
---|
65 | ; :version: |
---|
66 | ; |
---|
67 | ; $Id$ |
---|
68 | ; |
---|
69 | ;- |
---|
70 | FUNCTION DMS2DD, degree, minute, second |
---|
71 | |
---|
72 | compile_opt idl2, strictarrsubs |
---|
73 | |
---|
74 | ; Return to caller if errors |
---|
75 | ON_ERROR, 2 |
---|
76 | |
---|
77 | usage = 'result=dms2dss(degree, minute, second)' |
---|
78 | |
---|
79 | ; check parameters |
---|
80 | nparam = N_PARAMS() |
---|
81 | IF (nparam LT 3) THEN BEGIN |
---|
82 | ras = report(['Incorrect number of arguments.' $ |
---|
83 | + '!C' $ |
---|
84 | + 'Usage : ' + usage]) |
---|
85 | return, -1 |
---|
86 | ENDIF |
---|
87 | |
---|
88 | arg_type = size(degree,/type) |
---|
89 | IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN |
---|
90 | ras = report(['Incorrect arg type degree' $ |
---|
91 | + '!C' $ |
---|
92 | + 'Usage : ' + usage]) |
---|
93 | return, -1 |
---|
94 | ENDIF |
---|
95 | |
---|
96 | arg_dim = size(degree,/n_elements) |
---|
97 | IF (arg_dim GT 1) THEN BEGIN |
---|
98 | ras = report(['Incorrect arg dimension degree' $ |
---|
99 | + '!C' $ |
---|
100 | + 'Usage : ' + usage]) |
---|
101 | return, -1 |
---|
102 | ENDIF |
---|
103 | |
---|
104 | arg_type = size(minute,/type) |
---|
105 | IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN |
---|
106 | ras = report(['Incorrect arg type minute' $ |
---|
107 | + '!C' $ |
---|
108 | + 'Usage : ' + usage]) |
---|
109 | return, -1 |
---|
110 | ENDIF |
---|
111 | |
---|
112 | arg_dim = size(minute,/n_elements) |
---|
113 | IF (arg_dim GT 1) THEN BEGIN |
---|
114 | ras = report(['Incorrect arg dimension minute' $ |
---|
115 | + '!C' $ |
---|
116 | + 'Usage : ' + usage]) |
---|
117 | return, -1 |
---|
118 | ENDIF |
---|
119 | |
---|
120 | arg_type = size(second,/type) |
---|
121 | IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN |
---|
122 | ras = report(['Incorrect arg type second' $ |
---|
123 | + '!C' $ |
---|
124 | + 'Usage : ' + usage]) |
---|
125 | return, -1 |
---|
126 | ENDIF |
---|
127 | |
---|
128 | arg_dim = size(second,/n_elements) |
---|
129 | IF (arg_dim GT 1) THEN BEGIN |
---|
130 | ras = report(['Incorrect arg dimension second' $ |
---|
131 | + '!C' $ |
---|
132 | + 'Usage : ' + usage]) |
---|
133 | return, -1 |
---|
134 | ENDIF |
---|
135 | |
---|
136 | ; conversion |
---|
137 | dd = degree + float(minute/60.d) + (second/60.d)/60.d |
---|
138 | |
---|
139 | return,dd |
---|
140 | |
---|
141 | END |
---|