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

Home » Public Forums » archive » subseting a 3D array based on values from a 2D array
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: subseting a 3D array based on values from a 2D array [message #87485 is a reply to message #87484] Fri, 07 February 2014 05:37 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
eva.ivits-wasser@ext.jrc.ec.europa.eu writes:

> I have a 2D array (A) with dimensions of [ns,nl] (where ns=number of columns and nl=number of lines) and a 3D array (B) with dimensions of [ns,nl,nb] (where nb=number of bands). A is a classification image whereas B is a time-series, both have the same number of samples and lines.
> I'd need to find a certain value in A, let's say 100 (which occurs several times) and then I want to subset those elements of B which "overlaps" with A, i.e. have the same position as A.
>
> I've tried the where function but that gives me the one dimensional subscript of A and I don't quite manage to index B based on this subscript...
>
> I've tried array_indices but did not get further with that either.
>
> Any suggestions please?

dims = Size(A, /Dimenisions)
indices = Where(A ...)
colrow = Array_Indices(dims, indices, /Dimensions)
cols = colrow[0,*]
rows = colrow[1,*]
valuesIwant = B[cols, rows, *]

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: matchdelim
Next Topic: IDL_IDLBridge, spawn, and sftp, oh my!

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

Current Time: Wed Oct 08 16:14:29 PDT 2025

Total time taken to generate the page: 0.00410 seconds