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

Home » Public Forums » archive » Deleting specific instances of the structure
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
Deleting specific instances of the structure [message #87351] Mon, 27 January 2014 14:51 Go to next message
midhunjoyp is currently offline  midhunjoyp
Messages: 5
Registered: January 2014
Junior Member
Hi all,

I am having some difficulty working with structure arrays.

I initialized an array of 10 structures with the following fields.

domain = REPLICATE({frame :0, particles : fltarr(5,6000),link : [-1,-1]}, 10)

The calculations were performed for each field of the structure array. After calculations, there are some instances of the structure which are empty and needs to be deleted.

For eg, out of the 10 structure instances, domain[2], domain[6],domain[7] are the empty ones and needs to be deleted and the final result should have only 7 elements in the structure array.

Is there any way to perform delete operation(other than creating a new structure and assigning the selected ones to it) ?

Best,
Midhun
Re: Deleting specific instances of the structure [message #87352 is a reply to message #87351] Mon, 27 January 2014 14:59 Go to previous messageGo to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
Think "redefine variable" not "delete":

badInd = WHERE(domain.frame EQ 0, count, COMPLEMENT=goodInd)

IF count NE 0 THEN domain = domain[goodInd]

You could check for good values instead. I'm also assuming frame = 0 indicates an "empty" structure, i.e., good structures have a non-zero value for frame.
Re: Deleting specific instances of the structure [message #87353 is a reply to message #87351] Mon, 27 January 2014 15:01 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> For eg, out of the 10 structure instances, domain[2], domain[6],domain[7] are the empty ones and needs to be deleted and the final result should have only 7 elements in the structure array.

If you already know the structures you want to keep, you can just pick them out...

IDL> domain = REPLICATE({frame :0, particles : fltarr(5,6000),link : [-1,-1]}, 10)
IDL> iKeep = [0,1,3,4,5,8,9]
IDL> domain = domain[iKeep]
IDL> Help, domain
Re: Deleting specific instances of the structure [message #87360 is a reply to message #87351] Tue, 28 January 2014 06:48 Go to previous message
midhunjoyp is currently offline  midhunjoyp
Messages: 5
Registered: January 2014
Junior Member
On Monday, January 27, 2014 5:51:18 PM UTC-5, midhu...@gmail.com wrote:
> Hi all,
>
>
>
> I am having some difficulty working with structure arrays.
>
>
>
> I initialized an array of 10 structures with the following fields.
>
>
>
> domain = REPLICATE({frame :0, particles : fltarr(5,6000),link : [-1,-1]}, 10)
>
>
>
> The calculations were performed for each field of the structure array. After calculations, there are some instances of the structure which are empty and needs to be deleted.
>
>
>
> For eg, out of the 10 structure instances, domain[2], domain[6],domain[7] are the empty ones and needs to be deleted and the final result should have only 7 elements in the structure array.
>
>
>
> Is there any way to perform delete operation(other than creating a new structure and assigning the selected ones to it) ?
>
>
>
> Best,
>
> Midhun

Hi Phillip & Matthew,

That was a really good suggestion. Thanks a lot for the help.

Best,
Midhun
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: urgent-outliers removal
Next Topic: Instances of structure array with varying no. of elements

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

Current Time: Wed Oct 08 09:09:10 PDT 2025

Total time taken to generate the page: 0.00553 seconds