X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 20 Feb 2008 09:39 AM by  anon
Problems with structures
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
20 Feb 2008 09:39 AM
    Dear All, I'm currently trying to read in a .fits file into IDL (this is being done using a routine called MRDFITS which reads the .fits file into an IDL structure). So far I have been able to obtain information about how many columns and rows are within the structure (n_tags and n_elements) and then used this to simply create a double precision array of the same size. I now want to transfer the data from the structure into the array. For instance the first line of the structure looks like this { 2.3584720 0.10909307 18.3799 0.0305981 17.8795 0.0221304 17.1292 0.0457738 17.0786 0.0517783 0 0 0 0 -1 -1 -1 -1 0.373497 -1.24193 0.808172 -0.701736} should I want the first element I would use the following data(0,0)=structure(0).ra where ra was the tag name. My question is, Is there anyway to replace the tag name .ra with that from the tag_names function so I can simply set up a loop to do all the reading for me, without me having to know the number of columns beforehand thus eliminating the need to define the .ra, .dec extensions. Sorry if this is a bit unclear. Many Thanks David

    Deleted User



    New Member


    Posts:
    New Member


    --
    20 Feb 2008 09:39 AM
    Structure fields can take indexes. It is simply important that they be referenced with parentheses only (***not*** square brackets). Thus, the following is a valid set of nested loops querying each field of each structure in an array of structures: nStructureFields = n_tags(mystructs[0]) for i = 0, n_elements(mystructs)-1 do begin for k = 0, nStructureFields-1 do begin currentFieldData = mystructs[i].(k) help, currentFieldData endfor endfor James Jones
    You are not authorized to post a reply.