source: trunk/PLOTS/axe.pro @ 2

Last change on this file since 2 was 2, checked in by opalod, 22 years ago

Initial revision

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