source: trunk/SRC/ToBeReviewed/TRIANGULATION/tracemask.pro @ 373

Last change on this file since 373 was 370, checked in by pinsard, 16 years ago

improvemnts of headers (typo, links)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.6 KB
RevLine 
[2]1;+
2;
[150]3; @file_comments
4; Draw contours of a mask
[2]5;
[150]6; @categories
[157]7; Utilities
[226]8;
[150]9; @param MASKENTREE {in}{required}
[163]10; 2d array specifying the mask
[226]11;
[297]12; @param XIN {in}{required}
[163]13; 2d array specifying longitude coordinates.
[226]14;
[297]15; @param YIN {in}{required}
[163]16; 2d array specifying latitude coordinates.
[2]17;
[163]18; @keyword COAST_COLOR {default=0}
[150]19; The color of the coastline.
[163]20; Default is black (0).
[2]21;
[163]22; @keyword COAST_THICK {default=1}
[150]23; The thick of the trait to trace continents
[29]24;
[150]25; @keyword OVERPLOT
26; To do a plot over an other one.
[2]27;
[150]28; @keyword _EXTRA
[231]29; Used to pass keywords
[2]30;
[150]31; @uses
[370]32; <pro>common</pro>
[2]33;
[150]34; @history
[157]35; Sebastien Masson (smasson\@lodyc.jussieu.fr)
[2]36;
[150]37; @version
38; $Id$
[2]39;
40;-
[327]41PRO tracemask, maskentree, xin, yin $
42             , COAST_COLOR=coast_color, COAST_THICK=coast_thick $
43             , OVERPLOT=overplot, _EXTRA=ex
[29]44;
[114]45  compile_opt idl2, strictarrsubs
46;
[2]47   if keyword_set(overplot) then return
[29]48;---------------------------------------------------------
49@cm_general
50  IF NOT keyword_set(key_forgetold) THEN BEGIN
51@updatekwd
52  ENDIF
[226]53;---------------------------------------------------------
[150]54   tempsun = systime(1)         ; For key_performance
55; We avoid edging problems:
56   tempdeux = systime(1)        ; For key_performance =2
[2]57   tailleentree = size(maskentree)
58   nx = tailleentree[1]+1
59   ny = tailleentree[2]+1
[29]60; we check the input axis
61  IF n_elements(xin) EQ 0 THEN xentree = findgen(nx-1) ELSE xentree = xin
62  IF (size(xentree))[0] EQ 1 THEN xentree = xentree#replicate(1,ny-1)
63  IF n_elements(yin) EQ 0 THEN yentree = findgen(ny-1) ELSE yentree = yin
64  IF (size(yentree))[0] EQ 1 THEN yentree = replicate(1,nx-1)#yentree
[150]65; We enlarge the mask by 1 column to the left an d1 line to the bottom
[2]66   mask = intarr(tailleentree[1]+1, tailleentree[2]+1)
67   mask[1:tailleentree[1], 1:tailleentree[2]] = maskentree
[150]68; The 2 first columns are identical.
[2]69   mask[0, 1:tailleentree[2]] = maskentree[0, *]
[150]70; The 2 first lines are identical.
[2]71   mask[1:tailleentree[1], 0] = maskentree[*, 0]
[150]72; We calculate the position following x of points which will serve to trace the mask. They are situated between each points of the mask, exept for the last column we can not calculate and so we put at max (!x.range).
73   xrange = !x.range[sort(!x.range)] ; if REVERSE_X is used
[2]74   xentree = .5*(xentree+shift(xentree, -1, 0))
75   IF not keyword_set(overplot) THEN xentree[nx-2, *] = xrange[1] $
76   ELSE xentree[nx-2, *] = xentree[nx-3, *]
[150]77; we sill
[2]78   xentree = xrange[0] > xentree < xrange[1]
[226]79; we enlarge the array
[2]80   xf = fltarr(nx, ny)
81   xf[1:nx-1, 1:ny-1] = xentree
82   IF not keyword_set(overplot) THEN xf[0, *] = xrange[0] $
83   ELSE xf[0, *] = xf[1, *]
84   xf[1:nx-1, 0] = xentree[*, 0]
85;
86   yinverse = yentree[0, 0] GT yentree[0, ny-2]
87   yrange = !y.range[sort(!y.range)]
88   yentree = .5*(yentree+shift(yentree, 0, -1))
[226]89   IF not keyword_set(overplot) THEN BEGIN
[2]90      if yinverse then yentree[*, ny-2] = yrange[0] ELSE yentree[*, ny-2] = yrange[1]
91   ENDIF ELSE yentree[*, ny-2] = yentree[*, ny-3]
92   yentree = yrange[0] > yentree < yrange[1]
93   yf = fltarr(nx, ny)
94   yf[1:nx-1, 1:ny-1] = yentree
95   yf[0, 1:ny-1] = yentree[0, *]
[226]96   IF not keyword_set(overplot) THEN BEGIN
[2]97      if yinverse then yf[*, 0] = yrange[1] ELSE yf[*, 0] = yrange[0]
98   ENDIF ELSE yentree[*, 0] = yentree[*, 1]
99;
100   IF testvar(var = key_performance) EQ 2 THEN $
[297]101    print, 'temps tracemask: determination du mask et de ses coordonnees', systime(1)-tempdeux
[2]102;
[150]103; We trace vertical segments:
[2]104;
[150]105   tempdeux = systime(1)        ; For key_performance =2
[2]106   liste = where(mask+shift(mask, -1, 0) EQ 1)
107   IF liste[0] NE -1 THEN BEGIN
[150]108; We recuperate lx and ly which are indexes in a 2d array of points given by list
[2]109      ly = liste/nx & lx = temporary(liste)-nx*ly
[226]110      indice = where(ly NE 0) ; We do not take points concerning
111; the first line because in this case, the point j-1 is not defined
[2]112      if indice[0] NE -1 then begin
113         lx = lx[indice] & ly = ly[temporary(indice)]
114         IF testvar(var = key_performance) EQ 2 THEN $
115          print, 'temps tracemask: liste traits verticaux', systime(1)-tempdeux
[150]116         tempdeux = systime(1)  ; For key_performance =2
117; loop on concerned points and drawing of the segment.
118; comments: we use plots instead of plot because plots is faster.
[226]119         for pt = 0L, n_elements(lx)-1 do BEGIN
[2]120            i = lx[pt] & j = ly[pt]
121            plots, [xf[i, j-1], xf[i, j]], [yf[i, j-1], yf[i, j]] $
[29]122              , color = coast_color, thick = coast_thick, _extra = ex
[2]123            if pt LT 5 then begin
124            endif
125         endfor
126         IF testvar(var = key_performance) EQ 2 THEN $
127          print, 'temps tracemask: trace traits verticaux', systime(1)-tempdeux
128      endif
129   ENDIF
130;
[150]131; We trace horizontal segments:
[2]132;
[150]133   tempdeux = systime(1)        ; For key_performance =2
[2]134   liste = where(mask+shift(mask, 0, -1) EQ 1)
135   IF liste[0] NE -1 THEN BEGIN
136      ly = liste/nx & lx = temporary(liste)-nx*ly
[150]137      indice = where(lx NE 0)   ; We do not take point sof the first column.
[2]138      if indice[0] EQ -1 then return
139      lx = lx[indice] & ly = ly[temporary(indice)]
140      IF testvar(var = key_performance) EQ 2 THEN $
141       print, 'temps tracemask: liste traits horizontaux', systime(1)-tempdeux
[150]142      tempdeux = systime(1)     ; For key_performance =2
[226]143      for pt = 0L, n_elements(lx)-1 do BEGIN
[2]144         i = lx[pt] & j = ly[pt]
145         plots, [xf[i-1, j], xf[i, j]], [yf[i-1, j], yf[i, j]] $
[29]146           , color = coast_color, thick = coast_thick, _extra = ex
[2]147      endfor
148      IF testvar(var = key_performance) EQ 2 THEN $
149       print, 'temps tracemask: trace traits horizontaux', systime(1)-tempdeux
150   endif
151;
152;
[226]153   if keyword_set(key_performance) THEN print, 'temps tracemask', systime(1)-tempsun
154
[2]155   return
156end
157
158
159
160
161
Note: See TracBrowser for help on using the repository browser.