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

Home » Public Forums » archive » Re: CONTOUR & TRIGRID/TRIANGULATE
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: CONTOUR & TRIGRID/TRIANGULATE [message #48154] Fri, 31 March 2006 07:08
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ryan. writes:

> That code works great! Thank you so much for your help. I have one
> more question, I put a color bar on the graph (using your colorbar.pro)
> but the colorbar colors don't match what is on the contour. I can
> change the range of the color bar all I want and the colors don't
> change on the contour. I'm not sure what I'm doing wrong. I have the
> code you provided and this below it:
>
> COLORBAR, RANGE=[MIN(levels), MAX(levels)], NCOLORS=ncolors,
> DIVISIONS=8
>
> For Reference:
> c_colors = INDGEN(16)*15
> ncolors = nlevels +1

I think you need to read this article:

http://www.dfanning.com/color_tips/cbarcolors.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: CONTOUR & TRIGRID/TRIANGULATE [message #48155 is a reply to message #48154] Fri, 31 March 2006 06:56 Go to previous message
Ryan. is currently offline  Ryan.
Messages: 77
Registered: March 2006
Member
David,

That code works great! Thank you so much for your help. I have one
more question, I put a color bar on the graph (using your colorbar.pro)
but the colorbar colors don't match what is on the contour. I can
change the range of the color bar all I want and the colors don't
change on the contour. I'm not sure what I'm doing wrong. I have the
code you provided and this below it:

COLORBAR, RANGE=[MIN(levels), MAX(levels)], NCOLORS=ncolors,
DIVISIONS=8

For Reference:
c_colors = INDGEN(16)*15
ncolors = nlevels +1

Thanks,
Ryan.
Re: CONTOUR & TRIGRID/TRIANGULATE [message #48165 is a reply to message #48155] Thu, 30 March 2006 11:08 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ryan. writes:

> I am new to using IDL and cannot seem to figure out how to generate a
> contour map. I am attempting to produce a contour map of Relative
> Humidity at a certain altitude in the tropics. I have lats/lons/RH
> data (irregularly plot) but when I produce it all I get is various
> triangles and nothing nice. I have looked at David Fannings website
> and searched the newsgroup but I haven't found a clear answer how to do
> it. I am using version 6.2 and am using the /IRREGULAR keyword. An
> example of my code is below: (I am sorting it because I've read that
> it needs to be monotonically increasing by latitude)
>
> levels = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130,
> 140, 150, $
> 160, 170, 180, 190, 200]
> nlevels = N_ELEMENTS(levels)
> ncolors = nlevels + 1
> c_colors = INDGEN(ncolors) + 1
>
> A = data_array[1, *] ;The longitudes
> B = data_array[0, *] ;The latitudes
> C = data_array[3, *] ;The RH values
> sort_index = SORT(B)
> x = A[sort_index]
> y = B[sort_index]
> z = C[sort_index]
>
> DEVICE, DECOMPOSED=0
> LOADCT, 33, ncolors=ncolors, bottom = 1
> MAP_SET, /NOBORDER
> MAP_CONTINENTS
> CONTOUR, z, x, y, /IRREGULAR, /OVERPLOT, /CELL_FILL, levels=levels, $
> MIN_VALUE=-1, c_colors=c_colors

Leaving aside the fact that I didn't know relative humidity
could go to 200 percent, I think it is likely that
you have too few points in your data array to do a reasonable
grid.

I've never had much luck letting IDL do almost anything for me,
and I've really never had *any* luck letting it grid data
for me. In any case, there is no need to sort the data in the
way you are doing it. I would have a look at using TRIANGULATE
and TRIGRID to grid your data (or perhaps GRIDDATA if you are
feeling ambitions), then using the gridded data in Contour.
The code will look something like this:

A = data_array[1, *] ;The longitudes
B = data_array[0, *] ;The latitudes
C = data_array[3, *] ;The RH values
Triangulate, a, b, triangles, Sphere=sphere, /Degrees, FValue=c
gridded = TriGrid( a, b, c, triangles, [1.0, 1.0], /Quintic, $
XGrid=glon, YGrid=glat)
DEVICE, DECOMPOSED=0
LOADCT, 33, ncolors=ncolors, bottom = 1
MAP_SET, /NOBORDER
Contour, gridded, glon, glat, /Overplot, /Cell_Fill, $
Levels=levels, C_Colors=c_colors
MAP_CONTINENTS


Does that work any better?

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: iTools Layout - Some help for once :-)
Next Topic: Corrected copy of Intro to IDL available

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

Current Time: Wed Oct 08 13:56:28 PDT 2025

Total time taken to generate the page: 0.00407 seconds