⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 waveleted.m

📁 基于matlab的反演程序,用于地球物理勘探中射线追踪及偏移成像程序.
💻 M
📖 第 1 页 / 共 3 页
字号:
			set(hmenu,'checked','on');
			ind=find(abs(hws)==hmenu);
			hws(ind)=-hmenu;
		end

		set(hwave,'userdata',hws);


		waveleted('plot');

		return;

	end

% promote a wavelet to active (select it)
if( strcmp(action,'activate') )
		h=get(gcf,'userdata');
		hchange=h(3);
		hdelete=h(15);
		hrename=h(18);
		hcurve=gco;
		hmenu=get(gco,'userdata');
		wname=get(hmenu,'label');
		hactive=h(13);

		set(hactive,'userdata',hmenu,'string',['Active Wavelet: ' wname]);

		set(hchange,'enable','on');
		set(hdelete,'enable','on');
		set(hrename,'enable','on');

		return;

end

%initiate zoom
if(strcmp(action,'zoominit'))
	h=get(gcf,'userdata');
	hmsg=h(14);
	set(hmsg,'string','MB1: Draw zoom box');

	selboxinit('waveleted(''zoom'')');

	return;
end

%perform a zoom. This is called by the selbox routine after a zoom box is drawn
%This is implemented such that it deactivates itself after one zoom. Additionally
% a zero zoom box causes an autoscale. Unzoom will return the default view which
% is not an autoscale
if( strcmp(action,'zoom') )
	box=selboxfini;

	if(length(box)==5)
		delete(box(5));
	end
	xmin=min([box(1) box(3)]);
	xmax=max([box(1) box(3)]);
	ymin=min([box(2) box(4)]);
	ymax=max([box(2) box(4)]);
	%get the current axis settings
	xlim=get(gca,'xlim');
	ylim=get(gca,'ylim');
	test1=xmin-xlim(1)+xmax-xlim(2)+ymin-ylim(1)+ymax-ylim(2);
	test2=(xmin-xmax)*(ymin-ymax);
	if(abs(test1)<10*eps | abs(test2)< 10*eps)
		axis('auto')
	else
		set(gca,'xlim',[xmin xmax],'ylim',[ymin ymax]);
	end
	%turn off the zoom action
	set(gcf,'windowbuttondownfcn','');
	set(gcf,'windowbuttonmotionfcn','');
	set(gcf,'windowbuttonupfcn','');
	return;
end

%
if(strcmp(action,'unzoom') | strcmp(action,'unzoom2') )
	h=get(gcf,'userdata');
	hmsg=h(14);
	
	if(strcmp(action,'unzoom'))
		set(hmsg,'string','MB1: unzoom clicked plot  MB3: unzoom all plots');
		set(gcf,'windowbuttondownfcn','sca;waveleted(''unzoom2'')');
		return;
	end
	
	flag=get(gcf,'selectiontype');
	if(strcmp(flag,'normal'))
		hax=gca;
		%determine which axis
		ind=find(h(9:11)==hax);
		%if(ind==2)
		%	axis('auto');
		%	set(hax,'ylim',[-80 0]);
		%else
			axis('auto');
		%end
	else
		set(h(9),'ylimmode','auto','xlimmode','auto');
		set(h(10),'ylimmode','auto','xlimmode','auto');
		set(h(11),'ylimmode','auto','xlimmode','auto');
		set(h(10),'ylim',[-80,0]);
	end
	
	set(gcf,'windowbuttondownfcn','');
	set(hmsg,'string','');
	
	return;
end
	
