X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 30 Jul 2012 12:13 PM by  anon
Amateur IDL-ENVI problem with Band Math
 4 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
30 Jul 2012 12:13 PM
    Hi, I am amateur in IDL and ENVI I have a problem. I am working with 2 arrays of 1440 x 720 and I made a little function in IDL to run in ENVI and despite that I could compiled it without any problem in IDL and ENVI, when I tried to run in Band math, IDL console tell me that “Expression must be a scalar or 1 element array in this context: .” It is the function: FUNCTION dir_viento, b1, b2, dbl=dbl Wx = b1 Wy = b2 Grad = DOUBLE (180) /!DPI Rad = !DPI /DOUBLE (180) CASE 1 OF (Wx EQ 0) AND (Wy EQ 0): dir = 'ND' (Wx EQ 0) AND (Wy GT 0): dir = DOUBLE (360) (Wx GT 0) AND (Wy GT 0) And (Wx NE Wy): dir = DOUBLE (90) - Grad * (ATAN(Wy /Wx)) (Wx GT 0) And (Wy GT 0) And (Wx EQ Wy): dir = DOUBLE (45) (Wx GT 0) And (Wy EQ 0): dir = DOUBLE (90) (Wx GT 0) And (Wy LT 0) And (ABS (Wx) EQ ABS (Wy)): dir = DOUBLE (135) (Wx GT 0) And (Wy LT 0) And (ABS (Wx) NE ABS (Wy)): dir = DOUBLE (90) + ABS(Grad * (ATAN(Wy /Wx))) (Wx EQ 0) And (Wy LT 0): dir = DOUBLE (180) (Wx LT 0) And (Wy LT 0) And (ABS(Wx) EQ ABS (wy)): dir = DOUBLE (225) (Wx LT 0) And (Wy LT 0) And (ABS(Wx) NE ABS (wy)): dir = DOUBLE (180) + ABS((Grad * (Atan (wx/ABS(wy))))) (Wx LT 0) And (Wy EQ 0): dir = DOUBLE (270) (Wx LT 0) And (Wy GT 0) And (ABS(Wx) NE ABS (wy)): dir = DOUBLE (360) - ABS((Grad * (Atan (wx/ABS(wy))))) (Wx LT 0) And (Wy GT 0) And (ABS(Wx) EQ ABS (wy)): BEGIN dir = DOUBLE (315) END ENDCASE RETURN, Dir END Please, please someone can help me?

    Deleted User



    New Member


    Posts:
    New Member


    --
    30 Jul 2012 04:32 PM
    If Wx and Wy each contain more that the one value you'd like to test, you may have to write a for loop to go through the values individually. The variables above seem to contain multiple value arrays which can't be compared to scalars. Best, Crystal Exelis VIS

    Deleted User



    New Member


    Posts:
    New Member


    --
    30 Jul 2012 06:11 PM
    Crystal I knowledge your help and apologize because I do not speak English very well. I am working with data wind of the Earth surface. Every vector wind is compost for two components (X and Y). I have two arrays (1440 x 720 subarrays) that contain every one component (array Wx and array Wy) of the 1036800 vectors that represent wind in different point of Earth surface in a moment. I understand that IDL works with arrays, and for this reason I do not think I might write a loop, because I run function every “moment of wind record”, every one with 2 arrays. Tanks very much Crystal Jorge Tanks very much Crystal Jorge

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    31 Jul 2012 07:57 AM
    It looks like you are trying to create a new array where there are new values assigned based on your two wind vector arrays. You can assign new values to a new array, but you will need to use the WHERE function to find the indices of the pixel values to be replace. This help article does something similar with a classification image - you can see you will need to first generate a new array and then find the array indicies for each newly assigned value and then assign those values. http://www.exelisvis.com/.../ArticleId/4182.aspx

    Deleted User



    New Member


    Posts:
    New Member


    --
    31 Jul 2012 10:20 AM
    Yes I think it could work. Tanks a lot I am going to try to do it and after I send you my result. Jorge
    You are not authorized to post a reply.