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

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

modification of some headers (+some corrections) to prepare usage of the new idldoc

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1;+
2;
3; @file_comments
4; add land points on a 2D land-sea mask
5;
6; @categories
7; Grid
8;
9; @param TAB {in}{required}
10; a 2D land-sea mask, with 1 on sea and 0 on land
11;
12; @keyword CELLSIZE
13; size (in pixel) of the square
14; representing one point of the mask
15;
16; @returns
17; the new 2D land-sea mask
18;
19; @examples
20; IDL> a = changemsk(tmask[*,*,0])
21;  to add ocean points
22; IDL> a = 1 - changemsk(1 - tmask[*,*,0])
23;
24; @history
25;      Sebastien Masson (smasson\@lodyc.jussieu.fr)
26;      June 2006
27;
28; @version
29; $Id$
30;
31;-
32FUNCTION changemsk,tab, CELLSIZE = cellsize
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
43   tvscl, congrid(newmsk, taille[1]*cellsize, taille[2]*cellsize)
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.