Cell_Info_E.ReceivedPowerMap=zeros(203,203);
Cell_Info_F.ReceivedPowerMap=zeros(203,203);
Cell_Info_G.ReceivedPowerMap=zeros(203,203);
Cell_Info_H.ReceivedPowerMap=zeros(203,203);

Bangle=90-Cell_Info_B.azimuth;
Cangle=90-Cell_Info_C.azimuth;
Dangle=90-Cell_Info_D.azimuth+360;
Eangle=90-Cell_Info_E.azimuth+360;
Fangle=90-Cell_Info_F.azimuth;
Gangle=90-Cell_Info_G.azimuth+360;
Hangle=90-Cell_Info_H.azimuth+360;

%from A to D, add angleFactor             Aangle-Dangle=-122
%from D to A, subtract angleFactor        Dangle-Aangle=122


%Dangle-Eangle=-120 so add angleFactor
for x=1:203
    for y=1:203
        if Cell_Info_D.ReceivedPowerMap(y,x)~=0
            pixAngle=atan2(y-101,x-101)*180/pi-(Dangle+Eangle)/2;
            Cell_Info_E.ReceivedPowerMap(y,x)=Cell_Info_D.ReceivedPowerMap(y,x)+angleFactor(pixAngle);
        else
            distance=10*sqrt((x-101)^2+(y-101)^2);
            if ChangeCoordsAy(y)<size(BinaryMask,1) & ChangeCoordsAx(x)<size(BinaryMask,2) & BinaryMask(ChangeCoordsAy(y),ChangeCoordsAx(x))~=0
                Cell_Info_E.ReceivedPowerMap(y,x)=-polyval(logp1In,log10(distance));
            else
                Cell_Info_E.ReceivedPowerMap(y,x)=-polyval(logp1Out,log10(distance));
            end
        end
    end
end

figure
imagesc(Cell_Info_E.ReceivedPowerMap)
axis xy
axis equal
colorbar
title('Received Power Map for E')
xlabel('East/West location (1 pixel=10m)')
ylabel('North/South location (1 pixel=10m)')


%Bangle-Fangle=120 so subtract angleFactor
for x=1:203
    for y=1:203
        pixAngle=atan2(y-101,x-101)*180/pi-(Bangle+Fangle)/2;
        if Cell_Info_B.ReceivedPowerMap(y,x)~=0
            Cell_Info_F.ReceivedPowerMap(y,x)=Cell_Info_B.ReceivedPowerMap(y,x)-angleFactor(pixAngle);
        else
            distance=10*sqrt((x-101)^2+(y-101)^2);
            if ChangeCoordsBy(y)<size(BinaryMask,1) & 0<ChangeCoordsBy(y) & ChangeCoordsBx(x)<size(BinaryMask,2) & 0<ChangeCoordsBx(x) & BinaryMask(ChangeCoordsBy(y),ChangeCoordsBx(x))~=0
                Cell_Info_F.ReceivedPowerMap(y,x)=-polyval(logp1In,log10(distance))+delta;
            else
                Cell_Info_F.ReceivedPowerMap(y,x)=-polyval(logp1Out,log10(distance))+delta;
            end
        end
    end
end

figure
imagesc(Cell_Info_F.ReceivedPowerMap)
axis xy
axis equal
colorbar
title('Received Power Map for F')
xlabel('East/West location (1 pixel=10m)')
ylabel('North/South location (1 pixel=10m)')



%Bangle-Gangle=-120 so add angleFactor
for x=1:203
    for y=1:203
        pixAngle=atan2(y-101,x-101)*180/pi-(Bangle+Gangle)/2;
        if Cell_Info_B.ReceivedPowerMap(y,x)~=0
            Cell_Info_G.ReceivedPowerMap(y,x)=Cell_Info_B.ReceivedPowerMap(y,x)+angleFactor(pixAngle);
        else
            distance=10*sqrt((x-101)^2+(y-101)^2);
            if ChangeCoordsBy(y)<size(BinaryMask,1) & 0<ChangeCoordsBy(y) & ChangeCoordsBx(x)<size(BinaryMask,2) & 0<ChangeCoordsBx(x) & BinaryMask(ChangeCoordsBy(y),ChangeCoordsBx(x))~=0
                Cell_Info_G.ReceivedPowerMap(y,x)=-polyval(logp1In,log10(distance))+delta;
            else
                Cell_Info_G.ReceivedPowerMap(y,x)=-polyval(logp1Out,log10(distance))+delta;
            end
        end
    end
end

figure
imagesc(Cell_Info_G.ReceivedPowerMap)
axis xy
axis equal
colorbar
title('Received Power Map for G')
xlabel('East/West location (1 pixel=10m)')
ylabel('North/South location (1 pixel=10m)')



%Cangle-Hangle=-110 so add angleFactor
for x=1:203
    for y=1:203
        pixAngle=atan2(y-101,x-101)*180/pi-(Cangle+Hangle)/2;
        if Cell_Info_C.ReceivedPowerMap(y,x)~=0
            Cell_Info_H.ReceivedPowerMap(y,x)=Cell_Info_C.ReceivedPowerMap(y,x)+angleFactor(pixAngle);
        else
            distance=10*sqrt((x-101)^2+(y-101)^2);
            if ChangeCoordsCy(y)<size(BinaryMask,1) & 0<ChangeCoordsCy(y) & ChangeCoordsCx(x)<size(BinaryMask,2) & 0<ChangeCoordsCx(x) & BinaryMask(ChangeCoordsCy(y),ChangeCoordsCx(x))~=0
                Cell_Info_H.ReceivedPowerMap(y,x)=-polyval(logp1In,log10(distance));
            else
                Cell_Info_H.ReceivedPowerMap(y,x)=-polyval(logp1Out,log10(distance));
            end
        end
    end
end

figure
imagesc(Cell_Info_H.ReceivedPowerMap)
axis xy
axis equal
colorbar
title('Received Power Map for H')
xlabel('East/West location (1 pixel=10m)')
ylabel('North/South location (1 pixel=10m)')