RMSE in 3D coordiantes
I have a 3D data (of climate variables), (x=33,y=35,z=27) where x,y refer
to the grid points and z is time(in yrs). I need grid wise RMSE for the
given time period. I've to mask the file before calculating RMSE. The
dimensions of mask file and data are same (including time). The no. of
grids for which RMSE has to be found is reduced after masking(33*35=1155
to 357). I found RMSE for these reduced grids after reshaping the original
data. Now I have a column matrix of RMSE (357*1) which has to be shown in
2d i.e for the respective grids (33*35). How do perform reshaping from a
1d smaller array to 2d bigger array? My code is:
IMD_load=load('IMD.mat'); % mask file cum observation data
IMD1=IMD_load.IMD_OBS;
IMD(:,:,:)=IMD1(:,:,1:27); % I'm doing only for 27 yrs of available time
period
CFS_load=load('CFS.mat'); % model data
CFS1=CFS_load.CFSV2;
CFS2=CFS1(:,:,1:27); % I'm doing only for 27 yrs of available time period
CFS=CFS2-273.15;
for i = 1:1:27
IMD2=IMD(:,:,i);
IMD_1=reshape(IMD2,1155,1);
IMD_1(isnan(IMD_1))=0;
[IMD_m]=find(IMD_1==0);
% CFS3=CFS(:,:,i);
CFS4=reshape(CFS(:,:,i),1155,1);
CFS4(IMD_m,:)=0;
CFS5=reshape(CFS4,1155,1);
CFS6(:,i)=CFS5;
end
% I have to run the above for loop because for each year no. of grids with
NaN is varying
OO1=reshape(IMD,1155,27);
MM1=reshape(CFS,1155,27);
OO2=reshape(OO1,1155*27,1); % is this corret?
MM2=reshape(MM1,1155*27,1); % is this corret?
[cfs6_m]=find(CFS6~=0);
[cfs6_m2]=find(CFS6==0);
OO3=reshape(OO2(cfs6_m,:),357,27); % (OR) OO4=reshape(OO2(cfs6_m),357,27);
MM3=reshape(MM2(cfs6_m,:),357,27); % (OR) MM4=reshape(MM2(cfs6_m),357,27);
for i = 1:1:357
r2(i,:)=sqrt(sum((OO3(i,:)-MM3(i,:)).^2)/27);
end
% RR(1155,1)=reshape(R,33,35);
% I'm now left with 'r1'(357*1). But how do I convert it back to 33*35???
No comments:
Post a Comment