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

Home » Public Forums » archive » wrong results...
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
wrong results... [message #43811] Mon, 02 May 2005 06:49 Go to previous message
elias is currently offline  elias
Messages: 13
Registered: April 2005
Junior Member
Hi,

The following problem probably has something to do with definitions of
floating, integer etc, but I don't really know to solve it (although i
am sure the solution will be simple in the end...).

I have a data file that, amongst others, contains some longitude
columns. The longitude data is defined from -180 to 180 deg in this
data file. For some consistency with some other analysis I did before,
I want to convert it to 0-->360 deg.

So simply, I ask when it reads a longitude <0 to do: lon=360+lon

However, I am getting in the new data file created, values of longitude
more than 600 sometimes.... I am not sure why this happens

Below I post this simple code.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~


PRO restruct, fil, output

;reads data file of moon l-shell
;crossings and restructures its data
;so that:
;Cassini and Moon longitude>0
;(Cassini-Moon) longitude>0


filetemplate=ASCII_Template(fil)
data=Read_ASCII(fil,Template=filetemplate)

crossings=n_elements(data.field1)

openw, lunit, /get_lun, output

for i=0L,crossings-1 do begin

if data.field3[i] lt 0 then begin
data.field3[i]=360+data.field3[i]

endif

if data.field6[i] lt 0 then begin
data.field6[i]=360+data.field6[i]

endif

dlon=data.field6[i]-data.field3[i]

if dlon lt 0 then begin
data.field3[i]=360+data.field3[i]

endif

thisformat='(f14, 7f14)'
printf, lunit, data.field1[i], data.field2[i],$
data.field3[i], data.field4[i],$
data.field5[i], data.field6[i],$
data.field7[i], dlon, format=thisformat

endfor

free_lun, lunit

end
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Determining install directory
Next Topic: Adding flexibility at run time question

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

Current Time: Wed Oct 08 17:35:36 PDT 2025

Total time taken to generate the page: 0.00423 seconds