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

Home » Public Forums » archive » Re: Setting ranges on surfaces
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: Setting ranges on surfaces [message #12845] Fri, 18 September 1998 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Martin Schultz (mgs@io.harvard.edu) writes:

> Sounds like the solution is some kind of clip function like the quick
> hack attached below.

Not only that, it turns out to be the solution to Ken
Bowman's SEARCH question too!

Good work, Martin. Two birds with one stone. :-)

Cheers,

David

----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Setting ranges on surfaces [message #12848 is a reply to message #12845] Fri, 18 September 1998 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
David Fanning wrote:
>

> [...]
> It is
> not really the Z data we want to clip, it is the X and Y
> *locations* of the Z data. This implies (and, frankly, this
> is probably why the [XY]Range keywords don't work) that
> the Z data is tied to the X and Y range vectors. I'm guessing
> that in fact the Z data has nothing to do with those vectors,
> but exist independently of them. That is why changing the
> XRange definitely affects the X axis, but not the surface
> plot itself. In fact, IDL doesn't care what *values* you
> put in the X axis vector, only that it has as many elements
> as the X dimension of the Z data. The scaling of the axes
> and the Z data must exist totally independently of one
> another.
>
> Cheers,
>
> David
>

Sounds like the solution is some kind of clip function like the quick
hack attached below. Example

x=findgen(100)
y=findgen(50)
z=dist(100,50)
zc = sclip(z,x,y,xrange=[20,80],yrange=[20,40],xclip=xc,yclip=yc
surface,zc,xc,yc

Regards,
Martin.

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

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

e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------

;+
; SCLIP: clip a 2D Z array, and two matching 1D arrays for x
; and y.
;
; The function returns a 2D array that is truncated in x and y.
;
; XRANGE, YRANGE -> the range for x and y in data coordinates
; XCLIP, YCLIP -> return the truncated x and y arrays
;
; author: Martin Schultz, Harvard University (1998)
;
; EXAMPLE: x=findgen(100)
; y=findgen(50)
; z=dist(100,50)
; zc=sclip(z,x,y,xrange=[20,80],yrange=[20,40], $ ;
; xclip=xc,yclip=yc)
; surface,zc,xc,yc
;-
function sclip,z,x,y,xrange=xrange,yrange=yrange, $
xclip=xclip,yclip=yclip

; clip z,x, and y arrays for surface plot
; x and y must be monotone

if (n_elements(xrange) eq 0) then xrange=[min(x,max=xm),xm]
if (n_elements(yrange) eq 0) then yrange=[min(y,max=ym),ym]

; find minimum an dmaximum index in x and y
ix0 = min(where(x ge xrange[0])) ; <<
ix1 = max(where(x le xrange[1]))
iy0 = min(where(y ge yrange[0]))
iy1 = max(where(y le yrange[1])) ; <<
; NOTE: you can restrain these indices to valid values
; as :
; ix0 = min(...) > 0 ; ix0 always at least 0
; ix1 = max(...) < (n_elements(x)-1) ; prevent subscript range err

if (ix0<ix1<iy0<iy1 ge 0) then begin
xclip = x[ix0:ix1] ; clipped x array
yclip = y[iy0:iy1] ; clipped y array
return,z[ix0:ix1,iy0:iy1] ; clipped z array
endif else $
message,'Invalid range'

return,-1

end
Re: Setting ranges on surfaces [message #12861 is a reply to message #12845] Thu, 17 September 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Mirko Vukovic (mirko_vukovic@notes.mrc.sony.com) writes in
response to an article by Richard Hunt about restricting
the range of the surface display:

> The only way I could get around that feature is to do a surface plot of:
> (z>zmin)<zmax

Good answer, but to the wrong question I'm afraid. It is
not really the Z data we want to clip, it is the X and Y
*locations* of the Z data. This implies (and, frankly, this
is probably why the [XY]Range keywords don't work) that
the Z data is tied to the X and Y range vectors. I'm guessing
that in fact the Z data has nothing to do with those vectors,
but exist independently of them. That is why changing the
XRange definitely affects the X axis, but not the surface
plot itself. In fact, IDL doesn't care what *values* you
put in the X axis vector, only that it has as many elements
as the X dimension of the Z data. The scaling of the axes
and the Z data must exist totally independently of one
another.

Cheers,

David

----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Setting ranges on surfaces [message #12866 is a reply to message #12861] Thu, 17 September 1998 00:00 Go to previous message
mirko_vukovic is currently offline  mirko_vukovic
Messages: 50
Registered: January 1998
Member
In article <35FEECDD.357FAD5@sandia.gov>,
"Richard D. Hunt" <rdhunt@sandia.gov> wrote:
> I am having problems withthte surface command in that when I start
> setting ranges the surface
> extends past the axis region. It works fine for 2D plots. Try these
> examples.
>
> x = FindGen(100)
> y = FindGen(100)
> Plot, x, y
> Plot, x, y, XRange=[10,50]
>
> Both of these ploits are fine. Now try this.
>
> x = FindGen(100)
> y = FindGen(100)
> z = FindGen(100,100)
> Surface, z, x, y
> Surface, z, x, y, XRange=[10,50]
>
> You will see the first surface command plots the data within the axis
> region but the second
> doesn't. Does anyone know how to fix this without having to resample
> the data?
>
> Rich

The only way I could get around that feature is to do a surface plot of:
(z>zmin)<zmax

mirko

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
Re: Setting ranges on surfaces [message #12878 is a reply to message #12861] Wed, 16 September 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Alexander Proussevitch (alexp@plato.sr.unh.edu) writes:

> Hi Richard:
>
> The answer is
>
> Surface, z(10:50,*), x(10:50), y, XRange=[10,50]

Well, possibly if X = Indgen(60) or something like that,
but certainly not if X has real-world values in it. The
XRange keyword will throw everything off. Consider this
example:

data = Dist(60,60)
x = Indgen(60)*2
y = Indgen(60)
Surface, data(10:50,*), x(10:50), y, XRange=[10,50]

> PS If you need, I can write almost all kinds of programs (including
> interfaces and complex math) in this language for very little money

I charge as much as I can get away with, but I'm guessing
it might be worth it to you. :-)

Cheers,

David

----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Setting ranges on surfaces [message #12880 is a reply to message #12878] Wed, 16 September 1998 00:00 Go to previous message
Alexander Proussevitc is currently offline  Alexander Proussevitc
Messages: 3
Registered: September 1998
Junior Member
Hi Richard:

The answer is


Surface, z(10:50,*), x(10:50), y, XRange=[10,50]


- Alex P.

PS If you need, I can write almost all kinds of programs (including
interfaces and complex math) in this language for very little money

------------------------------------------------------------ ------
Alexander A. Proussevitch alex.proussevitch@unh.edu
Research Scientist

Climate Change Research Center, office (603)862-4796
Institute for the Study of fax (603)862-0188
Earth, Oceans, and Space,
University of New Hampshire,
Morse Hall, Room 357,
Durham, NH 03824-3525, USA
------------------------------------------------------------ ------


Richard D. Hunt wrote:
>
> I am having problems withthte surface command in that when I start
> setting ranges the surface
> extends past the axis region. It works fine for 2D plots. Try these
> examples.
>
> x = FindGen(100)
> y = FindGen(100)
> Plot, x, y
> Plot, x, y, XRange=[10,50]
>
> Both of these ploits are fine. Now try this.
>
> x = FindGen(100)
> y = FindGen(100)
> z = FindGen(100,100)
> Surface, z, x, y
> Surface, z, x, y, XRange=[10,50]
>
> You will see the first surface command plots the data within the axis
> region but the second
> doesn't. Does anyone know how to fix this without having to resample
> the data?
>
> Rich
>
> --
>
> Richard D. Hunt
> _/_/_/ _/ _/ _/ SANDIA NATIONAL LABORATORIES _/_/_/
> _/ _/_/ _/ _/ P.O. Box 5800 M/S 0965 _/_/
> _/_/_/ _/ _/ _/ _/ Albuquerque, NM 87185-0965 _/_/_/_/_/_/
> / _/ _/_/ _/ Voice: (505)844-3193 _/ _/_/ _/
> _/_/_/ _/ _/ _/_/_/_/ Fax: (505)844-5993 _/ _/_/ _/
> E-Mail: rdhunt@sandia.gov _/_/_/
Re: Setting ranges on surfaces [message #12883 is a reply to message #12878] Wed, 16 September 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Richard D. Hunt (rdhunt@sandia.gov) writes:

> I am having problems with the surface command in that when
> I start setting ranges the surface extends past the axis region.
> Does anyone know how to fix this without having to resample
> the data?

I don't think it *can* be fixed without resampling the data.
I presume it has to do with the way the surface algorithm
works with hidden line removal that is the problem, but I
am only guessing.

In any case, resampling the data is not hard. I would do
it something like this:

data = Dist(30,30)
x = Indgen(30)
y = Indgen(30)
Surface, data[10:20, 5:25], x[10:20], y[5:25]

Cheers,

David

----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
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: Re: object reference in a structure
Next Topic: Re: array subscripts

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

Current Time: Sun Oct 12 02:15:16 PDT 2025

Total time taken to generate the page: 0.80185 seconds