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

Home » Public Forums » archive » Type conversion error: Unable to convert given STRING to Float.
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
Type conversion error: Unable to convert given STRING to Float. [message #76763] Tue, 05 July 2011 07:36 Go to next message
Zac is currently offline  Zac
Messages: 3
Registered: July 2011
Junior Member
Hi,

Can anyone tell me why IDL thinks that the variable in the for loop
below is a string?

Here's the offending part of the script. After I've opened the input
file, I'm trying to loop over the one of the dimensions in the file
(in this case the vertical layers of a file that contains gridded, 3-d
aircraft emissions). I want to plot the emissions at each layer. I
can hard code the layer number in the script and it works fine. When
I try to implement the for loop, IDL is complaining that "lay" is a
string.

In addition, I tried to take the for loop out altogether and just add
in a variable for the layer number, something like:

lay = 2

This gives the same type conversion error

What am I doing wrong here?

Thanks in advance, Zac
...

ni=n_elements(lon)
nj=n_elements(lat)
nz=n_elements(lev)

for lay=0,nz-1 do begin
air_pl=air[*,*,lay]

myct, 1, range=[0.4,1], /reverse

!P.font(0)=0

minvar=0
maxvar=1E9

layr=lay+1

Open_Device, /ps, /Color, filename=''+outdir+'/emissions_'+sim
+'_air_level_'+layr+'_'+pol+'.ps'
tvmap, air_pl, lon, lat, BLACK=1, NColors=225, Bottom = 20, /coasts, $
Title='Layer '+layr+' Aircraft '+pol+' Emissions - '+simtitle,$
/Continents,/Cylindrical,/SAMPLE,/isotropic, $
/CBAR, Divisions=3, min_valid=minvar, $
mindata=minvar, maxdata=maxvar, $
CBFORMAT='(e12.2)', CBMAX=maxvar, CBMIN=minvar,CBUNIT='molec/cm2-
sec',$
/landscape, /grid, /countries, xthick=4,$
ythick=4, thick=1.2, charthick=2, charsize=1, csfac=0.7,
tcsfac=0.
close_device

endfor ; layer loop

endfor ; pollutant loop
Re: Type conversion error: Unable to convert given STRING to Float. [message #76855 is a reply to message #76763] Tue, 05 July 2011 14:27 Go to previous message
Brian Wolven is currently offline  Brian Wolven
Messages: 94
Registered: May 2011
Member
filename=''+outdir+'/emissions_'+sim+'_air_level_'+string(la yr)+'_'+pol+'.ps'

You can also supply a format specification to the STRING function; see the help file (?string) for details.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: step function
Next Topic: Re: Type conversion error: Unable to convert given STRING to Float.

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

Current Time: Wed Oct 08 15:26:24 PDT 2025

Total time taken to generate the page: 0.00679 seconds