PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 27 Oct 2017 08:43 AM by  David Starbuck
Outputting data to two columns
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Paul Manley



New Member


Posts:6
New Member


--
20 Oct 2017 11:39 AM
    I'm having trouble formatting my wavelength and spectral data to two columns in a text file. This code applies a thresholded region of interest to plant images and gets the average spectra. I can output the data into a single column just fine. I can output to two columns but it goes through all the wavelengths first and then the data points. I've been trying different ways and am still stuck. Thanks.

    Marcos Montes



    New Member


    Posts:30
    New Member


    --
    25 Oct 2017 07:50 AM
    I don't see any code here.

    However, if your vector of wavelengths is wl=fltarr(N), where N is number of wavelengths, and spectrum=fltarr(N), so both have the same dimensions, In that case, you can print to the screen like:
    for i=0,n-1 do print,wl,spec
    which will print in two columns, separated by white space.

    David Starbuck



    Basic Member


    Posts:133
    Basic Member


    --
    27 Oct 2017 08:43 AM
    I that the easiest way to do this is to use PRINTF using C formatting to put the output into columns. An example is shown below:

    pro dj_forum_20102017
    compile_opt idl2

    a = findgen(10)
    b = findgen(10)

    a = transpose(a)
    b = transpose(b)

    ;print output to console
    print,a,b,FORMAT="%f %f"

    ;print output to file
    openw,lun, "output.txt", /GET_LUN
    printf, lun, a,b,FORMAT="%f %f"
    FREE_LUN, lun

    end


    David Starbuck
    -Harris
    You are not authorized to post a reply.


    MOST RECENT

    Extract Actionable Information with Advanced ENVI Image Analytics on GBDX | Live Webinar

    3/13/2018

    Live Webinar hosted by DigitalGlobe | April 5 ENVI analytics are available directly within... more »

    ENVI Crop Science | DEMO

    3/13/2018

    Watch this video for a demonstration of ENVI Crop Science and learn about the features available in the... more »

    SIGN UP & STAY INFORMED

    Sign up to receive the latest news, events, technologies and special offers.

    SIGN ME UP