;+ ; ; @file_comments ; add land points on a 2D land-sea mask ; ; @categories ; Grid ; ; @param TAB {in}{required} ; a 2D land-sea mask, with 1 on sea and 0 on land ; ; @keyword CELLSIZE ; size (in pixel) of the square ; representing one point of the mask ; ; @returns ; the new 2D land-sea mask ; ; @examples ; ; IDL> a = changemsk(tmask[*,*,0]) ; ; to add ocean points ; IDL> a = 1 - changemsk(1 - tmask[*,*,0]) ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; June 2006 ; ; @version ; $Id$ ; ;- FUNCTION changemsk,tab, CELLSIZE=cellsize ; compile_opt idl2, strictarrsubs ; newmsk = -1 taille = size(tab) if taille[0] NE 2 then return, newmsk newmsk=byte(tab) if keyword_set(cellsize) THEN cellsize = long(cellsize) $ ELSE cellsize = long(2) window,xsize=taille[1]*cellsize,ysize=taille[2]*cellsize tvscl, congrid(newmsk, taille[1]*cellsize, taille[2]*cellsize) if NOT keyword_set(nouseinfos) then begin print, 'left button : use it twice to define the diagonal of the rectangle to be set to 0 (land)' print, 'middle button: put 0 (land) on the clicked point' print, 'right button : quit' endif cursor,x1,y1,/device, /up while (!mouse.button ne 4) do begin case !mouse.button of 0:return, newmsk 1:BEGIN cursor,x2,y2,/device, /up x = [x1, x2] x = x[sort(x)] x = round(x/cellsize) y = [y1, y2] y = y[sort(y)] y = round(y/cellsize) newmsk[x[0]:x[1], y[0]:y[1] ] = 0 tvscl, replicate(0,(x[1]-x[0]+1)*cellsize $ ,(y[1]-y[0]+1)*cellsize) $ ,x[0]*cellsize,y[0]*cellsize end 2:BEGIN x1 = round(x1/cellsize) y1 = round(y1/cellsize) newmsk[x1, y1] = 0 tvscl,replicate(0,cellsize,cellsize) $ ,x1*cellsize,y1*cellsize END ELSE: endcase cursor,x1,y1,/device, /up endwhile return, newmsk end