forked from williamBarnhart/gCent
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
bjmarfito
committed
Aug 7, 2023
1 parent
0fdef9b
commit 1e8d563
Showing
5 changed files
with
265 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
function datastruct = loadISCE_MAI(filename,zone,limitny,azo,scaleval) | ||
pathname =[]; | ||
datastruct=struct([]); | ||
if(nargin<5) | ||
scaleval=0; | ||
end | ||
if(nargin<4) | ||
azo=0; | ||
end | ||
if(nargin<3) | ||
limitny=0; | ||
end | ||
if(nargin<2) | ||
zone=0; | ||
end | ||
if(nargin<1) | ||
[infilename, pathname]=uigetfile({'*.geo','Unwrapped files (*.unw)'; ... | ||
'*.flat','Interferograms (*.flat)'; ... | ||
'*.slc','Single Look Complex (*.slc)'; ... | ||
% '*.amp','Amplitude files (*.amp)'; ... | ||
'*.cor','Correlation files (*.cor)'; ... | ||
'*.hgt','Height files (*.hgt)'; .... | ||
% '*.msk','Mask files (*.msk)'; ... | ||
'*.dem','DEMs (*.dem)'; ... | ||
% '*.byt','Byte files (*.byt)'; ... | ||
% '*.flg','Flag files (*.flg)'; ... | ||
% '*.slp','Slope files (*.slp)'; ... | ||
% '*.off','Offset files (*.off)'; ... | ||
'*','All files'}, ... | ||
'Pick an input file'); | ||
|
||
filename=[pathname infilename]; | ||
elseif length(strsplit(filename,'/'))>1 | ||
pathname = []; | ||
parts=strsplit(filename,'/'); | ||
if isempty(parts{1}) | ||
for k=2:length(parts)-1 | ||
pathname = [pathname '/' parts{k}]; | ||
end | ||
% pathname = ['/' pathname]; | ||
else | ||
for k=1:length(parts)-2 | ||
pathname =[pathname parts{k} '/']; | ||
end | ||
pathname = [pathname parts{end-1}]; | ||
end | ||
else | ||
pathname = '.'; | ||
end | ||
% if isempty(pathname) | ||
% pathname='.'; | ||
% end | ||
mag=[]; | ||
phs=[]; | ||
|
||
n = length(filename); | ||
patterns = {'phsig','cor','unw','rdr','flat','hgt','dem','slc','def'}; | ||
figtype = {'phsig','rmg','rmg','rmg','cpx','rmg','rmg','cpx','rmg'}; | ||
|
||
|
||
|
||
for k = 1:length(patterns) | ||
if(regexp(filename,patterns{k})) | ||
type=figtype{k}; | ||
break | ||
end | ||
end | ||
im = sqrt(-1); | ||
|
||
if(regexp(filename,'geo')) | ||
% [nx,ny,lambda,x1,y2,dx,dy] = load_xml([pathname '/insarProc.xml'],'GEO_WIDTH','GEO_LENGTH','radar_wavelength','maximum_longitude','maximum_latitude','LONGITUDE_SPACING','LATITUDE_SPACING'); | ||
% [nx,ny,x1,y2,dx,dy] = load_xml([pathname '/' filename '.xml'], | ||
[nx,ny,x1,y2,dx,dy] = loadGeoXml([filename '.xml']); | ||
if regexp(filename,'merged') | ||
lambda= '1'; | ||
elseif regexp(filename,'insar') | ||
lambda = '1'; | ||
else | ||
%lambda = loadGenericXml([pathname '/insarProc.xml'],'radar_wavelength'); | ||
lambda='1'; | ||
end | ||
|
||
nx = str2num(nx); ny = str2num(ny); x1 = str2num(x1); y2 = str2num(y2); dx = str2num(dx); dy = str2num(dy);lambda=str2num(lambda); | ||
else | ||
if regexp(filename,'merged') | ||
|
||
lambda = '0.05465763'; | ||
[nx, ny] = loadISCEinfo([pathname(1:end-7) '/isce.log'],'isce.mroipac.filter - DEBUG - width','isce.mroipac.filter - DEBUG - length'); | ||
|
||
else | ||
|
||
% [nx,ny,lambda] = loadGenericXml([pathname '/insarProc.xml'],'WIDTH','LENGTH','RADAR_WAVELENGTH'); | ||
[nx, ny,lambda] = loadISCEinfo([pathname '/isce.log'],'runCorrect.inputs.width','runCorrect.inputs.length','runCorrect.inputs.radar_wavelength'); | ||
end | ||
nx = str2num(nx); ny = str2num(ny); lambda =str2num(lambda); | ||
end | ||
|
||
fprintf('%s\n', 'IMPORTANT!! This code assumes that the MAI is already in meters so the wavelength is set to 1.') | ||
% lambda = getWavelength(sensor); | ||
|
||
if(limitny) | ||
ny = limitny; | ||
end | ||
|
||
switch type | ||
case 'rmg' | ||
disp('Loading rmg file') | ||
disp(filename) | ||
fid = fopen(filename,'r','native'); | ||
[rmg,count] = fread(fid,[nx,ny*2],'float32'); | ||
[nx,ny] = size(rmg); | ||
ny = ny/2; | ||
status = fclose(fid); | ||
mag = flipud((rmg(1:nx,1:2:ny*2))'); | ||
phs = flipud((rmg(1:nx,2:2:ny*2))'); | ||
data = phs; | ||
%if(regexp(filename,'unw')); | ||
%data = -phs*lambda/(4*pi); | ||
%end | ||
case 'cpx' | ||
|
||
disp('Loading cpx file') | ||
fid = fopen(filename,'r','native'); | ||
[rmg,count] = fread(fid,[nx*2,ny],'real*4'); | ||
status = fclose(fid); | ||
real = flipud((rmg(1:2:nx*2,1:ny))'); | ||
imag = flipud((rmg(2:2:nx*2,1:ny))'); | ||
mag = abs(real+im*imag); | ||
phs = angle(real+im*imag); | ||
data = phs; | ||
case 'phsig' | ||
disp('Loading PHSIG file') | ||
fid=fopen(filename,'r','native'); | ||
[cor,count]=fread(fid,[nx, ny],'real*4'); | ||
data = flipud(cor'); | ||
end | ||
|
||
|
||
|
||
if(scaleval) | ||
olddata = data; | ||
scale = 2^ceil(log2(min([ny nx])/scaleval)); | ||
extrax = scale-mod(nx,scale); | ||
extray = scale-mod(ny,scale); | ||
data = blkdiag(olddata,zeros(extray,extrax)); | ||
[ny,nx] = size(data); | ||
y2 = y2-extray*dy; | ||
disp(['padding X,Y,data,S with ' num2str(extrax) '/' num2str(extray) ' zeros']); | ||
else | ||
extrax = 0; | ||
extray = 0; | ||
scale = 0; | ||
end | ||
|
||
|
||
if(regexp(filename,'geo')) | ||
disp('File is geocoded') | ||
y1 =y2+dy*(ny-1); | ||
x2 =x1+dx*(nx-1); | ||
|
||
x =x1:dx:x2; | ||
y =y1:-dy:y2; | ||
|
||
[X,Y] =meshgrid(x,y); | ||
if zone==0 | ||
[jnk1,jnk2,zone] = my_utm2ll(mean(x),mean(y),2); | ||
end | ||
if(str2num(zone)<=-1) | ||
disp('not setting zone'); | ||
else | ||
[leng,width] =size(X); | ||
[X,Y] = my_utm2ll(X,Y,2,zone); | ||
X = reshape(X,leng,width); | ||
Y = reshape(Y,leng,width); | ||
pixelsize = mean([sqrt((X(1)-X(2))^2+(Y(1)-Y(2))^2) sqrt((X(nx*ny-1)-X(nx*ny))^2+(Y(nx*ny-1)-Y(nx*ny))^2)]); | ||
X = X+pixelsize/2; | ||
Y = Y-pixelsize/2; | ||
end | ||
else | ||
disp('File is not geocoded') | ||
[X,Y] = meshgrid(1:nx,1:ny); | ||
zone = []; | ||
end | ||
|
||
pixelsize=mean([sqrt((X(1)-X(2))^2+(Y(1)-Y(2))^2) sqrt((X(nx*ny-1)-X(nx*ny))^2+(Y(nx*ny-1)-Y(nx*ny))^2)]); | ||
|
||
baddata = mode(data(:)); | ||
badid = find(data==baddata); | ||
data(badid) = NaN; | ||
disp(['setting ' num2str(length(badid)) ' pts with phs=' num2str(baddata) ' to NaN']); | ||
|
||
|
||
datastruct=struct('data',data,'mag',mag,'phs',phs,'X',X,'Y',Y,'pixelsize',pixelsize, ... | ||
'zone',zone,'lambda',lambda,'nx',nx,'ny',ny,'filename',filename, ... | ||
'scale',scale','extrax',extrax,'extray',extray); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
function datastruct = loadLOS_ISCE_MAI(datastruct,losfilename, azo); | ||
|
||
|
||
if(isempty(losfilename)); | ||
filename = datastruct.filename; | ||
c = strsplit(filename,'/'); | ||
pathname = []; | ||
for k = 2:length(c)-1 | ||
pathname=[pathname '/' c{k}]; | ||
end | ||
|
||
losfilename=[pathname '/los.rdr.geo']; | ||
end | ||
clear c k | ||
squint = 0.1; | ||
if(azo==1) | ||
heading = datastruct.heading+squint; | ||
S = zeros(datastruct.ny, datastruct.nx,3); | ||
S(:,:,1)= sind(heading); | ||
S(:,:,2)= cosd(heading); | ||
S(:,:,3)= 0; | ||
else | ||
|
||
nx = datastruct.nx; | ||
ny = datastruct.ny; | ||
extrax = datastruct.extrax; | ||
extray = datastruct.extray; | ||
ox = nx-extrax; | ||
oy = ny-extray; | ||
|
||
fid = fopen(losfilename,'r','native'); | ||
[tmp,count] = fread(fid,[ox*2,oy],'real*4'); | ||
status = fclose(fid); | ||
|
||
look = tmp(1:ox,:); | ||
heading = tmp((ox+1):(ox*2),:); | ||
heading = 90-flipud(heading'); %Puts heading into same convention as ROI_PAC geo_incidence.unw | ||
|
||
look = flipud(look'); | ||
|
||
heading = heading.*pi/180; | ||
look = look.*pi/180; | ||
|
||
id = find(heading==0); | ||
jd = find(heading~=0); | ||
heading(id) = mean(heading(jd)); | ||
look(id) = mean(look(jd)); | ||
|
||
S1 = [sin(heading)]; | ||
S2 = [cos(heading)]; | ||
disp('Making the up-down unit vector zero for MAI') | ||
S3 = [cos(look).*0]; | ||
|
||
S1 = blkdiag(S1,zeros(extray,extrax)); | ||
S2 = blkdiag(S2,zeros(extray,extrax)); | ||
S3 = blkdiag(S3,zeros(extray,extrax)); | ||
badid = find(S1(:)==0); | ||
S1(badid) = S1(1); % set to average in load_los | ||
S2(badid) = S2(1); | ||
S3(badid) = S2(1); | ||
|
||
S(:,:,1) = S1; | ||
S(:,:,2) = S2; | ||
S(:,:,3) = S3; | ||
|
||
end | ||
|
||
datastruct.S=S; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters