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

Home » Public Forums » archive » IDL code - problem to convert 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
IDL code - problem to convert string to float [message #86703] Thu, 28 November 2013 09:05 Go to next message
capercas is currently offline  capercas
Messages: 4
Registered: November 2013
Junior Member
Dear all,

The problem comes from the strrs (SearchString value) when is converted to float. It could be because it is an string-ARRAY because I did not find this problem with uki1 and uki2 (using STRMATCH).
For the last example I can not understand what is happening because there is not any conversion…but the warning say: Unable to convert given STRING to Long64

If you could help me……

PROBLEM 1
*******************part of the code************************************

if country eq 'UK' then begin
uki1 = 'UKI1'
uki2 = 'UKI2'
ara90_uki1 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki1))+3]))/10000
ara90_uki2 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki2))+3]))/10000
pc90_uki1 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki1))+4]))/10000
pc90_uki2 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki2))+4]))/10000
past90_uki1 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki1))+5]))/10000
past90_uki2 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki2))+5]) )/10000
endif

ara= float(dataclc90[WHERE(STRMATCH(dataclc90,strrs))+3])
araclc90=float(ara)/10000
pc= float(dataclc90[WHERE(STRMATCH(dataclc90,strrs))+4])
pcclc90=float(pc)/10000
past= float(dataclc90[WHERE(STRMATCH(dataclc90,strrs))+5])
pastclc90=float(past)/10000


****************************console************************* ************
IDL> help, uki1
UKI1 STRING = 'UKI1'
IDL> help, strrs
STRRS STRING = Array[1]



PROBLEM2
******************part of the code************************************
Detected at: CAPRI_1990TO2050_PRIMESCOR_ALLMINMAX 965 E:\perpcar\Documents\LUMP\CAPRI_DATA\SCRIPTS\capri_1990to205 0_primescor_allminmax.pro
% Type conversion error: Unable to convert given STRING to Long64.

printf,1,uki2
for y=0L, nyears+4 do begin
printf, 1, ['dummies','noData',$ //This is the line 965
'noData','noData','noData', $
'noData','noData','noData'],$
format='(i10,i15,i15,i15,i15,i15,i15,i15)'

Thank you very much for your time.
Regards,
Carolina
Re: IDL code - problem to convert string to float [message #86704 is a reply to message #86703] Thu, 28 November 2013 09:24 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
capercas@topo.upv.es writes:

> printf,1,uki2
> for y=0L, nyears+4 do begin
> printf, 1, ['dummies','noData',$ //This is the line 965
> 'noData','noData','noData', $
> 'noData','noData','noData'],$
> format='(i10,i15,i15,i15,i15,i15,i15,i15)'

These are *strings* you are trying to print (e.g., "dummies", "noData",
etc.), not integers as your FORMAT statement would indicate. IDL is
complaining because you are sending it mixed messages. :-)

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: IDL code - problem to convert string to float [message #86707 is a reply to message #86703] Fri, 29 November 2013 01:07 Go to previous messageGo to next message
capercas is currently offline  capercas
Messages: 4
Registered: November 2013
Junior Member
On Thursday, November 28, 2013 6:05:21 PM UTC+1, cape...@topo.upv.es wrote:
> Dear all,
>
>
>
> The problem comes from the strrs (SearchString value) when is converted to float. It could be because it is an string-ARRAY because I did not find this problem with uki1 and uki2 (using STRMATCH).
>
> For the last example I can not understand what is happening because there is not any conversion…but the warning say: Unable to convert given STRING to Long64
>
>
>
> If you could help me……
>
>
>
> PROBLEM 1
>
> *******************part of the code************************************
>
>
>
> if country eq 'UK' then begin
>
> uki1 = 'UKI1'
>
> uki2 = 'UKI2'
>
> ara90_uki1 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki1))+3]))/10000
>
> ara90_uki2 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki2))+3]))/10000
>
> pc90_uki1 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki1))+4]))/10000
>
> pc90_uki2 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki2))+4]))/10000
>
> past90_uki1 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki1))+5]))/10000
>
> past90_uki2 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki2))+5]) )/10000
>
> endif
>
>
>
> ara= float(dataclc90[WHERE(STRMATCH(dataclc90,strrs))+3])
>
> araclc90=float(ara)/10000
>
> pc= float(dataclc90[WHERE(STRMATCH(dataclc90,strrs))+4])
>
> pcclc90=float(pc)/10000
>
> past= float(dataclc90[WHERE(STRMATCH(dataclc90,strrs))+5])
>
> pastclc90=float(past)/10000
>
>
>
>
>
> ****************************console************************* ************
>
> IDL> help, uki1
>
> UKI1 STRING = 'UKI1'
>
> IDL> help, strrs
>
> STRRS STRING = Array[1]
>
>
>
>
>
>
>
> PROBLEM2
>
> ******************part of the code************************************
>
> Detected at: CAPRI_1990TO2050_PRIMESCOR_ALLMINMAX 965 E:\perpcar\Documents\LUMP\CAPRI_DATA\SCRIPTS\capri_1990to205 0_primescor_allminmax.pro
>
> % Type conversion error: Unable to convert given STRING to Long64.
>
>
>
> printf,1,uki2
>
> for y=0L, nyears+4 do begin
>
> printf, 1, ['dummies','noData',$ //This is the line 965
>
> 'noData','noData','noData', $
>
> 'noData','noData','noData'],$
>
> format='(i10,i15,i15,i15,i15,i15,i15,i15)'
>
>
>
> Thank you very much for your time.
>
> Regards,
>
> Carolina

