Help with data gaps and interpolation [message #90653] |
Fri, 20 March 2015 07:18  |
zolile mtumela
Messages: 50 Registered: September 2011
|
Member |
|
|
Dear All,
I would to get help, sugestions on the ff program. i have tried many ways but I did not succed, any help will be highly appreciated.
1. I want to plot with data gaps which are represented by values such as 9999.99.
2. I would like to interpolate the data again to fill the data gaps.
the data look like this
06-10-2006 19:01:00.000 1.45000 -2.15000 0.120000
06-10-2006 19:02:00.000 1.36000 -2.31000 0.120000
06-10-2006 19:03:00.000 1.39000 -1.76000 0.140000
06-10-2006 19:04:00.000 9999.99 9999.99 9999.99
06-10-2006 19:05:00.000 9999.99 9999.99 9999.99
06-10-2006 19:06:00.000 1.20000 -1.91000 0.220000
06-10-2006 19:07:00.000 1.23000 -1.87000 0.230000
06-10-2006 19:08:00.000 1.22000 -1.84000 0.230000
06-10-2006 19:09:00.000 1.14000 -1.86000 0.310000
06-10-2006 19:10:00.000 1.05000 -1.86000 0.440000
06-10-2006 19:11:00.000 0.920000 -1.87000 0.660000
06-10-2006 19:12:00.000 0.790000 -1.60000 0.420000
06-10-2006 19:13:00.000 0.180000 -1.38000 0.810000
06-10-2006 19:14:00.000 0.900000 -0.970000 0.310000
06-10-2006 19:15:00.000 1.64000 -0.680000 -0.270000
06-10-2006 19:16:00.000 1.73000 -0.680000 -0.210000
06-10-2006 19:17:00.000 1.83000 -0.710000 0.0500000
The program looks like this
File = Dialog_PickFile(Filter='*.txt')
Date_array = 0
time_array = 0
Bx_array = 0
By_array = 0
Bz_array = 0
str = ''
openR, Lun, File,/Get_Lun
readf, Lun, str
while~eof(lun) do begin
readf,lun,date,time,Bx,By,Bz
;print,date,time,Bx,By,Bz
Bx_array = [Bx_array, Bx]
By_array = [By_array, By]
Bz_array = [Bz_array, Bz]
endwhile
free_lun,lun
Bx_array=Bx_array[1:*]
By_array=By_array[1:*]
Bz_array=Bz_array[1:*]
index = where(Bx_array eq 9999.99, count)
if (count gt 9999.99) then Bx_array[index] = !values.f_nan
; interpolate
if Bx_array lt 9999.99 then begin
temp=(Bx_array, count)
result=interpol(Bx_array[temp],temp, time[temp])
endif
Nx = n_elements(Bx_array)
time = findgen(Nx)
time = time/60
; plot with data gaps
plot, time, Bx_array[index];
plot,time, Result
end
Thank in advance for your time.
Zolile
|
|
|