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