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

Home » Public Forums » archive » Re: Slicing a volume
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: Slicing a volume [message #36902 is a reply to message #36901] Tue, 04 November 2003 09:17 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Nuno Oliveira writes:

> Since I began to work with IDL one of the things that makes confuse is when
> I want to make a two-dimension array from a three-dimension array (and I
> often do).
>
> For example I can create de three-dimension array vol
>
> vol=INTARR(100,100,100)
>
> But when I try to extract slices along different axes I get "different"
> variables.
>
> sliceX=vol(50,*,*)
> sliceY=vol(*,50,*)
> sliceZ=vol(*,*,50)
>
> Then, I see that sliceX is an array [1,100,100], and the same with sliceY
> but, sliceZ is an array [100,100]. sliceX and sliceY are what I am tempted
> to call a false 3D array because one of the dimensions can have only one
> value. My question is why they are not equal: all 2D arrays or all 3D
> arrays?

Oh, dear. These new guys always like to pick at
the old wounds, don't they? :-)

This is an old (and dear) "feature" of IDL, in which
the last dimension of a multi-dimensional array is dropped
if that dimension is 1. This is not the only kind of havoc
it can cause, as you will learn when you study the archives
of this newsgroup.

Typically, what is wanted is a 2D array after extraction.
You can get this by, for example, doing this:

IDL> vol = randomu(seed, 50, 50, 50)
IDL> sliceX = Reform(vol[25,*,*])
IDL> help, sliceX
SLICEX FLOAT = Array[50, 50]

> I know this not very important, just bores me that I need to make a specific
> code for the Z direction. I can use the function EXTRACT_SLICE, but it
> really makes me sad that it doesn't work the easy way. Anyone knows why? Am
> I making any mistake? Anyone had some time the same problem? Is the
> EXTRACT_SLICE the only solution?

I think EXTRACT_SLICE is for extracting a slice of a volume
at some arbitrary angles. Orthogonal slices are always (as
far as I know) extracted by array subscripting in the way
you are doing it.

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to solve a homogeneous system(Ax=0) with a gauss elimination method that x is not zero.
Next Topic: Automatic Updates to Coyote's Guide

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

Current Time: Sun Oct 12 04:24:50 PDT 2025

Total time taken to generate the page: 0.95657 seconds