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

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

improvements/corrections of some *.pro headers

  • 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;-
32;
[238]33FUNCTION changemsk,tab, CELLSIZE = cellsize
[119]34;
35  compile_opt idl2, strictarrsubs
36;
37   newmsk = -1
38   taille = size(tab)
39   if taille[0] NE 2 then return, newmsk
40   newmsk=byte(tab)
41   if keyword_set(cellsize) THEN cellsize = long(cellsize) $
42   ELSE cellsize = long(2)
43   window,xsize=taille[1]*cellsize,ysize=taille[2]*cellsize
[152]44   tvscl, congrid(newmsk, taille[1]*cellsize, taille[2]*cellsize)
[119]45
46   if NOT keyword_set(nouseinfos) then begin
47    print, 'left button  : use it twice to define the diagonal of the rectangle to be set to 0 (land)'
48    print, 'middle button: put 0 (land) on the clicked point'
49    print, 'right button : quit'
50  endif
51
52  cursor,x1,y1,/device, /up
53   while (!mouse.button ne 4) do begin
54      case !mouse.button of
55         0:return, newmsk
56         1:BEGIN
57            cursor,x2,y2,/device, /up
58            x = [x1, x2]
59            x = x[sort(x)]
60            x = round(x/cellsize)
61            y = [y1, y2]
62            y = y[sort(y)]
63            y = round(y/cellsize)
64            newmsk[x[0]:x[1], y[0]:y[1] ] = 0
65            tvscl, replicate(0,(x[1]-x[0]+1)*cellsize $
66                             ,(y[1]-y[0]+1)*cellsize) $
67             ,x[0]*cellsize,y[0]*cellsize
68         end
69         2:BEGIN
70            x1 = round(x1/cellsize)
71            y1 = round(y1/cellsize)
72            newmsk[x1, y1] = 0
73            tvscl,replicate(0,cellsize,cellsize) $
74             ,x1*cellsize,y1*cellsize
75
76          END
77         ELSE:
78      endcase
79      cursor,x1,y1,/device, /up
80   endwhile
81
82   return, newmsk
83end
Note: See TracBrowser for help on using the repository browser.