X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 01 May 2011 04:05 PM by  anon
reverse routine not working on a large array
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
01 May 2011 04:05 PM
    Hello I am trying to use the reverse() routine to change the order of a one column, 350 row float array. As demonstrated in this dummy example, the array is not reversed: IDL Version 8.0, Microsoft Windows (Win32 x86_64 m64). (c) 2010, ITT Visual Information Solutions IDL> a = fltarr(1, 5) IDL> for i = 0, n_elements(a)-1 do a[i] = i IDL> print, a 0.000000 1.00000 2.00000 3.00000 4.00000 IDL> b = reverse(a) IDL> print, b 0.000000 1.00000 2.00000 3.00000 4.00000 Could this be a problem with how my array is built? Here is the section of the larger code: openr, 101, 'C:\...\LayerProps.txt' Props = dblarr(9,351) readf, 101, Props Lyr = Props[0,*] delz = Props[1,*] ztop = Props[2,*] Tbar = Props[3,*] Pbar = Props[4,*] rho_air = Props[5,*] rho_wv = Props[6,*] M_air = Props[7,*] M_wv = Props[8,*] ; we want top down for now, so reverse the necessary arrays M_air_dn = reverse(M_air) M_wv_dn = reverse(M_wv) absair_dn = reverse(absair) abswv_dn = reverse(abswv) delz_dn = reverse(delz) When inquiring at the command line, this is a representative example of what these arrays look like. IDL> help, M_air M_AIR DOUBLE = Array[1, 351] IDL> help, M_air_dn M_AIR_DN DOUBLE = Array[1, 351] The results for any *_dn array is as in the first dummy example, the elements are not reversed. I have read the REVERSE help page, and have tried reverse(array, subscript_index), for subscript_index = 0 or 1 (1 causes an error), but get the same result. Any wisdom?

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    02 May 2011 02:57 PM
    Your variable 'a' is a 2-d array: IDL> help, a A FLOAT = Array[1, 5] So, you need to specify the second dimension index when using reverse: IDL> b=reverse(a,2) IDL> print, b 4.00000 3.00000 2.00000 1.00000 0.000000
    You are not authorized to post a reply.