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 | ; |
---|
21 | ; IDL> a = changemsk(tmask[*,*,0]) |
---|
22 | ; |
---|
23 | ; to add ocean points |
---|
24 | ; IDL> a = 1 - changemsk(1 - tmask[*,*,0]) |
---|
25 | ; |
---|
26 | ; @history |
---|
27 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
28 | ; June 2006 |
---|
29 | ; |
---|
30 | ; @version |
---|
31 | ; $Id$ |
---|
32 | ; |
---|
33 | ;- |
---|
34 | FUNCTION changemsk,tab, CELLSIZE=cellsize |
---|
35 | ; |
---|
36 | compile_opt idl2, strictarrsubs |
---|
37 | ; |
---|
38 | newmsk = -1 |
---|
39 | taille = size(tab) |
---|
40 | if taille[0] NE 2 then return, newmsk |
---|
41 | newmsk=byte(tab) |
---|
42 | if keyword_set(cellsize) THEN cellsize = long(cellsize) $ |
---|
43 | ELSE cellsize = long(2) |
---|
44 | window,xsize=taille[1]*cellsize,ysize=taille[2]*cellsize |
---|
45 | tvscl, congrid(newmsk, taille[1]*cellsize, taille[2]*cellsize) |
---|
46 | |
---|
47 | if NOT keyword_set(nouseinfos) then begin |
---|
48 | print, 'left button : use it twice to define the diagonal of the rectangle to be set to 0 (land)' |
---|
49 | print, 'middle button: put 0 (land) on the clicked point' |
---|
50 | print, 'right button : quit' |
---|
51 | endif |
---|
52 | |
---|
53 | cursor,x1,y1,/device, /up |
---|
54 | while (!mouse.button ne 4) do begin |
---|
55 | case !mouse.button of |
---|
56 | 0:return, newmsk |
---|
57 | 1:BEGIN |
---|
58 | cursor,x2,y2,/device, /up |
---|
59 | x = [x1, x2] |
---|
60 | x = x[sort(x)] |
---|
61 | x = round(x/cellsize) |
---|
62 | y = [y1, y2] |
---|
63 | y = y[sort(y)] |
---|
64 | y = round(y/cellsize) |
---|
65 | newmsk[x[0]:x[1], y[0]:y[1] ] = 0 |
---|
66 | tvscl, replicate(0,(x[1]-x[0]+1)*cellsize $ |
---|
67 | ,(y[1]-y[0]+1)*cellsize) $ |
---|
68 | ,x[0]*cellsize,y[0]*cellsize |
---|
69 | end |
---|
70 | 2:BEGIN |
---|
71 | x1 = round(x1/cellsize) |
---|
72 | y1 = round(y1/cellsize) |
---|
73 | newmsk[x1, y1] = 0 |
---|
74 | tvscl,replicate(0,cellsize,cellsize) $ |
---|
75 | ,x1*cellsize,y1*cellsize |
---|
76 | |
---|
77 | END |
---|
78 | ELSE: |
---|
79 | endcase |
---|
80 | cursor,x1,y1,/device, /up |
---|
81 | endwhile |
---|
82 | |
---|
83 | return, newmsk |
---|
84 | end |
---|