1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; |
---|
6 | ; @file_comments |
---|
7 | ; Manage axes for the different drawings created by plt, |
---|
8 | ; pltz and pltt |
---|
9 | ; |
---|
10 | ; @categories |
---|
11 | ; Graphics |
---|
12 | ; |
---|
13 | ; @param COUPE |
---|
14 | ; It is a string designating the type of cut to which the axes we create |
---|
15 | ; must report. For example: 'xy','xt'... |
---|
16 | ; |
---|
17 | ; @param TEMPSMIN {in}{required} |
---|
18 | ; In the case where we do cut containing the time dimension, we have |
---|
19 | ; to specify the beginning of the time's axis in julian days. |
---|
20 | ; |
---|
21 | ; @param TEMPSMAX {in}{required} |
---|
22 | ; In the case where we do cut containing the time dimension, we have |
---|
23 | ; to specify the end of the time's axis in julian days. |
---|
24 | ; |
---|
25 | ; @keyword SIN |
---|
26 | ; activated when we trace in sinus of the latitude |
---|
27 | ; |
---|
28 | ; @keyword SEPDATE |
---|
29 | ; string separating the différent constituents of the date. By default, |
---|
30 | ; it is a return to the linewhen we do a 'yt', 'zt' or a 't'. |
---|
31 | ; In the other cases, it is a blank. |
---|
32 | ; |
---|
33 | ; @keyword DIGITSYEAR |
---|
34 | ; =2 to use %Z format (2 digits) to code years |
---|
35 | ; instead of %Y format. See help of label_date for more |
---|
36 | ; informations on %Z and %Y. |
---|
37 | ; |
---|
38 | ; @keyword _EXTRA |
---|
39 | ; used to pass your keywords |
---|
40 | ; |
---|
41 | ; @uses |
---|
42 | ; common.pro |
---|
43 | ; |
---|
44 | ; @restrictions |
---|
45 | ; It modify !x. and !y. |
---|
46 | ; |
---|
47 | ; @history |
---|
48 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
49 | ; 11/12/98 |
---|
50 | ; Eric Guilyardi types x,y,z + amelioration de |
---|
51 | ; l''axe temporel |
---|
52 | ; |
---|
53 | ; @version |
---|
54 | ; $Id$ |
---|
55 | ; |
---|
56 | ;- |
---|
57 | ;------------------------------------------------------------ |
---|
58 | ;------------------------------------------------------------ |
---|
59 | ;------------------------------------------------------------ |
---|
60 | PRO axe, coupe,tempsmin,tempsmax, REVERSE_X = reverse_x, REVERSE_Y = reverse_y, SIN = sin, SEPDATE = sepdate, DIGITSYEAR = digitsyear, _EXTRA = ex |
---|
61 | ; |
---|
62 | compile_opt idl2, strictarrsubs |
---|
63 | ; |
---|
64 | @common |
---|
65 | tempsun = systime(1) ; pour key_performance |
---|
66 | ;-------------------------------------------------------------- |
---|
67 | ; Management of ticks of the time axis in the case of TEMPSMIN |
---|
68 | ; and TEMPSMAX are definied |
---|
69 | ;-------------------------------------------------------------- |
---|
70 | divday = 0 |
---|
71 | if n_params() EQ 3 then BEGIN |
---|
72 | ; |
---|
73 | if keyword_set(sepdate) then sep = sepdate ELSE $ |
---|
74 | if coupe EQ 'yt' OR coupe EQ 'zt' OR coupe EQ 't' then sep = '!C' ELSE sep = ' ' |
---|
75 | ; |
---|
76 | caldat,tempsmin, mmin, dmin, ymin, hmin, mnmin, smin, _EXTRA = ex |
---|
77 | caldat,tempsmax, mmax, dmax, ymax, hmax, mnmax, smax, _EXTRA = ex |
---|
78 | ; format used for the year (2 or 4/5 digits). |
---|
79 | IF NOT keyword_set(digitsyear) THEN digitsyear = 4 |
---|
80 | IF digitsyear EQ 2 THEN fmtyr = '%Z' ELSE fmtyr = '%Y' |
---|
81 | ; |
---|
82 | if ymax EQ ymin then BEGIN |
---|
83 | if mmin ne mmax then BEGIN |
---|
84 | ; Same year but several monthes |
---|
85 | nticks = mmax-mmin+1 |
---|
86 | ticknom = lonarr(nticks) |
---|
87 | for m = 0,nticks-1 do ticknom[m] = julday(m+mmin, 1, ymin, _EXTRA = ex) |
---|
88 | tminor = 6 |
---|
89 | datfmt = '%M'+sep+fmtyr |
---|
90 | ; We check that labels are betwenn TEMPSMIN and TEMPSMAX... |
---|
91 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax AND ticknom NE -1)] |
---|
92 | nticks = n_elements(ticknom) |
---|
93 | ; Particular case where we are overlap two monthes |
---|
94 | if nticks LE 1 then begin |
---|
95 | nticks = (dmax+(jourdsmois(mmin, ymin))[0]-dmin+1)/2 |
---|
96 | ticknom = lonarr(nticks) |
---|
97 | for d = 0,nticks-1 do ticknom[d] = julday(mmin, d*2+dmin, ymin, _EXTRA = ex) |
---|
98 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax $ |
---|
99 | AND ticknom NE -1)] |
---|
100 | nticks = n_elements(ticknom) |
---|
101 | tminor = 2 |
---|
102 | datfmt = '%D'+sep+'%M' |
---|
103 | endif |
---|
104 | ENDIF ELSE BEGIN |
---|
105 | ; Same year and same month |
---|
106 | IF dmax-dmin+1 GT 4 THEN BEGIN ; more than 4 days |
---|
107 | nticks = dmax-dmin+1 |
---|
108 | ticknom = lonarr(nticks) |
---|
109 | for d = 0,nticks-1 do ticknom[d] = julday(mmin, d+dmin, ymin, _EXTRA = ex) |
---|
110 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax $ |
---|
111 | AND ticknom NE -1)] |
---|
112 | nticks = n_elements(ticknom) |
---|
113 | tminor = 2 |
---|
114 | datfmt = '%D'+sep+'%M' |
---|
115 | ENDIF ELSE BEGIN ; less than 4 days : divday ticks per day |
---|
116 | divday = 4 |
---|
117 | nticks = (dmax-dmin)*divday + 1 |
---|
118 | ticknom = fltarr(nticks) |
---|
119 | for d = 0,nticks-1 do $ |
---|
120 | ticknom[d] = julday(mmin, d/divday+dmin, ymin, _EXTRA = ex) $ |
---|
121 | +(d MOD divday)/float(divday) |
---|
122 | tminor = 2 |
---|
123 | datfmt = '%H:00' |
---|
124 | ENDELSE |
---|
125 | ENDELSE |
---|
126 | ENDIF ELSE BEGIN |
---|
127 | ; Several years |
---|
128 | CASE 1 OF |
---|
129 | ymax-ymin+1 LE 10: BEGIN & freq = 1. & tminor = 12 & datfmt = '%M'+sep+fmtyr & end |
---|
130 | ymax-ymin+1 LE 20: BEGIN & freq = 2. & tminor = 6 & datfmt = '%M'+sep+fmtyr & end |
---|
131 | ymax-ymin+1 LE 50: BEGIN & freq = 5. & tminor = 5 & datfmt = '%M'+sep+fmtyr & end |
---|
132 | ymax-ymin+1 LE 100: BEGIN & freq = 10. & tminor = 10 & datfmt = fmtyr & end |
---|
133 | ymax-ymin+1 LE 1000: BEGIN & freq = 50. & tminor = 5 & datfmt = fmtyr & end |
---|
134 | ELSE : BEGIN & freq = 100. & tminor = 50 & datfmt = '%Y' & end |
---|
135 | ENDCASE |
---|
136 | nticks = floor((ymax-ymin)/freq)+1 |
---|
137 | IF floor((ymin)/freq) NE (ymin)/freq THEN $ |
---|
138 | yminf = (floor(ymin/freq)+1)*freq ELSE $ |
---|
139 | yminf = (floor(ymin/freq))*freq |
---|
140 | ticknom = lonarr(nticks) |
---|
141 | for y = 0, nticks-1 do ticknom[y] = julday(1, 1, yminf+(y*freq), _EXTRA = ex) |
---|
142 | ; We check that labels are betwenn TEMPSMIN and TEMPSMAX... |
---|
143 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax AND ticknom NE -1)] |
---|
144 | nticks = n_elements(ticknom) |
---|
145 | ; Particular case where we are overlap two monthes |
---|
146 | if nticks LE 1 then begin |
---|
147 | nticks = (mmax+12)-mmin+1 |
---|
148 | ticknom = lonarr(nticks) |
---|
149 | for m = 0,nticks-1 do ticknom[m] = julday(m+mmin, 1, ymin, _EXTRA = ex) |
---|
150 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax AND ticknom NE -1)] |
---|
151 | nticks = n_elements(ticknom) |
---|
152 | tminor = 6 |
---|
153 | datfmt = '%M'+sep+fmtyr |
---|
154 | ; Particular case where we are overlap two monthes |
---|
155 | if nticks LE 1 then begin |
---|
156 | nticks = (dmax+(jourdsmois(mmin, ymin))[0]-dmin+1)/2 |
---|
157 | ticknom = lonarr(nticks) |
---|
158 | for d = 0,nticks-1 do ticknom[d] = julday(mmin, d*2+dmin, ymin, _EXTRA = ex) |
---|
159 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax $ |
---|
160 | AND ticknom NE -1)] |
---|
161 | nticks = n_elements(ticknom) |
---|
162 | tminor = 2 |
---|
163 | datfmt = '%D'+sep+'%M' |
---|
164 | endif |
---|
165 | endif |
---|
166 | ENDELSE |
---|
167 | toto = label_date(0, 0, 0, DATE_FORMAT = datfmt, _EXTRA = ex) |
---|
168 | if chkstru(ex, 'DATE_FORMAT') then ex.DATE_FORMAT = '' |
---|
169 | ENDIF |
---|
170 | ;-------------------------------------------------------------- |
---|
171 | ; Definition of axes parameters case by case |
---|
172 | ;-------------------------------------------------------------- |
---|
173 | case coupe of |
---|
174 | 'pltv':BEGIN |
---|
175 | dtasize = tempsmin |
---|
176 | !x.range = [-0.5, dtasize[0] - 0.5] |
---|
177 | !y.range = [-0.5, dtasize[1] - 0.5] |
---|
178 | if keyword_set(reverse_x) then !x.range=reverse(!x.range) |
---|
179 | if keyword_set(reverse_y) then !y.range=reverse(!y.range) |
---|
180 | !x.title = 'nx' |
---|
181 | !y.title = 'ny' |
---|
182 | END |
---|
183 | 'xy':BEGIN |
---|
184 | if keyword_set(reverse_x) then !x.range=[lon2,lon1] ELSE !x.range=[lon1,lon2] |
---|
185 | if keyword_set(reverse_y) then !y.range=[lat2,lat1] ELSE !y.range=[lat1,lat2] |
---|
186 | IF key_onearth THEN !x.tickformat='lonaxe' |
---|
187 | IF key_onearth THEN !y.tickformat='lataxe' |
---|
188 | END |
---|
189 | 'yz':BEGIN |
---|
190 | if keyword_set(reverse_x) then !x.range=[lat2,lat1] ELSE !x.range=[lat1,lat2] |
---|
191 | if keyword_set(reverse_y) then !y.range=[0, -1] ELSE !y.range = [-1, 0] |
---|
192 | if keyword_set(sin) then BEGIN |
---|
193 | ; number of ticks by default |
---|
194 | plot, [0], [0], /noerase, /nodata, xtick_get = xaxe |
---|
195 | ; We increase this number to it be around 10 |
---|
196 | ticks = n_elements(xaxe)-1 |
---|
197 | ticks = ticks*[1, 2, 4, 8] |
---|
198 | ticks = ticks[(sort(abs(ticks-10)))[0]] |
---|
199 | ; We recuperate the x axis for this new number of ticks |
---|
200 | plot, [0], [0],xticks = ticks, /noerase, /nodata, xtick_get = xaxe |
---|
201 | !x.ticks = ticks |
---|
202 | !x.tickv = sin(!pi/180.*xaxe) |
---|
203 | tickname = strarr(ticks+1) |
---|
204 | for i = 0,ticks do tickname[i] = lataxe(0, 0, xaxe[i]) |
---|
205 | !x.tickname = tickname |
---|
206 | !x.range = sin(!pi/180.*!x.range) |
---|
207 | endif |
---|
208 | end |
---|
209 | 'xz':BEGIN |
---|
210 | if keyword_set(reverse_x) then !x.range=[lon2,lon1] ELSE !x.range=[lon1,lon2] |
---|
211 | if keyword_set(reverse_y) then !y.range=[0, -1] ELSE !y.range = [-1, 0] |
---|
212 | end |
---|
213 | 'xt' : begin |
---|
214 | if keyword_set(reverse_x) then !x.range = [lon2,lon1] ELSE !x.range=[lon1,lon2] |
---|
215 | if keyword_set(reverse_y) then !y.range=[tempsmax, tempsmin]-tempsmin $ |
---|
216 | ELSE !y.range=[tempsmin,tempsmax]-tempsmin |
---|
217 | IF key_onearth THEN !x.tickformat='lonaxe' |
---|
218 | ; result = LABEL_DATE(DATE_FORMAT = '%M'+sep+fmtyr) |
---|
219 | ; !y.tickformat='LABEL_DATE' |
---|
220 | !y.tickname = LABEL_DATE(1, 0,ticknom,_EXTRA = ex) |
---|
221 | !y.ticklen=1. |
---|
222 | !y.gridstyle=2 |
---|
223 | !y.ticks=nticks-1 |
---|
224 | !y.tickv=ticknom-tempsmin |
---|
225 | !y.minor=tminor |
---|
226 | IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ |
---|
227 | +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) |
---|
228 | end |
---|
229 | 'yt' : begin |
---|
230 | if keyword_set(reverse_x) then !x.range = [tempsmax,tempsmin]-tempsmin $ |
---|
231 | ELSE !x.range=[tempsmin,tempsmax]-tempsmin |
---|
232 | if keyword_set(reverse_y) then !y.range=[lat2, lat1] ELSE !y.range=[lat1,lat2] |
---|
233 | IF key_onearth THEN !y.tickformat='lataxe' |
---|
234 | !x.tickname = LABEL_DATE(0, 0,ticknom,_EXTRA = ex) |
---|
235 | !x.ticklen=1. |
---|
236 | !x.gridstyle=2 |
---|
237 | !x.ticks=nticks-1 |
---|
238 | !x.tickv=ticknom-tempsmin |
---|
239 | !x.minor=tminor |
---|
240 | IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ |
---|
241 | +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) |
---|
242 | end |
---|
243 | 'zt' : begin |
---|
244 | if keyword_set(reverse_x) then !x.range = [tempsmax,tempsmin]-tempsmin $ |
---|
245 | ELSE !x.range=[tempsmin,tempsmax]-tempsmin |
---|
246 | if vargrid EQ 'W' then gdep=gdepw[0:nzw-1] ELSE gdep=gdept[0:nzt-1] |
---|
247 | !x.tickname = LABEL_DATE(0, 0,ticknom,_EXTRA = ex) |
---|
248 | !x.ticklen=1. |
---|
249 | !x.gridstyle=2 |
---|
250 | !x.ticks=nticks-1 |
---|
251 | !x.tickv=ticknom-tempsmin |
---|
252 | !x.minor=tminor |
---|
253 | IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ |
---|
254 | +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) |
---|
255 | end |
---|
256 | 't' : BEGIN |
---|
257 | if keyword_set(reverse_x) then !x.range = [tempsmax,tempsmin]-tempsmin $ |
---|
258 | ELSE !x.range=[tempsmin,tempsmax]-tempsmin |
---|
259 | !x.tickname = LABEL_DATE(0, 0,ticknom,_EXTRA = ex) |
---|
260 | !x.ticklen=1. |
---|
261 | !x.gridstyle=2 |
---|
262 | !x.ticks=nticks-1 |
---|
263 | !x.tickv=ticknom-tempsmin |
---|
264 | !x.minor=tminor |
---|
265 | IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ |
---|
266 | +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) |
---|
267 | end |
---|
268 | 'x' : begin |
---|
269 | !x.range=[lon1,lon2] |
---|
270 | IF key_onearth THEN !x.tickformat='lonaxe' |
---|
271 | END |
---|
272 | 'y' : begin |
---|
273 | if keyword_set(sin) then BEGIN |
---|
274 | ; Number of ticks by default |
---|
275 | plot, [0], [0], /nodata, /noerase, xstyle = 5, ystyle = 5, xtick_get = xaxe |
---|
276 | ; We increase this number to it be around 10 |
---|
277 | ticks = n_elements(xaxe)-1 |
---|
278 | ticks = ticks*[1, 2, 4, 8] |
---|
279 | ticks = ticks[(sort(abs(ticks-10)))[0]] |
---|
280 | ; We recuperate the x axis for this new number of ticks |
---|
281 | plot, [0], [0],xticks = ticks,/nodata,/noerase,xstyle=5,ystyle=5,xtick_get=xaxe |
---|
282 | !x.ticks = ticks |
---|
283 | !x.tickv = sin(!pi/180.*xaxe) |
---|
284 | tickname = strarr(ticks+1) |
---|
285 | for i = 0,ticks do tickname[i] = lataxe(0, 0, xaxe[i]) |
---|
286 | !x.tickname = tickname |
---|
287 | !x.range = sin(!pi/180.*!x.range) |
---|
288 | ENDIF ELSE !x.range=[lat1,lat2] |
---|
289 | IF key_onearth THEN !x.tickformat='lataxe' |
---|
290 | END |
---|
291 | 'z' : begin |
---|
292 | ; if vargrid EQ 'W' then gdep=gdepw[0:nzw-1] ELSE gdep=gdept[0:nzt-1] |
---|
293 | ; if keyword_set(reverse_y) then !y.range=[gdep[0], gdep[n_elements(gdep)-1]] $ |
---|
294 | ; ELSE !y.range=[gdep[n_elements(gdep)-1], gdep[0]] |
---|
295 | END |
---|
296 | endcase |
---|
297 | if keyword_set(key_performance) THEN print, 'temps axe', systime(1)-tempsun |
---|
298 | return |
---|
299 | end |
---|