source: trunk/SRC/ToBeReviewed/TRIANGULATION/completecointerre.pro @ 163

Last change on this file since 163 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.0 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments
7;
8;
9; @categories
10; Graphics
11;
12; @param LONS
13;
14;
15; @param LATS
16;
17;
18; @param SEUIL
19;
20;
21; @keyword _EXTRA
22; Used to pass your keywords
23;
24; @keyword CONT_COLOR {default=(!d.n_colors - 1) < 255 => white}
25; The color of the continent.
26;
27; @uses
28; common.pro
29;
30; @history
31; Sebastien Masson (smasson\@lodyc.jussieu.fr)
32;                      01/10/1999
33;
34; @version
35; $Id$
36;
37;-
38;------------------------------------------------------------
39;------------------------------------------------------------
40;------------------------------------------------------------
41PRO draw_corner_triangle, lons, lats, seuil, CONT_COLOR = cont_color, _extra = ex
42;
43  compile_opt idl2, strictarrsubs
44;
45@cm_4mesh
46; the triangle must not be out of the domain
47  IF min(lons, max = maxlon) GE lon1 AND maxlon LE lon2 $
48    AND min(lats, max = maxlat) GE lat1 AND maxlat LE lat2 then BEGIN
49; the triangle must not be too big
50    z = convert_coord(lons, lats, /data, /to_normal)
51    alldist = [(z[0, 2]-z[0, 0])^2 + (z[1, 2]-z[1, 0])^2 $
52               , (z[0, 0]-z[0, 1])^2 + (z[1, 0]-z[1, 1])^2 $
53               , (z[0, 1]-z[0, 2])^2 + (z[1, 1]-z[1, 2])^2]
54    IF max(alldist) LT seuil^2 THEN polyfill, lons, lats $
55      , color = cont_color, _extra = ex
56    return
57  ENDIF
58end
59;------------------------------------------------------------
60;------------------------------------------------------------
61;------------------------------------------------------------
62;+
63;
64; @file_comments
65; To color cleanly continents
66;
67; @categories
68; Graphics
69;
70; @keyword _EXTRA
71; Used to pass your keywords
72;
73; @keyword CONT_COLOR
74; The color of the continent. default value is
75; (!d.n_colors - 1) < 255 => white
76;
77; @keyword COINMONTE {type=array}
78; To obtain the array of "ascending land corner"
79; to be treated with completecointerre.pro in the variable array
80; instead of make it pass by the global variable twin_corners_up.
81;
82; @keyword COINDESCEND {type=array}
83; See COINMONTE
84;
85; @keyword INDICEZOOM
86; The zoom's index
87;
88; @uses
89; common.pro
90;
91; @history
92; Sebastien Masson (smasson\@lodyc.jussieu.fr)
93;                      01/10/1999
94;
95; @version
96; $Id$
97;
98;-
99;------------------------------------------------------------
100;------------------------------------------------------------
101;------------------------------------------------------------
102PRO completecointerre, COINMONTE = coinmonte, COINDESCEND = coindescend $
103                       , CONT_COLOR = cont_color, INDICEZOOM = indicezoom $
104                       , _extra = ex
105;
106  compile_opt idl2, strictarrsubs
107;
108@common
109;------------------------------------------------------------
110;   if NOT keyword_set(coinmonte) then return
111;   if NOT keyword_set(coindescend) then return
112;   if NOT keyword_set(indicezoom) then return
113  tempsun = systime(1)          ; For key_performance
114;------------------------------------------------------------
115; definitions of vectors coinmont and coindesc
116;------------------------------------------------------------
117  if keyword_set(coinmonte) then coinmont = coinmonte $
118  ELSE coinmont = twin_corners_up
119  if keyword_set(coindescend) then coindesc = coindescend $
120  ELSE coindesc = twin_corners_dn
121  IF NOT keyword_set(cont_color) THEN cont_color = (!d.n_colors-1) <  255
122;------------------------------------------------------------
123; definition of coordinates of points numbered 1,2,3,4,5,6 (see figures below)
124;------------------------------------------------------------
125  tempdeux = systime(1)         ; For key_performance =2
126  if coinmont[0] NE -1 OR coindesc[0] NE -1 then BEGIN
127    if keyword_set(indicezoom) then BEGIN
128; if we use key_stide, the t, u, v and f points are no more related to
129; the same cell because glamf and gphif has be recomputed to be in the
130; middle of two t points
131      IF total(key_stride) EQ 3 AND finite(glamv[0]*gphiv[0]) NE 0 THEN BEGIN
132        long1 = glamv[indicezoom] & lati1 = gphiv[indicezoom]
133      ENDIF ELSE BEGIN
134        long1 = glamt[indicezoom] & lati1 = gphif[indicezoom]
135      ENDELSE
136      IF total(key_stride) EQ 3 AND finite(glamu[0]*gphiu[0]) NE 0 THEN BEGIN
137        long2 = glamu[indicezoom] & lati2 = gphiu[indicezoom]
138      ENDIF ELSE BEGIN
139        long2 = glamf[indicezoom] & lati2 = gphit[indicezoom]
140      ENDELSE
141      long3 = glamf[indicezoom] & lati3 = gphif[indicezoom]
142    ENDIF ELSE BEGIN
143      IF total(key_stride) EQ 3 AND finite(glamv[0]*gphiv[0]) NE 0 THEN BEGIN
144        long1 = glamv & lati1 = gphiv
145      ENDIF ELSE BEGIN
146        long1 = glamt & lati1 = gphif
147      ENDELSE
148      IF total(key_stride) EQ 3 AND finite(glamu[0]*gphiu[0]) NE 0 THEN BEGIN
149        long2 = glamu & lati2 = gphiu
150      ENDIF ELSE BEGIN
151        long2 = glamf & lati2 = gphit
152      ENDELSE
153      long3 = glamf & lati3 = gphif
154    ENDELSE
155;
156    nx = (size(long1, /dimensions))[0]
157    ny = (size(long1, /dimensions))[1]
158    seuil = 5 < (min([nx, ny])-2)
159    seuil = min([(!p.position[2]-!p.position[0])/seuil $
160                 , (!p.position[3]-!p.position[1])/seuil])
161;
162  ENDIF
163;
164  IF testvar(var = key_performance) EQ 2 THEN $
165    print, 'temps completecointerre: positions des points', systime(1)-tempdeux
166;
167;
168; Case land corner in ascent:
169;      2 land points in diagonal ascending with 2 ocean points on the descendant diagonal.
170;
171;                     4   
172;     t(i+nx)=1    u(i+nx)       t(i+nx+1)=0
173;                     |    \
174;                     |        \
175;         1         3 |            \   5
176;       v(i)---------f(i)------------v(i+1)
177;           \         |
178;              \      |
179;                 \   |
180;      t(i)=0       2 u(i)          t(i+1)=1
181;
182;
183  if coinmont[0] NE -1 then BEGIN
184    tempdeux = systime(1)       ; For key_performance =2
185    for id = 0, n_elements(coinmont)-1 do BEGIN
186      i = coinmont[id]
187      ii = i MOD nx
188      ij = i/nx
189; bottom triangle
190      lons = [long1[i], long2[i], long3[i]]
191      lats = [lati1[i], lati2[i], lati3[i]]
192      draw_corner_triangle, lons, lats, seuil, CONT_COLOR = cont_color, _extra = ex
193; upper triangle
194      IF ii NE nx-1 AND ij NE ny-1 THEN BEGIN
195        lons = [long3[i], long1[i+1], long2[i+nx]]
196        lats = [lati3[i], lati1[i+1], lati2[i+nx]]
197        draw_corner_triangle, lons, lats, seuil, CONT_COLOR = cont_color, _extra = ex
198      ENDIF
199    ENDFOR
200    IF testvar(var = key_performance) EQ 2 THEN $
201      print, 'temps completecointerre: trace de cointerremonte', systime(1)-tempdeux
202  ENDIF
203;------------------------------------------------------------
204; Case land corner in descent:
205;      2 land points in diagonal descending with 2 ocean points on the ascendant diagonal.
206;
207;                     4
208;     t(i+nx)=1    u(i+nx)       t(i+nx+1)=0
209;                /    |       
210;             /       |         
211;          /        3 |                5
212;       v(i)---------f(i)------------v(i+1)
213;         1           |            /
214;                     |         /
215;                     |      /
216;      t(i)=0      2 u(i)          t(i+1)=1
217;
218  if coindesc[0] NE -1 then begin
219    tempdeux = systime(1)       ; For key_performance =2
220    for id = 0, n_elements(coindesc)-1 do BEGIN
221      i = coindesc[id]
222      ii = i MOD nx
223      ij = i/nx
224      IF ii NE nx-1 AND ij NE ny-1 THEN BEGIN
225; left triangle
226        lons = [long1[i], long3[i], long2[i+nx]]
227        lats = [lati1[i], lati3[i], lati2[i+nx]]
228        draw_corner_triangle, lons, lats, seuil, CONT_COLOR = cont_color, _extra = ex
229; right triangle
230        lons = [long3[i], long2[i], long1[i+1]]
231        lats = [lati3[i], lati2[i], lati1[i+1]]
232        draw_corner_triangle, lons, lats, seuil, CONT_COLOR = cont_color, _extra = ex
233      ENDIF
234    ENDFOR
235    IF testvar(var = key_performance) EQ 2 THEN $
236      print, 'temps completecointerre: trace de cointerredescend', systime(1)-tempdeux
237  ENDIF
238
239;------------------------------------------------------------
240  IF keyword_set(key_performance) THEN print, 'temps completecointerre', systime(1)-tempsun
241;------------------------------------------------------------
242  return
243end
Note: See TracBrowser for help on using the repository browser.