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

Home » Public Forums » archive » (Beginner) issue setting variables using ENVI_FILE_QUERY
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
(Beginner) issue setting variables using ENVI_FILE_QUERY [message #86286] Wed, 23 October 2013 03:05 Go to next message
Simon Mitchell is currently offline  Simon Mitchell
Messages: 6
Registered: October 2013
Junior Member
Hello All,

I am having an issue when using ENVI_FILE_QUERY to set a variable containing the number of samples and number of lines from an opened image. This is possibly a very simple mistake that I am making, but I cannot see where I am going wrong (I am new to IDL, but having to update old existing code).

My code loops through a directory and opens .TIF images, to perform processing on.

------------------------------------------------------------ -------------
PRO CALL_HOTSPOT

COMMON PARAM, ns, nl, ifname, ofname, w, yd1, iyd, ib, yy
COMMON NAMES, opendir
COMMON LOOP, count_str

;Scan the tif_output directory for all files
tifdir = opendir + 'Tif_Output\'
CD, tifdir

tif_files = FILE_SEARCH('*.tif', COUNT = numfiles)
counter = 0


WHILE (counter LT numfiles) DO BEGIN

count_str = STRTRIM(STRING(counter), 2)

ifname = tif_files(counter)
OPENR, lun_tif, ifname, /GET_LUN

;determine the number of samples and lines

ENVI_FILE_QUERY, lun_tif, NS=ns, NL=nl

print, ns

; Call the TET algorithm
TET_HOTSPOT_IDL_MAIN_SIMULATION_SM


CLOSE, lun_tif
FREE_LUN, lun_tif

counter = counter + 1

ENDWHILE

END
------------------------------------------------------------ -------------

The error that I am getting is:
% PRINT: Variable is undefined: NS (PARAM).

Would anyone be able to help me with this?

Thanks in advance

Simon
Re: (Beginner) issue setting variables using ENVI_FILE_QUERY [message #86288 is a reply to message #86286] Wed, 23 October 2013 06:28 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Simon Mitchell writes:

> I am having an issue when using ENVI_FILE_QUERY to set a variable
containing the number of samples and number of lines from an opened
image. This is possibly a very simple mistake that I am making, but I
cannot see where I am going wrong (I am new to IDL, but having to update
old existing code).

> ;determine the number of samples and lines
>
> ENVI_FILE_QUERY, lun_tif, NS=ns, NL=nl
>
> The error that I am getting is:
> % PRINT: Variable is undefined: NS (PARAM).
>
> Would anyone be able to help me with this?

Instead of using ENVI_FILE_QUERY here, you want to use QUERY_TIFF:

void = Query_Tiff(ifname, fileInfo)
dims = fileInfo.dimensions
ns = dims[0]
nl = dims[1]

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: (Beginner) issue setting variables using ENVI_FILE_QUERY [message #86289 is a reply to message #86288] Wed, 23 October 2013 07:21 Go to previous messageGo to next message
Simon Mitchell is currently offline  Simon Mitchell
Messages: 6
Registered: October 2013
Junior Member
On Wednesday, 23 October 2013 15:28:45 UTC+2, David Fanning wrote:
> Simon Mitchell writes:
>
>
>
>> I am having an issue when using ENVI_FILE_QUERY to set a variable
>
> containing the number of samples and number of lines from an opened
>
> image. This is possibly a very simple mistake that I am making, but I
>
> cannot see where I am going wrong (I am new to IDL, but having to update
>
> old existing code).
>
>
>
>> ;determine the number of samples and lines
>
>>
>
>> ENVI_FILE_QUERY, lun_tif, NS=ns, NL=nl
>
>>
>
>> The error that I am getting is:
>
>> % PRINT: Variable is undefined: NS (PARAM).
>
>>
>
>> Would anyone be able to help me with this?
>
>
>
> Instead of using ENVI_FILE_QUERY here, you want to use QUERY_TIFF:
>
>
>
> void = Query_Tiff(ifname, fileInfo)
>
> dims = fileInfo.dimensions
>
> ns = dims[0]
>
> nl = dims[1]
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Hello David,

Thank you for your help.
I used your example code, but I get another error.

% Expression must be a structure in this context: FILEINFO.
With the "dims = fileInfo.dimensions" highlighted.

Would you please be able to tell me what this means?

Regards

Simon
Re: (Beginner) issue setting variables using ENVI_FILE_QUERY [message #86290 is a reply to message #86289] Wed, 23 October 2013 07:42 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Simon Mitchell writes:

> Thank you for your help.
> I used your example code, but I get another error.
>
> % Expression must be a structure in this context: FILEINFO.
> With the "dims = fileInfo.dimensions" highlighted.
>
> Would you please be able to tell me what this means?

It probably means that this isn't a TIFF file that you are trying to
read. Who knows why? Try this code:

isTiff = Query_Tiff(ifname, fileInfo)
IF isTiff THEN BEGIN
dims = fileInfo.dimensions
ns = dims[0]
nl = dims[1]
ENDIF ELSE BEGIN
Print, 'Problem file: ', ifname
Continue
ENDELSE

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: (Beginner) issue setting variables using ENVI_FILE_QUERY [message #86312 is a reply to message #86286] Fri, 25 October 2013 05:04 Go to previous message
Josh Sixsmith is currently offline  Josh Sixsmith
Messages: 13
Registered: December 2012
Junior Member
Seeing as you are still trying to use ENVI_FILE_QUERY, i suggest you ditch the call to openr, which is meant for access to a file on disk. ENVI_FILE_QUERY uses an fid to track files, and this is what you need to pass to ENVI_FILE_QUERY, not the file allocation unit.

If you want ENVI to open the file and then you can pass around the fid to all sorts of ENVI_DO_IT routines, then use ENVI_OPEN_DATA_FILE with the /TIFF keyword set for ENVI to automatically open the TIFF file. ENVI will internally keep track of the fid and you just pass around the fid to all sorts of ENVI related functions and procedures.

Cheers
Josh
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: xtickformat type conversion
Next Topic: Using POLYGON to plot unstructred mesh

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

Current Time: Wed Oct 08 14:00:14 PDT 2025

Total time taken to generate the page: 0.00512 seconds