source: trunk/src/dm2dd.pro @ 2

Last change on this file since 2 was 2, checked in by pinsard, 14 years ago

first commit with original work of Marina Levy and Francoise Pinsard

  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
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;-
55FUNCTION DM2DD, degree, minute
56
57compile_opt idl2, strictarrsubs
58
59; Return to caller if errors
60ON_ERROR, 2
61
62usage = 'result=dms2dss(degree, minute)'
63
64; check parameters
65nparam = N_PARAMS()
66IF (nparam LT 2) THEN BEGIN
67   ras = report(['Incorrect number of arguments.' $
68         + '!C' $
69         + 'Usage : ' + usage])
70   return, -1
71ENDIF
72
73arg_type = size(degree,/type)
74IF ((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
79ENDIF
80
81arg_dim =  size(degree,/n_elements)
82IF (arg_dim GT 1) THEN BEGIN
83   ras = report(['Incorrect arg dimension degree' $
84         + '!C' $
85         + 'Usage : ' + usage])
86   return, -1
87ENDIF
88
89arg_type = size(minute,/type)
90IF (arg_type NE 4) THEN BEGIN
91   ras = report(['Incorrect arg type minute' $
92         + '!C' $
93         + 'Usage : ' + usage])
94   return, -1
95ENDIF
96
97arg_dim =  size(minute,/n_elements)
98IF (arg_dim GT 1) THEN BEGIN
99   ras = report(['Incorrect arg dimension minute' $
100         + '!C' $
101         + 'Usage : ' + usage])
102   return, -1
103ENDIF
104
105; conversion
106dd = degree + minute/60.d
107
108return,dd
109
110END
Note: See TracBrowser for help on using the repository browser.