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

📄 rot3c.m,v

📁 具有特色的地震数据处理源码
💻 M,V
字号:
head	3.0;access;symbols;locks; strict;comment	@// @;3.0date	2000.06.13.19.21.12;	author gilles;	state Exp;branches;next	2.1;2.1date	2000.06.13.15.51.30;	author gilles;	state Exp;branches;next	2.0;2.0date	99.05.21.18.46.20;	author mah;	state Exp;branches;next	1.7;1.7date	99.05.19.21.03.02;	author mah;	state Exp;branches;next	1.6;1.6date	99.03.18.19.47.09;	author mah;	state Exp;branches;next	1.5;1.5date	99.02.22.22.24.26;	author mah;	state Exp;branches;next	1.4;1.4date	99.02.22.20.38.38;	author mah;	state Exp;branches;next	1.3;1.3date	99.02.22.20.12.24;	author mah;	state Exp;branches;next	1.2;1.2date	99.02.22.19.48.27;	author mah;	state Exp;branches;next	1.1;1.1date	99.02.22.19.16.20;	author mah;	state Exp;branches;next	;desc@rotate data by using 1 degree slices@3.0log@Release 3@text@function [dataout]=rot3c(datain,headw1,tstart,tend,comp1,comp2)%rot3c - function to rotate horizontal components for borehole data (DSI etc.) %into radial and transverse components%It is done by performing 1 degree increments in rotation and then checking for the best rotation%%function [dataout]=rot3c(datain,headw1,tstart,tend,comp1,comp2)%%INPUT VARIABLES%'datain' must be in official DSI data format%each record must represent a component x, y, or z in that order%this can be achieved using 'sortrec'%% headw1 = header word containing first break picks% tstart and tend = time interval before and after first breaks in seconds to be analyzed for proper rotation% comp1 = component to be maximized% comp2 = component to be minimized%% Please note: Software does not check for reasonable parameters or dead traces%%DSIsoft ver 2.0%DSI customized VSP processing software%%by G. Perron (Nov 15th, 1996)%based on rot3c_dirp from S. Guest and D. Eaton+%Rewritten by Marko Mah February 1999%$Id: rot3c.m,v 2.1 2000/06/13 15:51:30 gilles Exp gilles $%$Log: rot3c.m,v $%Revision 2.1  2000/06/13 15:51:30  gilles%*** empty log message ***%%Revision 2.0  1999/05/21 18:46:20  mah%Release 2%%Revision 1.7  1999/05/19 21:03:02  mah%version number%%Revision 1.6  1999/03/18 19:47:09  mah%made it more flexible by changing tint to tstart and tend%%Revision 1.5  1999/02/22 22:24:26  mah%made it more robust%%Revision 1.4  1999/02/22 20:38:38  mah%speed it up%%Revision 1.3  1999/02/22 20:12:24  mah%changed sign convention in rotation to make in line with current practice%%Revision 1.2  1999/02/22 19:48:27  mah%made program more flexible%%Revision 1.1  1999/02/22 19:16:20  mah%Initial revision%%%%Copyright (C) 1998 Seismology and Electromagnet+ic Section/%Continental Geosciences Division/Geological Survey of Canada%%This library is free software; you can redistribute it and/or%modify it under the terms of the GNU Library General Public%License as published by the Free Software Foundation; either%version 2 of the License, or (at your option) any later version.%%This library is distributed in the hope that it will be useful,%but WITHOUT ANY WARRANTY; without even the implied warranty of%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%Library General Public License for more details.%%You should have received a copy of the GNU Library General Public%License along with this library; if not, write to the%Free Software Foundation, Inc., 59 Temple Place - Suite 330,%Boston, MA  02111-1307, USA.%%DSI Consortium%Continental Geosciences Division%Geological Survey of Canada%615 Booth St.%Ottawa, Ontario%K1A 0E9%%email: dsi@@cg.nrcan.gc.cadisp('[dataout]=rot3c(datain,headw1,tstart,tend,comp1,comp2)');w=pi/180;trclength=datain.fh{7}; %number of points per tracesmpint=datain.fh{8}; %smpint is the sampling intervaldataout=datain;%check to make sure data is separated into components%ntr is the number of traces in each recordfor COUNT=3:-1:1 %get number of traces in each component	ntr(COUNT)=datain.th{COUNT}(12,1);end %forif (ntr(1)~=ntr(2)) | (ntr(1)~=ntr(3))	error('check data format - different number of traces in components');end%ifif length(datain.dat)~=3	error('data must have only 3 records - one for each of x, y and z');end %if%*************************************************************************%create a look-up table of sin and cos valuesfor COUNT=0:360   cosang(COUNT+1)=cos(COUNT*w);   sinang(COUNT+1)=sin(COUNT*w);end %for COUNTntr=ntr(1);angmx(1:ntr)=0; %initialize angmx vector for storing rotation anglesfor COUNT1=1:ntr samp1=round((datain.th{1}(headw1,COUNT1)-datain.fh{9})/smpint)-round(tstart/smpint)+1; %calulates start of interval to be analyzed samp2=round((datain.th{1}(headw1,COUNT1)-datain.fh{9})/smpint)+round(tend/smpint)+1; %calulates end of interval to be analyzed  fbsamp=round(datain.th{1}(headw1,COUNT1)/smpint); %this following loops over specified angles and returns the angle within %those specified that maximizes the radial component cmax=0; %initializing the max. energy of a component datawin=samp1:samp2; %the window over which the data is to be analyzed  lendatawin=length(datawin); %length of the data window xy=[datain.dat{comp1}(datawin,COUNT1), datain.dat{comp2}(datawin,COUNT1)]; %the window of data to be analyzed rt=zeros(lendatawin,2); for COUNT2=0:90 %checks from 0 to 90 degrees  %the following applies the rotation matrix and sums over each component  rt(:,1)=xy(:,1)*cosang(COUNT2+1)+xy(:,2)*sinang(COUNT2+1);  rt(:,2)=-xy(:,1)*sinang(COUNT2+1)+xy(:,2)*cosang(COUNT2+1);  c1rms=sum(rt(:,1).*rt(:,1));  c2rms=sum(rt(:,2).*rt(:,2));  % the following checks to see if either component is being maximized  if c1rms > cmax   angmx(COUNT1)=COUNT2;   cmax=c1rms;  end %if  if c2rms > cmax   angmx(COUNT1)=COUNT2+90;   cmax=c2rms;  end %if end %for COUNT2 %now that one knows that one component is maximized in the range 0 to 180 degrees %one now checks if there has been a 180 degree phase shift ampmax=zeros(1,2); for COUNT2=1:2  ang=angmx(COUNT1)+(COUNT2-1)*180; %calculates the angle for the current quadrant being checked  A=[cosang(ang+1),sinang(ang+1);-sinang(ang+1),cosang(ang+1)]; %rotation matrix  % now to determine where the firstbreak is%  fbloc=ceil(length(xy)/2);
  fbloc=fbsamp-samp1;  rt=A*xy(fbloc,:)'; %rotates the first break amplitudes  ampmax(COUNT2)=rt(1); end %for COUNT2maxloc=find(ampmax==max(ampmax)); %finds the location of the maximum amplitude of component 1 angmx(COUNT1)=angmx(COUNT1)+(maxloc(1)-1)*180; %sets the angle that maximizes component 1end %for COUNT1for COUNT=1:ntr  sinangmx=sinang(angmx(COUNT)+1);  cosangmx=cosang(angmx(COUNT)+1);  for COUNT2=1:trclength    data1=datain.dat{comp1}(COUNT2,COUNT);    data2=datain.dat{comp2}(COUNT2,COUNT);    dataout.dat{comp1}(COUNT2,COUNT)=data1*cosangmx + data2*sinangmx; %radial    dataout.dat{comp2}(COUNT2,COUNT)=-data1*sinangmx + data2*cosangmx; %transverse  end %loop over samplesend %for COUNT%make changes to trace headerdataout.th{comp1}(4,:)=dataout.th{comp1}(4,:)+3;dataout.th{comp2}(4,:)=dataout.th{comp2}(4,:)+3;dataout.th{comp1}(5,:)=angmx(:);dataout.th{comp2}(5,:)=angmx(:);@2.1log@*** empty log message ***@text@d28 1a28 1%$Id: rot3c.m,v 2.0 1999/05/21 18:46:20 mah Exp $d30 3@2.0log@Release 2@text@d28 1a28 1%$Id: rot3c.m,v 1.7 1999/05/19 21:03:02 mah Exp mah $d30 3d120 2a121 1d164 2a165 1  fbloc=ceil(length(xy)/2);d170 2a171 2 maxloc=find(ampmax==max(ampmax)); %finds the location of the maximum amplitude of component 1 angmx(COUNT1)=angmx(COUNT1)+(maxloc-1)*180; %sets the angle that maximizes component 1@1.7log@version number@text@d28 1a28 1%$Id: rot3c.m,v 1.6 1999/03/18 19:47:09 mah Exp mah $d30 3@1.6log@made it more flexible by changing tint to tstart and tend@text@d21 1a21 1%DSIsoft ver 1.0d28 1a28 1%$Id: rot3c.m,v 1.5 1999/02/22 22:24:26 mah Exp mah $d30 3@1.5log@made it more robust@text@d1 1a1 1function [dataout]=rot3c(datain,headw1,tint,comp1,comp2)d7 1a7 1%function [dataout]=rot3c(datain,headw1,tint,comp1,comp2)d15 1a15 1% tint= time interval before and after first breaks in seconds to be analyzed for proper rotationd28 1a28 1%$Id: rot3c.m,v 1.4 1999/02/22 20:38:38 mah Exp mah $d30 3d74 1a74 1disp('[dataout]=rot3c(datain,headw1,tint,comp1,comp2)');d109 2a110 2 samp1=round((datain.th{1}(headw1,COUNT1)-datain.fh{9})/smpint)-round(tint/smpint)+1; %calulates start of interval to be analyzed samp2=samp1+2*round(tint/smpint); %calculates end of interval to be analyzedd177 2a178 2dataout.th{comp1}(4,:)=4;dataout.th{comp2}(4,:)=5;@1.4log@speed it up@text@d15 1a15 1% tint= time interval after first breaks in seconds to be analyzed for proper rotationd28 1a28 1%$Id: rot3c.m,v 1.3 1999/02/22 20:12:24 mah Exp mah $d30 3d106 2a107 2 samp1=round((datain.th{1}(headw1,COUNT1)-datain.fh{9})/smpint) +1; %calulates start of interval to be analyzed samp2=samp1+round(tint/smpint); %calculates end of interval to be analyzedd136 1a136 1   angmx(COUNT1)=COUNT2;d142 2a143 2 %now that one knows that one component is maximized in the range 0 to 90 degrees %one now checks all 4 quadrants to see which one maximizes component 1d145 1a145 1 ampmax=zeros(1,4);d147 2a148 2 for COUNT2=1:4  ang=angmx(COUNT1)+(COUNT2-1)*90; %calculates the angle for the current quadrant being checkedd150 3a152 1  rt=A*xy(1,:)'; %rotates the datad157 1a157 1 angmx(COUNT1)=angmx(COUNT1)+(maxloc-1)*90; %sets the angle that maximizes component 1@1.3log@changed sign convention in rotation to make in line with current practice@text@d28 1a28 1%$Id: rot3c.m,v 1.2 1999/02/22 19:48:27 mah Exp mah $d30 3d115 2a117 3  A=[cosang(COUNT2+1),sinang(COUNT2+1);-sinang(COUNT2+1),cosang(COUNT2+1)]; %rotation matrix  c1rms=0.0; %sets the rms value for component 1 to zero  c2rms=0.0; %sets the rms value for component 2 to zer0d119 5a123 5  for COUNT3=1:lendatawin %rotates and sums over the length of the data   rt=A*xy(COUNT3,:)'; %rotation of data   c1rms=c1rms+(rt(1,1).*rt(1,1));   c2rms=c2rms+(rt(2,1).*rt(2,1));  end %for COUNT3d146 1a146 1  A=[cosang(ang+1),-sinang(ang+1);sinang(ang+1),cosang(ang+1)]; %rotation matrix@1.2log@made program more flexible@text@d28 1a28 1%$Id: rot3c.m,v 1.1 1999/02/22 19:16:20 mah Exp mah $d30 3d113 1a113 1  A=[cosang(COUNT2+1),-sinang(COUNT2+1);sinang(COUNT2+1),cosang(COUNT2+1)]; %rotation matrixd161 2a162 2    dataout.dat{comp1}(COUNT2,COUNT)=data1*cosangmx - data2*sinangmx; %radial    dataout.dat{comp2}(COUNT2,COUNT)=data1*sinangmx + data2*cosangmx; %transverse@1.1log@Initial revision@text@d1 1a1 1function [dataout]=rot3c(datain,headw1,tint)d7 1a7 1%function [dataout]=rot3c(datain,headw1,tint)d16 2d28 4a31 2%$Id: Exp $%$Log: $d34 1d62 1a62 1disp('[dataout]=rot3c(datain,headw1,tint)');d107 1a107 1 xy=[datain.dat{1}(datawin,COUNT1), datain.dat{2}(datawin,COUNT1)]; %the window of data to be analyzedd156 4a159 4    data1=datain.dat{1}(COUNT2,COUNT);    data2=datain.dat{2}(COUNT2,COUNT);    dataout.dat{1}(COUNT2,COUNT)=data1*cosangmx - data2*sinangmx; %radial    dataout.dat{2}(COUNT2,COUNT)=data1*sinangmx + data2*cosangmx; %transversed164 4a167 5dataout.th{1}(4,:)=4;dataout.th{2}(4,:)=5;dataout.th{1}(5,:)=angmx(:);dataout.th{2}(5,:)=angmx(:);@

⌨️ 快捷键说明

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