;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; ; @file_comments ; Manage axes for the different drawings created by plt, ; pltz and pltt ; ; @categories ; Graphics ; ; @param COUPE {type=string} ; It designate the type of cut to which the axes we create ; must report. For example: 'xy','xt'... ; ; @param TEMPSMIN {in}{required} ; In the case where we do cut containing the time dimension, we have ; to specify the beginning of the time's axis in julian days. ; ; @param TEMPSMAX {in}{required} ; In the case where we do cut containing the time dimension, we have ; to specify the end of the time's axis in julian days. ; ; @keyword SIN ; activated when we trace in sinus of the latitude ; ; @keyword SEPDATE {type=string} ; It separate the different constituents of the date. By default, ; it is a return to the line when we do a 'yt', 'zt' or a 't'. ; In the other cases, it is a blank. ; ; @keyword DIGITSYEAR ; =2 to use %Z format (2 digits) to code years ; instead of %Y format. See help of label_date for more ; information on %Z and %Y. ; ; @keyword _EXTRA ; used to pass your keywords ; ; @uses ; common.pro ; ; @restrictions ; It modify !x. and !y. ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; 11/12/98 ; Eric Guilyardi types x,y,z + amelioration de ; l''axe temporel ; ; @version ; $Id$ ; ;- ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ PRO axe, coupe,tempsmin,tempsmax, REVERSE_X = reverse_x, REVERSE_Y = reverse_y, SIN = sin, SEPDATE = sepdate, DIGITSYEAR = digitsyear, _EXTRA = ex ; compile_opt idl2, strictarrsubs ; @common tempsun = systime(1) ; pour key_performance ;-------------------------------------------------------------- ; Management of ticks of the time axis in the case of TEMPSMIN ; and TEMPSMAX are definied ;-------------------------------------------------------------- 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 ; format used for the year (2 or 4/5 digits). IF NOT keyword_set(digitsyear) THEN digitsyear = 4 IF digitsyear EQ 2 THEN fmtyr = '%Z' ELSE fmtyr = '%Y' ; if ymax EQ ymin then BEGIN if mmin ne mmax then BEGIN ; Same year but several monthes 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+fmtyr ; We check that labels are betwenn TEMPSMIN and TEMPSMAX... ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax AND ticknom NE -1)] nticks = n_elements(ticknom) ; Particular case where we are overlap two monthes if nticks LE 1 then begin nticks = (dmax+(jourdsmois(mmin, ymin))[0]-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 ; Same year and same month 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 ; Several years CASE 1 OF ymax-ymin+1 LE 10: BEGIN & freq = 1. & tminor = 12 & datfmt = '%M'+sep+fmtyr & end ymax-ymin+1 LE 20: BEGIN & freq = 2. & tminor = 6 & datfmt = '%M'+sep+fmtyr & end ymax-ymin+1 LE 50: BEGIN & freq = 5. & tminor = 5 & datfmt = '%M'+sep+fmtyr & end ymax-ymin+1 LE 100: BEGIN & freq = 10. & tminor = 10 & datfmt = fmtyr & end ymax-ymin+1 LE 1000: BEGIN & freq = 50. & tminor = 5 & datfmt = fmtyr & end ELSE : BEGIN & freq = 100. & tminor = 50 & 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) ; We check that labels are betwenn TEMPSMIN and TEMPSMAX... ticknom = ticknom[where(ticknom GE tempsmin AND ticknom LE tempsmax AND ticknom NE -1)] nticks = n_elements(ticknom) ; Particular case where we are overlap two monthes 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+fmtyr ; Particular case where we are overlap two monthes if nticks LE 1 then begin nticks = (dmax+(jourdsmois(mmin, ymin))[0]-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 of axes parameters case by case ;-------------------------------------------------------------- case coupe of 'pltv':BEGIN dtasize = tempsmin !x.range = [-0.5, dtasize[0] - 0.5] !y.range = [-0.5, dtasize[1] - 0.5] if keyword_set(reverse_x) then !x.range=reverse(!x.range) if keyword_set(reverse_y) then !y.range=reverse(!y.range) !x.title = 'nx' !y.title = 'ny' END '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] IF key_onearth THEN !x.tickformat='lonaxe' IF key_onearth THEN !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 ; number of ticks by default plot, [0], [0], /noerase, /nodata, xtick_get = xaxe ; We increase this number to it be around 10 ticks = n_elements(xaxe)-1 ticks = ticks*[1, 2, 4, 8] ticks = ticks[(sort(abs(ticks-10)))[0]] ; We recuperate the x axis for this new number of 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 IF key_onearth THEN !x.tickformat='lonaxe' ; result = LABEL_DATE(DATE_FORMAT = '%M'+sep+fmtyr) ; !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] IF key_onearth THEN !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] IF key_onearth THEN !x.tickformat='lonaxe' END 'y' : begin if keyword_set(sin) then BEGIN ; Number of ticks by default plot, [0], [0], /nodata, /noerase, xstyle = 5, ystyle = 5, xtick_get = xaxe ; We increase this number to it be around 10 ticks = n_elements(xaxe)-1 ticks = ticks*[1, 2, 4, 8] ticks = ticks[(sort(abs(ticks-10)))[0]] ; We recuperate the x axis for this new number of 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] IF key_onearth THEN !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