Changeset 35 for trunk


Ignore:
Timestamp:
05/02/06 16:44:47 (18 years ago)
Author:
pinsard
Message:

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

Location:
trunk
Files:
1 deleted
11 copied

Legend:

Unmodified
Added
Removed
  • trunk/ToBeReviewed/PLOTS/DESSINE/plt1d.pro

    r33 r35  
    2323;          * 1d:type doit qd meme etre specifie pour qu''on sache de 
    2424;          quel trace il sagit. Pour avoir une legende correcte, 
    25 ;          respecifier la zone d''extraction via BOITE 
     25;          respecifier la zone d''extraction via BOXZOOM 
    2626;       2) une structure repondant aux critaires specifies par 
    2727;       litchamp.pro. cf. IDL> xhelp,'litchamp'. Le tableau contennu ds 
     
    4141; KEYWORD PARAMETERS: 
    4242; 
    43 ;       BOITE:vecteur indiquant la zone geographique (3d) sur laquelle doit 
     43;       BOXZOOM:vecteur indiquant la zone geographique (3d) sur laquelle doit 
    4444; etre fait l''extraction du champ pour faire le hovmoeller. 
    45 ; Si BOITE a : 
    46 ; 1 element : l''extraction est faite sur [lon1, lon2, lat1, lat2, 0.,boite[0]] 
    47 ; 2 elements: l''extraction est faite sur [lon1, lon2, lat1, lat2, boite[0],boite[1]] 
    48 ; 4 elements: l''extraction est faite sur [Boite, prof1, prof2] 
    49 ; 5 elements: l''extraction est faite sur [Boite[0:3], 0, Boite[4]] 
    50 ; 6 elements: l''extraction est faite sur Boite 
    51 ; 
    52 ; Ou lon1, lon2,lat1,lat2,prof1,prof2 sont les variables globales 
     45; Si BOXZOOM a : 
     46; 1 element : l''extraction est faite sur [lon1, lon2, lat1, lat2, 0.,boxzoom[0]] 
     47; 2 elements: l''extraction est faite sur [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]] 
     48; 4 elements: l''extraction est faite sur [Boxzoom, vert1, vert2] 
     49; 5 elements: l''extraction est faite sur [Boxzoom[0:3], 0, Boxzoom[4]] 
     50; 6 elements: l''extraction est faite sur Boxzoom 
     51; 
     52; Ou lon1, lon2,lat1,lat2,vert1,vert2 sont les variables globales 
    5353; definies lors du dernier domdef! 
    5454; 
     
    128128; d'ouvrir plusieurs fenetres). par defaut on ouvre 'IDL0' 
    129129; 
    130 ;       YSURX: rapport d'echelle entre y et x. Par defaut=1 
     130;       YXASPECT: rapport d'echelle entre y et x. Par defaut=1 
    131131; Par defaut on adapte pour occupe une grande partie de la feuille en sortie 
    132132; postScript ou pour cree une fenetre pas trop etiree 
     133; 
     134;       /ZEROMIDDLE: fo force the middle of the colorbar to be equal 
     135;       to 0 (force max=max(abs([min,max])) and min=-max) 
    133136; 
    134137; COMMON BLOCKS: 
     
    150153;------------------------------------------------------------ 
    151154;------------------------------------------------------------ 
    152 pro plt1d,tab,giventype, givenmin,givenmax,BOITE = boite, SIN = sin $ 
    153           , MININ = minin, MAXIN = maxin, TYPEIN = typein,ENDPOINTS=endpoints $ 
    154           ,COL1D=col1d,STY1D=sty1d,OV1D=ov1d, X = x, Y = y, Z = z, TT = tt $ 
    155           , REVERSE_X = reverse_x, REVERSE_Y = reverse_y, _extra = ex 
    156 @common 
    157 ;------------------------------------------------------------ 
    158    tempsun = systime(1)         ; pour key_performance 
     155pro plt1d, tab, giventype, givenmin, givenmax, BOXZOOM = boxzoom, SIN = sin $ 
     156           , MININ = minin, MAXIN = maxin, TYPEIN = typein, ENDPOINTS = endpoints $ 
     157           , COL1D = col1d, STY1D = sty1d, OV1D = ov1d, X = x, Y = y, Z = z, TT = tt $ 
     158           , REVERSE_X = reverse_x, REVERSE_Y = reverse_y, SWITCHXY = switchxy $ 
     159           , _extra = ex 
     160;--------------------------------------------------------- 
     161; include common 
     162@cm_4mesh 
     163@cm_4data 
     164  IF NOT keyword_set(key_forgetold) THEN BEGIN 
     165@updatenew 
     166@updatekwd 
     167  ENDIF 
     168;------------------------------------------------------------ 
     169  tempsun = systime(1)          ; pour key_performance 
    159170;-------------------------------------------------------------- 
    160171; 1ere partie: initialisation et petits calculs... 
     
    164175; verification de la valeur de type 
    165176;-------------------------------------------------------------- 
    166    if n_elements(giventype) NE 0 then type = giventype 
    167    if n_elements(givenmin) NE 0 then min = givenmin 
    168    if n_elements(givenmax) NE 0 then max = givenmax 
    169    if n_elements(minin) NE 0 then min = minin 
    170    if n_elements(maxin) NE 0 then max = maxin 
    171    if keyword_set(tt) then typein = 't' 
    172    if keyword_set(typein) then BEGIN  
    173       if size(type, /type) NE 7 AND size(type, /type) NE 0 then begin 
    174          if n_elements(min) NE 0 then max = min 
    175          min = type 
    176       endif 
    177       type = typein 
    178    endif 
    179    if keyword_set(boite) then BEGIN  
    180       oldboite = [lon1, lon2, lat1, lat2, prof1, prof2] 
    181       vraiboite = boite 
    182    ENDIF 
    183    checktypeminmax, 'plt1d', TYPE = type, MIN = min, MAX = max, ENDPOINTS=endpoints $ 
    184     , XX = keyword_set(x) , YY = keyword_set(y) , ZZ = keyword_set(z)  
    185    if type EQ 't' then BEGIN 
    186       pltt, tab,type, min,max,BOITE = boite, SIN = sin, TYPEIN = typein $ 
    187        ,COL1D=col1d,STY1D=sty1d,OV1D=ov1d, ENDPOINTS=endpoints, _extra = ex 
    188       return 
    189    endif 
     177; 
     178  if n_elements(giventype) NE 0 then type = giventype 
     179  if n_elements(givenmin) NE 0 then min = givenmin 
     180  if n_elements(givenmax) NE 0 then max = givenmax 
     181  if n_elements(minin) NE 0 then min = minin 
     182  if n_elements(maxin) NE 0 then max = maxin 
     183  if keyword_set(tt) then typein = 't' 
     184  if keyword_set(typein) then BEGIN  
     185    if size(type, /type) NE 7 AND size(type, /type) NE 0 then begin 
     186      if n_elements(min) NE 0 then max = min 
     187      min = type 
     188    endif 
     189    type = typein 
     190  endif 
     191; 
     192  checktypeminmax, 'plt1d', TYPE = type, MIN = min, MAX = max, ENDPOINTS = endpoints $ 
     193    , XX = keyword_set(x), YY = keyword_set(y), ZZ = keyword_set(z)  
     194  if type EQ 't' then BEGIN 
     195    pltt, tab, type, min, max, BOXZOOM = boxzoom, SIN = sin, TYPEIN = typein $ 
     196      , COL1D = col1d, STY1D = sty1d, OV1D = ov1d, ENDPOINTS = endpoints, _extra = ex 
     197    return 
     198  endif 
    190199;-------------------------------------------------------------- 
    191200; I2) reinitialisation. !p.,!x.,!y. 
    192201; Rq: on ne reinitialise pas qd on rapelle plt1d 
    193202;-------------------------------------------------------------- 
    194    if NOT keyword_set(ov1d) then reinitplt 
     203  if NOT keyword_set(ov1d) then reinitplt 
    195204;-------------------------------------------------------------- 
    196205; I1) lecture du champ 
    197206;-------------------------------------------------------------- 
    198    if keyword_set(endpoints) then begin 
    199       section, tab, z1d, glam, gphi, ENDPOINTS = endpoints, TYPE = type, BOITE = boite, DIREC = direc 
    200       nx = n_elements(glam)  
    201       ny = nx 
    202       if strupcase(vargrid) EQ 'W' then begin 
    203          z = gdepw[premierzw:dernierzw] 
    204          nz = nzw 
    205       ENDIF ELSE BEGIN 
    206          z = gdept[premierzt:dernierzt] 
    207          nz = nzt 
    208       ENDELSE 
    209    ENDIF ELSE BEGIN  
    210       z1d = checkfield(tab, 'plt1d', TYPE = type, BOITE = boite, direc = direc, _extra = ex) 
    211       grille, mask, glam, gphi, gdep, nx, ny,nz 
    212    ENDELSE 
    213    if z1d[0] EQ -1 then BEGIN  
    214       if keyword_set(boite) then domdef, oldboite,GRILLE=vargrid 
    215       return 
    216    endif 
     207   if (keyword_set(boxzoom) OR keyword_set(endpoints)) THEN BEGIN 
     208     savedbox = 1b 
     209     saveboxparam, 'boxparam4plt1d.dat' 
     210   ENDIF 
     211; 
     212  if keyword_set(endpoints) then begin 
     213    section, tab, z1d, glam, gphi, ENDPOINTS = endpoints, TYPE = type $ 
     214      , BOXZOOM = boxzoom, DIREC = direc 
     215    nx = n_elements(glam)  
     216    ny = nx 
     217    if strupcase(vargrid) EQ 'W' then begin 
     218      z = gdepw[firstzw:lastzw] 
     219      nz = nzw 
     220    ENDIF ELSE BEGIN 
     221      z = gdept[firstzt:lastzt] 
     222      nz = nzt 
     223    ENDELSE 
     224  ENDIF ELSE BEGIN  
     225    z1d = checkfield(tab, 'plt1d', TYPE = type, BOXZOOM = boxzoom $ 
     226                     , direc = direc, _extra = ex) 
     227    grille, mask, glam, gphi, gdep, nx, ny, nz 
     228  ENDELSE 
     229  if z1d[0] EQ -1 then BEGIN  
     230    IF keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt1d.dat' 
     231    return 
     232  endif 
    217233; on construit le mask pour cela le tableau doit etre masque (fait 
    218234; automatiquement a la valeure valmask si on passe ds moyenne ou grossemoyenne) 
    219    mask = fltarr(n_elements(z1d)) 
    220    if n_elements(valmask) EQ 0 then valmask = 1e20 
    221    nan = total(finite(z1d,/nan))  < 1 
    222    if keyword_set(nan) then begin 
    223       notanum = where(finite(z1d) EQ 0) 
    224       z1d[notanum] = 0 
    225       mask(where(z1d LT valmask/10)) = 1 
    226       z1d[notanum] = !values.f_nan 
    227    ENDIF ELSE mask(where(z1d LT valmask/10)) = 1 
     235  mask = fltarr(n_elements(z1d)) 
     236  if n_elements(valmask) EQ 0 then valmask = 1e20 
     237  nan = total(finite(z1d, /nan))  < 1 
     238  if keyword_set(nan) then begin 
     239    notanum = where(finite(z1d) EQ 0) 
     240    z1d[notanum] = 0 
     241    mask(where(z1d LT valmask/10)) = 1 
     242    z1d[notanum] = !values.f_nan 
     243  ENDIF ELSE mask(where(z1d LT valmask/10)) = 1 
    228244;----------------------------------------------------------------------------- 
    229245; determination du min et du max apres la moyenne 
    230246;----------------------------------------------------------------------------- 
    231    nan = total(finite(z1d,/nan)) < 1 
    232    determineminmax, z1d, mask, mi, ma, MININ = min, MAXIN = max, nan = nan, INTERVALLE = intervalle 
    233    if z1d[0] EQ -1 THEN return 
    234 ;----------------------------------------------------------------------------- 
    235 ;----------------------------------------------------------------------------- 
    236    if NOT keyword_set(ov1d) THEN placedessin, 'autre', posfenetre, posbar, contour = contour, DIREC = direc, endpoints = endpoints, _extra = ex 
     247  nan = total(finite(z1d, /nan)) < 1 
     248  determineminmax, z1d, mask, mi, ma, MININ = min, MAXIN = max, nan = nan, INTERVALLE = intervalle, _extra = ex 
     249  if z1d[0] EQ -1 THEN return 
     250;----------------------------------------------------------------------------- 
     251;----------------------------------------------------------------------------- 
     252  if NOT keyword_set(ov1d) THEN placedessin, 'autre', posfenetre, posbar, contour = contour, DIREC = direc, endpoints = endpoints, _extra = ex 
    237253;-------------------------------------------------------------- 
    238254;-------------------------------------------------------------- 
     
    246262;----------------------------------------------------------------------------- 
    247263;----------------------------------------------------------------------------- 
    248    case type of 
    249       'y': begin 
    250          yy = z1d 
    251          if (size(gphi))[0] EQ 1 then xx = gphi ELSE xx = reform(gphi[0, *]) 
    252          if keyword_set(sin) then xx = sin(!pi/180.*xx) 
    253          min0 = lat1 & max0 = lat2 
    254       END 
    255       'x':begin 
    256          yy = z1d 
    257          xx = glam[*, 0] 
    258          min0 = lon1 & max0 = lon2 
    259       END  
    260       'z':begin 
    261          yy = reverse(gdep, 1) 
    262          xx = reverse(z1d, 1) 
    263          min0 = 0 & max0 = 0 
    264          case n_elements(vraiboite) of 
    265             0:!y.range=[prof1, prof2] 
    266             1:!y.range=[0, vraiboite] 
    267             2:!y.range=vraiboite 
    268             4:!y.range=[prof1, prof2] 
    269             5:!y.range=[0, vraiboite[4]] 
    270             6:!y.range=vraiboite[4:5] 
    271          endcase 
    272          if NOT keyword_set(ov1d) then !y.range = reverse(!y.range) 
    273       END  
    274    ENDCASE  
     264  case type of 
     265    'y': begin 
     266      yy = z1d 
     267      if (size(gphi))[0] EQ 1 then xx = gphi ELSE xx = reform(gphi[0, *]) 
     268      if keyword_set(sin) then xx = sin(!pi/180.*xx) 
     269      min0 = lat1 & max0 = lat2 
     270    END 
     271    'x':begin 
     272      yy = z1d 
     273      xx = glam[*, 0] 
     274      min0 = lon1 & max0 = lon2 
     275    END  
     276    'z':begin 
     277      yy = reverse(gdep, 1) 
     278      xx = reverse(z1d, 1) 
     279      min0 = 0 & max0 = 0 
     280      case n_elements(boxzoom) of 
     281        0:!y.range = [vert1, vert2] 
     282        1:!y.range = [0, boxzoom] 
     283        2:!y.range = boxzoom 
     284        4:!y.range = [vert1, vert2] 
     285        5:!y.range = [0, boxzoom[4]] 
     286        6:!y.range = boxzoom[4:5] 
     287      endcase 
     288      if NOT keyword_set(ov1d) then !y.range = reverse(!y.range) 
     289    END  
     290  ENDCASE  
    275291;----------------------------------------------------------- 
    276292;----------------------------------------------------------- 
     
    279295;    if keyword_set(integrationtps) then axe, type, time[0], time[jpt-1], SIN = sin, _extra = ex $ 
    280296;    ELSE axe, type, SIN = sin 
    281    if NOT keyword_set(ov1d) then axe, type, SIN = sin 
     297  if NOT keyword_set(ov1d) then axe, type, SIN = sin 
    282298;------------------------------------------------------------ 
    283299;------------------------------------------------------------ 
     
    285301;------------------------------------------------------------ 
    286302;------------------------------------------------------------ 
    287    if type EQ 'z' then begin 
    288       idx = where(xx NE valmask) 
    289       if NOT keyword_set(ov1d) then BEGIN  
    290          if min EQ mi then !x.range=[min-abs(max-min)/5.,max+abs(max-min)/5.] $ 
    291          ELSE !x.range=[min, max] 
     303  if type EQ 'z' then begin 
     304    idx = where(xx NE valmask) 
     305    if NOT keyword_set(ov1d) then BEGIN  
     306      if min EQ mi then !x.range = [min-abs(max-min)/5., max+abs(max-min)/5.] $ 
     307      ELSE !x.range = [min, max] 
     308    ENDIF 
     309  ENDIF ELSE BEGIN  
     310    idx = where(yy NE valmask) 
     311    if NOT keyword_set(ov1d) then BEGIN  
     312      if min EQ mi then !y.range = [min-abs(max-min)/5., max+abs(max-min)/5.] $ 
     313      ELSE !y.range = [min, max] 
     314    ENDIF 
     315  ENDELSE  
     316; 
     317  if NOT keyword_set(ov1d) then BEGIN  
     318    legende, mi, ma, type, CONTOUR = contour, DIREC = direc, ENDPOINTS = endpoints, _EXTRA = ex 
     319; 
     320  ENDIF 
     321  IF keyword_set(switchxy)  THEN BEGIN 
     322    tmp = xx 
     323    xx = yy 
     324    yy = temporary(tmp) 
     325    if NOT keyword_set(ov1d) then BEGIN  
     326      tmp = !x 
     327      !x = !y 
     328      !y = temporary(tmp) 
     329    ENDIF 
     330  ENDIF 
     331  if NOT keyword_set(ov1d) then BEGIN  
     332    if keyword_set(reverse_x) then !x.range = reverse(!x.range) 
     333    if keyword_set(reverse_y) then !y.range = reverse(!y.range) 
     334  ENDIF 
     335; 
     336  xx = xx[idx] 
     337  yy = yy[idx] 
     338  if (not keyword_set(col1d)) then col1d = 0 
     339  if keyword_set(sty1d) then BEGIN ;si on veut faire des barres 
     340    IF strlowcase(strtrim(sty1d)) EQ 'bar' then begin 
     341      !y.range = [!y.range[0]-(!y.range[1]-!y.range[0])*.05, !y.range[1]]  
     342      bar_plot, yy, background = (!d.n_colors-1) < 255,  $ 
     343        baselines = replicate(!y.range[0], n_elements(yy)), barnames = ['', ''], $ 
     344        colors    = replicate(col1d, n_elements(yy)), /outline 
     345      if n_elements(ex) NE 0 then BEGIN  
     346; pour avoir un cadre de la couleur noire 
     347        if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = 0 
    292348      ENDIF 
    293    ENDIF ELSE BEGIN  
    294       idx = where(yy NE valmask) 
    295       if NOT keyword_set(ov1d) then BEGIN  
    296          if min EQ mi then !y.range=[min-abs(max-min)/5.,max+abs(max-min)/5.] $ 
    297          ELSE !y.range=[min, max] 
    298       ENDIF 
    299    ENDELSE  
    300 ; 
    301    if NOT keyword_set(ov1d) then BEGIN  
    302       if keyword_set(reverse_x) then !x.range=reverse(!x.range) 
    303       if keyword_set(reverse_y) then !y.range=reverse(!y.range) 
    304    ENDIF 
    305 ; 
    306    xx = xx[idx] 
    307    yy = yy[idx] 
    308    if (not keyword_set(col1d)) then col1d = 0 
    309    if keyword_set(sty1d) then BEGIN ;si on veut faire des barres 
    310       IF strlowcase(strtrim(sty1d)) EQ 'bar' then begin 
    311          !y.range = [!y.range[0]-(!y.range[1]-!y.range[0])*.05,!y.range[1]]  
    312          bar_plot, yy, background = (!d.n_colors-1) < 255,  $ 
    313           baselines = replicate(!y.range[0], n_elements(yy)), barnames = ['', ''], $ 
    314           colors    = replicate(col1d      , n_elements(yy)), /outline 
    315          plot, [0], [0],/noerase,color=c_cote, _extra = ex 
    316          GOTO, fini 
    317       ENDIF  
    318    ENDIF 
    319    if NOT keyword_set(ov1d) then BEGIN  
    320       legende,mi,ma,type, CONTOUR = contour, DIREC = direc, ENDPOINTS = endpoints, _EXTRA = ex 
    321 ; 
    322       plot,xx,yy,color=col1d,linestyle=sty1d,thick=2, title = '', subtitle = '',_extra = ex 
    323       if n_elements(ex) NE 0 then BEGIN  
    324 ; pour avoir un cadre de la couleur c_cote et trace une ligne a y=0 
    325          if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = c_cote 
    326          if (where(tag_names(ex) EQ 'LINESTYLE'))[0] NE -1 then ex.LINESTYLE= 0 
    327          if (where(tag_names(ex) EQ 'THICK'))[0] NE -1 then ex.THICK= 0 
    328       ENDIF 
    329       plot, !x.range, [0, 0],/noerase,color=c_cote $ 
    330        , xstyle = 1+4*(keyword_set(endpoints) AND $ 
    331                        ((type EQ 'x' AND lat1 NE lat2) OR (type EQ 'y' AND lon1 NE lon2))) $ 
    332        , ystyle = 1, _extra = ex 
     349      plot, [0], [0], /noerase, /nodata, _extra = ex 
     350      GOTO, fini 
     351    ENDIF  
     352  ENDIF 
     353; 
     354  if NOT keyword_set(ov1d) then BEGIN  
     355; 
     356    plot, xx, yy, color = col1d, linestyle = sty1d, thick = 2, title = '', subtitle = '', _extra = ex 
     357    if n_elements(ex) NE 0 then BEGIN  
     358; pour avoir un cadre de la couleur 0 et trace une ligne a y=0 
     359      if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = 0 
     360      if (where(tag_names(ex) EQ 'LINESTYLE'))[0] NE -1 then ex.LINESTYLE = 0 
     361      if (where(tag_names(ex) EQ 'THICK'))[0] NE -1 then ex.THICK = 0 
     362    ENDIF 
     363    plot, !x.range, [0, 0], /noerase, /nodata $ 
     364      , xstyle = 1+4*(keyword_set(endpoints) AND $ 
     365                      ((type EQ 'x' AND lat1 NE lat2) OR (type EQ 'y' AND lon1 NE lon2))) $ 
     366      , ystyle = 1, _extra = ex 
    333367; ajout d'un axe ds le cas ou l'on utilise endpoints 
    334       if keyword_set(endpoints) then addaxe, endpoints, type, posfenetre, _EXTRA = ex 
     368    if keyword_set(endpoints) then addaxe, endpoints, type, posfenetre, _EXTRA = ex 
    335369; trace une ligne a x=0 
    336       plot, [0, 0],!y.range ,/noerase,color=c_cote, title = '', subtitle = '', _extra = ex 
    337    ENDIF ELSE oplot,xx,yy,color=col1d,linestyle=sty1d,thick=2, _extra = ex 
     370    plot, [0, 0], !y.range, /noerase, /nodata, title = '', subtitle = '', _extra = ex 
     371  ENDIF ELSE oplot, xx, yy, color = col1d, linestyle = sty1d, thick = 2, _extra = ex 
    338372;------------------------------------------------------------ 
    339373;------------------------------------------------------------ 
     
    342376;------------------------------------------------------------ 
    343377fini: 
    344    if keyword_set(oldboite) then domdef, oldboite,GRILLE=[vargrid, 'T'] 
    345    terminedessin, _extra = ex 
    346    if keyword_set(vraiboite) then boite = vraiboite 
    347 ;------------------------------------------------------------ 
    348    if n_elements(key_performance) NE 0 then $ 
     378  terminedessin, _extra = ex 
     379  if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4plt1d.dat' 
     380;------------------------------------------------------------ 
     381  if n_elements(key_performance) NE 0 then $ 
    349382    IF key_performance EQ 1 THEN print, 'temps plt1d', systime(1)-tempsun  
    350383;------------------------------------------------------------ 
    351384;------------------------------------------------------------ 
    352385;------------------------------------------------------------ 
    353    return 
     386  return 
    354387end 
    355388 
  • trunk/ToBeReviewed/PLOTS/DESSINE/pltsc.pro

    r33 r35  
    1 PRO  pltsc,tab1,tab2, min1, max1, min2, max2, varname2, BOITE = boite, $ 
     1PRO  pltsc,tab1,tab2, min1, max1, min2, max2, varname2, BOXZOOM = boxzoom, $ 
    22           COL1D=col1d,STY1D=sty1d,OV1D=ov1d, _extra = ex 
    33; 
     
    55; 
    66 
    7 @common 
     7;--------------------------------------------------------- 
     8; include common 
     9@cm_4mesh 
     10@cm_4data 
     11  IF NOT keyword_set(key_forgetold) THEN BEGIN 
     12@updatenew 
     13@updatekwd 
     14  ENDIF 
     15;-------------------------------------------------------------- 
    816 
    917; Rq: on ne reinitialise pas qd on rapelle pltsc 
     
    1119   ;; reduce data xyzt domain 
    1220 
    13    oldboite = [lon1, lon2, lat1, lat2, prof1, prof2] 
    14    if keyword_set(boite) then BEGIN  
    15       if n_elements(integration3d) EQ 0 THEN integration3d = n_elements(boite) ne 4 
    16       Case 1 Of 
    17          N_Elements(Boite) Eq 1:bte=[lon1, lon2, lat1, lat2, 0.,boite[0]] 
    18          N_Elements(Boite) Eq 2:bte=[lon1, lon2, lat1, lat2, boite[0],boite[1]] 
    19          N_Elements(Boite) Eq 4:bte=[Boite, prof1, prof2] 
    20          N_Elements(Boite) Eq 5:bte=[Boite[0:3], 0, Boite[4]] 
    21          N_Elements(Boite) Eq 6:bte=Boite 
    22          Else: Begin 
    23             ras = report('Mauvaise Definition de Boite')  
    24             return 
    25          End 
    26       endcase 
    27    ENDIF else bte=[lon1, lon2, lat1, lat2, prof1, prof2] 
    28  
    29    domdef, bte,GRILLE=vargrid 
     21   if keyword_set(boxzoom) then BEGIN  
     22     Case 1 Of 
     23       N_Elements(Boxzoom) Eq 1:bte = [lon1, lon2, lat1, lat2, 0., boxzoom[0]] 
     24       N_Elements(Boxzoom) Eq 2:bte = [lon1, lon2, lat1, lat2, boxzoom[0], boxzoom[1]] 
     25       N_Elements(Boxzoom) Eq 4:bte = [Boxzoom, vert1, vert2] 
     26       N_Elements(Boxzoom) Eq 5:bte = [Boxzoom[0:3], 0, Boxzoom[4]] 
     27       N_Elements(Boxzoom) Eq 6:bte = Boxzoom 
     28       Else: Begin 
     29         ras = report('Wrong Definition of Boxzoom')  
     30         return 
     31       End 
     32     endcase 
     33     savedbox = 1b 
     34     saveboxparam, 'boxparam4pltsc.dat' 
     35     domdef, bte, GRIDTYPE = vargrid 
     36   ENDIF 
    3037 
    3138; extract indexes to plot 
     
    6471 
    6572      if n_elements(ex) NE 0 then BEGIN  
    66 ; pour avoir un cadre de la couleur c_cote et trace une ligne a y=0 
    67          if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = c_cote 
     73; pour avoir un cadre de la couleur 0 et trace une ligne a y=0 
     74         if (where(tag_names(ex) EQ 'COLOR'))[0] NE -1 then ex.COLOR = 0 
    6875         if (where(tag_names(ex) EQ 'LINESTYLE'))[0] NE -1 then ex.LINESTYLE= 0 
    69       ENDIF 
    70       plot, !x.range, [0, 0],/noerase,color=c_cote, xstyle = 1, ystyle = 1, _extra = ex 
     76       ENDIF 
     77       plot, !x.range, [0, 0], /noerase, /nodata, xstyle = 1, ystyle = 1, _extra = ex 
    7178; trace une ligne a x=0 
    72       plot, [0, 0],!y.range ,/noerase,color=c_cote, title = '', subtitle = '', _extra = ex 
     79      plot, [0, 0], !y.range, /noerase, /nodata, title = '', subtitle = '', _extra = ex 
    7380   ENDIF ELSE oplot,xx,yy,color=col1d,linestyle=sty1d,thick=2, _extra = ex 
    7481;------------------------------------------------------------ 
     
    7885;------------------------------------------------------------ 
    7986fini: 
    80    domdef, oldboite,GRILLE=vargrid 
    8187   terminedessin, _extra = ex 
     88  if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4pltsc.dat' 
    8289;------------------------------------------------------------ 
    8390   if n_elements(key_performance) NE 0 then $ 
  • trunk/ToBeReviewed/PLOTS/DESSINE/pltz.pro

    r33 r35  
    1919;       peut etre de 2 types: 
    2020;         1) un tableau 2d ou 3d.  
    21 ;         Si le champ est 2d undiquer avec le mot cle boite les 
    22 ;         delimitations geographiques de la boite. Si le chyamp est 
     21;         Si le champ est 2d undiquer avec le mot cle boxzoom les 
     22;         delimitations geographiques de la boxzoom. Si le chyamp est 
    2323;         3d, on extrait la section et on moyenne eventuellement avant 
    2424;         de faire le plot 
     
    3737; KEYWORD PARAMETERS: 
    3838; 
    39 ;       BOITE:vecteur indiquant la zone geographique sur laquelle doit etre 
    40 ; faite la coupe. Si BOITE a : 
    41 ; 1 element : l''extraction est faite sur [lon1, lon2, lat1, lat2, 0.,boite[0]] 
    42 ; 2 elements: l''extraction est faite sur [lon1, lon2, lat1, lat2, boite[0],boite[1]] 
    43 ; 4 elements: l''extraction est faite sur [Boite, 0, 200] 
    44 ; 5 elements: l''extraction est faite sur [Boite[0:3], 0, Boite[4]] 
    45 ; 6 elements: l''extraction est faite sur Boite 
     39;       BOXZOOM:vecteur indiquant la zone geographique sur laquelle doit etre 
     40; faite la coupe. Si BOXZOOM a : 
     41; 1 element : l''extraction est faite sur [lon1, lon2, lat1, lat2, 0.,boxzoom[0]] 
     42; 2 elements: l''extraction est faite sur [lon1, lon2, lat1, lat2, boxzoom[0],boxzoom[1]] 
     43; 4 elements: l''extraction est faite sur [Boxzoom, 0, 200] 
     44; 5 elements: l''extraction est faite sur [Boxzoom[0:3], 0, Boxzoom[4]] 
     45; 6 elements: l''extraction est faite sur Boxzoom 
    4646; 
    4747; Ou lon1, lon2,lat1,lat2 sont les variables globales 
     
    5555; 
    5656;       CONTINTERVALLE: lorsque CONTOUR est active, valeur d'un 
    57 ; intervalle entre deux isolignes traces par un trait ds la couleur 
    58 ; c_lab. Il peut ainsi etre different de celui specifie par INTERVALLE 
     57; intervalle entre deux isolignes traces par un trait. Il peut ainsi 
     58; etre different de celui specifie par INTERVALLE  
    5959; qui, cas ce cas, ne controle que les isolignes coloriees en 
    6060; couleurs. Si aucun min n''est specifie, on choisit un contour min qui va 
     
    6969;       CONTMAX: lorsque CONTOUR est active, valeur maximum que l''on 
    7070; veut prendre en compte dans le trace des isolignes traces par un 
    71 ; trait de couleur c_lab. Par defaut on prend le max (sur les pts mer) 
     71; trait. Par defaut on prend le max (sur les pts mer) 
    7272; du tableau passe ds le mot cle CONTOUR.  
     73; 
     74;        COAST_COLOR: the color of the coastline. 
     75;                     defaut value is 0 => black 
     76; 
     77;        COAST_THICK: the thickness of the coastline. 
     78;                     defaut value is 1 
     79; 
     80;        /CONT_NOFILL: activer pour ne pas remplir les points masques 
     81;        pour les laisser en transparent!  
     82;        Rq: on trace qd meme le contour du mask 
     83; 
     84;        CONT_COLOR: the color of the continent. defaut value is 
     85;        (!d.n_colors - 1) < 255 => white 
    7386; 
    7487;       CONTMIN: lorsque CONTOUR est active, valeur minimum que l''on 
    7588; veut prendre en compte dans le trace des isolignes traces par un 
    76 ; trait de couleur c_lab. Par defaut on prend le max (sur les pts mer) 
     89; trait. Par defaut on prend le max (sur les pts mer) 
    7790; du tableau passe ds le mot cle CONTOUR.  
    7891; 
    7992;       CONTNLEVEL: lorsque CONTOUR est active, nombre de contours 
    80 ; trace par un trait de couleur c_lab a dessiner (actif si 
     93; trace par un trait a dessiner (actif si 
    8194; CONTLABEL=0) par defaut =20. 
    8295; 
     
    97110; INTERVALLE ne specifie que intervalle entre 2 isolignes coloriees en 
    98111; couleur. Pour specifier l''intervalle entre 2 isolignes traces par un trait 
    99 ; de couleur c_lab utiliser CONTINTERVALLE. 
     112; utiliser CONTINTERVALLE. 
    100113; 
    101114;       /INV: inverse le vecteur couleur utilisee pour colorier le graphe 
    102115;             (sans toucher au noir, au blanc et a la palette utilisee) 
    103116; 
    104 ;       HZSURHT: lorsque le dessin presente une partie zoomee, rapport de 
     117;       ZRATIO: lorsque le dessin presente une partie zoomee, rapport de 
    105118; taille entre la partie zommee, hz (hauteur zoom), et le dessin entier, ht 
    106119; (hauteur total). Par defaut =2./3 
     
    109122; label correspondant aux cas n. cf label.pro 
    110123; Rq: Qd CONTOUR est active, ne specifie le type de label que pour les 
    111 ; isolignes coloriees en couleur. Pour celles tracees par un trait de 
    112 ; couleur c_lab utiliser CONTLABEL. 
     124; isolignes coloriees en couleur. Pour celles tracees par un trait 
     125; utiliser CONTLABEL.  
    113126; 
    114127;       /LANDSCAPE: oblige la feuille ou la fenetre a etre en position 
     
    138151;       les couleurs 
    139152; 
    140 ;       /NOCOULEUR: activer si on veut juste les contours en noir et 
     153;       /NOFILL: activer si on veut juste les contours en noir et 
    141154;       blanc sur fond blanc 
    142155; 
     
    178191;       par petitdessin 
    179192; 
    180 ;       /REVERSE_X: pour inverser l''axe des x (et aussi le dessin) 
    181 ; 
    182 ;       /REVERSE_Y: pour inverser l''axe des y (et aussi le dessin) 
    183 ; 
    184193;       /SIN: activer ce mot cle si l''on veut que l'' axe des x soit 
    185194;       trace en sinus de la latitude qd on fait une coupe 'yz' 
     
    205214; d'ouvrir plusieurs fenetres). par defaut on ouvre 'IDL0' 
    206215; 
     216;       /WDEPTH: to specify that the field is at W depth instad of T  
     217;         depth (automatically activated if vargrid eq 'W') 
     218; 
    207219;       /XZ: force a faire une coupe xz 
    208220; 
    209221;       /YZ: force a faire une coupe yz 
    210222; 
    211 ;       YSURX: rapport d'echelle entre y et x (par ex: =1 pour un repere 
     223;       YXASPECT: rapport d'echelle entre y et x (par ex: =1 pour un repere 
    212224; presque orthonorme, =2 si l'axe des y est environ deux fois plus dilate 
    213225; que celui des x). Par defaut on adapte pour occupe une grande partie de 
    214226; la feuille en sortie postScript ou pour cree une fenetre pas trop etiree 
     227;  
     228;         /WDEPTH: to specify that the field is at W depth instad of T  
     229;         depth (automatically activated if vargrid eq 'W') 
    215230; 
    216231;       ZOOM: profondeur jusqu'a laquelle on fait un zoom. par defaut 200m ou 
    217232; la profondeur maximale si elle est inf a 200 
     233; 
     234;       /ZEROMIDDLE: fo force the middle of the colorbar to be equal 
     235;       to 0 (force max=max(abs([min,max])) and min=-max) 
    218236; 
    219237; OUTPUTS: 
     
    236254;------------------------------------------------------------ 
    237255;------------------------------------------------------------ 
    238 pro pltz,tab,giventype, givenmin,givenmax,BOITE=boite,CONTOUR=contour $ 
    239          ,ENDPOINTS=endpoints,INTERVALLE=intervalle,INV=inv,HZSURHT=hzsurht $ 
    240          ,CONTINTERVALLE=contintervalle,LABEL=label,CONTLABEL=contlabel $ 
    241          ,STYLE=style,CONTMAX=contmax, SIN = sin, TYPEIN = typein $ 
    242          ,CONTMIN=contmin,NLEVEL=nlevel,CONTNLEVEL=contnlevel, NOTRI = notri $ 
    243          ,ZOOM=zoom, XZ = xz, YZ = yz, MININ = minin, MAXIN = maxin $ 
    244          , STRICTFILL = strictfill, OVERPLOT = overplot, _EXTRA = ex 
    245 @common 
    246    tempsun = systime(1)         ; pour key_performance 
     256pro pltz, tab, giventype, givenmin, givenmax, BOXZOOM = boxzoom, CONTOUR = contour $ 
     257          , ENDPOINTS = endpoints, INTERVALLE = intervalle, INV = inv, ZRATIO = zratio $ 
     258          , CONTINTERVALLE = contintervalle, LABEL = label, CONTLABEL = contlabel $ 
     259          , STYLE = style, CONTMAX = contmax, SIN = sin, TYPEIN = typein $ 
     260          , CONTMIN = contmin, NLEVEL = nlevel, CONTNLEVEL = contnlevel $ 
     261          , NOTRI = notri, USETRI = usetri, FILLXDIR = fillxdir $ 
     262          , ZOOM = zoom, XZ = xz, YZ = yz, MININ = minin, MAXIN = maxin $ 
     263          , STRICTFILL = strictfill, OVERPLOT = overplot, MASKFILL = maskfill $ 
     264          , WDEPTH = wdepth, REALSECTION = realsection $ 
     265          , _EXTRA = ex 
     266;--------------------------------------------------------- 
     267; include common 
     268@cm_4mesh 
     269@cm_4data 
     270@cm_4ps 
     271  IF NOT keyword_set(key_forgetold) THEN BEGIN 
     272@updatenew 
     273@updatekwd 
     274  ENDIF 
     275;-------------------------------------------------------------- 
     276  tempsun = systime(1)          ; pour key_performance 
    247277;------------------------------------------------------------ 
    248278;-------------------------------------------------------------- 
     
    250280;-------------------------------------------------------------- 
    251281;on ne reinitialise pas qd on rapelle pltz en boucle pour utiliser contour 
    252    if n_elements(contour) ne 4 AND NOT keyword_set(overplot) then reinitplt 
    253 ; 
    254    if keyword_set(boite) then oldboite = [lon1, lon2, lat1, lat2, prof1, prof2] 
     282  if n_elements(contour) ne 4 AND NOT keyword_set(overplot) then reinitplt 
     283; 
     284  if n_elements(contour) ne 4 THEN saveboxparam, 'boxparam4pltz.dat' 
    255285;-------------------------------------------------------------- 
    256286; lecture du champ 
    257287;-------------------------------------------------------------- 
    258    if n_elements(giventype) NE 0 then type = giventype 
    259    if n_elements(givenmin) NE 0 then min = givenmin 
    260    if n_elements(givenmax) NE 0 then max = givenmax 
    261    if n_elements(minin) NE 0 then min = minin 
    262    if n_elements(maxin) NE 0 then max = maxin 
    263    if keyword_set(typein) then BEGIN  
    264       if size(type, /type) NE 7 AND size(type, /type) NE 0 then begin 
    265          if n_elements(min) NE 0 then max = min 
    266          min = type 
    267       endif 
    268       type = typein 
    269    endif 
    270    if keyword_set(boite) then vraiboite = boite 
    271    checktypeminmax, 'pltz', TYPE = type, MIN = min, MAX = max, XZ = xz, YZ = yz, ENDPOINTS=endpoints, BOITE = boite, _extra = ex 
    272    coupe = type 
    273    if keyword_set(endpoints) then begin 
    274       section, tab, z2d, glam, gphi, ENDPOINTS = endpoints, TYPE = type, BOITE = boite, DIREC = direc 
    275       nx = n_elements(glam)  
    276       ny = nx 
    277       if strupcase(vargrid) EQ 'W' then begin 
    278          z = gdepw[premierzw:dernierzw] 
    279          nz = nzw 
    280       ENDIF ELSE BEGIN 
    281          z = gdept[premierzt:dernierzt] 
    282          nz = nzt 
    283       ENDELSE 
    284    ENDIF ELSE BEGIN 
    285       z2d = checkfield(tab, 'pltz', TYPE = type, BOITE = boite, DIREC = direc, _extra = ex) 
    286       if z2d[0] EQ -1 then BEGIN  
    287          if keyword_set(boite) AND n_elements(oldboite) NE 0 then domdef, oldboite, GRILLE=vargrid 
    288          return 
    289       ENDIF 
    290       grille,mask,glam,gphi,z,nx,ny,nz 
    291    ENDELSE 
     288  if n_elements(giventype) NE 0 then type = giventype 
     289  if n_elements(givenmin) NE 0 then min = givenmin 
     290  if n_elements(givenmax) NE 0 then max = givenmax 
     291  if n_elements(minin) NE 0 then min = minin 
     292  if n_elements(maxin) NE 0 then max = maxin 
     293  if n_elements(realsection) EQ 0 then realsection = 1 
     294  IF n_elements(usetri) EQ 0 THEN BEGIN 
     295    IF n_elements(notri) NE 0 THEN usetri = 2-notri ELSE usetri = 1 
     296  ENDIF 
     297; no need of triangulation 
     298  IF usetri EQ 1 AND keyword_set(realsection) THEN usetri = 0 
     299; did we specify the type ? 
     300  if keyword_set(typein) then BEGIN  
     301    if size(type, /type) NE 7 AND size(type, /type) NE 0 then begin 
     302      if n_elements(min) NE 0 then max = min 
     303      min = type 
     304    endif 
     305    type = typein 
     306  ENDIF 
     307;  
     308  checktypeminmax, 'pltz', TYPE = type, MIN = min, MAX = max $ 
     309    , XZ = xz, YZ = yz, ENDPOINTS = endpoints, _extra = ex 
     310; 
     311  if keyword_set(endpoints) then begin 
     312    section, tab, z2d, glam, gphi, ENDPOINTS = endpoints, TYPE = type $  
     313    , BOXZOOM = boxzoom, DIREC = direc, WDEPTH = wdepth, _extra = ex 
     314    if z2d[0] EQ -1 AND n_elements(contour) ne 4 then BEGIN  
     315      restoreboxparam, 'boxparam4pltz.dat' 
     316      return 
     317    ENDIF 
     318    nx = n_elements(glam)  
     319    ny = nx 
     320    if strupcase(vargrid) EQ 'W' then begin 
     321      gdep = gdepw[firstzw:lastzw] 
     322      nz = nzw 
     323    ENDIF ELSE BEGIN 
     324      gdep = gdept[firstzt:lastzt] 
     325      nz = nzt 
     326    ENDELSE 
     327    mask = z2d LE valmask/10. 
     328  ENDIF ELSE BEGIN 
     329    z2d = checkfield(tab, 'pltz', TYPE = type, BOXZOOM = boxzoom $ 
     330                     , DIREC = direc, WDEPTH = wdepth, _extra = ex) 
     331    if z2d[0] EQ -1 AND n_elements(contour) ne 4 then BEGIN  
     332      restoreboxparam, 'boxparam4pltz.dat' 
     333      return 
     334    ENDIF 
     335    IF realsection EQ 1 THEN grille, mask, glam, gphi, gdep, nx, ny, nz, ifpltz = type, WDEPTH = wdepth $ 
     336    ELSE grille, mask, glam, gphi, gdep, nx, ny, nz, WDEPTH = wdepth 
     337  ENDELSE 
     338; stop 
    292339;--------------------------------------------------------------- 
    293    profmax = !y.range[0] 
    294    profmin = !y.range[1] 
    295    if not keyword_set(zoom) then zoom=200 
    296    zoom = zoom[0] 
    297    if zoom GE prof2 then zoom=profmax 
    298 ;-------------------------------------------------------------------- 
    299 ; construction du mask 
    300 ;-------------------------------------------------------------------- 
    301    mask = fltarr((size(z2d))[1],(size(z2d))[2] ) 
    302    nan = total(finite(z2d,/nan))  < 1 
    303    if keyword_set(nan) then begin 
    304       notanum = where(finite(z2d) EQ 0) 
    305       z2d[notanum] = 0 
    306       mask(where(z2d LT valmask/10)) = 1 
    307       z2d[notanum] = !values.f_nan 
    308    ENDIF ELSE mask(where(z2d LT valmask/10)) = 1 
    309    if (where(mask EQ 0))[0] EQ -1 AND NOT keyword_set(nan) then notri = 1 
     340  profmax = !y.range[0] 
     341  profmin = !y.range[1] 
     342  if not keyword_set(zoom) then zoom = 200 
     343  zoom = zoom[0] 
     344  IF zoom LT profmin THEN zoom = profmax 
     345  if zoom GE vert2 then zoom = profmax 
     346; construction of the mask and of the axis 
     347  axis4pltz, type, mask, glam, gphi, gdep, XXAXIS = xxaxis, ZZAXIS = zzaxis, SIN = sin, ZRATIO = zratio, ZOOM = zoom, PROFMAX = profmax, PROFMIN = profmin, _extra = ex 
     348; to draw from bottom to top (avoid using cell_fill) 
     349  z2d = reverse(z2d, 2) 
    310350;----------------------------------------------------------------------------- 
    311351;   determination du mi:min et du ma:max de tab1 ainsi que de max: max et 
    312352;   min: min pour le dessin. 
    313353;----------------------------------------------------------------------------- 
     354  nan = total(finite(z2d, /nan)) < 1 
    314355; faudra-t-il faire un autoscale ??? 
    315    autoscale = testvar(var = min) EQ testvar(var = max) AND NOT keyword_set(intervalle) 
    316    determineminmax, z2d,mask, mi, ma, MININ = min, MAXIN = max, nan = nan,INTERVALLE=intervalle 
    317    if z2d[0] EQ -1 THEN GOTO, sortie 
     356  autoscale = testvar(var = min) EQ testvar(var = max) AND NOT keyword_set(intervalle) 
     357  determineminmax, z2d, mask, mi, ma, MININ = min, MAXIN = max, nan = nan, INTERVALLE = intervalle, _extra = ex 
     358  if z2d[0] EQ -1 THEN GOTO, sortie 
    318359; on fait un autoscale si besoin 
    319    if autoscale then autoscale, min, max, intervalle 
    320 ;-------------------------------------------------------------- 
    321    z2d=reverse(z2d,2) 
    322    mask=reverse(mask,2) 
     360  if autoscale then autoscale, min, max, intervalle 
    323361;-------------------------------------------------------------- 
    324362;-------------------------------------------------------------- 
     
    326364;-------------------------------------------------------------- 
    327365;-------------------------------------------------------------- 
    328    if n_elements(contour) NE 4 AND NOT keyword_set(overplot) THEN $ 
    329     placedessin, 'pltz',posfenetre, posbar, contour = contour, endpoints = endpoints $ 
     366  if n_elements(contour) NE 4 AND NOT keyword_set(overplot) THEN $ 
     367    placedessin, 'pltz', posfenetre, posbar, contour = contour, endpoints = endpoints $ 
    330368    , direc = direc, _extra = ex 
    331369;------------------------------------------------------------ 
     
    333371; choix des labels 
    334372;----------------------------------------------------------- 
    335    if keyword_set(intervalle) AND NOT keyword_set(label) then label=1 
    336    if keyword_set(label) eq 0 then cas=0 else cas=label 
    337    label,cas,min,max,ncontour,level_z2d,NLEVEL=nlevel,INTERVALLE=intervalle $ 
    338     , strictfill = strictfill 
     373  if keyword_set(intervalle) AND NOT keyword_set(label) then label = 1 
     374  if keyword_set(label) eq 0 then cas = 0 else cas = label 
     375  label, cas, min, max, ncontour, level_z2d, colnumb, NLEVEL = nlevel $ 
     376         , INTERVALLE = intervalle, strictfill = strictfill 
    339377;-------------------------------------------------------------- 
    340378; choix de style 
    341379;----------------------------------------------------------- 
    342    if not keyword_set(style) then style=0 
    343    style,style,level_z2d,linestyle,thick 
    344    if keyword_set(inv) then couleur=reverse(couleur) 
     380  if not keyword_set(style) then style = 0 
     381  style, style, level_z2d, linestyle, thick 
     382  if keyword_set(inv) then colnumb = reverse(colnumb) 
    345383;----------------------------------------------------------- 
    346384;   definition des axes 
    347385;---------------------------------------------------------- 
    348    if NOT keyword_set(overplot) THEN axe, coupe, SIN = sin, _EXTRA = ex 
    349    if keyword_set(reverse_y) then !y.range=[0, -1] ELSE !y.range = [-1, 0] 
     386  if NOT keyword_set(overplot) THEN axe, type, SIN = sin, _EXTRA = ex 
     387  !y.range = [-1, 0] 
     388;-------------------------------------------------------------- 
     389; extrapolation des donnees sur les terres et seuillage 
     390;-------------------------------------------------------------- 
     391; define masknan 
     392  if keyword_set(nan) then BEGIN 
     393    masknan = finite(z2d) 
     394    z2d[where(masknan EQ 0)] = max 
     395  ENDIF ELSE masknan = 1 
     396  IF n_elements(fillxdir) EQ 0  THEN fillxdir = 1 
     397  IF keyword_set(fillxdir) THEN BEGIN 
     398; filling the mask values only in the x direction. 
     399    z2d = remplit(z2d, nite = nx*(1-(n_elements(maskfill) NE 0)) $ 
     400                  , mask = mask*masknan, /basique $ 
     401                  , /fillxdir, _extra = ex) 
     402; if some lines contains no data (the bottom line for ex) it must be 
     403; also filled with 8 neighbourg method 
     404    IF (where(total(mask*masknan, 1) EQ 0))[0] NE -1 THEN $ 
     405      z2d = remplit(z2d, nite = 1-(n_elements(maskfill) NE 0) $ 
     406                    , mask = z2d LT valmask/10, /basique, _extra = ex) 
     407  ENDIF ELSE BEGIN  
     408; filling the mask values with 8 neighbourg 
     409    z2d = remplit(z2d, nite = (1+(vargrid NE 'T')+keyword_set(nan)) $ 
     410                  *(1-(n_elements(maskfill) NE 0)), mask = mask*masknan $ 
     411                  , /basique, _extra = ex) 
     412  ENDELSE  
     413  if keyword_set(strictfill) EQ 0 AND n_elements(maskfill) EQ 0 $ 
     414    then z2d = min > z2d <  max 
     415  if n_elements(maskfill) NE 0 then BEGIN 
     416    z2d = z2d*mask*masknan 
     417    if maskfill NE 0 then z2d = temporary(z2d) + maskfill*(1b-mask*masknan) 
     418  ENDIF 
    350419;---------------------------------------------------------- 
    351 ; on projette l''axe z dans [0,1] 
    352 ;---------------------------------------------------------- 
    353    if not keyword_set(hzsurht) then hzsurht=2./3 
    354    if zoom ge profmax then hzsurht=1. 
    355    if zoom LT profmax then begin 
    356       mp = projsegment([profmin, zoom], [0, hzsurht], /mp) 
    357       z[where(z LE zoom)] = mp[0]*z[where(z LE zoom)]+mp[1] 
    358       mp = projsegment([zoom, profmax], [hzsurht, 1], /mp) 
    359       z[where(z GE zoom)] = mp[0]*z[where(z GE zoom)]+mp[1] 
    360    ENDIF ELSE BEGIN 
    361       mp = projsegment([profmin, profmax], [0, 1], /mp) 
    362       z = mp[0]*z+mp[1] 
    363    ENDELSE 
    364    z=reverse(-z,1) 
    365 ;---------------------------------------------------------- 
    366 ; on passe les axes en tableaux 2d pour pouvoir utiliser la 
    367 ; trianguletion 
    368 ;---------------------------------------------------------- 
    369    if coupe eq 'yz' then BEGIN  
    370       if (size(gphi))[0] EQ 2 then x=reform(gphi[0, *]) ELSE x=gphi  
    371       if keyword_set(sin) then x = sin(!pi/180.*x) 
    372       x = x#replicate(1, nz) 
    373       z = replicate(1, ny)#z 
    374    ENDIF ELSE BEGIN  
    375       x = glam[*, 0]#replicate(1, nz) 
    376       z = replicate(1, nx)#z 
    377    ENDELSE  
    378 ;-------------------------------------------------------------- 
    379 ; extrapolation des donnees sur les terres et seuillage 
    380 ;-------------------------------------------------------------- 
    381    if keyword_set(nan) then begin 
    382       notanumber = where(finite(z2d, /nan) EQ 1) 
    383       z2d[notanumber] = max 
    384       if coupe eq 'yz' then masknan = replicate(1, ny, nz) ELSE masknan = replicate(1, nx, nz)  
    385       masknan[notanumber] = 0 
    386    ENDIF ELSE masknan = 1 
    387    z2d = remplit(z2d,nite=1+keyword_set(nan), mask = mask*masknan, /basique, _extra=ex) 
    388    if NOT keyword_set(strictfill) then z2d = min > z2d <  max 
    389    if keyword_set(notri) then triangulation = -1 ELSE $ 
    390     triangulation = triangule(mask*masknan,/regulier,coinmonte=coinmontemask,coindescend=coindescendmask) 
     420; check the mask and the triangulation according to the grid type and  
     421; nan values. find the coordinates of the mask 
     422;----------------------------------------------------------  
     423;   if (where(mask EQ 0))[0] EQ -1 AND NOT keyword_set(nan) then notri = 1 
     424;   if keyword_set(notri) then trifield = -1 $ 
     425;   ELSE trifield = triangule(mask,/basic) 
     426  if (usetri GE 1 AND (vargrid EQ 'T' OR vargrid EQ 'W')) $ 
     427    OR (usetri EQ 2 AND (vargrid NE 'T' AND vargrid NE 'W')) THEN $ 
     428    trifield = triangule(mask, /basic) 
     429; 
     430  IF NOT keyword_set(endpoints)  THEN BEGIN 
     431    if keyword_set(nan) then trinan = triangule(masknan, /basic, coinmonte = coinmontenan, coindescend = coindescendnan) 
     432    decoupeterre, mask, glammsk, gphimsk, gdepmsk, type = type, WDEPTH = wdepth, REALSECTION = realsection 
     433    axis4pltz, type, mask, glammsk, gphimsk, gdepmsk, XXAXIS = xmask, ZZAXIS = zmask, SIN = sin, ZRATIO = zratio, ZOOM = zoom, PROFMAX = profmax, PROFMIN = profmin, _extra = ex 
     434  ENDIF ELSE BEGIN 
     435    xmask = xxaxis 
     436    zmask = zzaxis 
     437  ENDELSE  
     438; 
     439  if (usetri GE 1 AND (vargrid NE 'T' AND vargrid NE 'W')) THEN BEGIN  
     440    IF keyword_set(realsection) THEN trimsk = triangule(mask, /basic) $ 
     441    ELSE trimsk = triangule(mask, /basic, coinmonte = coinmontemask $ 
     442                            , coindescend = coindescendmask) 
     443  ENDIF      
    391444;------------------------------------------------------------ 
    392445; dessin en lui meme 
    393446;------------------------------------------------------------ 
    394    pltbase, z2d,x, z, mask,x, z, level_z2d,couleur, overplot = overplot $ 
    395     , contour = contour, trichamp = triangulation, trimsk = triangulation  $ 
    396     , c_linestyle=linestyle,c_labels=1-(indgen(n_elements(level_z2d)) MOD 2) $ 
    397     , c_thick=thick,unsur2 = unsur2 $ 
    398     , coinmontemask=-1,coindescendmask=-1, masknan = masknan $ 
    399     , _extra = ex 
    400 ;------------------------------------------------------------ 
    401 ; rappelle de plt en boucle qd contour est active 
    402 ;------------------------------------------------------------ 
    403    if n_elements(contour) eq 4 then BEGIN ; c''est la 2eme fois que je passe ds pltt 
    404       contour = {mietma:[mi, ma], unit:varunit, inter:intervalle} ; je renvoie le min, le max et l''unite 
    405       if keyword_set(vraiboite) then boite = vraiboite 
    406       return 
    407    endif 
    408    if keyword_set(contour) THEN BEGIN  
    409       pourlegende = [1, 1, 1, 1] 
    410       oldattributs = saveatt() 
    411       oldcouleur = couleur 
    412       pltz,contour,contmin,contmax,CONTOUR=pourlegende,HZSURHT=hzsurht $ 
    413        ,INTERVALLE=contintervalle,LABEL=contlabel,STYLE=style, /noerase, NOTRI = notri  $ 
    414        ,NLEVEL=contnlevel,ZOOM=zoom,BOITE=vraiboite,ENDPOINTS=endpoints, STRICTFILL = strictfill $ 
    415        , _extra = ex 
    416       restoreatt, oldattributs 
    417       couleur = oldcouleur 
    418    ENDIF 
     447  pltbase, z2d, xxaxis, zzaxis, mask, xmask, zmask $ 
     448    , level_z2d, colnumb, overplot = overplot $ 
     449    , contour = contour, trichamp = trifield, trimsk = trimsk  $ 
     450    , c_linestyle = linestyle $ 
     451    , c_labels = 1-(indgen(n_elements(level_z2d)) MOD 2) $ 
     452    , c_thick = thick, unsur2 = unsur2 $ 
     453    , masknan = masknan, trinan = trinan $ 
     454    , coinmontenan = coinmontenan, coindescendnan = coindescendnan $ 
     455    , coinmontemask = coinmontemask, coindescendmask = coindescendmask $ 
     456    , REALSECTION = realsection, USETRI = usetri, _extra = ex 
     457;------------------------------------------------------------ 
     458; rappelle de pltz en boucle qd contour est active 
     459;------------------------------------------------------------ 
     460  if n_elements(contour) eq 4 then BEGIN ; c''est la 2eme fois que je passe ds pltt 
     461    contour = {mietma:[mi, ma], unit:varunit, inter:intervalle} ; je renvoie le min, le max et l''unite 
     462    return 
     463  endif 
     464  if keyword_set(contour) THEN BEGIN  
     465    pourlegende = [1, 1, 1, 1] 
     466    oldattributs = saveatt() 
     467    oldcolnumb = colnumb 
     468    pltz, contour, contmin, contmax, CONTOUR = pourlegende, ZRATIO = zratio $ 
     469      , INTERVALLE = contintervalle, LABEL = contlabel, STYLE = style, /noerase  $ 
     470      , NLEVEL = contnlevel, ZOOM = zoom, BOXZOOM = boxzoom, ENDPOINTS = endpoints $ 
     471      , STRICTFILL = strictfill, REALSECTION = realsection, MASKFILL = maskfill $ 
     472      , USETRI = usetri, WDEPTH = wdepth, _extra = ex 
     473    restoreatt, oldattributs 
     474    colnumb = oldcolnumb 
     475  ENDIF 
    419476;------------------------------------------------------------ 
    420477;------------------------------------------------------------ 
    421478; 3eme partie: dessin du cadre, legendes, colorbar... 
    422479;------------------------------------------------------------ 
    423    if keyword_set(overplot) then BEGIN  
    424       !y.range =  [zoom, profmin] ; on repasse en coordonees physiques! 
    425       plot,[0], [0],/nodata, /noerase, title = '', subtitle = '', xstyle = 5, ystyle = 5 
    426       GOTO, fini 
    427    endif 
     480  if keyword_set(overplot) then BEGIN  
     481    !y.range =  [zoom, profmin] ; on repasse en coordonees physiques! 
     482    plot, [0], [0], /nodata, /noerase, title = '', subtitle = '', xstyle = 5, ystyle = 5 
     483    GOTO, fini 
     484  endif 
    428485;------------------------------------------------------------ 
    429486; legendes + affichage de celles-ci 
    430487;------------------------------------------------------------ 
    431    legende,mi,ma,coupe, CONTOUR = pourlegende, INTERVALLE = intervalle, DIREC = direc, endpoints = endpoints, _EXTRA = ex 
    432    if coupe eq 'yz' then xaxe='lataxe' else xaxe='lonaxe' 
    433    if keyword_set(sin) then xaxe = '' 
     488  legende, mi, ma, type, CONTOUR = pourlegende, INTERVALLE = intervalle, DIREC = direc, endpoints = endpoints, _EXTRA = ex 
     489  if type eq 'yz' then xaxe = 'lataxe' else xaxe = 'lonaxe' 
     490  if keyword_set(sin) OR NOT key_onearth then xaxe = '' 
    434491; cadre applique par defaut 
    435    plot,[x[0], x[n_elements(x)-1]],[-hzsurht,-hzsurht],/noerase,color=c_cote $ 
    436     ,xstyle=1+4*(keyword_set(endpoints) AND ((type EQ 'xz' AND lat1 NE lat2) OR (type EQ 'yz' AND lon1 NE lon2))) $ 
    437     ,xtickformat=xaxe, _extra = ex 
     492  plot, [xxaxis[0], xxaxis[n_elements(xxaxis)-1]], [-zratio, -zratio], /noerase $ 
     493    , xstyle = 1+4*(keyword_set(endpoints) AND ((type EQ 'xz' AND lat1 NE lat2) OR (type EQ 'yz' AND lon1 NE lon2))) $ 
     494    , xtickformat = xaxe, _extra = ex 
    438495; ajout d'un axe ds le cas ou l'on utilise endpoints 
    439    if keyword_set(endpoints) then addaxe, endpoints, type, posfenetre, _EXTRA = ex 
     496  if keyword_set(endpoints) then addaxe, endpoints, type, posfenetre, _EXTRA = ex 
    440497;------------------------------------------------------------ 
    441498; axe y en 1 ou 2 parties 
    442499;------------------------------------------------------------ 
    443    if n_elements(ex) NE 0 then BEGIN  
     500  if n_elements(ex) NE 0 then BEGIN  
    444501; pour ne plus mettre de titre 
    445       if (where(tag_names(ex) EQ 'TITLE'))[0] NE -1 then ex.TITLE = ' ' 
     502    if (where(tag_names(ex) EQ 'TITLE'))[0] NE -1 then ex.TITLE = ' ' 
    446503; pour ne plus mettre de sous titre 
    447       if (where(tag_names(ex) EQ 'SUBTITLE'))[0] NE -1 then ex.SUBTITLE = ' ' 
     504    if (where(tag_names(ex) EQ 'SUBTITLE'))[0] NE -1 then ex.SUBTITLE = ' ' 
    448505; pour n''avoir q''un ytitle 
    449       if (where(tag_names(ex) EQ 'YTITLE'))[0] NE -1 then BEGIN  
    450          ytitle = ex.YTITLE 
    451          ex.YTITLE = ' ' 
    452       endif 
    453    ENDIF 
    454    htotal=posfenetre[3]-posfenetre[1] 
    455    hzoom=1.*hzsurht*htotal 
    456    if zoom LT profmax then $ 
    457     plot,[0], [0],/noerase,color=c_cote,ystyle=1, yrange = [profmax, zoom+0.001] $ 
    458     , position=posfenetre+[0,0,0,-hzoom], _extra = ex, title = '', subtitle = '', ytitle = '' 
    459 ; 
    460    !y.range =  [zoom, profmin]  ; on repasse en coordonees physiques! 
    461    plot,[0], [0],/noerase,color=c_cote,ystyle=1, _extra = ex $ 
    462     , title = '', subtitle = '', ytitle = '', position=posfenetre+[0,htotal-hzoom,0,0] 
     506    if (where(tag_names(ex) EQ 'YTITLE'))[0] NE -1 then BEGIN  
     507      ytitle = ex.YTITLE 
     508      ex.YTITLE = ' ' 
     509    endif 
     510  ENDIF 
     511  htotal = posfenetre[3]-posfenetre[1] 
     512  hzoom = 1.*zratio*htotal 
     513  if zoom LT profmax then $ 
     514    plot, [0], [0], /nodata, /noerase, ystyle = 1, yrange = [profmax, zoom+0.001] $ 
     515    , position = posfenetre+[0, 0, 0, -hzoom], _extra = ex, title = '', subtitle = '', ytitle = '' 
     516; 
     517  !y.range =  [zoom, profmin]   ; on repasse en coordonees physiques! 
     518  plot, [0], [0], /nodata, /noerase, ystyle = 1, _extra = ex $ 
     519    , title = '', subtitle = '', ytitle = '', position = posfenetre+[0, htotal-hzoom, 0, 0] 
    463520;------------------------------------------------------------ 
    464521; pour ecrire le ytitle... 
    465522;------------------------------------------------------------ 
    466    if !d.name EQ 'PS' then $ 
    467     xs = (grandfeuille*(1-key_portrait)+petitfeuille*key_portrait)*!d.x_px_cm $ 
    468    ELSE xs = !d.x_size 
    469    if n_elements(ytitle) NE 0 then !y.title = ytitle 
    470    charsize = chkstru(ex, 'ycharsize', /extract) 
    471    if charsize EQ -1 then charsize = !p.charsize 
    472    IF chkstru(ex, 'charsize') THEN ex.charsize = charsize 
    473    if chkstru(ex, 'ytitle', /extract) NE '' then $ 
    474    decalage = string(format='(e10.3)',profmax) 
    475    decalage = float(strmid(decalage,strpos(decalage,'e')+1)) 
    476    posy=posfenetre[1]+1.*htotal/2 
    477    posx=posfenetre[0]-(decalage+3)*!d.x_ch_size*charsize/xs 
    478     xyouts,posx,posy,!y.title, /normal,orientation=90,color=0,ALIGNMENT = .5, charsize = charsize, _extra = ex 
     523  if !d.name EQ 'PS' then $ 
     524    xs = (max(page_size, min = mi)*(1-key_portrait) + mi*key_portrait)*!d.x_px_cm $ 
     525  ELSE xs = !d.x_size 
     526  if n_elements(ytitle) NE 0 then !y.title = ytitle 
     527  charsize = chkstru(ex, 'ycharsize', /extract) 
     528  if charsize EQ -1 then charsize = !p.charsize 
     529  IF chkstru(ex, 'charsize') THEN ex.charsize = charsize 
     530  if chkstru(ex, 'ytitle', /extract) NE '' then $ 
     531    decalage = string(format = '(e10.3)', profmax) 
     532  decalage = float(strmid(decalage, strpos(decalage, 'e')+1)) 
     533  posy = posfenetre[1]+1.*htotal/2 
     534  posx = posfenetre[0]-(decalage+3)*!d.x_ch_size*charsize/xs 
     535  xyouts, posx, posy, !y.title, /normal, orientation = 90, color = 0, ALIGNMENT = .5, charsize = charsize, _extra = ex 
    479536 
    480537;------------------------------------------------------------ 
    481538; barre de couleur 
    482539;------------------------------------------------------------ 
    483    couleur = couleur[0:ncontour-1-keyword_set(strictfill)] 
    484    barrecouleur, position=posbar,divisions=(ncontour-keyword_set(strictfill))/2,min=min $ 
    485     , max=max,discret=couleur,_extra = ex 
     540  colnumb = colnumb[0:ncontour-1-keyword_set(strictfill)] 
     541  barrecouleur, colnumb, min,  max, (ncontour-keyword_set(strictfill))/2 $ 
     542                , position = posbar, _extra = ex 
    486543;------------------------------------------------------------ 
    487544;------------------------------------------------------------ 
     
    490547;------------------------------------------------------------ 
    491548fini: 
    492    if keyword_set(oldboite) then domdef, oldboite,GRILLE=[vargrid, 'T'] 
    493    terminedessin, _extra = ex 
    494    if keyword_set(vraiboite) then boite = vraiboite 
     549  terminedessin, _extra = ex 
    495550;------------------------------------------------------------ 
    496551;------------------------------------------------------------ 
     
    498553;------------------------------------------------------------ 
    499554sortie: 
    500    if keyword_set(key_performance) NE 0 THEN print, 'temps pltz', systime(1)-tempsun  
    501    return 
     555  restoreboxparam, 'boxparam4pltz.dat' 
     556; 
     557  if keyword_set(key_performance) NE 0 THEN print, 'temps pltz', systime(1)-tempsun  
     558  return 
    502559end 
    503560 
  • trunk/ToBeReviewed/PLOTS/DESSINE/scontour.pro

    r33 r35  
    3131; EXAMPLE: 
    3232;      IDL> z = dist(100)  
    33 ;      IDL> scontour, z, nlevels=10,petit=[1,2,1],xstyle=1,ystyle=1 
     33;      IDL> scontour, z, nlevels=10,small=[1,2,1],xstyle=1,ystyle=1 
    3434;      IDL> @ps 
    3535; 
     
    4343@common 
    4444; 1) je reinitialise l''environnememt graphique (les variables !x, !y et !p):  
    45    if NOT keyword_set(NOREINITPLT) then reinitplt, _extra = ex  
     45  if NOT keyword_set(NOREINITPLT) then reinitplt, _extra = ex  
    4646; 2) je place le dessin a l'ecran comme sur le postcript  
    47    IF chkstru(ex, 'overplot')EQ 0 THEN placedessin, 'autre', _extra = ex 
     47; if ex contains norease and c_orientation keywords we force ex.noerase = 0 
     48  IF chkstru(ex, 'overplot') EQ 0 THEN placedessin, 'autre', _extra = ex 
     49; fiddle when noerase is used with c_orentation... 
     50; call contour with /nodata to get the graphic envoronment, then force 
     51; noerase = 0 and overplot = 1 
     52  IF size(ex, /type) EQ 8 THEN BEGIN 
     53; check if noerase is used with c_orentation 
     54    alltags = strlowcase(tag_names(ex)) 
     55    dummy = where(alltags EQ 'noerase', count1) 
     56    dummy = where(alltags EQ 'c_orientation', count2) 
     57    IF count1*count2 NE 0 THEN BEGIN  
     58      case n_params() OF 
     59        1:contour, x, /nodata, _EXTRA = ex 
     60        2:contour, x, y, /nodata, _EXTRA = ex 
     61        3:contour, x, y, z, /nodata, _EXTRA = ex 
     62      endcase 
     63      ex.noerase = 0 
     64      ex = get_extra(/overplot, _extra = ex) 
     65      noerase_orientation = 1 
     66    ENDIF  
     67  ENDIF  
    4868; 3) je fais mon joli dessin  
    49    case n_params() OF 
    50       1:contour, x, _EXTRA = ex 
    51       2:contour, x, y, _EXTRA = ex 
    52       3:contour, x, y, z, _EXTRA = ex 
     69  case n_params() OF 
     70    1:contour, x, xstyle = 1, ystyle = 1, _EXTRA = ex 
     71    2:contour, x, y, xstyle = 1, ystyle = 1, _EXTRA = ex 
     72    3:contour, x, y, z, xstyle = 1, ystyle = 1, _EXTRA = ex 
     73  ENDCASE 
     74; fiddle when noerase is used with c_orentation... draw the contour axis 
     75  IF keyword_set(noerase_orientation)  THEN BEGIN 
     76    ex.noerase = 1 
     77    ex.overplot = 0 
     78    case n_params() OF 
     79      1:contour, x, xstyle = 1, ystyle = 1, /nodata, _EXTRA = ex 
     80      2:contour, x, y, xstyle = 1, ystyle = 1, /nodata, _EXTRA = ex 
     81      3:contour, x, y, z, xstyle = 1, ystyle = 1, /nodata, _EXTRA = ex 
     82    ENDCASE 
     83  ENDIF 
     84; 4) je termine le dessin  
     85  terminedessin, _extra = ex  
    5386 
    54    endcase 
    55     
    56 ; 4) je termine le dessin  
    57    terminedessin, _extra=ex  
    58  
    59    return 
     87  return 
    6088end 
  • trunk/ToBeReviewed/PLOTS/DESSINE/tvplus.pro

    r33 r35  
    55; NAME: tvplus 
    66; 
    7 ; PURPOSE: tvscl ameliore, permet de visualiser un tableau sans interpolation 
    8 ; 
    9 ; CATEGORY: pour regarder un tableau au point par point, chaque point 
    10 ; etant represente par un carre de coefzoom pixels de cote. la couleur 
    11 ; du carre, representant sa valeur, est une interpolation lineaire 
    12 ; entre le min du tableau de couleur 0 et le max du tableau de couleur 
    13 ; !d.n_colors-1 <255 
    14 ; 
    15 ; CALLING SEQUENCE:tvplus,z2d [,coefzoom] 
    16 ; 
    17 ; INPUTS: z2d le tableau 2d a visualiser 
    18 ; 
    19 ;         coefzoom : (optionnel) c''est la taille des cotes des carres 
    20 ;         representant un point, mesure en pixel. si cet argument 
    21 ;         n''est pas specifie, la taille des carres est calculee pour 
    22 ;         que la fenetre soit au plus pres de 95% de la taille de l''ecran 
     7; PURPOSE: enhanced version of tvscl 
     8; 
     9; CATEGORY: quick exploration of 2D arrays  
     10; 
     11; CALLING SEQUENCE: tvplus,z2d [,cellsize] 
     12; 
     13; INPUTS:  
     14; 
     15;    z2d: 2D array to visualize 
     16; 
     17;    cellsize: (optional) this is the size (in pixel) of the square 
     18;    representing 1 array element. By default, this size is computed 
     19;    automatically in order that the size of the plotting window do 
     20;    not exceed the screen size. If the user specify a large value 
     21;    of cellsize that forces tvplus to create a window larger than 
     22;    the screen, a "scrolling window" will be displayed instead of a 
     23;    regular window. Unfortunately the nice fonctionnalities of tvplus 
     24;    are not coded for "scrolling window" case... 
    2325; 
    2426; KEYWORD PARAMETERS: 
     
    2729;       the bar. default is 0. 
    2830; 
    29 ;       C_NAN: c'est le numero de la couleur des points a 
    30 ;       !values.f_nan. par defaut c''est !d.n_colors< 256 -1 
    31 ; 
    32 ;       C_MASK: c'est le numero de la couleur des points a 
    33 ;       la valeur specifiee par MASK. par defaut c''est 0 
    34 ; 
    35 ;       OFFSET: c''est un vecteur de 2 elements donnant la valeur dont 
    36 ;       il faut decaler la numerotation des points en x et en y. 
    37 ;       Par ex: 
    38 ;          tvplus,sst[x1:x2,y1:y2],offest=[x1,y1] 
    39 ; 
    40 ;       MASK: la valeur qui sert de mask a l''ecran. si abs(mask) lt 
    41 ;       1e6 les points egaux a mask seronts en noir, dans le cas 
    42 ;       contraire ce seront les points ge que abs(mask)/10. Ceci est 
    43 ;       nessaire pour eviter les erreurs d''arrondi.  
    44 ; 
    45 ;       MIN et MAX permet de borner z2d a un min ou a un max, les 
    46 ;       points inferieurs a min etant de la couleur 0 (noir) et ceux 
    47 ;       superieurs a max etant de la couleur (!d.n_colors-1) < 255 (blanc) 
     31;       C_NAN: The color number that should be used for the NaN values. 
     32;       default value is !d.n_colors < 255 
     33; 
     34;       C_MASK: The color number that should be used for the mask values. 
     35;       default value is 0 
     36; 
     37;       OFFSET: 2 elements vector used by tvplus itself when shoing zoom. 
     38;       It is used to shift the ranges of xaxis and yaxis. 
     39;       For example: tvplus,sst[x1:x2,y1:y2],offest=[x1,y1] 
     40; 
     41;       MASK: The mask value. Note that if abs(mask) < 1.e6, then the 
     42;       exact value of the mask is used to find the maskwd point. 
     43;       if abs(mask) > 1.e6, the test to find the masked value is ge 
     44;       abs(mask)/10. This is necessary to avoid the rounding errors 
     45; 
     46;       MIN and MAX: scalars used to specify the min and max values 
     47;       of the color bar. default is from 0 to !d.n_colors < 255 
    4848; 
    4949;       NCOLORS:  This is the number of colors in the color 
    5050;       bar. default is !d.n_colors<255 -1 
    5151; 
    52 ;       NOINTERP: activer si on ne veut pas que les valeurs du tableau 
    53 ;       soient interpoles entre 0 et !d.n_colors-1 < 255 pour obtenir 
    54 ;       les correspondances avec les couleurs. Utile qd on travaille 
    55 ;       avec des tableaux de type byte 
    56 ; 
    57 ;       WINDOW: numero de la fenetre ou l''on veut faire la visualisation (permet 
    58 ;       d''ouvrir plusieurs fenetres). par defaut on ouvre 'IDL0' 
    59 ; 
    60 ; OUTPUTS: affichage de parametres selectionnes a la souris, cf. apres 
    61 ; 
    62 ; COMMON BLOCKS: 
     52;       NOINTERP: used this keyword if you don't whant that the values 
     53;       are interpolated between 0 (or min) and !d.n_colors < 255 (or max). 
     54;       This can be for example usefull when working on byte type arrays. 
     55; 
     56;       NOUSEINFOS: activite to supress the printed message explaining 
     57;       how to use tvplus 
     58; 
     59;       WINDOW: Number of the window used to display the array values. 
     60;       default is window number 0. 
     61; 
     62; OUTPUTS: no (except the printed finformations, see below) 
     63; 
     64; COMMON BLOCKS: no 
    6365; 
    6466; SIDE EFFECTS: 
    65 ;       1) qd la fenetre qui doit etre ouverte a une dimension -imposee 
    66 ;       par la presence de coefzoom- superieure a 75% de la taille de 
    67 ;       l''ecran, c''est une fenetre avec un scrolling bar qui est 
    68 ;       ouverte. 
    69 ; 
    70 ;       2) qd le dessin est realise ds une fenetre normale, le 
    71 ;       programme s''arrete apres le trace pour faire des l'analyses au 
    72 ;       point par point a l''aide de la souris: 
    73 ;          Bouton de gauche: position du curseur et valeur du tableau en ce point 
    74 ;          Bouton du milieu: zoom 
    75 ;          Bouton de droite: quitter 
    76 ; 
    77 ; RESTRICTIONS: l''analyse a la souris ne marche pas ds les fenetres 
    78 ; avec une scrolling bar... 
    79 ; 
    80 ; EXAMPLE:  IDL> tvplus,nlec('sst'),max=30 
     67; 
     68; use your mouse to scan the array values... 
     69;     left button  : mouse position and associated array value 
     70;     middle button: use it twice to define a zoom box 
     71;     right button : quit 
     72; 
     73; RESTRICTIONS: the nice fonctionnalities of tvplus are not coded 
     74;               for "scrolling window" case... 
     75; 
     76; EXAMPLE:  IDL> tvplus, dist(100) 
    8177; 
    8278; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 
    8379;                       18/12/98 
     80; Aug 2005: quick cleaning + english 
    8481;- 
    8582;------------------------------------------------------------ 
    8683;------------------------------------------------------------ 
    8784;------------------------------------------------------------ 
    88 PRO tvplus, z2d, coefzoom, BOTTOM = bottom, C_MASK = c_mask, C_NAN = c_nan, WINDOW = window $ 
    89             , MIN = min, MAX = max, MASK = mask, OFFSET = offset, PASBLABLA = PASBLABLA $ 
     85PRO tvplus, z2d, cellsize, BOTTOM = bottom, C_MASK = c_mask, C_NAN = c_nan, WINDOW = window $ 
     86            , MIN = min, MAX = max, MASK = mask, OFFSET = offset, NOUSEINFOS = NOUSEINFOS $ 
    9087            , NCOLORS = ncolors, NOINTERP = nointerp, _EXTRA = ex 
    9188; 
    92    tab = float(z2d) 
    93 ;------------------------------------------------------------ 
    94 ; on verifie la taille de tab 
    95 ;------------------------------------------------------------ 
    96    if (size(tab))[0] NE 2 then begin 
    97       ras = report('le tableau doit etre 2D') 
    98       return 
    99    endif 
    100 ;------------------------------------------------------------ 
    101 ; on definit au besoin ncoulmax, bottom, topcoul et ncolors 
    102 ;------------------------------------------------------------ 
    103    ncoulmax = !d.n_colors < 256 
    104    IF N_ELEMENTS(bottom) EQ 0 THEN bottom = 0 
    105    if NOT keyword_set(ncolors) then ncolors = ncoulmax-bottom 
    106    topcoul = (bottom+ncolors-1) < (ncoulmax-1) 
    107 ;------------------------------------------------------------ 
    108 ; on fait le menage 
    109 ;------------------------------------------------------------ 
    110    xenvsauve = !x & yenvsauve = !y & penvsauve = !p 
    111    reinitplt, /z, /invert 
    112 ;------------------------------------------------------------ 
    113 ; le tableau contient des valeurs a !values.f_nan ??? 
    114 ;------------------------------------------------------------ 
    115    nan = total(finite(z2d,/nan)) < 1 
    116    if keyword_set(nan) then begin 
    117       nanindex = where(finite(z2d,/nan) EQ 1) 
    118       tab[nanindex] = min(tab, /nan) 
    119    endif 
    120 ;------------------------------------------------------------ 
    121 ; on calcule coefzoom ou bien on verifit qu''il n''est pas trop grand 
    122 ;------------------------------------------------------------ 
    123    dimensions = GET_SCREEN_SIZE() 
    124    if n_elements(coefzoom) EQ 0 then BEGIN  
    125       coefzoom = min(floor(dimensions/(size(z2d))[1: 2]*.85)) 
    126    ENDIF ELSE $  
    127 ; il faudra ouvrir une fenetre avec une scrolling barre 
    128    if coefzoom GE min(floor(dimensions/(size(z2d))[1: 2]*.85)) then scrolling = 1 
    129    if coefzoom LT 1 then begin 
    130       coefzoom = 1 
    131       scrolling = 1 
    132    endif 
    133 ;------------------------------------------------------------ 
    134 ; on met les valeurs masques au max (sur les points non masques) du tableau 
    135 ;------------------------------------------------------------ 
    136    if n_elements(mask) then BEGIN  
    137       if abs(mask) LT 1e6 then BEGIN  
    138          terre = where(tab EQ mask) 
    139          if terre[0] NE -1 then tab(terre) = min(tab(where(tab NE mask))) 
    140       ENDIF ELSE BEGIN  
    141          terre = where(abs(tab) GE abs(mask)/10.) 
    142          if terre[0] NE -1 then tab(terre) = min(tab(where(abs(tab) LT abs(mask)/10.))) 
    143       ENDELSE 
    144    ENDIF ELSE terre = -1 
    145 ;------------------------------------------------------------ 
    146 ; on borne le tableau a min et max s''il sont declares 
    147 ;------------------------------------------------------------ 
    148    if keyword_set(min) then BEGIN  
    149       tab = min > tab 
    150       vraimin = min 
    151    ENDIF ELSE vraimin = min(tab) 
    152    if keyword_set(max) then BEGIN  
    153       tab = tab < max 
    154       vraimax = max 
    155    ENDIF ELSE vraimax = max(tab) 
    156 ;------------------------------------------------------------ 
    157 ; on bidoulle tab  
    158 ;------------------------------------------------------------ 
    159    if NOT keyword_set(nointerp) then BEGIN 
    160 ; on interpole tab entre bottom et bottom+ncolors-1 
    161       m=1.*(ncolors-1)/(vraimax-vraimin) 
    162       p=bottom-1.*vraimin*m 
    163       tab=round(1.*m*tab+p)  
    164    endif 
    165 ; on met les point nan a la couleur numero c_nan 
    166    if keyword_set(nan) then begin 
    167       if keyword_set(c_nan) THEN tab[nanindex] = c_nan <  (ncoulmax -1) $ 
    168       ELSE tab[nanindex] = topcoul 
    169    endif 
    170 ; on met les point terre a la couleur numero c_mask 
    171    if keyword_set(c_mask) AND terre[0] NE -1 THEN $ 
    172     tab[terre] = c_mask < (ncoulmax -1) 
    173 ; on passe le tableau en byte 
    174    tab = byte(tab) 
    175 ; on augmente la taille de tab pour pouvoir faire le tv 
    176    tab = congridseb(tab, (size(tab))[1]*coefzoom,(size(tab))[2]*coefzoom) 
    177 ;------------------------------------------------------------ 
    178 ; on ouvre une fenetre a la bonne taille et on dessine 
    179 ;------------------------------------------------------------ 
    180    nx = (size(tab))[1] 
    181    ny = (size(tab))[2] 
    182 ; marges en pixel 
    183    rapportaspect = 1.*nx/ny 
    184    if rapportaspect GE 1 THEN margepix = 1.*[25, 25, 75, 25] ELSE margepix = 1.*[25, 100, 25, 25] 
    185 ; 
    186    if n_elements(scrolling) EQ 0 then BEGIN ; on ouvre une fenetre classique 
    187       if NOT keyword_set(window) then window = 0 
    188       window,window, xsize = nx+margepix[0]+margepix[1] $ 
    189        , ysize = ny+margepix[2]+margepix[3] ; ouverture de la fenetre 
    190 ; qd on utilise des couleurs codees sur 24 bit, je n''arrive pas a stipuler la couleur du 
    191 ; fond d''une fenetre a l'aide de !p.background, je suis oblige de faire cette bidouille!!! 
    192       if !d.n_colors gt 256 then BEGIN ; alors  les couleurs sont codees sur 24 bit 
    193          device, decomposed=1 
    194          !p.background='ffffff'x 
    195          plot,[0],[0], xstyle = 5, ystyle = 5 
    196          device, decomposed=0 
    197       endif 
    198       tv, tab,margepix[0], margepix[2], _EXTRA = ex ; dessin de tab interpole entre 0 et !d.n_colors-1 < 255 
    199 ; 
    200 ; mise en place des axes et du cadre 
    201 ; 
    202 ; on recupere en coordonnees normalises la position du tv et donc 
    203 ; cette du cadre 
    204       poscadre = fltarr(4) 
    205       poscadre[0] = margepix[0]/!d.x_size 
    206       poscadre[2] = 1.-margepix[1]/!d.x_size 
    207       poscadre[1] = margepix[2]/!d.y_size 
    208       poscadre[3] = 1-margepix[3]/!d.y_size 
    209 ;    on trace le cadre a l''aide d''un plot 
    210       if NOT keyword_set(offset) then offset = [0, 0] 
    211       plot, [0], [0],/noerase, position = poscadre, color = 0 $ 
    212        , xstyle = 1, ystyle = 1, xticklen = 1, yticklen = 1 $ 
    213        , xrange = 1.*[0, nx]/coefzoom-.5+offset[0], yrange = 1.*[0, ny]/coefzoom-.5+offset[1] 
    214 ; 
    215 ; mise en place de la colorbar 
    216 ; 
    217       if rapportaspect ge 1 then $ 
    218        posbar = [25./!d.x_size, 25./!d.y_size, 1-25./!d.x_size, 50./!d.y_size] $ 
    219       ELSE posbar = [1-75./!d.x_size, 25./!d.y_size, 1-50./!d.x_size, 1-25./!d.y_size] 
    220    if keyword_set(nointerp) then BEGIN & vraimin = 0 & vraimax = ncoulmax & endif 
    221       colorbar, min = vraimin, max = vraimax, division = 10, cb_color = 0, position = posbar $ 
    222        , vertical = rapportaspect lt 1, /right, BOTTOM = bottom, NCOLORS = ncolors, _EXTRA = ex 
    223    ENDIF ELSE BEGIN  
    224 ;------------------------------------------------------------ 
    225 ; dessin ds une fenetre avec une scrolling barre 
    226 ;------------------------------------------------------------ 
    227 ; qd on utilise des couleurs codees sur 24 bit, je n''arrive pas a stipuler la couleur du 
    228 ; fond d''une fenetre a l'aide de !p.background, je suis oblige de faire cette bidouille!!! 
    229       if !d.n_colors gt 256 then begin 
    230          window, /pixmap 
    231          device, decomposed=1 
    232          !p.background='ffffff'x 
    233          plot,[0],[0] 
    234          device, decomposed=0 
    235       endif 
    236       slide_image, tab $        ; on le dessine ds une fenetre avec une scrolling bar 
    237        , xsize = nx, ysize = ny $ 
    238        ,xvisible=round(.7*dimensions[0]) < (size(tab))[1] $ 
    239        ,yvisible=round(.7*dimensions[1]) < (size(tab))[2],/register,congrid=0,show_full=0 
    240       return 
    241    ENDELSE  
    242 ;------------------------------------------------------------ 
    243 ; on prend des infos a la souris 
    244 ;------------------------------------------------------------ 
    245    if NOT keyword_set(pasblabla) then begin 
    246       print, 'Bouton de gauche: position du curseur et valeur du tableau en ce point' 
    247       print, 'Bouton du milieu: zoom' 
    248       print, 'Bouton de droite: quitter' 
    249    endif 
    250    cursor,x,y,/device, /down 
    251    while (!mouse.button ne 4) do BEGIN 
    252       x = x-margepix[0] & x = 0 > floor(x/coefzoom) < ((size(tab))[1]-1) 
    253       y = y-margepix[2] & y = 0 > floor(y/coefzoom) < ((size(tab))[2]-1) 
    254       case !mouse.button of 
    255          1:BEGIN                ; saisie d''une valeur 
    256             if x LE nx/coefzoom AND y LE ny/coefzoom then begin 
    257                print,'position: x='+strtrim(x+offset[0],1)+', y= '+strtrim(y+offset[1],1) $ 
    258                 +' valeur: '+strtrim(float(z2d[x,y]), 1) 
    259             ENDIF 
    260             cursor,x,y,/device, /down 
    261          END 
    262          2:BEGIN                ; zoom 
    263             cursor,x2,y2,/device, /down 
    264             x2 = x2-margepix[0] & x2 =  0 > floor(x2/coefzoom) < ((size(tab))[1]-1) 
    265             y2 = y2-margepix[2] & y2 =  0 > floor(y2/coefzoom) < ((size(tab))[2]-1) 
    266             x =  [x, x2] & x =  x[sort(x)] 
    267             y =  [y, y2] & y =  y[sort(y)] 
    268             tvplus, z2d[x[0]:x[1],y[0]:y[1] ], WINDOW = window, MIN = min, MAX = max $ 
    269              , MASK = mask, C_MASK = c_mask, C_NAN = c_nan, /PASBLABLA, OFFSET = [x[0],y[0]] $ 
    270              , NCOLORS = ncolors, NOINTERP = nointerp, BOTTOM = bottom, _EXTRA = ex 
    271             return 
    272          END 
    273       endcase 
    274    ENDWHILE 
    275 ;------------------------------------------------------------ 
    276    !x = xenvsauve & !y = yenvsauve & !p = penvsauve 
    277 ;------------------------------------------------------------ 
    278    return 
     89  IF n_elements(z2d) EQ 0 THEN return 
     90  arr = reform(float(z2d)) 
     91;------------------------------------------------------------ 
     92; check the size of the input array  
     93;------------------------------------------------------------ 
     94  if (size(arr))[0] NE 2 then begin 
     95    ras = report('Input array must have only 2 dimensions and not '+ strtrim(size(arr, /n_dimensions), 1)) 
     96    return 
     97  endif 
     98;------------------------------------------------------------ 
     99; def of ncolmax, bottom, topcol et ncolors 
     100;------------------------------------------------------------ 
     101  ncolmax = !d.n_colors < 256 
     102  IF N_ELEMENTS(bottom) EQ 0 THEN bottom = 0 
     103  if NOT keyword_set(ncolors) then ncolors = ncolmax-bottom 
     104  topcol = (bottom+ncolors-1) < (ncolmax-1) 
     105;------------------------------------------------------------ 
     106; get default values of !x, !y, !z 
     107;------------------------------------------------------------ 
     108;   xenvsauve = !x & yenvsauve = !y & penvsauve = !p 
     109  reinitplt, /z, /invert 
     110;------------------------------------------------------------ 
     111; Do we have NaN values in arr??? 
     112;------------------------------------------------------------ 
     113  nan = total(finite(z2d, /nan)) < 1 
     114  if keyword_set(nan) then begin 
     115    nanindex = where(finite(z2d, /nan) EQ 1) 
     116    arr[nanindex] = min(arr, /nan) 
     117  endif 
     118;------------------------------------------------------------ 
     119; Compute the size (in pixel) of the square representing 1 
     120; point of the input array  
     121;------------------------------------------------------------ 
     122  dimensions = GET_SCREEN_SIZE() 
     123  if n_elements(cellsize) EQ 0 then BEGIN  
     124    cellsize = min(floor(dimensions/(size(z2d))[1: 2]*.75)) 
     125  ENDIF ELSE $  
     126; we need to use a scrolling bar window 
     127  if cellsize GE min(floor(dimensions/(size(z2d))[1: 2]*.75)) then scrolling = 1 
     128  if cellsize LT 1 then begin 
     129    cellsize = 1 
     130    scrolling = 1 
     131  endif 
     132;------------------------------------------------------------ 
     133; Change the value of the masked value for the min of the non-masked values 
     134;------------------------------------------------------------ 
     135  if n_elements(mask) then BEGIN  
     136    if abs(mask) LT 1e6 then BEGIN  
     137      masked = where(arr EQ mask) 
     138      if masked[0] NE -1 then arr(masked) = min(arr(where(arr NE mask))) 
     139    ENDIF ELSE BEGIN  
     140      masked = where(abs(arr) GE abs(mask)/10.) 
     141      if masked[0] NE -1 then arr(masked) = min(arr(where(abs(arr) LT abs(mask)/10.))) 
     142    ENDELSE 
     143  ENDIF ELSE masked = -1 
     144;------------------------------------------------------------ 
     145; apply min/max keywords 
     146;------------------------------------------------------------ 
     147  if n_elements(min) NE 0 then BEGIN  
     148    arr = min > arr 
     149    truemin = min 
     150  ENDIF ELSE truemin = min(arr) 
     151  if n_elements(max) NE 0 then BEGIN  
     152    arr = arr < max 
     153    truemax = max 
     154  ENDIF ELSE truemax = max(arr) 
     155; 
     156  IF truemin EQ truemax THEN BEGIN 
     157    dummy = report('constant value everywhere: '+ strtrim(truemin, 1)) 
     158    return 
     159  ENDIF 
     160;------------------------------------------------------------ 
     161; apply other keywords (nointerp, c_nan, c_mask)  
     162;------------------------------------------------------------ 
     163  if NOT keyword_set(nointerp) then BEGIN 
     164; interpolation between bottom and bottom+ncolors-1 
     165    m = 1.*(ncolors-1)/(truemax-truemin) 
     166    p = bottom-1.*truemin*m 
     167    arr = round(1.*m*arr+p)  
     168  endif 
     169; set c_nan for NaN values  
     170  if keyword_set(nan) then begin 
     171    if n_elements(c_nan) NE 0 THEN arr[nanindex] = c_nan <  (ncolmax -1) $ 
     172    ELSE arr[nanindex] = topcol 
     173  endif 
     174; c_mask for masked values 
     175  if n_elements(c_mask) NE 0 AND masked[0] NE -1 THEN $ 
     176    arr[masked] = c_mask < (ncolmax -1) 
     177; use byte type to save memory 
     178  arr = byte(arr) 
     179; increase the size of the array in order to be displayed 
     180; with the suitable size  
     181  arr = congridseb(arr, (size(arr))[1]*cellsize, (size(arr))[2]*cellsize) 
     182;------------------------------------------------------------ 
     183; open a window with the correct size 
     184;------------------------------------------------------------ 
     185  nx = (size(arr))[1] 
     186  ny = (size(arr))[2] 
     187; margin size (in pixel) 
     188  xyaspect = 1.*nx/ny 
     189  if xyaspect GE 1 THEN marginpix = 1.*[25, 25, 75, 25] ELSE marginpix = 1.*[25, 100, 25, 25] 
     190; 
     191  if n_elements(scrolling) EQ 0 then BEGIN ; open the regular window 
     192    if NOT keyword_set(window) then window = 0 
     193    window, window, xsize = nx+marginpix[0]+marginpix[1] $ 
     194            , ysize = ny+marginpix[2]+marginpix[3]  
     195; for 24 bits colors, make sure thate the background color is the good one... 
     196    if !d.n_colors gt 256 then BEGIN 
     197      device, decomposed = 1 
     198      !p.background = 'ffffff'x 
     199      plot, [0], [0], xstyle = 5, ystyle = 5 
     200      device, decomposed = 0 
     201    endif 
     202    tv, arr, marginpix[0], marginpix[2], _EXTRA = ex 
     203; 
     204; axis and plot frame  
     205; 
     206; get the normalized position of the tv (we just done above) 
     207; to know where the frame should be drawn 
     208    poscadre = fltarr(4) 
     209    poscadre[0] = marginpix[0]/!d.x_size 
     210    poscadre[2] = 1.-marginpix[1]/!d.x_size 
     211    poscadre[1] = marginpix[2]/!d.y_size 
     212    poscadre[3] = 1-marginpix[3]/!d.y_size 
     213; Use plot to draw the frame 
     214    if NOT keyword_set(offset) then offset = [0, 0] 
     215    !p.position = poscadre 
     216    plot, [0], [0], /nodata, /noerase, position = poscadre, color = 0 $ 
     217          , xstyle = 1, ystyle = 1, xticklen = 1, yticklen = 1 $ 
     218          , xrange = 1.*[0, nx]/cellsize-.5+offset[0], yrange = 1.*[0, ny]/cellsize-.5+offset[1] 
     219    xenvsauve = !x & yenvsauve = !y & penvsauve = !p 
     220; 
     221; draw the colorbar  
     222; 
     223    IF truemin ne truemax THEN BEGIN 
     224      if xyaspect ge 1 then $ 
     225        posbar = [25./!d.x_size, 25./!d.y_size, 1-25./!d.x_size, 50./!d.y_size] $ 
     226        ELSE posbar = [1-75./!d.x_size, 25./!d.y_size, 1-50./!d.x_size, 1-25./!d.y_size] 
     227    if keyword_set(nointerp) then BEGIN & truemin = 0 & truemax = ncolmax & endif 
     228      colorbar, min = truemin, max = truemax, division = 10, cb_color = 0, position = posbar $ 
     229                , vertical = xyaspect lt 1, /right, BOTTOM = bottom, NCOLORS = ncolors, _EXTRA = ex 
     230    ENDIF 
     231;      !p.position = poscadre 
     232  ENDIF ELSE BEGIN  
     233;------------------------------------------------------------ 
     234; scrolling bar window case... 
     235;------------------------------------------------------------ 
     236; for 24 bits colors, make sure thate the background color is the good one... 
     237    if !d.n_colors gt 256 then begin 
     238      window, /pixmap 
     239      device, decomposed = 1 
     240      !p.background = 'ffffff'x 
     241      plot, [0], [0] 
     242      device, decomposed = 0 
     243    endif 
     244    slide_image, arr $          ; on le dessine ds une fenetre avec une scrolling bar 
     245                 , xsize = nx, ysize = ny $ 
     246                 , xvisible = round(.7*dimensions[0]) < (size(arr))[1] $ 
     247                 , yvisible = round(.7*dimensions[1]) < (size(arr))[2], /register, congrid = 0, show_full = 0 
     248    return 
     249  ENDELSE  
     250;------------------------------------------------------------ 
     251; Use the mouse to get nice functionalities 
     252;------------------------------------------------------------ 
     253; format to print the mouse position 
     254  CASE 1 OF 
     255    nx LT 10:fmt1 = '(i1)' 
     256    nx LT 100:fmt1 = '(i2)' 
     257    nx LT 1000:fmt1 = '(i3)' 
     258    nx LT 10000:fmt1 = '(i4)' 
     259    ELSE:fmt1 = '' 
     260  ENDCASE 
     261  CASE 1 OF 
     262    ny LT 10:fmt2 = '(i1)' 
     263    ny LT 100:fmt2 = '(i2)' 
     264    ny LT 1000:fmt2 = '(i3)' 
     265    ny LT 10000:fmt2 = '(i4)' 
     266    ELSE:fmt2 = '' 
     267  ENDCASE 
     268; 
     269  if NOT keyword_set(nouseinfos) then begin 
     270    print, 'left button  : mouse position and associated array value' 
     271    print, 'middle button: use it twice to define a zoom box' 
     272    print, 'right button : quit' 
     273  endif 
     274  cursor, x, y, /device, /down 
     275  x = x-marginpix[0] & x = 0 > floor(x/cellsize) < ((size(arr))[1]/cellsize-1) 
     276  y = y-marginpix[2] & y = 0 > floor(y/cellsize) < ((size(arr))[2]/cellsize-1) 
     277  while (!mouse.button ne 4) do BEGIN 
     278    case !mouse.button of 
     279      0:return 
     280      1:BEGIN                   ; get value 
     281        if x LE nx/cellsize AND y LE ny/cellsize then begin 
     282          print, '(x, y) = (' + string(x+offset[0], format = fmt1) $ 
     283                 + ', ' + string(y+offset[1], format = fmt2) $ 
     284                 + '), value = '+strtrim(float((reform(z2d))[x, y]), 1) 
     285        ENDIF 
     286        cursor, x, y, /device, /down 
     287        x = x-marginpix[0] & x = 0 > floor(x/cellsize) < ((size(arr))[1]/cellsize-1) 
     288        y = y-marginpix[2] & y = 0 > floor(y/cellsize) < ((size(arr))[2]/cellsize-1) 
     289      END 
     290      2:BEGIN                   ; zoom 
     291        cursor, x2, y2, /device, /down 
     292        x2 = x2-marginpix[0] & x2 =  0 > floor(x2/cellsize) < ((size(arr))[1]/cellsize-1) 
     293        y2 = y2-marginpix[2] & y2 =  0 > floor(y2/cellsize) < ((size(arr))[2]/cellsize-1) 
     294        x =  [x, x2] & x =  x[sort(x)] 
     295        y =  [y, y2] & y =  y[sort(y)] 
     296        IF keyword_set(OFFSET) THEN offset = [x[0], y[0]]+offset ELSE offset = [x[0], y[0]] 
     297        tvplus, z2d[x[0]:x[1], y[0]:y[1] ], WINDOW = window, MIN = min, MAX = max $ 
     298                , MASK = mask, C_MASK = c_mask, C_NAN = c_nan, /NOUSEINFOS, OFFSET = OFFSET $ 
     299                , NCOLORS = ncolors, NOINTERP = nointerp, BOTTOM = bottom, _EXTRA = ex 
     300        return 
     301      END 
     302      ELSE: 
     303    endcase 
     304  ENDWHILE 
     305;------------------------------------------------------------ 
     306  !x = xenvsauve & !y = yenvsauve & !p = penvsauve 
     307  !x.range = 1.*[0, nx]/cellsize-.5+offset[0] 
     308  !y.range = 1.*[0, ny]/cellsize-.5+offset[1] 
     309;------------------------------------------------------------ 
     310  return 
    279311end 
Note: See TracChangeset for help on using the changeset viewer.