1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; NAME:axe |
---|
6 | ; |
---|
7 | ; PURPOSE:gerre les axes pour les differents dessins crees par plt, |
---|
8 | ; pltz et pltt |
---|
9 | ; |
---|
10 | ; CATEGORY:environnement graphique |
---|
11 | ; |
---|
12 | ; CALLING SEQUENCE:axe,coupe[,tempsmin,tempsmax] |
---|
13 | ; |
---|
14 | ; INPUTS: |
---|
15 | ; coupe: un string qui designe le type de coupe auquel doit de |
---|
16 | ; raporter les axes que l''on cree. par ex: 'xy','xt'... |
---|
17 | ; |
---|
18 | ; tempsmin et tempsmax: ds le cas ou l''on fait une coupe |
---|
19 | ; contenant la dimension temps, il faut specifier le debut et |
---|
20 | ; la fin de l''axe des temps en jours julien. |
---|
21 | ; |
---|
22 | ; KEYWORD PARAMETERS: /SIN active qd on trace en sinus de la latitude |
---|
23 | ; |
---|
24 | ; SEPDATE: string separant les differents constituants de la |
---|
25 | ; date. Par defaut c''est un retour a la ligne qd on fait un |
---|
26 | ; 'yt', 'zt' ou 't' dans les autres cas c''est un blanc. |
---|
27 | ; |
---|
28 | ; DIGITSYEAR=2 to use %Z format (2 digits) to code years |
---|
29 | ; instead of %Y format. See help of label_date for more |
---|
30 | ; informations on %Z and %Y. |
---|
31 | ; |
---|
32 | ; OUTPUTS:les variables globales d''environnement graphique: !x. et !y. |
---|
33 | ; |
---|
34 | ; COMMON BLOCKS: |
---|
35 | ; common.pro |
---|
36 | ; |
---|
37 | ; SIDE EFFECTS:modifie !x. et !y. |
---|
38 | ; |
---|
39 | ; RESTRICTIONS: |
---|
40 | ; |
---|
41 | ; EXAMPLE: |
---|
42 | ; |
---|
43 | ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
44 | ; 11/12/98 |
---|
45 | ; Eric Guilyardi types x,y,z + amelioration de |
---|
46 | ; l''axe temporel |
---|
47 | ;- |
---|
48 | ;------------------------------------------------------------ |
---|
49 | ;------------------------------------------------------------ |
---|
50 | ;------------------------------------------------------------ |
---|
51 | PRO axe, coupe,tempsmin,tempsmax, REVERSE_X = reverse_x, REVERSE_Y = reverse_y, SIN = sin, SEPDATE = sepdate, DIGITSYEAR = digitsyear, _EXTRA = ex |
---|
52 | ; |
---|
53 | compile_opt idl2, strictarrsubs |
---|
54 | ; |
---|
55 | @common |
---|
56 | tempsun = systime(1) ; pour key_performance |
---|
57 | ;-------------------------------------------------------------- |
---|
58 | ; gestion des ticks de l'axe des temps ds le ces ou tempsmin et |
---|
59 | ; tempsmax sont definits |
---|
60 | ;-------------------------------------------------------------- |
---|
61 | divday = 0 |
---|
62 | if n_params() EQ 3 then BEGIN |
---|
63 | ; |
---|
64 | if keyword_set(sepdate) then sep = sepdate ELSE $ |
---|
65 | if coupe EQ 'yt' OR coupe EQ 'zt' OR coupe EQ 't' then sep = '!C' ELSE sep = ' ' |
---|
66 | ; |
---|
67 | caldat,tempsmin, mmin, dmin, ymin, hmin, mnmin, smin, _EXTRA = ex |
---|
68 | caldat,tempsmax, mmax, dmax, ymax, hmax, mnmax, smax, _EXTRA = ex |
---|
69 | ; format used for the year (2 or 4/5 digits). |
---|
70 | IF NOT keyword_set(digitsyear) THEN digitsyear = 4 |
---|
71 | IF digitsyear EQ 2 THEN fmtyr = '%Z' ELSE fmtyr = '%Y' |
---|
72 | ; |
---|
73 | if ymax EQ ymin then BEGIN |
---|
74 | if mmin ne mmax then BEGIN |
---|
75 | ; meme annee mais plusieurs mois |
---|
76 | nticks = mmax-mmin+1 |
---|
77 | ticknom = lonarr(nticks) |
---|
78 | for m = 0,nticks-1 do ticknom[m] = julday(m+mmin, 1, ymin, _EXTRA = ex) |
---|
79 | tminor = 6 |
---|
80 | datfmt = '%M'+sep+fmtyr |
---|
81 | ; on verifie que les labels rentrent bien entre tempsmin et tempsmax... |
---|
82 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax AND ticknom NE -1)] |
---|
83 | nticks = n_elements(ticknom) |
---|
84 | ; cas particulier ou l''on est a cheval sur 2 mois |
---|
85 | if nticks LE 1 then begin |
---|
86 | nticks = (dmax+(jourdsmois(mmin, ymin))[0]-dmin+1)/2 |
---|
87 | ticknom = lonarr(nticks) |
---|
88 | for d = 0,nticks-1 do ticknom[d] = julday(mmin, d*2+dmin, ymin, _EXTRA = ex) |
---|
89 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax $ |
---|
90 | AND ticknom NE -1)] |
---|
91 | nticks = n_elements(ticknom) |
---|
92 | tminor = 2 |
---|
93 | datfmt = '%D'+sep+'%M' |
---|
94 | endif |
---|
95 | ENDIF ELSE BEGIN |
---|
96 | ; meme annee et meme mois |
---|
97 | IF dmax-dmin+1 GT 4 THEN BEGIN ; more than 4 days |
---|
98 | nticks = dmax-dmin+1 |
---|
99 | ticknom = lonarr(nticks) |
---|
100 | for d = 0,nticks-1 do ticknom[d] = julday(mmin, d+dmin, ymin, _EXTRA = ex) |
---|
101 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax $ |
---|
102 | AND ticknom NE -1)] |
---|
103 | nticks = n_elements(ticknom) |
---|
104 | tminor = 2 |
---|
105 | datfmt = '%D'+sep+'%M' |
---|
106 | ENDIF ELSE BEGIN ; less than 4 days : divday ticks per day |
---|
107 | divday = 4 |
---|
108 | nticks = (dmax-dmin)*divday + 1 |
---|
109 | ticknom = fltarr(nticks) |
---|
110 | for d = 0,nticks-1 do $ |
---|
111 | ticknom[d] = julday(mmin, d/divday+dmin, ymin, _EXTRA = ex) $ |
---|
112 | +(d MOD divday)/float(divday) |
---|
113 | tminor = 2 |
---|
114 | datfmt = '%H:00' |
---|
115 | ENDELSE |
---|
116 | ENDELSE |
---|
117 | ENDIF ELSE BEGIN |
---|
118 | ; plusieurs annees |
---|
119 | CASE 1 OF |
---|
120 | ymax-ymin+1 LE 10: BEGIN & freq = 1. & tminor = 12 & datfmt = '%M'+sep+fmtyr & end |
---|
121 | ymax-ymin+1 LE 20: BEGIN & freq = 2. & tminor = 6 & datfmt = '%M'+sep+fmtyr & end |
---|
122 | ymax-ymin+1 LE 50: BEGIN & freq = 5. & tminor = 5 & datfmt = '%M'+sep+fmtyr & end |
---|
123 | ymax-ymin+1 LE 100: BEGIN & freq = 10. & tminor = 10 & datfmt = fmtyr & end |
---|
124 | ymax-ymin+1 LE 1000: BEGIN & freq = 50. & tminor = 5 & datfmt = fmtyr & end |
---|
125 | ELSE : BEGIN & freq = 100. & tminor = 50 & datfmt = '%Y' & end |
---|
126 | ENDCASE |
---|
127 | nticks = floor((ymax-ymin)/freq)+1 |
---|
128 | IF floor((ymin)/freq) NE (ymin)/freq THEN $ |
---|
129 | yminf = (floor(ymin/freq)+1)*freq ELSE $ |
---|
130 | yminf = (floor(ymin/freq))*freq |
---|
131 | ticknom = lonarr(nticks) |
---|
132 | for y = 0, nticks-1 do ticknom[y] = julday(1, 1, yminf+(y*freq), _EXTRA = ex) |
---|
133 | ; on verifie que les labels rentrent bien entre tempsmin et tempsmax... |
---|
134 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax AND ticknom NE -1)] |
---|
135 | nticks = n_elements(ticknom) |
---|
136 | ; cas particulier ou l''on est a cheval sur 2 annees |
---|
137 | if nticks LE 1 then begin |
---|
138 | nticks = (mmax+12)-mmin+1 |
---|
139 | ticknom = lonarr(nticks) |
---|
140 | for m = 0,nticks-1 do ticknom[m] = julday(m+mmin, 1, ymin, _EXTRA = ex) |
---|
141 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax AND ticknom NE -1)] |
---|
142 | nticks = n_elements(ticknom) |
---|
143 | tminor = 6 |
---|
144 | datfmt = '%M'+sep+fmtyr |
---|
145 | ; cas particulier ou l''on est a cheval sur 2 mois |
---|
146 | if nticks LE 1 then begin |
---|
147 | nticks = (dmax+(jourdsmois(mmin, ymin))[0]-dmin+1)/2 |
---|
148 | ticknom = lonarr(nticks) |
---|
149 | for d = 0,nticks-1 do ticknom[d] = julday(mmin, d*2+dmin, ymin, _EXTRA = ex) |
---|
150 | ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax $ |
---|
151 | AND ticknom NE -1)] |
---|
152 | nticks = n_elements(ticknom) |
---|
153 | tminor = 2 |
---|
154 | datfmt = '%D'+sep+'%M' |
---|
155 | endif |
---|
156 | endif |
---|
157 | ENDELSE |
---|
158 | toto = label_date(0, 0, 0, DATE_FORMAT = datfmt, _EXTRA = ex) |
---|
159 | if chkstru(ex, 'DATE_FORMAT') then ex.DATE_FORMAT = '' |
---|
160 | ENDIF |
---|
161 | ;-------------------------------------------------------------- |
---|
162 | ; definition des parametres des axes au cas par cas |
---|
163 | ;-------------------------------------------------------------- |
---|
164 | case coupe of |
---|
165 | 'xy':BEGIN |
---|
166 | if keyword_set(reverse_x) then !x.range=[lon2,lon1] ELSE !x.range=[lon1,lon2] |
---|
167 | if keyword_set(reverse_y) then !y.range=[lat2,lat1] ELSE !y.range=[lat1,lat2] |
---|
168 | IF key_onearth THEN !x.tickformat='lonaxe' |
---|
169 | IF key_onearth THEN !y.tickformat='lataxe' |
---|
170 | END |
---|
171 | 'yz':BEGIN |
---|
172 | if keyword_set(reverse_x) then !x.range=[lat2,lat1] ELSE !x.range=[lat1,lat2] |
---|
173 | if keyword_set(reverse_y) then !y.range=[0, -1] ELSE !y.range = [-1, 0] |
---|
174 | if keyword_set(sin) then BEGIN |
---|
175 | ; nombre de ticks par defaut |
---|
176 | plot, [0], [0], /noerase, /nodata, xtick_get = xaxe |
---|
177 | ; on augmente ce nombre pour qu''il soit autour de 10 |
---|
178 | ticks = n_elements(xaxe)-1 |
---|
179 | ticks = ticks*[1, 2, 4, 8] |
---|
180 | ticks = ticks[(sort(abs(ticks-10)))[0]] |
---|
181 | ; on recupere l''axex pour ce nouveau nombre de ticks |
---|
182 | plot, [0], [0],xticks = ticks, /noerase, /nodata, xtick_get = xaxe |
---|
183 | !x.ticks = ticks |
---|
184 | !x.tickv = sin(!pi/180.*xaxe) |
---|
185 | tickname = strarr(ticks+1) |
---|
186 | for i = 0,ticks do tickname[i] = lataxe(0, 0, xaxe[i]) |
---|
187 | !x.tickname = tickname |
---|
188 | !x.range = sin(!pi/180.*!x.range) |
---|
189 | endif |
---|
190 | end |
---|
191 | 'xz':BEGIN |
---|
192 | if keyword_set(reverse_x) then !x.range=[lon2,lon1] ELSE !x.range=[lon1,lon2] |
---|
193 | if keyword_set(reverse_y) then !y.range=[0, -1] ELSE !y.range = [-1, 0] |
---|
194 | end |
---|
195 | 'xt' : begin |
---|
196 | if keyword_set(reverse_x) then !x.range = [lon2,lon1] ELSE !x.range=[lon1,lon2] |
---|
197 | if keyword_set(reverse_y) then !y.range=[tempsmax, tempsmin]-tempsmin $ |
---|
198 | ELSE !y.range=[tempsmin,tempsmax]-tempsmin |
---|
199 | IF key_onearth THEN !x.tickformat='lonaxe' |
---|
200 | ; result = LABEL_DATE(DATE_FORMAT = '%M'+sep+fmtyr) |
---|
201 | ; !y.tickformat='LABEL_DATE' |
---|
202 | !y.tickname = LABEL_DATE(1, 0,ticknom,_EXTRA = ex) |
---|
203 | !y.ticklen=1. |
---|
204 | !y.gridstyle=2 |
---|
205 | !y.ticks=nticks-1 |
---|
206 | !y.tickv=ticknom-tempsmin |
---|
207 | !y.minor=tminor |
---|
208 | IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ |
---|
209 | +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) |
---|
210 | end |
---|
211 | 'yt' : begin |
---|
212 | if keyword_set(reverse_x) then !x.range = [tempsmax,tempsmin]-tempsmin $ |
---|
213 | ELSE !x.range=[tempsmin,tempsmax]-tempsmin |
---|
214 | if keyword_set(reverse_y) then !y.range=[lat2, lat1] ELSE !y.range=[lat1,lat2] |
---|
215 | IF key_onearth THEN !y.tickformat='lataxe' |
---|
216 | !x.tickname = LABEL_DATE(0, 0,ticknom,_EXTRA = ex) |
---|
217 | !x.ticklen=1. |
---|
218 | !x.gridstyle=2 |
---|
219 | !x.ticks=nticks-1 |
---|
220 | !x.tickv=ticknom-tempsmin |
---|
221 | !x.minor=tminor |
---|
222 | IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ |
---|
223 | +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) |
---|
224 | end |
---|
225 | 'zt' : begin |
---|
226 | if keyword_set(reverse_x) then !x.range = [tempsmax,tempsmin]-tempsmin $ |
---|
227 | ELSE !x.range=[tempsmin,tempsmax]-tempsmin |
---|
228 | if vargrid EQ 'W' then gdep=gdepw[0:nzw-1] ELSE gdep=gdept[0:nzt-1] |
---|
229 | !x.tickname = LABEL_DATE(0, 0,ticknom,_EXTRA = ex) |
---|
230 | !x.ticklen=1. |
---|
231 | !x.gridstyle=2 |
---|
232 | !x.ticks=nticks-1 |
---|
233 | !x.tickv=ticknom-tempsmin |
---|
234 | !x.minor=tminor |
---|
235 | IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ |
---|
236 | +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) |
---|
237 | end |
---|
238 | 't' : BEGIN |
---|
239 | if keyword_set(reverse_x) then !x.range = [tempsmax,tempsmin]-tempsmin $ |
---|
240 | ELSE !x.range=[tempsmin,tempsmax]-tempsmin |
---|
241 | !x.tickname = LABEL_DATE(0, 0,ticknom,_EXTRA = ex) |
---|
242 | !x.ticklen=1. |
---|
243 | !x.gridstyle=2 |
---|
244 | !x.ticks=nticks-1 |
---|
245 | !x.tickv=ticknom-tempsmin |
---|
246 | !x.minor=tminor |
---|
247 | IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ |
---|
248 | +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) |
---|
249 | end |
---|
250 | 'x' : begin |
---|
251 | !x.range=[lon1,lon2] |
---|
252 | IF key_onearth THEN !x.tickformat='lonaxe' |
---|
253 | END |
---|
254 | 'y' : begin |
---|
255 | if keyword_set(sin) then BEGIN |
---|
256 | ; nombre de ticks par defaut |
---|
257 | plot, [0], [0], /nodata, /noerase, xstyle = 5, ystyle = 5, xtick_get = xaxe |
---|
258 | ; on augmente ce nombre pour qu''il soit autour de 10 |
---|
259 | ticks = n_elements(xaxe)-1 |
---|
260 | ticks = ticks*[1, 2, 4, 8] |
---|
261 | ticks = ticks[(sort(abs(ticks-10)))[0]] |
---|
262 | ; on recupere l''axex pour ce nouveau nombre de ticks |
---|
263 | plot, [0], [0],xticks = ticks,/nodata,/noerase,xstyle=5,ystyle=5,xtick_get=xaxe |
---|
264 | !x.ticks = ticks |
---|
265 | !x.tickv = sin(!pi/180.*xaxe) |
---|
266 | tickname = strarr(ticks+1) |
---|
267 | for i = 0,ticks do tickname[i] = lataxe(0, 0, xaxe[i]) |
---|
268 | !x.tickname = tickname |
---|
269 | !x.range = sin(!pi/180.*!x.range) |
---|
270 | ENDIF ELSE !x.range=[lat1,lat2] |
---|
271 | IF key_onearth THEN !x.tickformat='lataxe' |
---|
272 | END |
---|
273 | 'z' : begin |
---|
274 | ; if vargrid EQ 'W' then gdep=gdepw[0:nzw-1] ELSE gdep=gdept[0:nzt-1] |
---|
275 | ; if keyword_set(reverse_y) then !y.range=[gdep[0], gdep[n_elements(gdep)-1]] $ |
---|
276 | ; ELSE !y.range=[gdep[n_elements(gdep)-1], gdep[0]] |
---|
277 | END |
---|
278 | endcase |
---|
279 | if keyword_set(key_performance) THEN print, 'temps axe', systime(1)-tempsun |
---|
280 | return |
---|
281 | end |
---|