Hi David and Philip.
Thank you very much for your precisse assistance.
Lim
On Thursday, October 10, 2013 10:16:46 AM UTC-4, David Fanning wrote:
> 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.")
|