source: trunk/procs/def_month.pro @ 203

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

remove trailing blanks

  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1;+
2;
3; translate month number in string
4;
5; @categories
6; Calendar
7;
8; @param TIMAVE {in}{required}{type=string}
9;
10; @param DATE {in}{required}{type=string}
11;
12; @examples
13;
14; IDL> date='186001'
15; IDL> timave='1m\@t412'
16; IDL> mn = def_month(timave, date)
17; IDL> print, mn
18; January
19;
20; IDL> timave='1mm'
21; IDL> date='01_1860-1959'
22; IDL> mn = def_month(timave, date)
23; IDL> print, mn
24; January
25;
26; @returns
27; month name or season code
28; '???' or '??????' if decoding problem
29;
30; @uses
31; <pro>common</pro>
32; <propost_it>com_eg</propost_it>
33;
34; @todo
35; be more explicit when returns ??? or ??????
36;
37; add explanation on season code
38;
39; @history
40;
41; - fplod 20091208T165219Z aedon.locean-ipsl.upmc.fr (Darwin)
42;
43;   * check parameters
44;
45; @version
46; $Id$
47;
48;-
49FUNCTION def_month, timave, date
50;
51  compile_opt idl2, strictarrsubs
52;
53@common
54@com_eg
55;
56; Return to caller if errors
57 ON_ERROR, 2
58;
59 usage='result=def_month(timave, date)'
60;
61 nparam = N_PARAMS()
62 IF (nparam LT 2) THEN BEGIN
63    ras = report(['Incorrect number of arguments.' $
64          + '!C' $
65          + 'Usage : ' + usage])
66    mn = '???'
67    return, mn
68 ENDIF
69 arg_type = size(timave,/type)
70 IF (arg_type NE 7) THEN BEGIN
71   ras = report(['Incorrect arg type timave' $
72          + '!C' $
73          + 'Usage : ' + usage])
74    mn = '???'
75    return, mn
76 ENDIF
77 arg_type = size(date,/type)
78 IF (arg_type NE 7) THEN BEGIN
79   ras = report(['Incorrect arg type date' $
80          + '!C' $
81          + 'Usage : ' + usage])
82    mn = '???'
83    return, mn
84 ENDIF
85
86   IF strpos(date, '_') GT -1 THEN date = strmid(date, 0, strpos(date, '_'))
87   CASE strmid(timave, 0, 2) OF
88      '1m': BEGIN
89         CASE strmid(date, strlen(date)-2, 2) OF
90            '01': mn = 'January'
91            '02': mn = 'February'
92            '03': mn = 'March'
93            '04': mn = 'April'
94            '05': mn = 'May'
95            '06': mn = 'June'
96            '07': mn = 'July'
97            '08': mn = 'August'
98            '09': mn = 'September'
99            '10': mn = 'October'
100            '11': mn = 'November'
101            '12': mn = 'December'
102            ELSE: mn = '???'
103         ENDCASE
104      END
105      '3m': BEGIN
106         IF strpos(timave, '3mm') GT -1 THEN BEGIN
107            CASE time_array[0] OF
108               1: BEGIN
109                  CASE strmid(date, strlen(date)-2, 2) OF
110                     '01': mn = 'JFM'
111                     '02': mn = 'AMJ'
112                     '03': mn = 'JAS'
113                     '04': mn = 'OND'
114                     ELSE: mn = '???'
115                  ENDCASE
116               END
117               -9: BEGIN
118                  CASE strmid(date, strlen(date)-2, 2) OF
119                     '01': mn = 'MAM'
120                     '02': mn = 'JJA'
121                     '03': mn = 'SON'
122                     '04': mn = 'DJF'
123                     ELSE: mn = '???'
124                  ENDCASE
125               END
126               ELSE: BEGIN      ; = 4 or 11
127                  CASE strmid(date, strlen(date)-2, 2) OF
128                     '01': mn = 'DJF'
129                     '02': mn = 'MAM'
130                     '03': mn = 'JJA'
131                     '04': mn = 'SON'
132                     ELSE: mn = '???'
133                  ENDCASE
134               END
135            ENDCASE
136
137            ENDIF ELSE BEGIN
138               CASE time_array[0] OF
139                  -11: BEGIN
140                     CASE strmid(date, strlen(date)-2, 2) OF
141                        '01': mn = 'JFM'
142                        '04': mn = 'AMJ'
143                        '07': mn = 'JAS'
144                        '10': mn = 'OND'
145                        ELSE: mn = '???'
146                     ENDCASE
147                  END
148                  ELSE: BEGIN
149                     CASE strmid(date, strlen(date)-2, 2) OF
150                        '01': mn = 'DJF'
151                        '04': mn = 'MAM'
152                        '07': mn = 'JJA'
153                        '10': mn = 'SON'
154                        ELSE: mn = '???'
155                     ENDCASE
156                  END
157               ENDCASE
158
159            ENDELSE
160      END
161      '6m': BEGIN
162         IF strpos(timave, '6mm') GT -1 THEN BEGIN
163            CASE strmid(date, strlen(date)-2, 2) OF
164               '01': mn = 'JFMAMJ'
165               '02': mn = 'JASOND'
166               ELSE: mn = '??????'
167            ENDCASE
168         ENDIF
169      END
170      ELSE:
171   ENDCASE
172
173   return, mn
174END
Note: See TracBrowser for help on using the repository browser.