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

Home » Public Forums » archive » cgContour and NaN values
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: cgContour and NaN values [message #86138 is a reply to message #86117] Thu, 10 October 2013 07:16 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Lim writes:

> I am having some trouble using contour with data which has NaN values. My valid range of data is -1 to 1. I have also change the NaN to -999. In that case the -999 appear as the same color as -1. I would like that the NaN values appear as white. Please, Could you tell me what I am doing wrong? (I am following a example I found at http://www.idlcoyote.com/graphics_tips/contourcolors.php but Im sure i missed somthing)

It is almost *never* a good idea to try filled contours with missing
data. The results are always unsatisfactory. But, if you have to, you
have to. I would try something like this.

data = dist(192,145)
data[50:60,75:79] = !Values.F_NaN
minval=-1.
maxval=1.
nanIndices = Where(Finite(data) EQ 0, count)
data=cgScaleVector(data, minval, maxval, /NaN)
IF count GT 0 THEN data[nanIndices] = minval - 1
cgWindow
ncontours = 10
cgLoadCT, 22, /Brewer, /Reverse, NColors=ncontours+1, Bottom=2
TVLCT, cgColor('white', /Triple), 1
clevels = [minval-1, cgScaleVector(Findgen(ncontours+1), $
minval, maxval)]
colors = Bindgen(ncontours+1) + 1B
cgContour, data, lons, lats, Levels=clevels, C_Colors=colors, /Fill, $
missing=!Values.F_Nan, Position=[0.125, 0.125, 0.925, 0.8], /AddCmd
cgColorbar, NColors=ncontours, Range=[minval,maxval], Divisions=10, $
Bottom=2, Ticklen=0.001, /AddCmd
END


Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: scopes
Next Topic: Yet another user with poly_fit problems

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

Current Time: Fri Oct 10 12:43:34 PDT 2025

Total time taken to generate the page: 1.75737 seconds