Thank you very much for answering.
The code is not mine, and I do not know how to fix this problem.

Regards,
Carolina
Re: IDL code - problem to convert string to float [message #86710 is a reply to message #86707] Fri, 29 November 2013 05:49 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
capercas@topo.upv.es writes:

> The code is not mine, and I do not know how to fix this problem.

Well, you need to match the type of data you are printing with the
proper format code. The format code for strings is "A" not "I", which is
the format code for integers. Try looking up "format codes" in the IDL
on-line help.

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: IDL code - problem to convert string to float [message #86775 is a reply to message #86703] Mon, 02 December 2013 10:17 Go to previous message
capercas is currently offline  capercas
Messages: 4
Registered: November 2013
Junior Member
On Thursday, November 28, 2013 6:05:21 PM UTC+1, cape...@topo.upv.es wrote:
> Dear all,
>
>
>
> The problem comes from the strrs (SearchString value) when is converted to float. It could be because it is an string-ARRAY because I did not find this problem with uki1 and uki2 (using STRMATCH).
>
> For the last example I can not understand what is happening because there is not any conversion…but the warning say: Unable to convert given STRING to Long64
>
>
>
> If you could help me……
>
>
>
> PROBLEM 1
>
> *******************part of the code************************************
>
>
>
> if country eq 'UK' then begin
>
> uki1 = 'UKI1'
>
> uki2 = 'UKI2'
>
> ara90_uki1 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki1))+3]))/10000
>
> ara90_uki2 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki2))+3]))/10000
>
> pc90_uki1 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki1))+4]))/10000
>
> pc90_uki2 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki2))+4]))/10000
>
> past90_uki1 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki1))+5]))/10000
>
> past90_uki2 = (float(dataclc90[WHERE(STRMATCH(dataclc90,uki2))+5]) )/10000
>
> endif
>
>
>
> ara= float(dataclc90[WHERE(STRMATCH(dataclc90,strrs))+3])
>
> araclc90=float(ara)/10000
>
> pc= float(dataclc90[WHERE(STRMATCH(dataclc90,strrs))+4])
>
> pcclc90=float(pc)/10000
>
> past= float(dataclc90[WHERE(STRMATCH(dataclc90,strrs))+5])
>
> pastclc90=float(past)/10000
>
>
>
>
>
> ****************************console************************* ************
>
> IDL> help, uki1
>
> UKI1 STRING = 'UKI1'
>
> IDL> help, strrs
>
> STRRS STRING = Array[1]
>
>
>
>
>
>
>
> PROBLEM2
>
> ******************part of the code************************************
>
> Detected at: CAPRI_1990TO2050_PRIMESCOR_ALLMINMAX 965 E:\perpcar\Documents\LUMP\CAPRI_DATA\SCRIPTS\capri_1990to205 0_primescor_allminmax.pro
>
> % Type conversion error: Unable to convert given STRING to Long64.
>
>
>
> printf,1,uki2
>
> for y=0L, nyears+4 do begin
>
> printf, 1, ['dummies','noData',$ //This is the line 965
>
> 'noData','noData','noData', $
>
> 'noData','noData','noData'],$
>
> format='(i10,i15,i15,i15,i15,i15,i15,i15)'
>
>
>
> Thank you very much for your time.
>
> Regards,
>
> Carolina

Thank you very much David.
I will check in the IDL on-line help.

Best Regards,
Carolina
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: VERT_COLORS Problem
Next Topic: IDL environment "idlde" doesn't work

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

Current Time: Wed Oct 08 11:32:28 PDT 2025

Total time taken to generate the page: 0.00537 seconds