GP265 /EE 355 Homework 8 (Final project 2) · GP265 /EE 355 Homework 8 (Final project 2) March 14,...
Transcript of GP265 /EE 355 Homework 8 (Final project 2) · GP265 /EE 355 Homework 8 (Final project 2) March 14,...
GP265 /EE 355 Homework 8 (Final project 2)
March 14, 2018
1. Display interferogram phase
2. Calculate the curved earth fringe pattern and subtract it from the interferogram phase.
First I compute the slant range pixel spacing ∆r:
∆r = nlooksrc
2fs= 3 · 2.99792458 · 10
8m/s
2(16.0 · 106Hz)= 28.1055 m. (1)
Then the range ρ to each range bin ir is:
ρ(ir) = ρ0 + (ir − 1)∆r, ir = 0, 1, ..., nrange− 1 (2)
where ρ0 = 844768 m is the range to the first bin and nrange = 1024 range bins.
1
The look angle θz0 to each range bin for z = 0 (no topography) is:
θz0 = cos−1
((h+ re)
2 + ρ2 − (z + re)2
2ρ(h+ re)
)|z=0 = cos−1
((h+ re)
2 + ρ2 − r2e2ρ(h+ re)
)(3)
where h = 696000 m is the radar altitude and re = 6378000 m is the earth radius.
Then the curved earth phase ϕz0 for z = 0 (no topography) is:
ϕz0 = −4π
λ
(B2
2ρ−B sin (θz0 − α)
)(4)
where λ = 0.236057 m is the radar wavelength, B = 307 m is the baseline length, and α isthe orientation angle.
To remove this curved earth phase from the complex interferogram S (displayed in Problem1), I apply a phase correction T = Se−iϕz0 , and here is the resulting phase arg(T ), whichshould have only topography effects. The fringe lines look more like elevation contour lineshere:
3. Flatten the interferogram by further correcting for any tilts over the image.
We assume that the topography is flat over the caldera at the top of the volcano, at rangebins 110-150 and azimuth bins 925-960. I used least squares to find the slope of the fringeswithin the caldera (in radians/pixel), in both the range and azimuth directions, and apply
2
these phase corrections to the interferogram from Problem 2 to ”flatten” the tilt from theinterferogram. The flattened interferogram no longer has fringes within the caldera, and thefringes look more like elevation contour lines around the volcano. Note that the area I choseis small enough that we can avoid the problem of phase unwrapping.
This is not the only way to correct for tilts - many other solutions are acceptable. For example,you can also try guessing different values of orientation angle α that remove the tilt withinthe caldera.
4. Determine the ambiguity height, ha, for this geometry.
The ambiguity height is defined as the height dz where the topography phase ϕtopo = 2π
ϕtopo = 2π = −4π
λ(Bsin(θ − α)−Bsin(θflat − α)) (5)
We can compute θflat using the law of cosines using Eq. (3) and ha can be computed oncewe obtain the look angle θ from Eq. (5), again using the law of cosines.
The ambiguity height depends on the range ρ, so here is a plot of the range dependence:
3
At the reference (first) range bin, ha = 227.6 m. At the last range bin, ha = 257.9 m.
5. Unwrap the flattened interferogram using the snaphu program.
I write out the flattened interferogram to a file called ’flatinterferogram’ and then run itthrough snaphu to unwrap the phase, writing it out to a file called ’snaphu.out’. I then readin the ’snaphu.out’ file into MATLAB, and plot its phase, which is now unwrapped - no morefringes here, and the phase is no longer limited to the interval [−π, π].
4
6. Using the ambiguity height ha from (4), convert the unwrapped phase values to heights. Youhave now created a digital elevation model (DEM) in radar coordinates.
I use the ambiguity height ha from Eq. (5), which varies as a function of range ρ, to scalethe unwrapped phase values ϕflat from Problem 5 into height values zDEM . I choose several’zero elevation’ reference pixels near the coast, and subtract their average phase ϕref fromevery point in the unwrapped interferogram. Since we are dealing with topography here, Ichoose to plot the contour of the DEM.
zDEM =(ϕflat − ϕref )
2πha (6)
The elevation of Mauna Loa is 4169 m, so our DEM looks reasonable. There are some heightsbelow 0 m, but they were in the region over water so I would not expect to have useful heightvalues here.
7. Map correlation into height error
First, I display the correlation to check that I read it in properly.
5
Problem 7: Correlation
range bin200 400 600 800 1000
azim
uth
bin
100
200
300
400
500
600
700
800
900
1000
1100
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
I use this equation to compute the height error σz as a function of correlation ρc (range is ρ):
σz =λρ sin θz0
4πB cos(θz0 − α)
√1− ρc2ρc
(7)
Here is a plot of the height error σz, ranging from 0 to 50 m. It makes sense that the heighterror is greatest at the locations where the correlation is lowest, such as the water in thetop-right corner, as well as the slopes in the top-left and bottom-right corners.
6
8. Map DEM to ground coordinates
To compute the ground range, which depends on both range and azimuth since I take theDEM heights into account, I first compute the look angle (compare to Eq. (3)):
θz = cos−1
((h+ re)
2 + ρ2 − (zDEM + re)2
2ρ(h+ re)
)(8)
Then I can compute the angle βz at the center of the earth, using the law of sines:
βz = sin−1
(ρ
resin θz
)(9)
The ground range rg,z is thenrg,z = reβz (10)
I get the platform velocity v from the effective platform velocity veff = 7179.4 m/s, radaraltitude h = 696000 m, and earth radius re = 6378000 m:
v = veff
√h+ rere
= (7179.4m/s)
√696000 + 6378000
6378000= 7560.98 m/s. (11)
Then the azimuth bin ground spacing ∆azg is
∆azg = nlooksazv
prf
reh+ re
= 127560.98
2159.827
6378000
696000 + 6378000= 37.8757 m (12)
7
I generated a ”ground coordinates” grid with a spacing of ∆azg between adjacent groundrange bins, in order to get square pixels. I resampled only in range, not in azimuth. Thereare some ”holes” in the image from resampling.
9. Map DEM to ground coordinates: Nice image with interpolation
I resampled the new DEM using linear interpolation. There are no longer ”holes” in theimage.
8
% Hw8 Final Pt.2
clear; close all; clc;
%% parameters
nr=1024;
naz=1190;
nrlook=3;
nazlook=12;
B=307; % baseline,m
B_par=-170;
B_perp=-263;
hgt=696000; % altitude in orbit,m
wvl=0.236057; % wavelength, m
prf=2159.827;
fs=16e6;
c=3e8;
veff=7179.4;
r0=844768; % near range
deltar=c/2/fs*nrlook;
rmid=r0+(nr/2)*deltar+deltar/2; % mid range
re=6378e3; % Earth radius,m
costheta0=((hgt+re)^2+rmid^2-re^2)/2/rmid/(hgt+re);
theta0=acos(costheta0);
alpha=atan(B_perp/B_par)+theta0-pi/2; % baseline angle, rad
alphadg=alpha/pi*180; % baseline angle, degree
%% read files
fid=fopen(’interferogram’);
data=fread(fid,[nr*2 naz],’float’);
fclose(fid);
reald=data(1:2:end,:);
imagd=data(2:2:end,:);
intgram=complex(reald,imagd);
intgram=intgram.’;
phase=angle(intgram);
fid=fopen(’amplitude’);
data=fread(fid,[nr*2 inf],’float’);
fclose(fid);
amp1=data(1:2:end,:);
amp2=data(2:2:end,:);
amp=amp1.’;
fid=fopen(’correlation’);
data=fread(fid,[nr*2 inf],’float’);
fclose(fid);
col=data(nr+1:end,:);
col=col.’;
% display the phase of the interferogram
9
figure
colormap jet
imagesc(phase)
axis image
saveas(gcf,’1.png’,’png’)
%% calculate the curved Earth pattern and substract it.
phase_bg=zeros(naz,nr);
for i=1:nr
rg=r0+(i-1)*deltar;
costhetaflat=((hgt+re)^2+rg^2-re^2)/2/rg/(hgt+re);
thetaflat=acos(costhetaflat);
sindiff=sin(thetaflat-alpha);
phase_bg(:,i)=-4*pi/wvl*(B^2/2/rg-B*sindiff);
end
intgram_bg=exp(1j*phase_bg);
figure
imagesc(angle(intgram_bg))
colormap(jet)
colorbar
saveas(gcf,’2_2.png’,’png’)
topo=intgram.*conj(intgram_bg);
figure
colormap jet
imagesc(angle(topo))
saveas(gcf,’2.png’,’png’)
% pic=mycolormap(amp,angle(topo),nr,naz);
% figure
% imagesc(pic)
%% flatten the interferogram by further correcting for any tilts over the image
% select a small flat area where we expect no change in phase
% note that the area should be small enough that there is no phase wrapping
testsite=topo(925:960,110:150);
testphase=angle(testsite);
figure
imagesc(testphase)
colormap jet
colorbar
% fit a 2-D plane
[valid_x,valid_y]=meshgrid(1:size(testsite,2),1:size(testsite,1));
valid_x=valid_x(:);
valid_y=valid_y(:);
valid_data=testphase(:);
design_A = [ones(size(valid_data)) valid_x valid_y];
coef = design_A\valid_data;
ramppart=design_A*coef;
figure
imagesc(testphase-reshape(ramppart,size(testsite)))
% get the ramp for the whole interferogram
[all_x,all_y] = meshgrid (1:nr, 1:naz);
10
all_x1=all_x(:);
all_y1=all_y(:);
full_A=[ones(nr*naz,1) all_x1 all_y1 ];
ramp=full_A*coef;
ramp=reshape(ramp,naz,nr);
ramp=exp(1j*ramp);
topo_detilt=topo.*conj(ramp);
pic=mycolormap(amp,angle(topo_detilt),nr,naz);
figure
colormap jet
imagesc(pic)
xlabel(’range’)
ylabel(’azimuth’)
title(’corrected interferogram’)
saveas(gcf,’3.png’,’png’)
%% determine the ambiguity height as a function of range
ha=zeros(nr,1);
for i=1:nr
rg=r0+(i-1)*deltar;
costhetaflat=((hgt+re)^2+rg^2-re^2)/2/rg/(hgt+re);
thetaflat=acos(costhetaflat);
dffsin=wvl/2/B;
sindifftopo=dffsin+sin(thetaflat-alpha);
thetatopo=asin(sindifftopo)+alpha;
ha(i)=sqrt((hgt+re)^2+rg^2-2*rg*(hgt+re)*cos(thetatopo))-re;
end
ha(1)
ha(end)
figure
plot(1:nr,ha,’linewidth’,2)
grid on
xlabel(’range bin’)
ylabel(’ambiguity height (m)’)
saveas(gcf,’4.png’,’png’)
%% unwrap the flattened interferogram
fid=fopen(’intgram.uw’,’r’);
dat=fread(fid,[2*nr,inf],’float’,’ieee-le’);
phase_uw=dat(nr+1:end,:)’;
figure
imagesc(phase_uw)
colormap jet
pic=mycolormap(amp,phase_uw,nr,naz);
figure
imagesc(pic)
colorbar
phaselo=prctile(phase_uw(:),0);
phasehi=prctile(phase_uw(:),99);
11
colormap jet
caxis([phaselo,phasehi])
saveas(gcf,’5.png’,’png’)
%% construct a DEM model
% choose a reference point where height is zero and correlation is good.
% figure
% imagesc(col(1:200,500:1000));
rgref=[550,693,792,974];
azref=[31,94,167,159];
phref=0;
for i=1:4
phref=phase_uw(azref(i),rgref(i))+phref;
end
phref=mean(phref);
DEM=nan(size(phase_uw));
for i=1:nr
DEM(:,i)=(phase_uw(:,i)-phref)/2/pi*ha(i);
DEM(DEM<0)=0;
end
figure
contourf(DEM,40)
colormap jet
colorbar
ch=colorbar; ylabel(ch,’Height,m’);
set(gca,’Ydir’,’reverse’)
axis image
saveas(gcf,’6.png’,’png’)
%% map of standard deviation of map
stdphase=((1-col)./2./col).^0.5;
stdDEM=nan(size(stdphase));
for i=1:nr
stdDEM(:,i)=ha(i)*stdphase(:,i)/2/pi;
end
figure
imagesc(stdDEM)
colormap jet
caxis([0 50])
axis image
colorbar
ch=colorbar; ylabel(ch,’Height Uncertainty,m’);
title(’uncertainty map’)
saveas(gcf,’7.png’,’png’)
%% rectify your map into ground range and azimuth coordinate
vel=veff*sqrt((hgt+re)/re);
deltaaz=vel/prf*re/(re+hgt)*nazlook;
12
% determine the nearest ground range
demline=DEM(:,1);
cosgama=((hgt+re)^2-r0^2+(re+demline).^2)./2/(hgt+re)./(demline+re);
gama=acos(cosgama);
rnear=min(re*gama);
% determine the farest ground range
rmax=r0+(nr-1)*deltar;
demline=DEM(:,nr-1);
cosgama=((hgt+re)^2-rmax^2+(re+demline).^2)./2/(hgt+re)./(demline+re);
gama=acos(cosgama);
rfar=max(re*gama);
nrg=round((rfar-rnear)/deltaaz);
newDEM=nan(naz,nrg);
% determine the offsets in range (pixels) and reesample
rgoffset=zeros(naz,nr);
for i=1:nr
rsl=r0+(i-1)*deltar;
demline=DEM(:,i);
cosgama=((hgt+re)^2-rsl^2+(re+demline).^2)./2/(hgt+re)./(demline+re);
gama=acos(cosgama);
rgr=re*gama; % ground range
idxrgnew=((rgr-rnear)/deltaaz+1); % range index in new coordinates
rgoffset(:,i)=idxrgnew;
end
h = waitbar(0,’Range resampling’);
for j=1:naz
idxrgnew=rgoffset(j,:);
for i=1:nrg
idxintper=find((abs(idxrgnew-i)<1));
if ~isempty(idxintper)
newDEM(j,i)= mean(DEM(j,idxintper));
end
end
waitbar(j/naz)
end
close(h)
figure
contourf(newDEM,40)
colormap jet
colorbar
ch=colorbar; ylabel(ch,’Height,m’);
axis image
set(gca,’Ydir’,’reverse’)
axis off
saveas(gcf,’8.png’,’png’)
13
%% interpolate to obtain good looking pictures
% linear interpolation
[idxaz,idxrg]=find(isnan(newDEM));
h = waitbar(0,’Interpolating’);
cull_window=1;
DEM_interp=newDEM;
for i=1:length(idxaz)
rneari=min(rgoffset(idxaz(i),:));
rfari=max(rgoffset(idxaz(i),:));
if idxrg(i)>rneari && idxrg(i)<rfari
index_az = max(1, idxaz(i)-cull_window):min(idxaz(i)+cull_window, naz);
index_rg= max(1, idxrg(i)-cull_window):min(idxrg(i)+cull_window, nr);
patch=newDEM(index_az,index_rg);
patch=patch(:);
patch=patch(isfinite(patch));
DEM_interp(idxaz(i),idxrg(i))=mean(patch(:));
end
waitbar(i/length(idxaz))
end
close(h)
figure
contourf(DEM_interp,40)
colormap jet
colorbar
ch=colorbar; ylabel(ch,’Height,m’);
set(gca,’Ydir’,’reverse’)
axis image
axis off
saveas(gcf,’9.png’,’png’)
Function to overlay phase image on the amplitude image
function pic=mycolormap(amp,phase,nr,naz)
amplow=prctile(amp(:),5);
amphi=prctile(amp(:),95);
amp(amp<amplow)=amplow;
amp(amp>amphi)=amphi;
scale=(amp-amplow)/(amphi-amplow);
phlow=prctile(phase(:),1);
phhi=prctile(phase(:),99);
% create a color table
colormap jet;
map=colormap;
stack=max(phase,phlow);
stack=min(phase,phhi);
colorstack=round((stack-phlow)/(phhi-phlow)*64);
14
colorstack=max(colorstack,1);
colorstack=min(colorstack,64);
for k=1:naz
for kk=1:nr
red(k,kk)=map(colorstack(k,kk),1);
green(k,kk)=map(colorstack(k,kk),2);
blue(k,kk)=map(colorstack(k,kk),3);
end
end
pic(:,:,1)=red.*scale;
pic(:,:,2)=green.*scale;
pic(:,:,3)=blue.*scale;
15