📄 plotseisva.m
字号:
function plotseisva(hax,smat,t,x,ampflag,clip,scaleopt,c)
% PLOTSEISVA ... Image display utility for seismic matrices
%
% plotimage(hax,smat,t,x,ampflag)
% plotimage(hax,smat,t,x)
% plotimage(hax,smat,t)
% plotimage(hax,smat)
%
% PLOTIMAGE does a quick plot of a seismic matrix in a figure window
% (made by plotimage). By default, it plots the seismic matrix in gray levels
% using the seisclrs colormap.
%
% smat ... the seismic matrix to be plotted. Traces are assumed stored in
% the columns smat.
% t ... time coordinates of traces.
% ****** default 1:nrows where nrows = number of rows in smat ****
% x ... x coordinates of the traces
% ****** default 1:ncols where ncols=number of columns *****
% ampflag ... 1->independent, 2->master, 3->slave
% ****************** default =0 *******************
%
%
% NOTE: Scaling options, colormap, and picking are controlled by defining 8 global variables in
% your base workspace and setting their value as needed. The variables are SCALE_OPT,
% NUMBER_OF_COLORS, GRAY_PCT, CLIP, COLOR_MAP, NOBRIGHTEN. The easiest thing to do is to put their
% declarations in your startup.m file:
%
% global SCALE_OPT NUMBER_OF_COLORS GRAY_PCT CLIP COLOR_MAP NOBRIGHTEN PICKS PICKCOLOR XAXISTOP
% You can also simply type this command at the matlab prompt. And then assign values to these
% variables. The default for these parameters is
% is 2, 64, 50, 4, 'seisclrs', 0, [], 'r', 0
%
% SCALE_OPT=1 ... the plotimage window begins in mean scaling mode with a clip level of 4
% =2 ... the plotimage window begins in maximum scaling mode (no clipping).
% Note: only SCALE_OPT=2 is a true amplitude display, but see also GRAY_PCT.
% *************** defaults to 2 if no global is found ***************
% NUMBER_OF_COLORS ... this integer value sets the number of colors (gray levels usually)
% Use a bigger number for more detail, but beware that it takes longer to compute.
% *************** defaults to 64 if no global is found ***************
% GRAY_PCT=x ... Should be a number between 1 and 100. This affects how the seisclrs colomap
% is built. When GRAY_PCT=100, you get a true linear gray scale. For a true-amplitude
% display, you should use GRAY_PCT=100 and SCALE_OPT=2. When GRAY_PCT is say, 20, it
% means that then first 40% of the gray levels are set to black and the last 40% to white.
% Only in the middle 20% to you get a gradient from black to white. This accomplishes a
% display that is visually similar to wiggle trace in that the positives tend to be all
% black and the negatives all white. It is a kind of clipping.
% *************** defaults to 50 if no global is found ***************
% CLIP ... data clip level in standard deviations from the mean
% *************** defaults to 4 if no global is found ***************
% COLOR_MAP ... string with the name of the colormap to use
% *************** defaults to SEISCLRS if no global is found ***************
% NOBRIGHTEN ... 0 means the seisclrs colormap is automatically brightened
% ... 1 means the seisclrs colormap is left as a clipped linear ramp
% *************** defaults to 0 if no global is found ***************
% PICKCOLOR ... color to draw picks in. The default red works well with the seisclrs
% colormap. Other colors may be needed for other colormaps.
% *************** defaults to 'r' if no global is found ***************
% PICKS ... as you make picks, they accumulate in this array. The array is 2*n-by-2 where n
% is the number of picks. A given pick adds two rows to PICKS for the two points
% that define the start and end of the line segment. The first column containes the
% x (horizontal) coordinates and the second is the y (vertical) coordinates.
% Unlike the other globals, it is not wise to assign values to PICKS. Rather, simply
% retrieve the coordinates in PICKS by assigning them to local variables.
% XAXISTOP ... if 1, put the x axis on top. 0 means on bottom.
% *************** defaults to 0 if no global is found ***************
%
% There are two picking modes, Pick(O) and Pick(N). The 'O' and 'N' stand for old and new. This
% signifies that invoking Picks(N) begins a new pickset by clearing the existing PICKS matrix
% and deleting any picks drawn on top of the plot. Picks(O) simply continues picking by adding
% to the existing pickset. This is useful when picking is interrupted to zoom the display and
% then it is desired to resume picking.
%
% The two basic plot modes, mean and maximum scaling, are described below. Mean scaling is
% best for real data (with a large dynamic range) while maximum scaling is preferred for
% synthetic when you want an accurate display of amplitudes.
%Mean scaling (SCALE_OPT=1)... The mean and standard deviation of all samples are computed.
% samples>= mean+CLIP*stddev are clipped (set equal to mean+CLIP*stddev).
% (The same is done for negative samples which are set to mean -CLIP*stddev).
% These two extremes are mapped to the ends of the color map and all intermed
% values are displayed linearly.
%Maximum scaling (SCALE_OPT=2) ... The maximum absolute value of the data is computed (say mxs).
% The extremes of the colormap are then assigned to +/- mxs and all intermed
% values are displayed linearly. There is no clipping but the display may
% be dominated by any large values.
%
% Each plotimage window can also be set to the status of "independent", "master", or "slave". This
% refers to the method by which the maximum absolute value and standard deviations of the data
% are obtained. For both "independent" and "master" these numbers are measured from the input
% data while for the "slave" case the numbers are the same as for the most recent plotimage window
% that is declared as "master". This allows two plotimage windows to be displayed in true relative
% amplitude with respect to one another by setting one to be "master" and the other to be "slave". Note
% that if the identity of the "master" window is changed, any "slave" windows will not automatically refresh
% themselves. To do this, you must reselect the "slave" option after the new "master" window is declared.
%
% G.F. Margrave, CREWES Project, U of Calgary, 1996, 1999, and 2000
%
% NOTE: It is illegal for you to use this software for a purpose other
% than non-profit education or research UNLESS you are employed by a CREWES
% Project sponsor. By using this software, you are agreeing to the terms
% detailed in this software's Matlab source file.
% BEGIN TERMS OF USE LICENSE
%
% This SOFTWARE is maintained by the CREWES Project at the Department
% of Geology and Geophysics of the University of Calgary, Calgary,
% Alberta, Canada. The copyright and ownership is jointly held by
% its author (identified above) and the CREWES Project. The CREWES
% project may be contacted via email at: crewesinfo@crewes.org
%
% The term 'SOFTWARE' refers to the Matlab source code, translations to
% any other computer language, or object code
%
% Terms of use of this SOFTWARE
%
% 1) Use of this SOFTWARE by any for-profit commercial organization is
% expressly forbidden unless said organization is a CREWES Project
% Sponsor.
%
% 2) A CREWES Project sponsor may use this SOFTWARE under the terms of the
% CREWES Project Sponsorship agreement.
%
% 3) A student or employee of a non-profit educational institution may
% use this SOFTWARE subject to the following terms and conditions:
% - this SOFTWARE is for teaching or research purposes only.
% - this SOFTWARE may be distributed to other students or researchers
% provided that these license terms are included.
% - reselling the SOFTWARE, or including it or any portion of it, in any
% software that will be resold is expressly forbidden.
% - transfering the SOFTWARE in any form to a commercial firm or any
% other for-profit organization is expressly forbidden.
%
% END TERMS OF USE LICENSE
global SCALE_OPT NUMBER_OF_COLORS GRAY_PCT CLIP COLOR_MAP NOBRIGHTEN PICKS PICKCOLOR XAXISTOP
if(isempty(NOBRIGHTEN)) nobrighten=0; else nobrighten=NOBRIGHTEN; end
if (isempty(SCALE_OPT)) scaleopt=2; else scaleopt=SCALE_OPT; end %default to max scaling
if (isempty(NUMBER_OF_COLORS)) number_of_colors=64;
else number_of_colors=NUMBER_OF_COLORS; end %default to 64 gray levels
if (isempty(GRAY_PCT)) gray_pct=50; else gray_pct=GRAY_PCT; end %default to 50% gray transition
if (isempty(CLIP)) clip=4; else clip=CLIP; end %default to clip of 4
if (isempty(COLOR_MAP)|strcmp(COLOR_MAP,'seisclrs'))
clrmap=seisclrs(number_of_colors,gray_pct);
else
eval(['clrmap=' COLOR_MAP '(' int2str(number_of_colors) ');']);
end
if (isempty(PICKCOLOR))
PICKCOLOR='r';
end
if (isempty(XAXISTOP))
XAXISTOP=0;
end
gray_pct=round(gray_pct); %force an integer
if( nargin < 1 | ~isstr(smat) )
action='init';
else
action = smat;
end
if(strcmp(action,'init'))
if(nargin<1)
% do a demo
%Make a fake reflectivity
t=0:.002:1.0;
r=randn(size(t)).^5;
%make a ricker wavelet
tw=-.1:.002:.1;
arg=(pi*15*tw).^2;
w=(1-2.*arg).*exp(-arg);
%convolve
s=conv(r,w);
s=s(51:length(t)+50)';
s=s/max(s); %normalize
smat=s*ones(1,20);
end
if(nargin<4)
ampflag=1;
end
if(nargin<3)
ncols=size(smat,2);
x=1:ncols;
end
if(nargin<2)
nrows=size(smat,1);
t=1:nrows;
end
if(length(t)~=size(smat,1))
error(' length of ''time'' coordinate vector incompatible with seismic matrix');
end
if(length(x)~=size(smat,2))
error(' length of ''space'' coordinate vector incompatible with seismic matrix');
end
clips=[30 25 20 15 10 9 8 7 6 5 4 3 2 1 .5 .25 .1 .05 .01 .005 .001];
iclip=near(clips,clip);
clip=clips(iclip); %make sure we have a sanctioned value
if(length(x)>1)
bnds=(max(x)-min(x))/(length(x)+1);
else
bnds=max(smat-min(smat))/2;
end
figure;
%
colormap(clrmap)
%set(gca,'ydir','reverse');
%scale the image
clrmap=get(gcf,'colormap');
[nkols,m]=size(clrmap);
mxs=full(max(max(abs(smat))));
%determine clipping
smean=full(mean(mean(smat)));
stddev=full(sqrt( sum(sum((smat-smean).^2 ) )...
/prod(size(smat))));
disp(['data maximum: ' num2str(full(mxs))])
disp(['data mean: ' num2str(full(smean))])
disp(['data stddev: ' num2str(full(stddev))])
smean2=smean;
mxs2=mxs;
stddev2=stddev;
%smean2, mxs2, and stddev2 are actually used for scaling.
if(ampflag==2)
global SMEAN STDDEV MXS
SMEAN=smean;
STDDEV=stddev;
MXS=mxs;
elseif(ampflag==3)
global SMEAN STDDEV MXS
smean2=SMEAN;
stddev2=STDDEV;
mxs2=MXS;
end
disp(['number of gray levels ' int2str(number_of_colors)])
disp(['Percentage of gray transition ' int2str(gray_pct)])
if( scaleopt ==1) %mean scaling
if(~isnan(clip))
mxsprime=min([smean2+clip*stddev2,mxs2]);
end
mns=-mxsprime;
disp(['mean scaling ']);
disp(['data clipped outside or mean +/- '...
num2str(clip) ' standard deviations ']);
disp(['sigma = ' num2str(full(stddev2))])
seis = (smat -mns)/(mxsprime-mns)*(nkols-1)+1;
clear smat
elseif( scaleopt==2 )
mns=-mxs;
%mns=0;
disp(['max scaling ']);
seis = (smat -mns)/(mxs-mns)*(nkols-1)+1;
clear smat
else
error('invalid scaling option');
end
smat=[];
ix=1:length(x);
dx=x(2)-x(1);
dt=t(2)-t(1);
if(dx~=(x(3)-x(2)))
dx=0;
end
if(dt~=(t(3)-t(2)))
dt=0;
end
hi=image(x,t,seis(:,ix));
%install zooming
selboxinit('plotimage(''zoom'')',1);
set(gcf,'name','Seismic Image Plot, Simplezooming installed (Use MB1)')
%put the x axis on top
if(XAXISTOP)
set(gca,'xaxislocation','top')
end
%make a few buttons
sep=.005;
ht=.05;
wd=.11;
x=sep;
hzoompick=uicontrol('style','popupmenu',...
'string','Zoom|Pick(O)|Pick(N)',...
'units','normalized','tooltipstring','Define mouse action as zoom or pick',...
'position',[x 0 wd ht],'callback','plotimage(''zoompick'')');
x=x+wd+sep;
wd=.18;
hflip=uicontrol('style','popupmenu',...
'string','Normal Polarity|Reverse Polarity',...
'units','normalized','tooltipstring','Set display polarity',...
'position',[x 0 wd ht],'callback','plotimage(''flip'')',...
'userdata',1);
x=x+wd+sep;
wd=.05;
fsize=get(0,'factoryuicontrolfontsize');
black=[0 0 0];white=[1 1 1];
hbrighten=uicontrol('style','pushbutton','fontsize',fsize/3,'string','brt',...
'units','normalized','tooltipstring','Brighten the image','backgroundcolor',white,'foregroundcolor',black,...
'position',[x 0 wd ht],'callback','brighten(.5)','visible','off');
x=x+wd+sep;
hdarken=uicontrol('style','pushbutton','fontsize',fsize/3,'string','drk',...
'units','normalized','tooltipstring','Darken the image','backgroundcolor',black,'foregroundcolor',white,...
'position',[x 0 wd ht],'callback','brighten(-.5)','visible','off');
x=x-wd-sep;
wd=.1;
fsize=get(0,'factoryuicontrolfontsize');
hlabel=uicontrol('style','text','fontsize',fsize/2,'string','Bright 0','units','normalized',...
'position', [x,ht/2,wd,2*ht/3],'tooltipstring','Current brightness level','userdata',0);
hslider=uicontrol('style','slider','string','Bright','units','normalized','position',...
[x,0,wd,ht/2],'callback','plotimage(''brighten'')',...
'tooltipstring','Set image brightness','max',10,'min',-10,...
'tag','phase','value',0,'userdata',hlabel,'sliderstep',[1/20 1/20]);
% wd=.1;
% fsize=get(0,'factoryuicontrolfontsize');
% hbrighten=uicontrol('style','pushbutton','fontsize',fsize/3,'string','brighten',...
% 'units','normalized',...
% 'position',[x ht/2 wd ht/2],'callback','brighten(.5)');
% %x=x+wd+sep;
% hdarken=uicontrol('style','pushbutton','fontsize',fsize/3,'string','darken',...
% 'units','normalized',...
% 'position',[x 0 wd ht/2],'callback','brighten(-.5)');
x=x+wd+sep;
wd=.1;
hcmap=uicontrol('style','pushbutton','string','Colormap',...
'units','normalized',...
'position',[x 0 wd ht],'callback','plotimage(''colormap'')',...
'visible','off');
%x=x+wd+sep;
wd=.17;
hmsg=uicontrol('style','text','string','Polarity Normal',...
'units','normalized',...
'position',[x 0 wd ht],'visible','off');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -