source: trunk/SRC/ToBeReviewed/PLOTS/DIVERS/determineminmax.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: 3.3 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments
7; Determine the min and the max of a mask array
8;
9; @categories
10; Plotting
11;
12; @param TAB {in}{required}
13; The array whose we determine the min and the max
14;
15; @param MASK {in}{required}
16; The mask array
17;
18; @keyword MININ {type=scalar}
19; If it is not defined, it takes the value of VRAIMIN
20;
21; @keyword MAXIN {type=scalar}
22; If it is not defined, it takes the value of VRAIMAX
23;
24; @keyword ZEROMIDDLE
25; Force the middle of the colorbar to be equal
26; to 0 (force max=max(abs([min,max])) and min=-max)
27;
28; @keyword _EXTRA
29; used to pass your keywords
30;
31; @keyword USETRI
32; To force using triangulation.
33;
34; @param VRAIMIN {out}
35; The min of the array
36;
37; @param VRAIMAX {out}
38; The max of the array
39;
40; @uses
41; Common.pro
42;
43; @restrictions
44; Look if the field is constant on the sea
45;
46; @history
47; Sebastien Masson (smasson\@lodyc.jussieu.fr)
48;                       11/12/98
49;
50; @version
51; $Id$
52;
53; @todo seb: manque les param glam et gphi
54;
55;-
56;------------------------------------------------------------
57;------------------------------------------------------------
58;------------------------------------------------------------
59PRO determineminmax, tab, mask, vraimin, vraimax, glam, gphi, MAXIN = maxin, MININ = minin, INTERVALLE = intervalle, usetri = usetri, ZEROMIDDLE = zeromiddle, _extra = ex
60;
61  compile_opt idl2, strictarrsubs
62;
63@common
64;-----------------------------------------------------------------------------
65;-----------------------------------------------------------------------------
66; Type o fthe vertical grid:
67  if vargrid EQ 'W' then nz = nzw ELSE nz = nzt
68; liste des points mer
69  if (size(mask))[0] EQ 3 then mer = mask[*, *, 0] $
70  ELSE mer = mask
71; If key_irregular eq 1, we mask also points which are not in the geographic
72; domain defined by lon1,lon2,lat1,lat2
73  if keyword_set(key_irregular) AND n_elements(glam) NE 0 AND n_elements(gphi) NE 0 then begin
74    dom =   where(glam LT lon1 OR glam GT lon2 OR gphi LT lat1 OR gphi GT lat2)
75    if dom[0] NE -1 then mer[dom] = 0
76  endif
77;
78  mer = where(mer eq 1)
79;
80  if mer[0] eq -1 then begin
81    ras = report('Il n''y a que de la terre sur le dessin!')
82    vraimax = 0
83    vraimin = 0
84    maxin = vraimax+1
85    minin = vraimin-1
86    usetri = 0
87    return
88  endif
89; ma and mi : max and min on ocean points
90  vraimax = max(tab[mer], min = vraimin, _extra = ex)
91  sameminmax = testvar(var = minin) EQ testvar(var = maxin)
92  if n_elements(maxin) EQ 0 OR sameminmax then maxin = vraimax
93  if n_elements(minin) EQ 0 OR sameminmax then BEGIN
94    if keyword_set(intervalle) then minin = floor(vraimin/intervalle)*intervalle $
95    ELSE minin = vraimin
96  endif
97  if vraimin eq vraimax then BEGIN
98    IF size(vraimin, /type) EQ 1 THEN vraimin = fix(vraimin)
99    question = ['Warning: constant filed, same value everywhere : ' + strtrim(vraimin, 2) +'!', 'Shall we make the plot?']
100    answer = report(question, /default_no, /question)
101    if answer then begin
102      maxin = vraimax+1
103      minin = vraimin-1
104    endif ELSE tab = -1
105  ENDIF
106  IF keyword_set(zeromiddle) THEN BEGIN
107      maxin = max(abs([minin, maxin]))
108      minin = -maxin
109  ENDIF
110
111
112  return
113end
Note: See TracBrowser for help on using the repository browser.