% initiate the creation of a new wavelet through the WAVELETDESIGN
% dialog
if(strcmp(action,'new')|strcmp(action,'new2') )
	h=get(gcf,'userdata');
	hnew=h(2);
	hsaveobject=h(7);
	hquit=h(8);
	hwave=h(12);
	hmsg=h(14);

	% see if we have a non-null wavelet object and determine the sample
	% rate
	wlet=get(hquit,'userdata');
	if( ~isempty(wlet) )
		% get the wavelet matrix
		fmw=objget(wlet,'wavelets');
		% the time axis
		t=fmget(fmw,'y');
		if( length(t)<2 )
			dt=.01;
		else
			dt=t(2)-t(1);
		end
	else
		dt=get(hsaveobject,'userdata');
		if( isempty(dt) )
			dt=0;
		end
	end

	% if the first time through, put up the dialog
	if( strcmp(action,'new'))
	 dat=get(hnew,'userdata');
	 hdesign=dat(2);
	 % test to see if this is a legit design window
	 if( ~waveletdesign('test',hdesign) )
		hdesign=0;
	 end
	 if(hdesign)
		figure(hdesign);
		return;
	 else
		hfig=gcf;
		waveletdesigninit('waveleted(''new2'')',1,dt,hfig);
		hdesign=gcf;
		dat(2)=hdesign;
		set(hnew,'userdata',dat);
		return;
	 end
	end

	% complete the wavelet dialog
	[w,t,name]=waveletdesignfini(0);
	dat=get(hnew,'userdata');
	hdesign=dat(2);
	close(hdesign);
	
	%check for cancel
	if( isempty(w) )
		set(hmsg,'string','New wavelet cancelled');
		return;
	end

	% put the new wavelet in the object
	if( isempty(wlet) )
		wlet=contobj('Waveleted Wavelets','wlet');
		fmw=fmset([],1,t,w);
		wlet=objset(wlet,'wavelets',fmw);
		wlet=objset(wlet,'wavelet_names',name);
	else
		nwave=fmget(fmw,'x');
		newnum=max(nwave)+1;
		fmw=fmset(fmw,newnum,t,w);
		names=objget(wlet,'wavelet_names');
		names=strmat(names,name);
		wlet=objset(wlet,'wavelets',fmw);
		wlet=objset(wlet,'wavelet_names',names);
			%make a default file object
			fileobj=contobj('file','prvt');
			filename='undefined';
			pathname=' ';
			fileobj=objset(fileobj,'filename',filename);
			fileobj=objset(fileobj,'pathname',pathname);

			wlet=objset(wlet,'file',fileobj);
	end

	%put the wavelet object back
	set(hquit,'userdata',wlet);

	%make a new menu, set it current, and invoke its display
 	hnewwave=uimenu(hwave,'label',name,'callback','waveleted(''switchwave'')');
     
 	hwaves=get(hwave,'userdata');
 	set(hwave,'userdata',[hwaves hnewwave]);

 	%set(gcf,'currentmenu',hnewwave);
	currentMenu=hnewwave;
 	waveleted('switchwave');

 	return;

end
	
% initiate the change of an existing wavelet through the WAVELETCHANGE
% dialog
if(strcmp(action,'change') || strcmp(action,'change2') )
	h=get(gcf,'userdata');
	hnew=h(2);
	hquit=h(8);
	hwave=h(12);
	hactive=h(13);
	hmsg=h(14);
	
	%determine the name of the active wavelet
	hmenu=get(hactive,'userdata');
	if( isempty(hmenu) )
		set(hmsg,'string','Please select an active wavelet and try again');
		error('No active wavelet selected');
	end
	name=get(hmenu,'label');

	% get the wavelet object and the active wavelet
	wlet=get(hquit,'userdata');
	wletnames=objget(wlet,'wavelet_names');
	[numwaves,r]=size(wletnames);
	kwave=[];
	for k=1:numwaves
		if(strcmp(name,wletnames(k,1:length(name))))
			kwave=k;
			break;
		end
	end
	if( isempty(kwave) )
		set(hmsg,'string','Invalid active wavelet');
		return;
	end
	
	% get the wavelet matrix
	fmw=objget(wlet,'wavelets');
	% the wavelet counters
	nwave=fmget(fmw,'x');
	xwave=nwave(kwave);
	% the time axis
	twact=fmget(fmw,'y');
	% the active wavelet
	wmat=fmget(fmw,'mat');
	wact=wmat(:,kwave);
	

	% if the first time through, put up the dialog
	if( strcmp(action,'change'))
		hfig=gcf;
		%remove any nan's from the active wavelet
		ilive=find(~isnan(wact));
		wact=wact(ilive);
		twact=twact(ilive);
		waveletchangeinit('waveleted(''change2'')',wact,twact,name,hfig);
		return;
	end

	% complete the wavelet dialog
	[w,t,newname]=waveletchangefini;
	
	%check for cancel
	if( isempty(w) )
		set(hmsg,'string','Wavelet Change Cancelled');
		return;
	end

	% put the new wavelet in the object
	if( strcmp(newname,name) )
		fmw=fmset(fmw,xwave,t,w);
		wlet=objset(wlet,'wavelets',fmw);

		%put the wavelet object back
		set(hquit,'userdata',wlet);
	
		% replot		
 		waveleted('plot');

	else
		% see if the new name matches any existing name
		kwave=[];
		if(length(newname)<=r)
			for k=1:numwaves
				if(strcmp(newname,wletnames(k,1:length(newname))))
					kwave=k;
					break;
				end
			end
		end
		if( ~isempty(kwave) )
			xwave=fmget(fmw,'x');
			fmw=fmset(fmw,xwave(kwave),t,w);
			wlet=objset(wlet,'wavelets',fmw);

			%put the wavelet object back
			set(hquit,'userdata',wlet);
	
			% replot		
 			waveleted('plot');
 	else
			nwave=fmget(fmw,'x');
			newnum=max(nwave)+1;
			fmw=fmset(fmw,newnum,t,w);
			names=objget(wlet,'wavelet_names');
			names=strmat(names,newname);
			wlet=objset(wlet,'wavelets',fmw);
			wlet=objset(wlet,'wavelet_names',names);
		
			%make a new menu, set it current, and invoke its display
 			hnewwave=uimenu(hwave,'label',newname,'callback',...
					'waveleted(''switchwave'')');

 			hwaves=get(hwave,'userdata');
 			set(hwave,'userdata',[hwaves hnewwave]);

 			%hnewwave = get(gcf,'currentmenu');
			hnewwave=gcbo;

			%put the wavelet object back
			set(hquit,'userdata',wlet);
	
			% replot		
 			waveleted('switchwave');
 	end
	end
	
 return;

