source: trunk/SRC/ToBeReviewed/PLOTS/DIVERS/determineminmax.pro @ 262

Last change on this file since 262 was 262, checked in by pinsard, 17 years ago

corrections of some headers and parameters and keywords case. change of pro2href to replace proidl

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