X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 10 Mar 2010 05:03 PM by  anon
Use WHERE on Structure ?
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
10 Mar 2010 05:03 PM
    Hi All, I have a quick question... Is it possible to use WHERE on STRUCTURE? For example, I have a structure Profile (temperature:0.0, pressure:0:0) How can I get all the temperature where pressure between 100 and 500 in the structure? I did it by using FOR but it takes long time for a large files i.e. few millions profiles... Regards,

    Deleted User



    New Member


    Posts:
    New Member


    --
    15 Mar 2010 11:22 AM
    Absolutely. take for example something like this: An example structure: IDL> x = replicate({temperature:0.0, pressure:0.0}, 10) IDL> x.pressure = findgen(10)*100 IDL> help, x X STRUCT = -> Array[10] IDL> print, x { 0.000000 0.000000}{ 0.000000 100.000}{ 0.000000 200.000}{ 0.000000 300.000}{ 0.000000 400.000}{ 0.000000 500.000}{ 0.000000 600.000}{ 0.000000 700.000}{ 0.000000 800.000}{ 0.000000 900.000} Now look for the values you want and make a new structure array with only those values: IDL> w = where( (x.pressure ge 100) and (x.pressure le 500) ) IDL> newx = x[w] IDL> help, newx NEWX STRUCT = -> Array[5] IDL> print, newx { 0.000000 100.000}{ 0.000000 200.000}{ 0.000000 300.000}{ 0.000000 400.000}{ 0.000000 500.000} This will allow you to do what you want without the use of FOR loops, which will greatly speed up your code. The where statement can have as many conditional statements as you want inside, using standard bitwise operators such as AND, OR, XOR, NOT, etc. -Josh ITT-VIS Tech Support
    You are not authorized to post a reply.