;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; NAME:axe ; ; PURPOSE:gerre les axes pour les differents dessins crees par plt, ; pltz et pltt ; ; CATEGORY:environnement graphique ; ; CALLING SEQUENCE:axe,coupe[,tempsmin,tempsmax] ; ; INPUTS: ; coupe: un string qui designe le type de coupe auquel doit de ; raporter les axes que l''on cree. par ex: 'xy','xt'... ; ; tempsmin et tempsmax: ds le cas ou l''on fait une coupe ; contenant la dimension temps, il faut specifier le debut et ; la fin de l''axe des temps en jours julien. ; ; KEYWORD PARAMETERS: /SIN active qd on trace en sinus de la latitude ; ; SEPDATE: string separant les differents constituants de la ; date. Par defaut c''est un retour a la ligne qd on fait un ; 'yt', 'zt' ou 't' dans les autres cas c''est un blanc. ; ; OUTPUTS:les variables globales d''environnement graphique: !x. et !y. ; ; COMMON BLOCKS: ; common.pro ; ; SIDE EFFECTS:modifie !x. et !y. ; ; RESTRICTIONS: ; ; EXAMPLE: ; ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) ; 11/12/98 ; Eric Guilyardi types x,y,z + amelioration de ; l''axe temporel ;- ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ PRO axe, coupe,tempsmin,tempsmax, REVERSE_X = reverse_x, REVERSE_Y = reverse_y, SIN = sin, SEPDATE = sepdate, _EXTRA = ex @common tempsun = systime(1) ; pour key_performance ;-------------------------------------------------------------- ; gestion des ticks de l'axe des temps ds le ces ou tempsmin et ; tempsmax sont definits ;-------------------------------------------------------------- divday = 0 if n_params() EQ 3 then BEGIN ; if keyword_set(sepdate) then sep = sepdate ELSE $ if coupe EQ 'yt' OR coupe EQ 'zt' OR coupe EQ 't' then sep = '!C' ELSE sep = ' ' ; caldat,tempsmin, mmin, dmin, ymin, hmin, mnmin, smin, _EXTRA = ex caldat,tempsmax, mmax, dmax, ymax, hmax, mnmax, smax, _EXTRA = ex if ymax EQ ymin then BEGIN if mmin ne mmax then BEGIN ; meme annee mais plusieurs mois nticks = mmax-mmin+1 ticknom = lonarr(nticks) for m = 0,nticks-1 do ticknom[m] = julday(m+mmin, 1, ymin, _EXTRA = ex) tminor = 6 datfmt = '%M'+sep+'%Z' ; on verifie que les labels rentrent bien entre tempsmin et tempsmax... ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax AND ticknom NE -1)] nticks = n_elements(ticknom) ; cas particulier ou l''on est a cheval sur 2 mois if nticks LE 1 then begin nticks = (dmax+jourdsmois(mmin, ymin)-dmin+1)/2 ticknom = lonarr(nticks) for d = 0,nticks-1 do ticknom[d] = julday(mmin, d*2+dmin, ymin, _EXTRA = ex) ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax $ AND ticknom NE -1)] nticks = n_elements(ticknom) tminor = 2 datfmt = '%D'+sep+'%M' endif ENDIF ELSE BEGIN ; meme annee et meme mois IF dmax-dmin+1 GT 4 THEN BEGIN ; more than 4 days nticks = dmax-dmin+1 ticknom = lonarr(nticks) for d = 0,nticks-1 do ticknom[d] = julday(mmin, d+dmin, ymin, _EXTRA = ex) ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax $ AND ticknom NE -1)] nticks = n_elements(ticknom) tminor = 2 datfmt = '%D'+sep+'%M' ENDIF ELSE BEGIN ; less than 4 days : divday ticks per day divday = 4 nticks = (dmax-dmin)*divday + 1 ticknom = fltarr(nticks) for d = 0,nticks-1 do $ ticknom[d] = julday(mmin, d/divday+dmin, ymin, _EXTRA = ex) $ +(d MOD divday)/float(divday) tminor = 2 datfmt = '%H:00' ENDELSE ENDELSE ENDIF ELSE BEGIN ; plusieurs annees CASE 1 OF ymax-ymin+1 LE 10: BEGIN & freq = 1. & tminor = 12 & datfmt = '%M'+sep+'%Z' & end ymax-ymin+1 LE 20: BEGIN & freq = 2. & tminor = 6 & datfmt = '%M'+sep+'%Z' & end ymax-ymin+1 LE 50: BEGIN & freq = 5. & tminor = 5 & datfmt = '%M'+sep+'%Z' & end ymax-ymin+1 LE 100: BEGIN & freq = 10. & tminor = 10 & datfmt = '%Z' & end ELSE : BEGIN & freq = 20 & tminor = 20 & datfmt = '%Y' & end ENDCASE nticks = floor((ymax-ymin)/freq)+1 IF floor((ymin)/freq) NE (ymin)/freq THEN $ yminf = (floor(ymin/freq)+1)*freq ELSE $ yminf = (floor(ymin/freq))*freq ticknom = lonarr(nticks) for y = 0, nticks-1 do ticknom[y] = julday(1, 1, yminf+(y*freq), _EXTRA = ex) ; on verifie que les labels rentrent bien entre tempsmin et tempsmax... ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax AND ticknom NE -1)] nticks = n_elements(ticknom) ; cas particulier ou l''on est a cheval sur 2 annees if nticks LE 1 then begin nticks = (mmax+12)-mmin+1 ticknom = lonarr(nticks) for m = 0,nticks-1 do ticknom[m] = julday(m+mmin, 1, ymin, _EXTRA = ex) ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax AND ticknom NE -1)] nticks = n_elements(ticknom) tminor = 6 datfmt = '%M'+sep+'%Z' ; cas particulier ou l''on est a cheval sur 2 mois if nticks LE 1 then begin nticks = (dmax+jourdsmois(mmin, ymin)-dmin+1)/2 ticknom = lonarr(nticks) for d = 0,nticks-1 do ticknom[d] = julday(mmin, d*2+dmin, ymin, _EXTRA = ex) ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax $ AND ticknom NE -1)] nticks = n_elements(ticknom) tminor = 2 datfmt = '%D'+sep+'%M' endif endif ENDELSE toto = label_date(0, 0, 0, DATE_FORMAT = datfmt, _EXTRA = ex) if chkstru(ex, 'DATE_FORMAT') then ex.DATE_FORMAT = '' ENDIF ;-------------------------------------------------------------- ; definition des parametres des axes au cas par cas ;-------------------------------------------------------------- case coupe of 'xy':BEGIN if keyword_set(reverse_x) then !x.range=[lon2,lon1] ELSE !x.range=[lon1,lon2] if keyword_set(reverse_y) then !y.range=[lat2,lat1] ELSE !y.range=[lat1,lat2] !x.tickformat='lonaxe' !y.tickformat='lataxe' END 'yz':BEGIN if keyword_set(reverse_x) then !x.range=[lat2,lat1] ELSE !x.range=[lat1,lat2] if keyword_set(reverse_y) then !y.range=[0, -1] ELSE !y.range = [-1, 0] if keyword_set(sin) then BEGIN ; nombre de ticks par defaut plot, [0], [0], /noerase, /nodata, xtick_get = xaxe ; on augmente ce nombre pour qu''il soit autour de 10 ticks = n_elements(xaxe)-1 ticks = ticks*[1, 2, 4, 8] ticks = ticks[(sort(abs(ticks-10)))[0]] ; on recupere l''axex pour ce nouveau nombre de ticks plot, [0], [0],xticks = ticks, /noerase, /nodata, xtick_get = xaxe !x.ticks = ticks !x.tickv = sin(!pi/180.*xaxe) tickname = strarr(ticks+1) for i = 0,ticks do tickname[i] = lataxe(0, 0, xaxe[i]) !x.tickname = tickname !x.range = sin(!pi/180.*!x.range) endif end 'xz':BEGIN if keyword_set(reverse_x) then !x.range=[lon2,lon1] ELSE !x.range=[lon1,lon2] if keyword_set(reverse_y) then !y.range=[0, -1] ELSE !y.range = [-1, 0] end 'xt' : begin if keyword_set(reverse_x) then !x.range = [lon2,lon1] ELSE !x.range=[lon1,lon2] if keyword_set(reverse_y) then !y.range=[tempsmax, tempsmin]-tempsmin $ ELSE !y.range=[tempsmin,tempsmax]-tempsmin !x.tickformat='lonaxe' ; result = LABEL_DATE(DATE_FORMAT = '%M'+sep+'%Z') ; !y.tickformat='LABEL_DATE' !y.tickname = LABEL_DATE(1, 0,ticknom,_EXTRA = ex) !y.ticklen=1. !y.gridstyle=2 !y.ticks=nticks-1 !y.tickv=ticknom-tempsmin !y.minor=tminor IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) end 'yt' : begin if keyword_set(reverse_x) then !x.range = [tempsmax,tempsmin]-tempsmin $ ELSE !x.range=[tempsmin,tempsmax]-tempsmin if keyword_set(reverse_y) then !y.range=[lat2, lat1] ELSE !y.range=[lat1,lat2] !y.tickformat='lataxe' !x.tickname = LABEL_DATE(0, 0,ticknom,_EXTRA = ex) !x.ticklen=1. !x.gridstyle=2 !x.ticks=nticks-1 !x.tickv=ticknom-tempsmin !x.minor=tminor IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) end 'zt' : begin if keyword_set(reverse_x) then !x.range = [tempsmax,tempsmin]-tempsmin $ ELSE !x.range=[tempsmin,tempsmax]-tempsmin if vargrid EQ 'W' then gdep=gdepw[0:nzw-1] ELSE gdep=gdept[0:nzt-1] !x.tickname = LABEL_DATE(0, 0,ticknom,_EXTRA = ex) !x.ticklen=1. !x.gridstyle=2 !x.ticks=nticks-1 !x.tickv=ticknom-tempsmin !x.minor=tminor IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) end 't' : BEGIN if keyword_set(reverse_x) then !x.range = [tempsmax,tempsmin]-tempsmin $ ELSE !x.range=[tempsmin,tempsmax]-tempsmin !x.tickname = LABEL_DATE(0, 0,ticknom,_EXTRA = ex) !x.ticklen=1. !x.gridstyle=2 !x.ticks=nticks-1 !x.tickv=ticknom-tempsmin !x.minor=tminor IF divday GT 0 THEN !y.title = 'Time from '+strtrim(dmin,1)+' ' $ +def_month('1m', strtrim(mmin, 1))+' '+strtrim(ymin,1) end 'x' : begin !x.range=[lon1,lon2] !x.tickformat='lonaxe' END 'y' : begin if keyword_set(sin) then BEGIN ; nombre de ticks par defaut plot, [0], [0], /nodata, /noerase, xstyle = 5, ystyle = 5, xtick_get = xaxe ; on augmente ce nombre pour qu''il soit autour de 10 ticks = n_elements(xaxe)-1 ticks = ticks*[1, 2, 4, 8] ticks = ticks[(sort(abs(ticks-10)))[0]] ; on recupere l''axex pour ce nouveau nombre de ticks plot, [0], [0],xticks = ticks,/nodata,/noerase,xstyle=5,ystyle=5,xtick_get=xaxe !x.ticks = ticks !x.tickv = sin(!pi/180.*xaxe) tickname = strarr(ticks+1) for i = 0,ticks do tickname[i] = lataxe(0, 0, xaxe[i]) !x.tickname = tickname !x.range = sin(!pi/180.*!x.range) ENDIF ELSE !x.range=[lat1,lat2] !x.tickformat='lataxe' END 'z' : begin ; if vargrid EQ 'W' then gdep=gdepw[0:nzw-1] ELSE gdep=gdept[0:nzt-1] ; if keyword_set(reverse_y) then !y.range=[gdep[0], gdep[n_elements(gdep)-1]] $ ; ELSE !y.range=[gdep[n_elements(gdep)-1], gdep[0]] END endcase if keyword_set(key_performance) THEN print, 'temps axe', systime(1)-tempsun return end