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

Home » Public Forums » archive » Comparing structures
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: Comparing structures [message #87671 is a reply to message #87670] Fri, 21 February 2014 14:13 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
cab581 writes:

> I have two structures that are made up of several fields. The last field (5) is the array which contains the measurement itself and the others contain information about the measurement (much like the star example on the Exelis website http://www.exelisvis.com/docs/Creating_and_Defining_St.html).
>
> The two structures that I have need to be compared, but I'll use the star example from Exelis to explain what I want to do. Say I have two structures, one contains the masses of the star and the other contains the volumes and I want to work out the density of each part of the star at altitude i (OK, the astronomy in the example is a bit off, but it works), but the list of stars is not the same (the measurements may have been incomplete), so the star id (given by
letters) fields may be
>
> strucA.(1) = [a, b, c, f, g, i, m, n, p, q, r, s, w, x, y, z]
> strucB.(1) = [b, d, e, f, h, i, j, l, m, q, r, s, t, v, w, x, y, z]
>
> I tried to use something like,
>
> for i=0,50
> match = where(strucA.(1) eq strucB.(1), count)
> if count le 0.0 then strucA[match].(5)[i] = !values.f_nan
> density[i]=strucA/strucB
> endfor
>
> What I'm trying to say is where I have a, b, c, etc in the first row, find the corresponding letter in the second row and do the calculation.
>
> However when I do this all it does is compare the nth letter in the first row to the nth letter in the second row, so the only results I'm getting in the example above are from f, q, r and s so I'm missing out on b, m, w, x, y, z.
>
> Any ideas would be greatly appreciated. If I haven't explained myself properly then I'd be glad to make it clearer.

It might take a week or so to sort out the problems with this code, but
here is a place to start. There is a famous Where function gotcha that
occurs when there are two arrays on either side of the EQ operator in
the Where function.

http://www.idlcoyote.com/misc_tips/noidea.html

In this case, the Where function seldom (if ever) does what you think it
is doing. I would walk though this code with a very fine sieve and see
if you can discover the places where your logic is leaking out.

Cheers,

David

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: Position, normal coordinates, and multiple images
Next Topic: IDL reading tiff files

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

Current Time: Fri Oct 10 00:39:38 PDT 2025

Total time taken to generate the page: 0.24078 seconds