source: trunk/SRC/Grid/changemsk.pro @ 327

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

modification of headers : mainly blanks around = sign for keywords in declaration of function and pro

  • Property svn:keywords set to Id
File size: 2.0 KB
RevLine 
[231]1;+
[232]2;
[230]3; @file_comments
4; add land points on a 2D land-sea mask
[119]5;
[231]6; @categories
[157]7; Grid
[119]8;
[231]9; @param TAB {in}{required}
[230]10; a 2D land-sea mask, with 1 on sea and 0 on land
[119]11;
[231]12; @keyword CELLSIZE
[163]13; size (in pixel) of the square
14; representing one point of the mask
[119]15;
[231]16; @returns
[238]17; the new 2D land-sea mask
[119]18;
[124]19; @examples
20; IDL> a = changemsk(tmask[*,*,0])
[119]21;  to add ocean points
[124]22; IDL> a = 1 - changemsk(1 - tmask[*,*,0])
[119]23;
24; @history
25;      Sebastien Masson (smasson\@lodyc.jussieu.fr)
26;      June 2006
27;
[231]28; @version
[157]29; $Id$
[119]30;
[231]31;-
[327]32FUNCTION changemsk,tab, CELLSIZE=cellsize
[119]33;
34  compile_opt idl2, strictarrsubs
35;
36   newmsk = -1
37   taille = size(tab)
38   if taille[0] NE 2 then return, newmsk
39   newmsk=byte(tab)
40   if keyword_set(cellsize) THEN cellsize = long(cellsize) $
41   ELSE cellsize = long(2)
42   window,xsize=taille[1]*cellsize,ysize=taille[2]*cellsize
[152]43   tvscl, congrid(newmsk, taille[1]*cellsize, taille[2]*cellsize)
[119]44
45   if NOT keyword_set(nouseinfos) then begin
46    print, 'left button  : use it twice to define the diagonal of the rectangle to be set to 0 (land)'
47    print, 'middle button: put 0 (land) on the clicked point'
48    print, 'right button : quit'
49  endif
50
51  cursor,x1,y1,/device, /up
52   while (!mouse.button ne 4) do begin
53      case !mouse.button of
54         0:return, newmsk
55         1:BEGIN
56            cursor,x2,y2,/device, /up
57            x = [x1, x2]
58            x = x[sort(x)]
59            x = round(x/cellsize)
60            y = [y1, y2]
61            y = y[sort(y)]
62            y = round(y/cellsize)
63            newmsk[x[0]:x[1], y[0]:y[1] ] = 0
64            tvscl, replicate(0,(x[1]-x[0]+1)*cellsize $
65                             ,(y[1]-y[0]+1)*cellsize) $
66             ,x[0]*cellsize,y[0]*cellsize
67         end
68         2:BEGIN
69            x1 = round(x1/cellsize)
70            y1 = round(y1/cellsize)
71            newmsk[x1, y1] = 0
72            tvscl,replicate(0,cellsize,cellsize) $
73             ,x1*cellsize,y1*cellsize
74
75          END
76         ELSE:
77      endcase
78      cursor,x1,y1,/device, /up
79   endwhile
80
81   return, newmsk
82end
Note: See TracBrowser for help on using the repository browser.