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

Home » Public Forums » archive » Re: [Q] Reading from ASCII file?
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
Re: [Q] Reading from ASCII file? [message #12253] Fri, 24 July 1998 00:00
mgs is currently offline  mgs
Messages: 144
Registered: March 1995
Senior Member
In article <35B6E8E9.75FCB5A3@ramses.tss.no>, gunnarlr@phys.uit.no wrote:

> Hi!
>
> I'm reading UTM map coordinates from an ASCII file, which has lines
> like:
> 681765.37 7450650.54 334 1
>
> I read this with code on the form:
> while (NOT EOF(unit)) do begin
> format='(2D,2I)'
> readf,unit,temp1,temp2
> UTMcoords(*,i)=temp1
> pixelcoords(*,i)=temp2
> i=i+1
> endwhile
> (all relevant variables in double format)
>
> Everything works out fine, exept that the second column is rounded off:
> 7450650.54 ---> 7450650.5
> that is: 8 numbers in any case (before or after the decimal-point). "So
> what?" you're saying? The problem is that I really need all my 9
> numbers. Anyone got an idea??
>
> Regards,
> Gunnar L. Rasmussen, Applied Physics, Univ. of Tromsoe, Norway

I suspect your data is read and stored intact, but printed in a rounded
format. Look at the Print, Format=() commands to see what's actually in
the variables.

--
Mike Schienle Interactive Visuals
mgs@la.znet.com http://la.znet.com/~mgs/
Re: [Q] Reading from ASCII file? [message #12261 is a reply to message #12253] Thu, 23 July 1998 00:00 Go to previous message
Vap User is currently offline  Vap User
Messages: 31
Registered: April 1998
Member
TSS Operator on duty <operator@ramses.tss.no> writes:


I think the 'D' format assumes the numbers are 'float' as opposed to
'double' so there will probably be some rounding. In any case, perhaps
the following will work, and be faster than the loop.

Say there are 'Nlines' lines in the file.

tmp=dblarr(4,nlines)
readf, unit, tmp
UTMCoords = tmp(0:1,*)
pixelcoords = long( tmp(2:3,*) ) ; perhaps 'fix' instead of long?
tmp=0 ;be nice to your fellow users!
close, unit

This assumes there are always four columns.

whd

>
> Hi!
>
> I'm reading UTM map coordinates from an ASCII file, which has lines
> like:
> 681765.37 7450650.54 334 1
>
> I read this with code on the form:
> while (NOT EOF(unit)) do begin
> format='(2D,2I)'
> readf,unit,temp1,temp2
> UTMcoords(*,i)=temp1
> pixelcoords(*,i)=temp2
> i=i+1
> endwhile
> (all relevant variables in double format)
>
> Everything works out fine, exept that the second column is rounded off:
> 7450650.54 ---> 7450650.5
> that is: 8 numbers in any case (before or after the decimal-point). "So
> what?" you're saying? The problem is that I really need all my 9
> numbers. Anyone got an idea??
>
> Regards,
> Gunnar L. Rasmussen, Applied Physics, Univ. of Tromsoe, Norway
>

--
I don't speak for JPL, it doesn't speak for me.
Well, not all the time, at least.
William Daffer <vapuser@haifung.jpl.nasa.gov>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: my god this should be easy!
Next Topic: problems with plot_2d

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

Current Time: Wed Oct 08 16:50:19 PDT 2025

Total time taken to generate the page: 0.00462 seconds