wrong results... [message #43811] |
Mon, 02 May 2005 06:49  |
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
|
|
|