X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 05 Jun 2012 05:06 PM by  anon
HELP with outputting array
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
05 Jun 2012 05:06 PM
    I'm very confused about file output in IDL. I have an array , 4096 rows, 2 columns. I need to output this to a file that is of seemingly normal format where each line is " number-delimiter-number " 3.45103 1.21235 3.45103 1.21235 3.45103 1.21235 3.45103 1.21235 3.45103 1.21235 ...... My current output line is printf, 3, out where out is the 2x4096 array and 3 is the lun. Unfortunately, the file it creates instead looks like the following 3.1082969 12.6824770 3.1105733 12.3875389 3.1128500 12.3739986 3.1151261 12.4075155 3.1174023 12.4616051 ... With a random number of spaces in front of the first column and one between the two. Regretfully, this prevents other programs from working with my data outputs. It seems absolutely daft that a program would precede its data output with spaces. I've played with the 'format' code, but it hasn't been any help. I'm a former matlab user and new to IDL.

    Deleted User



    New Member


    Posts:
    New Member


    --
    06 Jun 2012 02:08 AM
    You need to 'play' with format codes a bit .... For example try this: FORMAT='(F,";",F)' This will print two floats delimited by semicolon ... rinse and repeat until the end of array ;) . In the example, the default with and decimal places for floats are used (15 and 7) so it is actually F15.7 and you can play with different setting to achieve exactly what you need.

    Deleted User



    New Member


    Posts:
    New Member


    --
    06 Jun 2012 09:27 AM
    Ok, so I ran that with the following, though instead of looping I opted to just output it as two vectors. printf, 3, format='(F,";",F)', vector1 ,vector2 Regardless, it does the same thing: prints several zeros, then the first number, then several zeros then the second number. It is almost like it thinks that things should be aligned on the right... Is it just me or does it seem absurd to have this as the default output setting. One would think that default output would be something left aligned with a single delimited between values.

    Deleted User



    New Member


    Posts:
    New Member


    --
    06 Jun 2012 10:05 AM
    I did figure it out... you need to write the format as "F-10" in order to get IDL to align left....
    You are not authorized to post a reply.