please help me out, the code above works when i plot output model but did not work when i plot sensitivities . Error using reshape: To RESHAPE the number of elements must not change. Error in (line 121) rho_sens=reshape(rho_sens,nx,ny);
1 view (last 30 days)
Show older comments
%%%Plot outputmodell, with stations and grid if you want. Or plot
%%%the sensitivities but scale them to reasonable values.
clear all
close all
%%%------------------------------------------------------------------------
%%%Fixed parameter
save_plot='yes';
n_st=1045;
plot_name='Rmt1_rmt';
titel='Rmt1_rmt, $\rho_0$ = 50 \Omega m, $\lambda$ =20'; %%go to 325
titel_sens='Rmt1_rmt, TM';
titel_doi='Profile 2 Kr: DOI, tm';
path1='/home/data/';
f_s=18;
pr1_plot=0;
shift_stat=0;
xshift=0; %
abst_st=10; %Station distance
x_view=[0 200];
stat_1=0;
% % % pr1
%%%x_view=[0 340];
y_view=[0 50];
%%------------------------------------------------------------------------
%%%Calculate Depth of investigation with different methods
%%%Plot 2z*
sens=1; %%%Plot model==0 or sensitivities==1???
plot_zstar=0;
zstar_te=0; %%%tm =0, te=1;
plot_sens=1;
contval_sens=[-4.1,-20];
%shade_sens=1;
shade_sens=1;
alpha_lim=[-3.0, -2.5];
z_sens=4;
%%%if z_sens=0, then this will not be done
plot_doi=0; %%%Plot DOI
plot_doi_fig=0; %%%PLot DOI in a seperate figure
save_plot_doi='no';
conval=[0.2];
plot_blockmodel=0; %%%plot the model blocks
plot_reldiff_fig=0; %%%plot reltaive differences betw. m1 and m2
save_plot_reldiff='no';
%%------------------------------------------------------------------------
%%%Which Colorbar and colormap??
%colmap=(func_colormaps);
colmap=flipud(jet);%colormap(jet);
close all
col_log=1; %PLot logarithmic colormap=1,no=0
col_lim='auto';
%col_lim=[0 600]; %%%specify colorlimits if not set to auto it
n_ytic_colbar=9;
%col_lim=[-4.5 -1.5];
col_lim=[log10(10) log10(100)];
col_lim_sens=[-4.5 -1.5];
%%%plot grid
pl_grid=0; %%%plot the f*** grid man=1, no=0
linestyle_gr='-'; %%%Line style grid
linewidth_gr=0.1; %%%line width grid
linecol_gr='yel2z*low';
%%------------------------------------------------------------------------
%%%------------------------------------------------------------------------
%%%Read the Inversion result to plot/or read sensiti
% pathname='m_fwd_models/inv_1/';
% filename='model_nlcg2_fast.dat';
[filename,pathname11]=uigetfile([path1,'model_nlcg2_fast.dat'],'Inversion-model-result or sens');
fid = fopen([pathname11 filename], 'r');
nx=fscanf(fid, '%d', 1);
ny=fscanf(fid, '%d', 1);
breite=fscanf(fid, '%f', nx);
dicke=fscanf(fid, '%f', ny);
tmp=nx*ny;
rho=fscanf(fid, '%f', tmp);
%rms_inv=fscanf(fid, '%f', 1);
rms_inv =3.34;
fclose (fid);
clear fid %pathname %filename
if plot_sens==1
[filename,pathname1]=uigetfile([path1,'sens.dat'],'sens');
fid = fopen([pathname1 filename], 'r');
nx1=fscanf(fid, '%d', 1);
ny1=fscanf(fid, '%d', 1);
breite1=fscanf(fid, '%f', nx1);
dicke1=fscanf(fid, '%f', ny1);
tmp1=nx1*ny1;
rho_sens=fscanf(fid, '%f', tmp1);
%rms_inv1=fscanf(fid, '%f', 1);
fclose (fid);
clear fid %pathname %filename
%%%---------------------------------------------------------------------
%%%For sensitivities. replace -inf in the .dat file
%%%if (sens==1)
ind_inf1=find(rho_sens<-10000);
rho_sens(ind_inf1)=-1000;
% % % % else
% % % % ind_inf=find(rho<-10000);
% % % % rho(ind_inf)=-1000;
%%%end
%rho_sens=reshape(rho_sens,nx,ny,);
rho_sens=reshape(rho_sens,nx,ny);
end
%%%------------------------------------------------------------------------
%%%Read two inversion Dataset for calculating DOI
if (plot_doi==1 && sens==0)
%%%first inversion result
% pathname='m_fwd_models/inv_1/';
% filename='model_nlcg2_fast.dat';
[filename1,pathname]=uigetfile([path1,'model_nlcg2_fast.dat'],'inversion-model-result for doi 1');
fid = fopen([pathname filename1], 'r');
fscanf(fid, '%d', 1);
fscanf(fid, '%d', 1);
fscanf(fid, '%f', nx);
fscanf(fid, '%f', ny);
tmp1=nx*ny;
rho_doi1=fscanf(fid, '%f', tmp1);
fclose (fid);
clear fid tmp tmp1 %pathname %filename
%%%secon inversion result
[filename1,pathname]=uigetfile([path1,'model_nlcg2_fast.dat'],'inversion-model-result for doi 1');
fid = fopen([pathname filename1], 'r');
fscanf(fid, '%d', 1);
fscanf(fid, '%d', 1);
fscanf(fid, '%f', nx);
fscanf(fid, '%f', ny);
tmp1=nx*ny;
rho_doi2=fscanf(fid, '%f', tmp1);
fclose (fid);
clear fid tmp tmp1 %pathname %filename
end
% % tmp_ind1=find(rho_doi1>1000);
% % tmp_ind2=find(rho_doi2<0.001);
% % rho_doi1(tmp_ind1)=1000;
% % rho_doi2(tmp_ind2)=0.001;
%%%------------------------------------------------------------------------
%%%Read the calc/measured Data for 2z*
%%%Read the data
if (plot_zstar==1 && sens==0)
[filename3,pathname2]=uigetfile([pathname11,'output.dat'],'inversion-data-result for 2z-star');
fid = fopen([pathname2 filename3], 'r');
%n_st=20;
ind_st(1:n_st)=1;
rms(1:n_st)=1;
n_f(1:n_st)=1;
%%%read data in a cellarray data{1,2}(:,6)
data(1,1:n_st)={1};
for i=1:n_st
ind_st(i)=fscanf(fid, '%d', 1);
rms(i)=fscanf(fid, '%f', 1);
n_f(i)=fscanf(fid, '%d', 1);
tmp=fscanf(fid, '%f %f %f %f %f %f %f %f %f %f', [10 n_f(1,i)]);
data(1,i)={tmp'};
end
fclose (fid);
clear fid %pathname %filename
end
%%%------------------------------------------------------------------------
%%%Read the data from the true model for plotting lines
if (plot_blockmodel==1)
[filename1,pathname1]=uigetfile(path1,'blockmodel-index: xl, xr, yl, yr');
fid = fopen([pathname1 filename1], 'r');
n_bl=fscanf(fid,'%g', 1);
ind_xl=fscanf(fid,'%g', [n_bl 1]);
ind_xr=fscanf(fid,'%g', [n_bl 1])+1; %%%plus one is correct
ind_yl=fscanf(fid,'%g', [n_bl 1]);
ind_yr=fscanf(fid,'%g', [n_bl 1])+1;
fclose (fid);
clear fid %pathname %filename
end
%%------------------------------------------------------------------------
%%%Matrix for rho which has nx*ny size for Data Model
rho=reshape(rho,nx,ny);
%%%breite -> profilmeter
x(1,2)=breite(1,1);
for i= 2:size(breite,1)
x(1,i+1) = breite(i,1)+x(1,i);
end
for i = 1:ny+1;
x(i,:)=x(1,:);
end
%%%dicke -> tiefe
y(2,1)=dicke(1,1);
for i= 2:size(dicke,1)
y(i+1,1) = dicke(i,1)+y(i,1);%!!!!!!!!!!!!!!!
end
for i = 1:nx+1;
y(:,i)=y(:,1);
end
%%%The first station is located at profilmeter 0
%%%The Stations are always between adjacent gridlines
%%%Thats sometimes fuzzy
l_profil=(n_st-1)*abst_st;
x_st1=x(1,nx/2+1)-l_profil/2;
%%x_st1=x(1,nx/2+3)-l_profil/2;
% % % if isempty(indx_stat)==0
% % % x_st1=(x(indx_stat(1))+x(indx_stat(1)+1))/2;
% % % end
%%%shift the x-array, so that the first receiver is located at 0m but so
%%%that all the Array symmetrical to the grid.
x=x-x_st1+xshift;
%%%Shift the Receivers a half grid line towards the right
x=x-(x(1,round(nx/2))-x(1,round(nx/2)+1))/2;
x=x-((x(1,round(nx/2))-x(1,round(nx/2)+1))/2*shift_stat);
% % % profile 1
%%%x=x-x_st1+(126.25);
%%%Shift the Receivers a half grid line towards the right
% % % if (isempty(find(0==x(1,:)))~=1)
% % % x=x-(x(1,nx/2)-x(1,nx/2+1))/2;
% % % end
%%%------------------------------------------------------------------------
%%%Resistivity Aray
%%%Make rho have the size (nx+1)*(ny+1) the new boundary blocks have the
%%%value of the neighboring one.
rho(size(rho,1)+1,:)=rho(size(rho,1),:);
rho(:,size(rho,2)+1)=rho(:,size(rho,2));
if plot_sens==1
rho_sens(size(rho_sens,1)+1,:)=rho_sens(size(rho_sens,1),:);
rho_sens(:,size(rho_sens,2)+1)=rho_sens(:,size(rho_sens,2));
end
% % pr1_plot=1;
if pr1_plot==1
rho=flipud(rho);
rho_sens=flipud(rho_sens);
% % % DOI is flipped further down!!!!
end
%%%------------------------------------------------------------------------
%%%colorbar label for sensitivities and logmodel
col_label='\bf{\rho (\Omega \cdot m)}';
if (col_log==1)
rho=log10(rho);
col_label='\bf{$\rho$ ($\Omega$ m)}';
end
if (sens==1)
col_label='\bf{sens}';
if (col_log==1)
rho=log10(abs(rho));
col_label='\bf{(sens)}';
end
end
%%------------------------------------------------------------------------
%%%Calculate DOI out of two inversion results with different starting
%%%models. First one has increasing resistivity, secon one decreasing.
%%%First make a nice matrice out of rho_doi1/2. The should have the
%%%size (nx+1*ny+1)
if (plot_doi==1)
rho_doi1=reshape(rho_doi1,nx,ny);
rho_doi1(size(rho_doi1,1)+1,:)=rho_doi1(size(rho_doi1,1),:);
rho_doi1(:,size(rho_doi1,2)+1)=rho_doi1(:,size(rho_doi1,2));
rho_doi2=reshape(rho_doi2,nx,ny);
rho_doi2(size(rho_doi2,1)+1,:)=rho_doi2(size(rho_doi2,1),:);
rho_doi2(:,size(rho_doi2,2)+1)=rho_doi2(:,size(rho_doi2,2));
if pr1_plot==1;rho_doi1=flipud(rho_doi1);rho_doi2=flipud(rho_doi2); end
rho_doi1=rho_doi1';rho_doi2=rho_doi2';
%%%relativ differences between m1 and m2
diff_m1m2=abs(rho_doi1-rho_doi2)./max(rho_doi1,rho_doi2);
%%%Calculate Cross-Korrelation between each cell of inversion 1 and
%%%inversion 2
%%%C value for each cell, except last 2 border cells on the side and
%%%except 1 boarder cell on the top and bootom.
%%%The correlation is calculated over (x=5) times (y=3) cells
CC(1:ny+1,1:nx+1)=-1;
for j=2:ny
for i=3:nx-1
mean_m1=(sum(sum(rho_doi1(j-1:j+1,i-2:i+2))))/15;
mean_m2=(sum(sum(rho_doi2(j-1:j+1,i-2:i+2))))/15;
CC_1=0;
CC_2a=0;
CC_2b=0;
for l=j-1:j+1
for k=i-2:i+2
tmp1=(rho_doi1(l,k)-mean_m1);
tmp2=(rho_doi2(l,k)-mean_m2);
CC_1=CC_1+(tmp1*tmp2);
CC_2a=CC_2a+tmp1^2;
CC_2b=CC_2b+tmp2^2;
end
end
CC(j,i)=CC_1/sqrt(CC_2a*CC_2b);
end
end
%%%Now only for the boundary: all boundary cells are already set to the
%%%value C=-1. For the upper cells C has to be calculated with less
%%%then 5*3 cells-> only with 5*2 cells.
for i=3:nx-1 %%%skip to cells on the left and right boarder
mean_m1=(sum(sum(rho_doi1(1:2,i-2:i+2))))/10;
mean_m2=(sum(sum(rho_doi2(1:2,i-2:i+2))))/10;
CC_1=0;
CC_2a=0;
CC_2b=0;
for l=1:2
for k=i-2:i+2
tmp1=(rho_doi1(l,k)-mean_m1);
tmp2=(rho_doi2(l,k)-mean_m2);
CC_1=CC_1+(tmp1*tmp2);
CC_2a=CC_2a+tmp1^2;
CC_2b=CC_2b+tmp2^2;
end
end
CC(1,i)=CC_1/sqrt(CC_2a*CC_2b);
end
%%%CC is in the range [-1 1]-> Calculate R in the range [0 1]
%%%R=(1-C/2)
R=(1-CC)/2;
end
%%------------------------------------------------------------------------
%%%Calculate 2z* 2fachen Schwerpunktstiefe
%%%remove 0-lines from output
if plot_zstar==1
for k=1:n_st;
if (zstar_te==1);
index=find(data{k}(:,5)==0.0);
data{k}(index,:)=[];
else
index=find(data{k}(:,1)==0.0);
data{k}(index,:)=[];
end
end
if (zstar_te==1);
col_rho_mess=5;
col_phi_mess=6;
else
col_rho_mess=1;
col_phi_mess=2;
end
if (plot_zstar==1 && sens==0)
zstar(1:n_st)=1;
for i=1:n_st
n_f(i)=size(data{i},1);
f_zs_min=data{1,i}(n_f(i),10);
%%%rho and phi values for min f
rhozs_fmin=data{1,i}(n_f(i),col_rho_mess);
phizs_fmin=abs(data{1,i}(n_f(i),col_phi_mess));
if (rhozs_fmin==0 && phizs_fmin==0);
rhozs_fmin=abs(data{1,i}(n_f(i),col_rho_mess));
phizs_fmin=abs(data{1,i}(n_f(i),col_phi_mess));
end
zstar(i)=sqrt(rhozs_fmin/(2*pi*f_zs_min*4*pi*10^-7))*sind(phizs_fmin);
end
end
end
%%%------------------------------------------------------------------------
%%plotten
scrsz=get(0,'screensize');
fig1=figure('PaperSize',[25 22],'PaperUnits','centimeter' ,...
'Position',[1 1 scrsz(3) scrsz(4)*1/2], 'Color',[1 1 1],...
'colormap',colmap);
% fig1=figure('PaperType','a4','PaperOrientation','Landscape',...
% 'Position',[1 1 scrsz(3)*2/3 scrsz(4)*3/5], 'Color',[1 1 1],...
% 'colormap',colmap);
%colormap(jet);
%%%------------------------------------------------------------------------
%%%uere Axen, unsichtbar
%handle_1 = axes('Position',[0.03 0.03 0.91 0.96],'Visible','off');
handle_1 = axes('Position',[0 0 0.87 0.1],'Visible','off');
%%%Plot Text and legend ausserhalb der Achsen
hold(handle_1,'on')
%text(1.045,0.4,col_label,'FontSize',f_s,'Rotation',90);
%axis(handle_1,[0.0 1.0 0.0 1.0])
text(1.005,0.4,col_label,'FontSize',14,'fontweight','bold','Interpreter','latex')%,'Rotation',90);
axis(handle_1,[0.0 1.0 0.0 1.0])
box('on')
grid off
%hold(handle_1,'off')
%%%------------------------------------------------------------------------
%%innere axen sichtbar
ax=axes('Position',[.06 .15 .85 .65],...
'layer', 'top', 'YDir', 'Reverse');
%%%position, [x_links, y_oben, breite, hoehe ]
axis(ax,[x_view y_view]...
,'on')
set(ax, 'layer', 'top', 'YDir', 'Reverse', 'XDir', 'normal','fontsize',f_s,'fontweight','bold')
grid off
%%%------------------------------------------------------------------------
% BESCHRIFTUNG
%title(strcat(titel,', rms=',num2str(round(rms_inv*100)/100)),'Interpreter','Latex','FontSize',f_s,'fontweight','bold');
title('$\rho_0=50$ $\Omega$ m, $\lambda$ = 20, RMS = 3.39 $\%$','Interpreter','latex');
xlabel('\bf{x (m)}','FontSize',f_s,'fontweight','bold');
ylabel('\bf{z (m)}','FontSize',f_s,'fontweight','bold');
%%%------------------------------------------------------------------------
% ind_s=[47,59,67,75,83,95,103,119,127,143,175,195,215,235];
% x_st=x(1,ind_s);
% y_st(1:size(ind_s,2))=0;
%
% rho=rho';
% rho_topo=rho;
% inc_topo=1;
% if inc_topo==1
% kk=1;
% topo_val_st=[0,1,1,2,3,4,4,4,3,4,3,2,1,0];
% ind_s_1=[47:1:235];
% topo_val = interp1(ind_s,topo_val_st,ind_s_1);
% for i=1:size(topo_val,2)-1
% ind_zz=find(y(:,1)<=topo_val(i));
% ind_zz(1:end-1)=[];
% rho_topo(1:ind_zz,ind_s_1(i):ind_s_1(i+1))=nan;
% rho_topo(ind_zz:end,ind_s_1(i):ind_s_1(i+1))=rho(1:end-ind_zz+1,ind_s_1(i):ind_s_1(i+1));
% if ind_s_1(i)==ind_s(kk)
% ind_zz_1=find(y(:,1)<=topo_val_st(kk));
% ind_zz_1(1:end-1)=[];
% y_st(kk)=y(ind_zz_1,1);
% kk=kk+1;
% end
%
% end
%
%
% rho=rho_topo';
% end
%%interpolate on new finer grid
x_ip=[-5:1:700];
y_ip=[0:1:100];
[xx_ip,yy_ip]=meshgrid(x_ip,y_ip);
rho1=interp2(x,y,rho',xx_ip,yy_ip,'spline')';
%rho1=fliplr(rho1);
%%make topo
% ind_s=[47,59,67,75,83,95,103,119,127,143,175,195,215,235];
% x_st=x(1,ind_s);
% y_st(1:size(ind_s,2))=0;
rho1=rho1';
rho_topo=rho1;
inc_topo=0;
if inc_topo==1
kk=1;
topo_val_st=[0,1,1,2,3,4,4,4,3,4,3,2,1,0];% in metre for every station
ind_s_1=[47:1:235];
ind_s_1mod=find(x_ip==x(:,1));
topo_val = interp1(ind_s,topo_val_st,ind_s_1mod);
for i=1:size(topo_val,2)-1
ind_zz=find(y(:,1)<=topo_val(i));
ind_zz(1:end-1)=[];
rho_topo(1:ind_zz,ind_s_1(i):ind_s_1(i+1))=nan;
rho_topo(ind_zz:end,ind_s_1(i):ind_s_1(i+1))=rho(1:end-ind_zz+1,ind_s_1(i):ind_s_1(i+1));
if ind_s_1(i)==ind_s(kk)
ind_zz_1=find(y(:,1)<=topo_val_st(kk));
ind_zz_1(1:end-1)=[];
y_st(kk)=y(ind_zz_1,1);
kk=kk+1;
end
end
rho=rho_topo';
end
hold on
pcolor(xx_ip,yy_ip,rho1) %+17.5 is correct, see old script
%pcolor(xx_ip+17.5,yy_ip,fliplr(rho1));%in case need to flip
% pcolor(ax,xx_ip,yy_ip,rho1');
shading interp
grid off
%conval=[0.2, 0.3];
%caxis(col_lim);
%caxis(caxis) %%%this freezes the colorlimit
if (plot_sens==1)
rho_sens1=rho_sens';
rho_sens1(1:7,:)=-1.5;
grid_space=abs(x(1,nx/2)-x(1,nx/2+1));
ind_zzz=find(y(:,1)>z_sens);
if (z_sens>0)
rho_sens1(1:ind_zzz(1),round(nx/2)-(l_profil+4*grid_space)/2/grid_space-1:round(nx/2)+(l_profil+4*grid_space)/2/grid_space-1)=-1.5;
end
if shade_sens==1
% % % alpha_lim=[-3.5, -3.0];
alim(alpha_lim)
alpha(rho_sens1)
end
[C,h]=contour(gca,x,y,rho_sens1,contval_sens,'-w','linewidth',3.0);
%%%clabel(contval)
%%%clabel(C,h,'LabelSpacing',720)
% clabel(C,h)
end
if (plot_doi==1)
[ccc,hhh]=contour(ax,x,y,R,conval,'--k','linewidth',3.0);
%%%set(cont,'ShowText','on')
%%%clabel(ccc,hhh,'LabelSpacing',72*10);
end
% % % text(5,15,'DOI','Fontsize',f_s,'Fontweight','bold')
%%%------------------------------------------------------------------------
%%%grid plotten
if (pl_grid==1)
line(x,y,'Color',linecol_gr,'LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
line(x',y','Color',linecol_gr,'LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
end
%%%------------------------------------------------------------------------
%%%plot the blockmodel
if (plot_blockmodel==1)
xl=x(1,ind_xl)';
xr=x(1,ind_xr)';
yl=y(ind_yl,1);
yr=y(ind_yr,1);
line([xl,xr]',[yl,yl]','Color','black','LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
line([xl,xr]',[yr,yr]','Color','black','LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
line([xl,xl]',[yl,yr]','Color','black','LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
line([xr,xr]',[yl,yr]','Color','black','LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
end
%%%------------------------------------------------------------------------
%%%The position is given with regard to the inner axes
min_rho=min(min(min(rho)));
max_rho=max(max(max(rho)));
if strmatch('auto',col_lim,'exact')
ytic_colbar=[min_rho:(max_rho-min_rho)/n_ytic_colbar:max_rho];
col_lim=[ytic_colbar(1) ytic_colbar(end)];
else
ytic_colbar=[col_lim(1):(col_lim(2)-col_lim(1))/n_ytic_colbar:col_lim(2)];
col_lim=[ytic_colbar(1) ytic_colbar(end)];
end
caxis(col_lim);
%col_ax=colorbar('peer',gca,[0.92 0.15 0.02 0.75],'ytick',ytic_colbar,'fontsize',f_s,'fontweight','bold');
col_ax=colorbar('ytick',ytic_colbar,'fontsize',f_s,'fontweight','bold');
% caxis(caxis)
if (col_log==1)
a=get(col_ax,'ytick');
set(col_ax,'Yticklabel',(round((10.^a)*10)/10),'fontsize',f_s,'fontweight','bold');
%%%caxis(caxis);
end
% % % col_ax=colorbar([0.92 0.1 0.02 0.8],'fontsize',12,'fontweight','bold');
% % % % caxis(col_lim);
% % % if (col_log==1)
% % % tick=get(col_ax,'ytick');
% % % set(col_ax,'Yticklabel',round((10.^tick)));
% % % end
%%%------------------------------------------------------------------------
%%%stationen Plotten
% % % PROFILE 1
% ind_s=[47,59,67,75,83,95,103,119,127,143,175,195,215,235];
% x_st=x(1,ind_s);
% y_st(1:size(ind_s,2))=0;
x_st=0:abst_st:l_profil;
x_st=x_st+stat_1;
%x_st= [0 10 20 25 30 35 40 45 50 55 60 65 70 75 80 90 100];
y_st(1:size(x_st,2))=0;
scatter(x_st,y_st-0.7,60,'kv','filled');
%%%------------------------------------------------------------------------
%%%plot 2*zstar
if (plot_zstar==1 && sens==0)
plot(x_st,2*zstar,'-.r','linewidth',2.0)
end
%%%------------------------------------------------------------------------
box on
grid off
hold off
%%%------------------------------------------------------------------------
if (strcmp(save_plot,'yes')==1)
file_plot=strcat(pathname11,'/',plot_name);
set(gcf,'PaperPositionMode','auto');
%saveas(gcf,[file_plot,'_model'],'fig')
%print('-dpdf','-r300',[file_plot,'alpha.pdf'])
%print('-depsc',[file_plot,'_model.eps'])
print('-djpeg','-r300',[file_plot,'_model.jpeg'])
% set(gcf,'paperorientation','landscape','Papertype','a4');
% print('-dpdf','-r300',[file_plot,'alpha.pdf'])
end
%%------------------------------------------------------------------------
%%%plot the sensitivity
if plot_sens==1;
scrsz=get(0,'screensize');
fig1=figure('PaperSize',[25 22],'PaperUnits','centimeter' ,...
'Position',[1 1 scrsz(3) scrsz(4)*2/5], 'Color',[1 1 1],...
'colormap',colmap);
% fig1=figure('PaperType','a4','PaperOrientation','Landscape',...
% 'Position',[1 1 scrsz(3)*2/3 scrsz(4)*3/5], 'Color',[1 1 1],...
% 'colormap',colmap);
%colormap(jet);
%%%------------------------------------------------------------------------
%%%uere Axen, unsichtbar
%handle_1 = axes('Position',[0.03 0.03 0.91 0.96],'Visible','off');
handle_1 = axes('Position',[0 0 0.87 0.1],'Visible','off');
%%%Plot Text and legend ausserhalb der Achsen
hold(handle_1,'on')
%text(1.045,0.4,'\bf{sensitivity}','FontSize',f_s,'Rotation',90);
%axis(handle_1,[0.0 1.0 0.0 1.0])
text(1.005,0.4,'\bf{sens}','FontSize',14,'fontweight','bold')%,'Rotation',90);
axis(handle_1,[0.0 1.0 0.0 1.0])
box('on')
grid off
%hold(handle_1,'off')
%%%------------------------------------------------------------------------
%%innere axen sichtbar
ax=axes('Position',[.06 .15 .85 .75],...
'layer', 'top', 'YDir', 'Reverse');
%%%position, [x_links, y_oben, breite, hoehe ]
axis(ax,[x_view y_view]...
,'on')
set(ax, 'layer', 'top', 'YDir', 'Reverse','fontsize',f_s,'fontweight','bold','Interpreter','latex')
grid off
%%%------------------------------------------------------------------------
% BESCHRIFTUNG
title(strcat(titel_sens,', rms=',num2str(round(rms_inv*100)/100)),'FontSize',f_s,'fontweight','bold','Interpreter','latex');
xlabel('\bf{x (m)}','FontSize',f_s,'fontweight','bold');
ylabel('\bf{z (m)}','FontSize',f_s,'fontweight','bold');
%%%------------------------------------------------------------------------
hold on
rho_sens=rho_sens;
%%%rho_sens(1:7,:)=-1.5;
pcolor(ax,x,y,rho_sens');
shading flat
grid off
caxis(col_lim_sens);
%caxis(caxis) %%%this freezes the colorlimit
[C,h]=contour(gca,x,y,rho_sens',[-3.5, -3.0, -2.5],'-w','linewidth',3.0);
%%%clabel(contval)
%clabel(C,h,'LabelSpacing',720)
clabel(C,h)
%%%------------------------------------------------------------------------
%%%grid plotten
if (pl_grid==1)
line(x,y,'Color',linecol_gr,'LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
line(x',y','Color',linecol_gr,'LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
end
%%%------------------------------------------------------------------------
ytic_colbar=[col_lim_sens(1):(col_lim_sens(2)-col_lim_sens(1))/(n_ytic_colbar+1):col_lim_sens(2)];
col_lim=[ytic_colbar(1) ytic_colbar(end)];
caxis(col_lim_sens);
col_ax=colorbar('ytick',ytic_colbar,'fontsize',f_s,'fontweight','bold');
%%%------------------------------------------------------------------------
%%%stationen Plotten
% % % PROFILE 1
% % % ind_s=[47,59,67,75,83,95,103,119,127,f_s3,175,195,215,235];
% % % x_st=x(1,ind_s);
% % % y_st(1:size(ind_s,2))=0;
x_st=0:abst_st:l_profil;
%x_st= [0 10 20 25 30 35 40 45 50 55 60 65 70 75 80 90 100];
y_st(1:size(x_st,2))=0;
scatter(x_st,y_st-0.7,60,'kv','filled');
%%%------------------------------------------------------------------------
box on
grid off
hold off
%%%------------------------------------------------------------------------
if (strcmp(save_plot,'yes')==1)
file_plot=strcat(pathname11,'/',plot_name);
set(gcf,'PaperPositionMode','auto');
%saveas(gcf,[file_plot,'_sens'],'fig')
%%print('-dpdf','-r300',[file_plot,'alpha.pdf'])
%%%print('-depsc2',[file_plot,'.eps'])
%print('-depsc2',[file_plot,'_sens.eps'])
print('-djpeg','-r300',[file_plot,'_sens.jpeg'])
% set(gcf,'paperorientation','landscape','Papertype','a4');
% print('-dpdf','-r300',[file_plot,l'alpha.pdf'])
end
end
%%%------------------------------------------------------------------------
%%plotten of doi
if (plot_doi_fig==1)
scrsz=get(0,'screensize');
figure('PaperSize',[25 22],'PaperUnits','centimeter' ,...
'Position',[1 1 scrsz(3) scrsz(4)*2/5], 'Color',[1 1 1],...
'colormap',colmap);
% fig1=figure('PaperType','a4','PaperOrientation','Landscape',...
% 'Position',[1 1 scrsz(3)*2/3 scrsz(4)*3/5], 'Color',[1 1 1],...
% 'colormap',colmap);
%colormap(jet);
%%%------------------------------------------------------------------------
%%%uere Axen, unsichtbar
handle_1 = axes('Position',[0.03 0.03 0.91 0.96],'Visible','off');
%%%Plot Text and legend ausserhalb der Achsen
hold(handle_1,'on')
text(1.045,0.45,'DOI-index','FontSize',f_s,'fontweight','bold','Rotation',90);
axis(handle_1,[0.0 1.0 0.0 1.0])
box('on')
grid off
%hold(handle_1,'off')
%%%------------------------------------------------------------------------
%%innere axen sichtbar
axes('Position',[.06 .1 .85 .8],...
'layer', 'top', 'YDir', 'Reverse')
%%%position, [x_links, y_oben, breite, hoehe ]
axis(gca,[x_view y_view]...
,'on')
set(gca, 'layer', 'top', 'YDir', 'Reverse','fontsize',f_s,'fontweight','bold')
grid off
%%%------------------------------------------------------------------------
% BESCHRIFTUNG
%title('DOI: correlation of two inversion models','FontSize',f_s,'fontweight','bold');
title(strcat(titel_doi,', rms=',num2str(round(rms_inv*100)/100)),'FontSize',f_s,'fontweight','bold');
xlabel('\bf{x (m)}','FontSize',f_s,'fontweight','bold');
ylabel('\bf{z (m)}','FontSize',f_s,'fontweight','bold');
%%%------------------------------------------------------------------------
hold on
pcolor(x,y,R);
shading flat
grid off
contour(x,y,R,conval,'-w','linewidth',2.0);
%%%------------------------------------------------------------------------
%%%grid plotten
if (pl_grid==1)
line(x,y,'Color',linecol_gr,'LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
line(x',y','Color',linecol_gr,'LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
end
%%%------------------------------------------------------------------------
%%%The position is given with regard to the inner axes
colorbar('peer',gca,[0.92 0.1 0.02 0.8],'fontsize',f_s,'fontweight','bold');
caxis([0 1])
%%%------------------------------------------------------------------------
%%%plot 2*zstar
if (plot_zstar==1 && sens==0)
plot(x_st,2*zstar,'-.w','linewidth',2.0)
end
%%%------------------------------------------------------------------------
%%%stationen Plotten
x_st=0:abst_st:l_profil;
y_st(1:size(x_st,2))=0;
scatter(x_st,y_st-0.7,60,'kv','filled');
%%%------------------------------------------------------------------------
Box on
grid off
hold off
%%%------------------------------------------------------------------------
if (strcmp(save_plot_doi,'yes')==1)
file_plot=strcat(pathname11,'/',plot_name);
set(gcf,'PaperPositionMode','auto');
%saveas(gcf,[file_plot,'_doi'],'fig')
%print('-dpdf','-r100',file_plot)
%print('-depsc2',[file_plot,'_doi.eps'])
print('-djpeg','-r150',[file_plot,'_doi.jpeg'])
end
end
%%%------------------------------------------------------------------------
%%plotten of relative difference
if (plot_reldiff_fig==1)
scrsz=get(0,'screensize');
figure('PaperSize',[25 22],'PaperUnits','centimeter' ,...
'Position',[1 1 scrsz(3) scrsz(4)*2/5], 'Color',[1 1 1],...
'colormap',colmap);
% fig1=figure('PaperType','a4','PaperOrientation','Landscape',...
% 'Position',[1 1 scrsz(3)*2/3 scrsz(4)*3/5], 'Color',[1 1 1],...
% 'colormap',colmap);
%colormap(jet);
%%%------------------------------------------------------------------------
%%%uere Axen, unsichtbar
handle_1 = axes('Position',[0.03 0.03 0.91 0.96],'Visible','off');
%%%Plot Text and legend ausserhalb der Achsen
hold(handle_1,'on')
text(1.045,0.4,'relative difference','FontSize',f_s,'fontweight','bold','Rotation',90);
axis(handle_1,[0.0 1.0 0.0 1.0])
Box('on')
grid off
%hold(handle_1,'off')
%%%------------------------------------------------------------------------
%%innere axen sichtbar
axes('Position',[.06 .1 .85 .8],...
'layer', 'top', 'YDir', 'Reverse')
%%%position, [x_links, y_oben, breite, hoehe ]
axis(gca,[x_view y_view]...
,'on')
set(gca, 'layer', 'top', 'YDir', 'Reverse','fontsize',f_s,'fontweight','bold')
grid off
%%%------------------------------------------------------------------------
% BESCHRIFTUNG
title('relative difference between two models','FontSize',f_s);
xlabel('\bf{x (m)}','FontSize',f_s,'fontweight','bold');
ylabel('\bf{z (m)}','FontSize',f_s,'fontweight','bold');
%%%------------------------------------------------------------------------
hold on
pic=pcolor(x,y,diff_m1m2);
shading flat
grid off
contour(x,y,R,conval,'-w','linewidth',2.0)
%%%------------------------------------------------------------------------
%%%grid plotten
if (pl_grid==1)
line(x,y,'Color',linecol_gr,'LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
line(x',y','Color',linecol_gr,'LineWidth',linewidth_gr,'LineStyle',linestyle_gr);
end
%%%------------------------------------------------------------------------
%%%The position is given with regard to the inner axes
colorbar('peer',gca,[0.92 0.1 0.02 0.8],'fontsize',f_s,'fontweight','bold');
caxis([0 1])
%%%------------------------------------------------------------------------
%%%plot 2*zstar
if (plot_zstar==1 && sens==0)
plot(x_st,2*zstar,'-.w','linewidth',2.0)
end
%%%------------------------------------------------------------------------
%%%stationen Plotten
x_st=0:abst_st:l_profil;
y_st(1:size(x_st,2))=0;
scatter(x_st,y_st-0.7,60,'kv','filled');
%%%------------------------------------------------------------------------
Box on
grid off
hold off
if (strcmp(save_plot_reldiff,'yes')==1)
file_plot=strcat(pathname1,'/',plot_name);
set(gcf,'PaperPositionMode','auto');
%print('-dpdf','-r100',file_plot)
%print('-depsc2',[file_plot,'_reldiff.eps'])
print('-djpeg','-r300',[file_plot,'_reldiff.jpeg'])
end
end
%%%------------------------------------------------------------------------
%%%Station index
% station_ind(1:n_st)=1;
% for i=1:n_st
% station_ind(i)=find(x_st(i)<=x(1,:),1)-1;
% end
% stations=station_ind';
% io=fopen(strcat(pathname,'/','mackie.control'),'a+');
% fprintf(io,'%d \n' ,stations);
% fclose(io)
0 Comments
Answers (1)
Walter Roberson
on 20 Nov 2017
You have
tmp1=nx1*ny1;
rho_sens=fscanf(fid, '%f', tmp1);
[...]
rho_sens=reshape(rho_sens,nx,ny);
However, it is not certain that nx == nx1 and ny1 == ny . You do not have any test to check that so we must assume that it is possible that they are different.
Also, fscanf(fid, '%f', tmp1) is a request to read at most tmp1 numbers from the file. If the file contains fewer than that then whatever is in the file is returned. You are not testing to be sure you got as many as you expected.
2 Comments
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!