comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Error when calling ENVI_WRITE_ENVI_FILE
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Error when calling ENVI_WRITE_ENVI_FILE [message #86313] Fri, 25 October 2013 08:35 Go to previous message
Simon Mitchell is currently offline  Simon Mitchell
Messages: 6
Registered: October 2013
Junior Member
Hi All,

I am getting an error when using the ENVI_WRITE_ENVI_FILE command. Note that I am a beginner with using IDL.

The error that I am getting is:
ERROR: "FLOAT: Struct expression not allowed in this context: DATA." The result may be invalid.

I have to add, that this error does not stop my code from creating a file, but the values are not what I am expecting.

A little background on what I am trying to do.
I want to be able to replicate in IDL (for batch script) opening multiple ASCII files (each representing a band of image data) and then saving them as an ENVI Standard file with multiple bands.
So essentially doing the "File->Open External File->Generic Formats->ASCII" for three files, then "Save File As->ENVI Standard" as one file with three bands in BSQ format.

My code is as follows, and I am just using a dummy test image of 11 samples and lines as my input, with 6 header lines.

PRO COMBINE_ASCII

opendir = 'D:\Directory'

redfile = opendir+'red_output_short.txt'
mirfile = opendir+'mir_template_short.txt'
tirfile = opendir+'tir_template_short.txt'
ofname = opendir+'random_image_1'
descrip = 'Random point image #1'
ns = 11
nl = 11
nc = 3*nl

rnd_data = FLTARR([ns], [nc]) ;float array of ns = 11, nl = 11 for 3 bands
;rnd_data = FLTARR([ns],[nl],3)

;Open the files

OPENR, lun_red, redfile, /GET_LUN
red_data = READ_ASCII(redfile, DATA_START = 6, DELIMITER = string(9B))

rnd_data = [red_data]

OPENR, lun_mir, mirfile, /GET_LUN
mir_data = READ_ASCII(mirfile, DATA_START = 6, DELIMITER = string(9B))

rnd_data = [[rnd_data], [mir_data]]

OPENR, lun_tir, tirfile, /GET_LUN
tir_data = READ_ASCII(tirfile, DATA_START = 6, DELIMITER = string(9B))

rnd_data = [[rnd_data], [tir_data]]

;rnd_data = [[red_data],[mir_data],[tir_data]]

;OPENW, lun_out, ofname, /GET_LUN

print, rnd_data

;reddata = READ_ASCII(redfile, DATA_START = 6)
;mirdata = READ_ASCII(mirfile, DATA_START = 6)
;tirdata = READ_ASCII(tirfile, DATA_START = 6)


ENVI_WRITE_ENVI_FILE, rnd_data, FILE_TYPE = 4, INTERLEAVE = 0, NB = 3, NS = ns, NL = nl, OUT_DT = 4, OUT_NAME = ofname

; FILE_TYPE = 4

ENVI_SETUP_HEAD, FNAME = ofname, NS = ns, NL = nl, NB = 3, $
XSTART = 0, YSTART = 0, DATA_TYPE = 1, INTERLEAVE = 0, $
file_type = 4, $
DESCRIP = descrip, /WRITE, /OPEN

CLOSE, /ALL

END

I am wondering if any one can tell me where I am going wrong, or could suggest a better way of doing this!!! As you can probably guess, I am not the best idl coder and have only been using it for a short time, but I think I may be doing something wrong with the array concatenation.

Many thanks in advance for your help.

Simon
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Airy function implementation?
Next Topic: New Coyote Store Up and Running

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:36:51 PDT 2025

Total time taken to generate the page: 0.00434 seconds