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

Home » Public Forums » archive » Re: Type conversion error: Unable to convert given STRING to Float.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Type conversion error: Unable to convert given STRING to Float. [message #76762 is a reply to message #76759] Tue, 05 July 2011 08:55 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 7/5/11 8:36 AM, Zac wrote:
> Can anyone tell me why IDL thinks that the variable in the for loop
> below is a string?

See below, but I think it is the opposite, you have an integer and are
treating it like 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'

You are doing string operations above, but layr is an int.

> 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
>

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Type conversion error: Unable to convert given STRING to Float.
Next Topic: North American Regional Reanalysis (NARR) projection

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

Current Time: Fri Oct 10 00:53:46 PDT 2025

Total time taken to generate the page: 0.47902 seconds