X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 07 Apr 2014 05:57 PM by  anon
Reading in file and performing calculations
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
07 Apr 2014 05:57 PM
    Hi, Forgive me, but I'm very very new to programming and was hoping for some guidance. Using this script: http://idlastro.gsfc.nasa...pro/astro/gcirc.pro, I can calculate the distances between two objects given the Right Ascension and Declination for star 1 and star 2. There are roughly 150 different stars I need to do this for, so I was hoping there is a way I can read in a file that contains the coordinates for all the stars and perform the distance calculation in a loop. The RA and Dec for star 1 will have a fixed value. It's the values for star 2 (around 150) that will change. Is this possible? Thank you in advance.

    Berangere Casson



    New Member


    Posts:61
    New Member


    --
    08 Apr 2014 09:51 AM
    You can definitively read data from a file using IDL. The way to read the data will depend on the file type (ASCII, binary,...) I added below a few links that point to routines to read data from files http://www.exelisvis.com/docs/READ_AS... http://www.exelisvis.com/docs/READ.html http://www.exelisvis.com/docs/READU.html

    Deleted User



    New Member


    Posts:
    New Member


    --
    08 Apr 2014 11:04 AM
    Hi Ryan, If your file contains two columns for RA and DEC with no header information, then you could do: ; Select a text file and open for reading file = '\filename.dat' OPENR, lun, file, /GET_LUN data = READ_ASCII(file, DATA_START=0) help, data ; Close the file and free the file unit FREE_LUN, lun end Since "data" is a structure, then"help, data" will show something like: FIELD1 FLOAT Array[2, 150] And to read a structure you can do the following, for example: Star 1 will have the RA and DEC given by: data.FIELD1[*,0] i.e. RA =data.FIELD1[0,0] DEC=data.FIELD1[1,0] Foe star 2 data.FIELD1[*,1]\ i.e. RA =data.FIELD1[0,1] DEC=data.FIELD1[1,1] and so on until star 150 data.FIELD1[*,150] I think that's correct. I hope that helps. Cheers, Fernando
    You are not authorized to post a reply.