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 
Return to the default flat view Create a new topic Submit Reply
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/
[Message index]
 
Read Message
Read Message
Read Message
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 17:46:52 PDT 2025

Total time taken to generate the page: 0.00375 seconds