comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: IDL plotting query - how can I get rid of unwanted colour for a particular data value???
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: IDL plotting query - how can I get rid of unwanted colour for a particular data value??? [message #60095] Thu, 01 May 2008 10:20
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Vince Hradil writes:

> a clever use if "where()" comes to mind...

Well, with an intelligent use of BYTSCL, too. :-)

Image pixels, no matter what they are *have*
to be displayed. No getting around it.

If you don't what certain pixels to "mean" anything,
then what is typically done is to assign those
pixels the same value as the background color.

This assumes you know how to reserve certain colors
for the image and certain colors for the background.
Something like this should work:

Window, XSIZE=400, YSIZE=400
Loadct, 13, NCOLORS=250
TVLCT, 255, 255, 255, 251 ; White background color.
TVLCT, 0, 0, 0, 252 ; Black drawing color.
image = dist(400)
image [10:50, 300:350] = -999
badpixels = Where(image EQ -999)
Device, Decomposed=0, Get_Decomposed=theState
Erase, COLOR=251
pos = [0.1, 0.1, 0.9, 0.75]
scaled = BytScl(image, TOP=249, MIN=0, MAX=max(image))
scaled[badpixels] = 251
TVImage, scaled, Position=pos, /KEEP_ASPECT
Colorbar, NCOLORS=250, AnnotateColor='black', $
Position=[0.1, 0.85, 0.9, 0.9]
Device, decomposed=theState
END

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: IDL plotting query - how can I get rid of unwanted colour for a particular data value??? [message #60096 is a reply to message #60095] Thu, 01 May 2008 09:57 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On May 1, 11:51 am, edhanna2...@gmail.com wrote:
> Hi,
>
> When using the IDL code below or similar (which uses one of the built-
> in colour tables to display a range of data), does anyone have any
> idea how I can force a particular value (e.g. -999 = nodata) to be NOT
> plotted in the image, e.g. ocean/land area surrounding Greenland Ice
> Sheet in this instance? At the moment it's plotting the image fine
> except that it's colouring parts of the grid (nodata) that I don't
> want it to, which makes my results less clear than they should be.
>
> Many thanks,
>
> Edward
>
> pro icedh2
>
> ;common colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
> loadct,33,bottom=0
> ;tvlct, r_orig, g_orig, b_orig
> set_plot,'ps', /int
>
> device, /portrait, bits=8, xoffset=1, yoffset=1.75, xsize=6, ysize=7,$
> /inches, /color,$
>
> filename='/home/gg1eh/era40/runoff/
> runoffmon_dh1995to2005_base19772006.ps'
>
> openu,1,'/home/gg1eh/era40/runoff/runoffmon_dh1995to2005_bas e19772006'
>
> ;device,/close
>
> nx=329L
> ny=561L
> h1=fltarr(nx,ny)
> readu,1,h1
> ;print,h1
> ;byteorder,h1, /FTOXDR
> close,1
>
> map_set,71,-44,/stereographic,limit=[58,-60,82,-20],$
> title= 'GrIS annual dH/dt: 1995-2005 (base 1977-2006)',$
>
> position=[0,0,1,1],/grid,/noerase
>
> data = bytscl(h1,min=-1.0,max=0.5,top=255)
>
> lats=fltarr(nx,ny)
> lons=fltarr(nx,ny)
> pi=3.141592654
> for iy = 0 , ny-1 do begin
> for ix = 0 , nx-1 do begin
> ;print,ix,iy,data
> i=((ix+1)-149.0)*5000.0;
> j=((iy+1)-681.0)*5000.0;
> a=2*atan(sqrt((i*i)+(j*j))/(2*6371221*0.9728));
> ;print,i,j,a
> lats[ix,iy]=asin(cos(a))*(180.0/pi);
> lons[ix,iy]=atan(i/(-j))*(180.0/pi)-44.0;
> ;print,lons[ix,iy],lats[ix,iy]
> ;stop
> endfor
> endfor
> print,'gothere22'
>
> data=reform(data,nx*ny)
> lats=reform(lats,nx*ny)
> lons=reform(lons,nx*ny)
> print,'gothere23'
>
> data =
> map_patch(data,lons,lats,xstart=xs,ystart=ys,xsize=xsize,ysi ze=ysize,$
> triangulate=1,missing=0)
>
> tv, data, xs, ys, xsize=xsize, ysize=ysize
> map_grid,latdel=5,londel=10,/label
> map_continents
> border = intarr(2,2)
> contour, border,
> position=[0,0,1,1],xticks=1,yticks=1,xstyle=1,ystyle=1, $
> XCharsize=0.001,YCharsize=0.001, /nodata, /noerase
> print,'gothere24'
>
> levs=(findgen(11)*0.15-1.0)
> levs2=fltarr(11,2)
> levs2(*,0)=levs(*)
> levs2(*,1)=levs(*)
> cl=findgen(11)*25.599
> contour,levs2,levs,[0,1],/
> cell_fill,levels=levs,position=[0.2,0.0,0.7,0.05],$
> /noerase,xticks=1,yticks=1,xstyle=1,ystyle=1, XCharsize=1.25,
> YCharsize=0.001,$
> c_colors=cl, xtitle = 'dH/dt (m/yr)'
>
> print,'gothere25'
> device,/close
> set_plot,'X'
>
> print,'gothere26'
> end

a clever use if "where()" comes to mind...
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL plotting query - how can I get rid of unwanted colour for a particular data value???
Next Topic: HDF_SD_ADDDATA problem

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 01:17:09 PDT 2025

Total time taken to generate the page: 0.16051 seconds