source: trunk/SRC/ToBeReviewed/PLOTS/axe.pro @ 76

Last change on this file since 76 was 42, checked in by pinsard, 18 years ago

upgrade of PLOTS according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/

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