[119] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ; |
---|
| 5 | ; @file_comments add land points on a 2D land-sea mask |
---|
| 6 | ; |
---|
| 7 | ; @categories grid |
---|
| 8 | ; |
---|
| 9 | ; @param msk {in}{required} a 2D land-sea mask, with 1 on sea and 0 on land |
---|
| 10 | ; |
---|
| 11 | ; @keyword CELLSIZE size (in pixel) of the square |
---|
| 12 | ; representing one point of the mask |
---|
| 13 | ; |
---|
| 14 | ; @keyword NOUSEINFOS activite to supress the printed message explaining |
---|
| 15 | ; how to use tvplus |
---|
| 16 | ; |
---|
| 17 | ; @returns newmsk the new 2D land-sea mask |
---|
| 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 | ; |
---|
| 28 | ; @version $Id$ |
---|
| 29 | ; |
---|
| 30 | ;------------------------------------------------------------ |
---|
| 31 | ;------------------------------------------------------------ |
---|
| 32 | ;------------------------------------------------------------ |
---|
| 33 | function changemsk,tab, CELLSIZE = cellsize |
---|
| 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 |
---|
| 44 | tvscl, congridseb(newmsk, taille[1]*cellsize, taille[2]*cellsize) |
---|
| 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 |
---|
| 83 | end |
---|
| 84 | |
---|