X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 08 Jul 2012 01:50 PM by  anon
transfering variables between procedures
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
08 Jul 2012 01:50 PM
    HI all This is my problem. I have two IDL procedures hr2altaz, hour, dec, alt, az -- which takes the HA and DEC and converts it to ALT and AZ altaz2hr, hour, dec, alt, az -- which takes ALT and AZ, and converts it to HA and DEC. What I need to do, is to begin with a certain HA and DEC, execute hr2altaz, which will give me the ALT and AZ, and then take those two outputs to execute altaz2hr, which will convert them back to HA and DEC, and then repeat the process many times (say 100 times). The purpose being to compare the initial HA, DEC to the final (after 100 reps) HA, DEC. in order to see any changes in precision. I have no idea how to do this. I think I might need some loops, but I dont know how to tranfer the output of the first procedure to be the input of the other, and back. Thank you for your help

    Deleted User



    New Member


    Posts:
    New Member


    --
    09 Jul 2012 04:30 PM
    Hi the source007, Just a thought... you could create an array to hold the outputs of the first procedure and that would then be the input for the second procedure. Consider this pseudo-code: ;Create some data to store in a file: data=findgen(2,100) ;Open a new file for writing as IDL file unit number 1: openw, 1, 'newfile' ;Write the data from 'data' to the file: writeu, 1, data ;print the first 10 lines to check print, data[*,0:10] ;Close file unit 1: close, 1 Hope this provides some ideas.

    Deleted User



    New Member


    Posts:
    New Member


    --
    19 Jul 2012 01:56 PM
    IDL passes values by reference so the values will automatically be updated if the variables exist outside of the procedure. Create another procedure to call hr2altaz and altaz2hr such as the one below. pro runner numDataPoints = ;read in hour and dec values, something like: HA = readFromFile() DEC = readFromFile() ;you'll have to implement readFromFile yourself, ; but thats another topic ;if you need to create new or empty arrays to hold all the ; values try this ALT= make_array(numDataPoints); AZ = make_array(numDataPoints); ;also if you want to hardcode the values you can do: ; HA=[1,2,3,4] for i = 0, numDataPoints-1 do begin hr2altaz, HA[i], DEC[i], ALT[i], AZ[i] ;values are passed out by reference altaz2hr, HA[i], DEC[i], ALT[i], AZ[i] ;values are passed out by reference endfor end I hope this helps.
    You are not authorized to post a reply.