end

	
% delete the active wavelet 
if(strcmp(action,'delete'))
	h=get(gcf,'userdata');
	hnew=h(2);
	hchange=h(3);
	hdelete=h(15);
	hrename=h(18);
	hquit=h(8);
	hwave=h(12);
	hactive=h(13);
	hmsg=h(14);
	
	%determine the name of the active wavelet
	hmenu=get(hactive,'userdata');
	if( isempty(hmenu) )
		set(hmsg,'string','Please select an active wavelet and try again');
		error('No active wavelet selected');
	end
	name=get(hmenu,'label');

	% get the wavelet object and the active wavelet
	wlet=get(hquit,'userdata');
	wletnames=objget(wlet,'wavelet_names');
	[numwaves,r]=size(wletnames);
	for k=1:numwaves
		if(strcmp(name,wletnames(k,1:length(name))))
			kwave=k;
			break;
		end
	end
	if( isempty(kwave) )
		set(hmsg,'string','Invalid active wavelet');
		return;
	end
	
	% get the wavelet matrix
	fmw=objget(wlet,'wavelets');
	% the wavelet counters
	nwave=fmget(fmw,'x');
	xwave=nwave(kwave);
	% the time axis
	twact=fmget(fmw,'y');
	% the active wavelet
	wmat=fmget(fmw,'mat');
	wact=wmat(:,kwave);
	
	% remove the active wavelet from the object
	fmw=fmset(fmw,xwave,[],[]);
	
	wletnames=[wletnames(1:kwave-1,:);wletnames(kwave+1:numwaves,:)];
	wlet=objset(wlet,'wavelets',fmw);
	wlet=objset(wlet,'wavelet_names',wletnames);
		
	%delete the menu
 	delete(hmenu);

 	hwaves=get(hwave,'userdata');
 	ind=find(abs(hwaves)==hmenu);
 	hwaves(ind)=[];
 	set(hwave,'userdata',hwaves);
 	
	%put the wavelet object back
	set(hquit,'userdata',wlet);
	
	%
	set(hactive,'userdata',[],'string','Active Wavelet: none');

	set(hchange,'enable','off');
	set(hdelete,'enable','off');
	set(hrename,'enable','off');

	set(hmsg,'string',['Wavelet ' name ' deleted']);
	
	% replot		
 	waveleted('plot');

	
 return;
end
	
% rename the active wavelet 
if(strcmp(action,'rename')|strcmp(action,'rename2'))
	h=get(gcf,'userdata');
	hnew=h(2);
	hchange=h(3);
	hdelete=h(15);
	hrename=h(18);
	hquit=h(8);
	hwave=h(12);
	hactive=h(13);
	hmsg=h(14);
	
	%determine the name of the active wavelet
	hmenu=get(hactive,'userdata');
	if( isempty(hmenu) )
		set(hmsg,'string','Please select an active wavelet and try again');
		error('No active wavelet selected');
	end
	name=get(hmenu,'label');

	% get the wavelet object and the active wavelet
	wlet=get(hquit,'userdata');
	wletnames=objget(wlet,'wavelet_names');
	[numwaves,r]=size(wletnames);
	for k=1:numwaves
		if(strcmp(name,wletnames(k,1:length(name))))
			kwave=k;
			break;
		end
	end
	if( isempty(kwave) )
		set(hmsg,'string','Invalid active wavelet');
		return;
	end

	if(strcmp(action,'rename'))
		askthingsinit('waveleted(''rename2'')','New Name',name);
		return;
	end

	newname=askthingsfini;

	%check for cancel
	if(newname==-1)
		set(hmsg,'string','Rename cancelled');
		return;
	end

	% see if the new name matches any existing name
	kwave2=[];
	if(length(newname)<=r)
		for k=1:numwaves
			if(strcmp(newname,wletnames(k,1:length(newname))))
				kwave2=k;
				break;
			end
		end
	end

	if( ~isempty(kwave2) )
		set(hmsg,'string','The new name must be unique! Try again...');
		return;
	end
	
	names1=wletnames(1:kwave-1,:);
	names2=wletnames(kwave+1:numwaves,:);
	wletnames=strmat(names1,newname);
	wletnames=strmat(wletnames,names2);
	wlet=objset(wlet,'wavelet_names',wletnames);
		
	%rename the menu
 	set(hmenu,'label',newname);
	set(hmsg,'string','Wavelet renamed');

	%put the wavelet object back
	set(hquit,'userdata',wlet);
	
	%
	set(hactive,'userdata',[],'string',['Active Wavelet: ' newname]);

	set(hchange,'enable','off');
	set(hdelete,'enable','off');
	set(hrename,'enable','off');
	
	% reactivate		
	dat=get(hmenu,'userdata');
 set(gcf,'currentobject',dat(1));
 waveleted('activate');

	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -