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

Home » Public Forums » archive » Re: Newbie question - showing grid
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: Newbie question - showing grid [message #10926] Tue, 03 February 1998 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Jeff (jeffe@fl.ensco.com) writes:

> One item that some of my peers here want is the ability to
> see the actual grid values.(i.e. a shaded representation is fine)
> They like the contours but they would also like the ability to view
> the raw regularly spaced grid or the points for the irregular
> spaced grid.
>
> Are there any IDL functions that do this.
> I would appreciate any pointers.

If I wanted to see a shaded surface representation of my
data and I wanted to view the grid lines, I might draw the
grid lines right on the shade plot, by doing something like
this:

a=Shift(Dist(30), 20, 15)
peak = Exp(-(a/15)^2)
y = Findgen(30)
x = RandomU(seed, 30) * 30
x = x(Sort(x))
Shade_Surf, peak, x, y
Surface, peak, x, y, XStyle=4, YStyle=4, ZStyle=4, /NoErase

If I wanted to show the contours, but also put in the grid
lines, I would have to go to a bit more trouble, because
IDL only draws grid lines at tick locations. I could try
something like this:

Contour, peak, x, y, /Follow, NLevels=12
FOR j=0, N_Elements(x)-1 DO PlotS, [x[j],x[j]], !Y.CRange, $
LineStyle=2

Cheers,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Newbie question - showing grid [message #10927 is a reply to message #10926] Tue, 03 February 1998 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Jeff wrote:
>
> I have just started learning IDL and am very happy with the speed I
> am able to get things done. I have put together a couple of examples
> showing displays using the contour and surface procedures in IDL.
>
> One item that some of my peers here want is the ability to
> see the actual grid values.(i.e. a shaded representation is fine)
> They like the contours but they would also like the ability to view
> the raw regularly spaced grid or the points for the irregular
> spaced grid.
>
> Are there any IDL functions that do this.
> I would appreciate any pointers.
>
> Thanks,
>
> Jeff

oh, there are several ways to do this ! It all depends what you *really*
want. A few examples:

If you just want to have some symbols where your grid points are, you
will of course need a position vector. If you called contour as
CONTOUR,Z,X,Y,...
then you are already there, all you have to do is add a
OPLOT,X,Y,psym=[symbol]
statement (where symbol is a number from 1-7 or 8, see manual)

If you don't have the positions of your data, then IDL will probably
use the array index as defaults. Then you can simply generate an X and
Y array via
X=findgen(n_elements(Z(*,0)))
and
Y=findgen(n_elements(Z(0,*)))
{others may tell you to use the SIZE() function}

You can also overlay a (regular) grid (the major axis ticks) by
assigning a length of one to them and overlay the coordinate system
over your plot again with
PLOT,X,Y,/NODATA,...options...,ticklen=1,/NOERASE
{you can then change the style of the lines etc., again:see manual for
details}

If you want to have the values printed on the plot, you can use the
XYOUTS statement, and I would recommend to first format the data into
strings
LABELS=string(Z,format='(f5.1)')
XYOUTS,XL,YL,LABELS,/DATA,align=0.5,...options
Note that the Z array is seen here as a 1-dimensional vector, and you
must supply XL and YL values for each element of this array (I'll leave
that as an excersize to figure out how to do this ;-)

If you "created" your regular grid from irregular gridded stuff, you
have probably used the TRI_GRID and/or TRIANGULATE routine. In this
case, there are options to these which will return the triangulation
points, and you can then overlay those with PLOTS like
triangulate,x,y,tr,b
for i=0,n_elements(tr)/3-1 do begin
t = [tr(*,i), tr(0,i)]
plots,xx(t),yy(t),color=2,thick=0.8
endfor

Etc.

{you can also get a copy of David Fanning's great book and "discover the
possibilities" of IDL ;-)}




Martin.


--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Fun with CDF_ENCODE_EPOCH
Next Topic: Anyone know how to read *.au sound files into IDL?

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

Current Time: Wed Oct 08 16:00:26 PDT 2025

Total time taken to generate the page: 0.00631 seconds