1 | ;+ |
---|
2 | ; |
---|
3 | ; ========== |
---|
4 | ; dm2dd.pro |
---|
5 | ; ========== |
---|
6 | ; |
---|
7 | ; .. function:: dm2dd(degree,minute) |
---|
8 | ; |
---|
9 | ; Calculate the decimal degree for a given degree and minute |
---|
10 | ; |
---|
11 | ; :param degree: degree |
---|
12 | ; :type degree: integer |
---|
13 | ; :raise degree: required |
---|
14 | ; |
---|
15 | ; :param minute: minute |
---|
16 | ; :type minute: float |
---|
17 | ; :raise minute: required |
---|
18 | ; |
---|
19 | ; :returns: decimal degree or -1 if error in parameters type or dimension |
---|
20 | ; :rtype: double |
---|
21 | ; |
---|
22 | ; :examples: |
---|
23 | ; |
---|
24 | ; :: |
---|
25 | ; |
---|
26 | ; IDL> degree=45 |
---|
27 | ; IDL> minute=30.5 |
---|
28 | ; IDL> dd=dm2dd(degree,minute) |
---|
29 | ; IDL> print,dd |
---|
30 | ; 45.5083 |
---|
31 | ; |
---|
32 | ; :uses: |
---|
33 | ; |
---|
34 | ; :func:`report` |
---|
35 | ; |
---|
36 | ; :see also: |
---|
37 | ; |
---|
38 | ; http://www.csgnetwork.com/gpscoordconv.html |
---|
39 | ; |
---|
40 | ; :todo: |
---|
41 | ; |
---|
42 | ; authorize arrays in inputs (like :func:`julday`) |
---|
43 | ; |
---|
44 | ; :history: |
---|
45 | ; |
---|
46 | ; - fplod 20101126T140307Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
47 | ; |
---|
48 | ; * creation |
---|
49 | ; |
---|
50 | ; :version: |
---|
51 | ; |
---|
52 | ; $Id$ |
---|
53 | ; |
---|
54 | ;- |
---|
55 | FUNCTION DM2DD, degree, minute |
---|
56 | |
---|
57 | compile_opt idl2, strictarrsubs |
---|
58 | |
---|
59 | ; Return to caller if errors |
---|
60 | ON_ERROR, 2 |
---|
61 | |
---|
62 | usage = 'result=dms2dss(degree, minute)' |
---|
63 | |
---|
64 | ; check parameters |
---|
65 | nparam = N_PARAMS() |
---|
66 | IF (nparam LT 2) THEN BEGIN |
---|
67 | ras = report(['Incorrect number of arguments.' $ |
---|
68 | + '!C' $ |
---|
69 | + 'Usage : ' + usage]) |
---|
70 | return, -1 |
---|
71 | ENDIF |
---|
72 | |
---|
73 | arg_type = size(degree,/type) |
---|
74 | IF ((arg_type NE 2) AND (arg_type NE 3)) THEN BEGIN |
---|
75 | ras = report(['Incorrect arg type degree' $ |
---|
76 | + '!C' $ |
---|
77 | + 'Usage : ' + usage]) |
---|
78 | return, -1 |
---|
79 | ENDIF |
---|
80 | |
---|
81 | arg_dim = size(degree,/n_elements) |
---|
82 | IF (arg_dim GT 1) THEN BEGIN |
---|
83 | ras = report(['Incorrect arg dimension degree' $ |
---|
84 | + '!C' $ |
---|
85 | + 'Usage : ' + usage]) |
---|
86 | return, -1 |
---|
87 | ENDIF |
---|
88 | |
---|
89 | arg_type = size(minute,/type) |
---|
90 | IF (arg_type NE 4) THEN BEGIN |
---|
91 | ras = report(['Incorrect arg type minute' $ |
---|
92 | + '!C' $ |
---|
93 | + 'Usage : ' + usage]) |
---|
94 | return, -1 |
---|
95 | ENDIF |
---|
96 | |
---|
97 | arg_dim = size(minute,/n_elements) |
---|
98 | IF (arg_dim GT 1) THEN BEGIN |
---|
99 | ras = report(['Incorrect arg dimension minute' $ |
---|
100 | + '!C' $ |
---|
101 | + 'Usage : ' + usage]) |
---|
102 | return, -1 |
---|
103 | ENDIF |
---|
104 | |
---|
105 | ; conversion |
---|
106 | dd = degree + minute/60.d |
---|
107 | |
---|
108 | return,dd |
---|
109 | |
---|
110 | END |
---|