• READ ARRAY and extract the values

    From Tanvir Hussain@21:1/5 to All on Fri Apr 29 14:18:31 2016
    Hi All

    I have a data which is organized in the following way

    obj1 12.5
    obj1 14.5
    obj1 15.4
    obj1 14.0
    obj1 12.5
    obj1 14.5
    obj1 15.4
    obj1 14.0
    obj1 12.5
    obj1 14.5
    obj1 15.4
    obj1 14.0
    obj2 12.5
    obj2 14.5
    obj2 15.4
    obj2 14.0
    obj2 12.5
    obj2 14.5
    obj2 15.4
    obj2 14.0
    obj2 12.5
    obj2 14.5
    obj2 15.4
    obj2 14.0

    I want to extract all the values associated with obj1 and write them in a separate array. In the similar way for the obj2. Please help.

    Thanks
    Tanvir

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nelson.kevin09@gmail.com@21:1/5 to Tanvir Hussain on Wed Nov 1 07:33:26 2017
    On Friday, April 29, 2016 at 4:18:31 PM UTC-5, Tanvir Hussain wrote:
    Hi All

    I have a data which is organized in the following way

    obj1 12.5
    obj1 14.5
    obj1 15.4
    obj1 14.0
    obj1 12.5
    obj1 14.5
    obj1 15.4
    obj1 14.0
    obj1 12.5
    obj1 14.5
    obj1 15.4
    obj1 14.0
    obj2 12.5
    obj2 14.5
    obj2 15.4
    obj2 14.0
    obj2 12.5
    obj2 14.5
    obj2 15.4
    obj2 14.0
    obj2 12.5
    obj2 14.5
    obj2 15.4
    obj2 14.0

    I want to extract all the values associated with obj1 and write them in a separate array. In the similar way for the obj2. Please help.

    Thanks
    Tanvir

    Hi Tanvir,

    The IDL WHERE function is helpful here. Assuming the name of your full [24,2] array is "vals":

    ii = WHERE(vals[*,0] EQ 'obj1', cnt_obj1)
    jj = WHERE(vals[*,0] EQ 'obj2', cnt_obj2)

    IF cnt_obj1 GT 0 THEN obj1_vals = vals[ii]
    IF cnt_obj2 GT 0 THEN obj2_vals = vals[jj]

    Something along those lines should do the trick. See the IDL WHERE documentation with other questions: http://www.harrisgeospatial.com/docs/where.html

    Kevin Nelson
    PhD Student, CMSS/Meteorology - TAMUCC
    MS Atmospheric Science - University of Kansas
    BS Meteorology - Florida Institute of Technology

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)