Home > other >  Based on the collection of kalman filtering is realized in matlab data assimilation
Based on the collection of kalman filtering is realized in matlab data assimilation

Time:09-15

I write a collection of matlab application of kalman filter (ENKF) used for remote sensing precipitation data assimilation/fusion, but why I but the result was a fusion of precipitation is almost a observation data (also is a kind of remote sensing of precipitation data, I use it as an observation data for data assimilation/fusion), the code I write wrong?


 
clear all;
clc;

% % of satellite remote sensing precipitation data import and parameter setting of
Dec=0.25; % precipitation spatial resolution data
Site_number=27; % the observed number of site
A=1; % state transition matrix
H=1; % observation operator
Data=https://bbs.csdn.net/topics/xlsread (' \ ENKF \ 1. XLSX '); % import background field precipitation data fusion and data
Coord=xlsread (' \ ENKF \ basin lattice latitude and longitude coordinates. XLSX '); % import, yanghe watershed within the grid points of latitude and longitude coordinates,
X1=data (:, 1); 1
% background field precipitation dataX2=data (:, 2);
% observation field precipitation dataR=0.7;
Random_count=1000; % is set to generate a random number number
N=50; % to set the number of drawn from a random number
N=80; Observations can be set up %

% % generated background field collection and observation field collection of random disturbance
For I=1: Site_number
The random=0 + randn (1, Random_count); % randomly generated in accordance with the mean to 0, variance of 1 1000 random Numbers (background)
Randn randomGC=0 + SQRT (R) * (1, Random_count); % randomly generated in accordance with the mean to 0, variance of R 1000 random Numbers (observation)
Randomcopy (I)=random; % record of the trip all random number (background)
RandomcopyGC (I)=randomGC; % in the same way (observation)
Random_choose (I, :)=randsample (Random_count, N, false); % randomly selected from the generated random number before the number N as the column index (background)
Random_chooseGC (I, :)=randsample (Random_count, n, false); % in the same way (observation)
The Random (I, :)=the Random (random_choose (I, :)); Follow the above indexes for N % value of the random number (background)
RandomGC (I)=RandomGC (random_chooseGC (I, :)); % in the same way (observation)
End

% % add disturbance to the background field collection and observation field collection
X1copy=kron (x1, ones (1, N)); % the initial background field x1 copy for each column of the same array
X2copy=kron (x2, ones (1, n)); % the initial observation field x2 copy for each column of the same array
Xb=x1copy + Random; % generated with disturbance of background field collection
XbGC=x2copy + RandomGC; % generated with perturbation of observation field collection

% % calculation error covariance matrix of observations and background field
Xbmean=mean (Xb, 2); Average collection
% oXbmeancopy=kron (Xbmean, ones (1, N)); % copies collection average for each column of the same n column array
XbRD=Xb - Xbmeancopy; %
computing background field collection the disturbanceQ=var (XbRD, 0, 2); % to calculate variance background field collection the disturbance
PbInitial=(XbRD * XbRD ')/(N - 1); % to calculate initial background field error covariance matrix
Ob=(RandomGC * RandomGC ')/(n - 1); % calculation observation field error covariance matrix

% % to calculate the local cutting function and update background error covariance matrix games
For j=1: size (data, 1)
For m=1: size (data, 1)
Z (j, m)=short (Coord (j, 3), Coord (j, 4), Coord (m, 3), Coord (m, 4)); Z % calculated distance matrix
LCF (j, m)=Local_clipping (Z (j, m), 0.75); % calculation of the local cutting function matrix
End

End

Pb=LCF. * PbInitial; % calculation error covariance matrix after a local background field


% % ENKF data fusionFor ii=1:27
X (1, :, ii)=Xb (ii); The optimal estimate % initial
P (2, 1)=Pb (ii, ii); % initial error covariance
For jj=2: n + 1% iterations jj
% % 1, prediction equation
X (jj, :, ii)=A * X (jj - 1, :, ii); % calculation model predicted
P1 (ii, jj - 1)=A * P (ii, jj - 1) * A '+ Q (ii); % calculation error covariance estimates, on behalf of the site background field ii error covariance

% % 2, update equationKg (ii, jj - 1)=p (ii, jj - 1) * H '/P1 (H * (ii, jj - 1) * H' + Ob (ii, ii)); % this state kalman coefficient calculation, on behalf of the site ii iteration to first jj Kg
XGC=kron (XbGC (ii, :) ', 'ones (1, N));
X (jj, :, ii)=X (jj, :, ii) + Kg (ii, jj - 1) * (XGC (jj - 1, :) - H * X (jj, :, ii)); % to calculate the optimal estimate, this state representative ii site iteration to jj times the value of the
P=(1 - (ii, jj) Kg (ii, jj - 1) * H) * P1 (ii, jj - 1); % the optimal covariance is calculated under this state, on behalf of the site ii iteration to jj time optimal covariance
End
Xmean (ii, :)=mean (X (:, :, ii), 2) '; % the last column of the data for the final fusion after precipitation data

End








 function [Z]=short (lat1, lon1, lat2, lon2) 
% short function is used to calculate the Distance between two grid points of latitude and longitude coordinates
Z=SQRT ((lat1 - lat2) ^ 2 + (lon1 - lon2) ^ 2);

End


 
The function [P]=Local_clipping (z, c)
% Local_clipping function is local cutting function, used to reduce the influence of long distance pseudo relevant
If z>=0 & amp; & ZP=1 - (5/3 when) * (z/c) ^ 2 + (5/8) * (z/c) ^ 3 + (1/2) * (z/c) ^ 4 - (1/4) * (z/c ^ 5);
Elseif z>=c & amp; & ZP=- (2/3) * (z/c) ^ - 1 + 4-5 * (z/c) + (5/3 when) * (z/c) ^ 2 + (5/8) * (z/c) ^ 3 - (1/2) * (z/c) ^ 4 + (1/12) * (z/c ^ 5);
The else
P=0;
End

CodePudding user response:

X1=data (:, 2);
% background field precipitation dataX2=data (:, 3);
% observation field precipitation dataIsn't the problem

CodePudding user response:

I also tested the code, the problem should be X1 and X2

CodePudding user response:

refer to the second floor Qisphs response:
I also tested the code, the problem should be X1 and X2
,

Brother, you seem to understand the meaning of the wrong data assimilation

CodePudding user response:

reference 1st floor weixin_41443838 response:
x1=data (:, 2);
% background field precipitation dataX2=data (:, 3);
% observation field precipitation dataIsn't the problem ah
hello, take the liberty to disturb, ask a question, I completely according to the above programs and files, but few seconds to stop the operation, also don't show as a result, I don't know is what reason, hope to receive your reply, thank you very much,

CodePudding user response:

refer to the second floor Qisphs response:
I also tested the code, the problem should be X1 and X2
hello, take the liberty to disturb, ask a question, I completely according to the above programs and files, but few seconds to stop the operation, also does not display the results, I don't know is what reason, hope to receive your reply, thank you very much,

CodePudding user response:

reference Qisphs reply: 3/f
Quote: refer to the second floor Qisphs response:

I also tested the code, the problem should be X1 and X2
,

Brother, you seem to understand the meaning of the wrong data assimilation
hello, take the liberty to disturb, ask a question, I completely according to the above programs and files, but few seconds to stop the operation, also don't show as a result, I don't know is what reason, hope to receive your reply, thank you very much,

CodePudding user response:

Hello, do you have solve the problem of the results close to the observed value? I want to consult you write correct code, hope that you can code in the wrong place, points out that thank you very much!

CodePudding user response:

nullnullnullnullnullnullnullnull
  • Related