diff --git a/RELEASE b/RELEASE index c063cb2..a5fe4f9 100644 --- a/RELEASE +++ b/RELEASE @@ -1,8 +1,8 @@ To make a release: -(1) Check that all docuemntation is up-to-date - and committed. (Run "make install" in - doc_src, then git commit any changed +(1) Check that all documentation is up-to-date + and committed. (Run "make install" in + doc_src, then git commit any changed files). (2) In Matlab, check all tests run without error. diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 25ccc2f..e837217 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -3,26 +3,26 @@ MSAT Release Notes Development - ongoing -Enhancment to MS_plot including: +Enhancement to MS_plot including: -* Adding different projections (equal angle projection and equal area -projection - i.e. on a Wulff and Schmidt net, respectivly) with the new +* Adding different projections (equal angle projection and equal area +projection - i.e. on a Wulff and Schmidt net, respectively) with the new keyword 'projection' (options are 'sphere' - the default - 'angle' and 'area'. * Add the ability to plot lower hemisphere projections (rather than the default upper hemisphere). New keyword 'lower'. -* Add the ability to plot "bands" around each of the axes (e.g. to show -the location of the SWS window). This adds the 'band' keyword that takes +* Add the ability to plot "bands" around each of the axes (e.g. to show +the location of the SWS window). This adds the 'band' keyword that takes a vector of axis labels and a vector of angles. -* Handle non-row-vector input for sdata and pdata. We "flatten" any input +* Handle non-row-vector input for sdata and pdata. We "flatten" any input and turn it into a row vector (which is more or less what the documentation says). Input arguments just need the same number of elements. -* Only plot data ('sdata', 'pdata') on the upper or lower hemisphere -depending on the inclination. Add 'data_remap' to plot negative +* Only plot data ('sdata', 'pdata') on the upper or lower hemisphere +depending on the inclination. Add 'data_remap' to plot negative inclination data on the upper hemisphere or positive data on the lower hemisphere. @@ -33,22 +33,22 @@ This version of MSAT adds a handful of new feature alongside various bug fixes. Changes from 1.1.0 are: * Add MS_interpolate, which implements a new method for interpolating -between elasticity matricies. +between elasticity matrices. -* Add support for Anderson's (1961) TI parameterisation in -MS_TI. +* Add support for Anderson's (1961) TI parametrisation in +MS_TI. * Add a function (MS_rotRandom) to randomly rotate an elasticity matrix, the rotation is drawn from a uniform distribution such -that avaraging many such elasticity matricies yields a isotropic +that averaging many such elasticity matrices yields a isotropic version of the elasticity. -* Add quartz, fayalite, and ice to the database of elasic constants. +* Add quartz, fayalite, and ice to the database of elastic constants. Bug fixes include: * Fix symmetry detection for hexagonal (VTI) elasticity -in MS_axes. +in MS_axes. * Fix a bug leading to errors in the norm of the triclinic part of an elasticity matrix in MS_decomp. @@ -62,97 +62,97 @@ Version 1.1.0 - 1 July 2013 This version of MSAT focuses on the addition of new functionality to enable simple calculations involving shear wave splitting. It also includes several minor improvements, -pieces of new functionality and bug fixes. Changes from +pieces of new functionality and bug fixes. Changes from 1.0.1 are: * New functions for simple analysis of shear wave splitting: -** Splitting misfit calculation (see MS_splitting_misfit and +** Splitting misfit calculation (see MS_splitting_misfit and the new splitting_misfit example). -** Functions to generate a test wavelet, apply shear wave splitting -operator(s), measure the resulting splitting, and plot the resulting -waveforms (See MS_make_trace, MS_split_trace, MS_measure_trace_splitting +** Functions to generate a test wavelet, apply shear wave splitting +operator(s), measure the resulting splitting, and plot the resulting +waveforms (See MS_make_trace, MS_split_trace, MS_measure_trace_splitting and MS_plot_trace). ** Add a new mode for MS_effective_splitting_N to use the above functions instead of the default Silver and Savage (1994) method. -** Include the ability to plot measured splitting observations or -velocities alongside phase velocities from the elasticity in MS_plot +** Include the ability to plot measured splitting observations or +velocities alongside phase velocities from the elasticity in MS_plot and MS_sphere. * Add a new function, MS_save, to write files in the formats supported by MS_load. -* Allow MS_expand to handle the 9-element orthorhombic +* Allow MS_expand to handle the 9-element orthorhombic case. -* Add a new TI parameterization "global", which is like +* Add a new TI parametrisation "global", which is like "panning" but without the approximation of eta=1. -* Add options to produce nicer looking plots in MS_plot and -allow contour limits to be set in MS_sphere. Allow MS_plot to +* Add options to produce nicer looking plots in MS_plot and +allow contour limits to be set in MS_sphere. Allow MS_plot to show S1 and S2 phase velocity and allow user to select which subplots to include. * Include proper treatment of exactly parallel or perpendicular layers in the stack of operators in MS_effective_splitting_N. -* Add new example showing the simulation of texture inheritance +* Add new example showing the simulation of texture inheritance in the lowermost mantle. * Numerous minor improvements to the documentation. -We thank Andy Nowacki (Bristol), Alan Baird (Bristol), +We thank Andy Nowacki (Bristol), Alan Baird (Bristol), Jenny Di Leo (Bristol) and Nagaya Takayoshi (University of Nagoya) for suggestions, ideas and bug fixes and reports. Version 1.0.1 - 5 November 2012 ------------------------------- -This version of MSAT collects together several minor improvements +This version of MSAT collects together several minor improvements and minor bug fixes. Changes from version 1.0 are: -* Fix the 'reverse' argument of MS_sphere and MS_plot. This optional +* Fix the 'reverse' argument of MS_sphere and MS_plot. This optional argument was inoperative. * Clarify the behaviour of MS_rotEuler such that the default action is to rotate the crystal and not the frame of reference. Add optional arguments -'sense', 'passive' to allow previous behaviour (rotation of the frame of +'sense', 'passive' to allow previous behaviour (rotation of the frame of reference) -* Add a new function MS_TI_parameters which calculates a range of -values for VTI parameterisations given an elasticity matrix. +* Add a new function MS_TI_parameters which calculates a range of +values for VTI parametrisations given an elasticity matrix. -* Extend MS_sphere to plot slowness surfaces using 'slowP', 'slowS1' +* Extend MS_sphere to plot slowness surfaces using 'slowP', 'slowS1' or 'slowS2' values for the mode argument. * Speed up MS_phasevels by a factor of two. * Expand the range of materials in MS_elasticDB -* Include reference to the MSAT paper ("MSAT - A new toolkit for the -analysis of elastic and seismic anisotropy" Computers and Geosciences, +* Include reference to the MSAT paper ("MSAT - A new toolkit for the +analysis of elastic and seismic anisotropy" Computers and Geosciences, 49, pp.81-90. doi:10.1016/j.cageo.2012.05.031) in the documentation. -We thank Michele Zucali (University of Milan), Alan Baird (Bristol), -Jenny Di Leo (Bristol), Nagaya Takayoshi (University of Nagoya) and -an anonymous reviewer of the manuscript for contributing sugestions, +We thank Michele Zucali (University of Milan), Alan Baird (Bristol), +Jenny Di Leo (Bristol), Nagaya Takayoshi (University of Nagoya) and +an anonymous reviewer of the manuscript for contributing suggestions, bug reports, and code. Version 1.0 - 11 April 2012 --------------------------- -This version of MSAT completes the intended initial feature -set and contains more detailed documentation. There are -also a few bug fixes, an API change (to MS_sphere's optional -arguments) and a couple of new features. All users are -encouraged to report outstanding bugs and request missing +This version of MSAT completes the intended initial feature +set and contains more detailed documentation. There are +also a few bug fixes, an API change (to MS_sphere's optional +arguments) and a couple of new features. All users are +encouraged to report outstanding bugs and request missing features. Major changes from version 0.9 include: -* The way MS_sphere handles optional +* The way MS_sphere handles optional arguments has been made consistent with the rest of the code. @@ -161,79 +161,79 @@ along with documentation on the various examples. These release notes now form part of the documentation available within the Matlab environment. -* A new function, MS_TI, has been written to bring together +* A new function, MS_TI, has been written to bring together the various ways of creating a elasticity matrix with -transverse isotropy from the various representations. MS_VTI -and MS_VTI2 now act as aliases to this function. Love's +transverse isotropy from the various representations. MS_VTI +and MS_VTI2 now act as aliases to this function. Love's parameterisation has been added. -* Added new effective medium theories (for aligned cracks and -thin layering) to MS_effective medium. Fixed a bug in the -ellipsoidal inclusions case where the material parameters were +* Added new effective medium theories (for aligned cracks and +thin layering) to MS_effective medium. Fixed a bug in the +ellipsoidal inclusions case where the material parameters were provided as velocities rather than elasticity matrices. -* MS_phasevels has been made ~50% faster when called with -a very large number of directions. The function also rejects -invalid elasticity matrices (which, for example, can yield +* MS_phasevels has been made ~50% faster when called with +a very large number of directions. The function also rejects +invalid elasticity matrices (which, for example, can yield imaginary velocities). -Thanks to Alan Baird (Bristol) and Alex -Cote (UCL) for reporting bugs in and -suggesting improvements to version 0.9. +Thanks to Alan Baird (Bristol) and Alex +Cote (UCL) for reporting bugs in and +suggesting improvements to version 0.9. Version 0.9 - 24 November 2011 ------------------------------ -This is the public beta version of -MSAT with expanded documentation, -new examples, some bug fixes and +This is the public beta version of +MSAT with expanded documentation, +new examples, some bug fixes and a few new functions. Users of version -0.8 are advised to upgrade. All users -are encouraged to report bugs and +0.8 are advised to upgrade. All users +are encouraged to report bugs and request missing features. Major changes from version 0.8 are: -* The way MS_plot handles optional -arguments has been made consistent -with the rest of the code. New -optional arguments have been added. +* The way MS_plot handles optional +arguments has been made consistent +with the rest of the code. New +optional arguments have been added. -* An MSAT quick start guide has been -added to the built-in and web based -documentation. The full user guide -has been started but is incomplete. +* An MSAT quick start guide has been +added to the built-in and web based +documentation. The full user guide +has been started but is incomplete. -* Six usage examples have been provided. -They are located in subdirectories of +* Six usage examples have been provided. +They are located in subdirectories of the distributed examples directory. -* A new function, MS_poisson, has been -added to evaluate Poisson's ratio for -generally anisotropic materials as a +* A new function, MS_poisson, has been +added to evaluate Poisson's ratio for +generally anisotropic materials as a function of strain direction. -* A new function, MS_VTI2, has been added -to generate an elasticity matrix with -hexagonal symmetry from the vp, vs, xi, -phi and eta parameters sometimes used +* A new function, MS_VTI2, has been added +to generate an elasticity matrix with +hexagonal symmetry from the vp, vs, xi, +phi and eta parameters sometimes used in global tomography. -* Provide a work around for Matlab version +* Provide a work around for Matlab version dependent compatibility issue in MS_checkC. Version 0.8 - 4 October 2011 ---------------------------- -This is the first version of MSAT -so there are no backwards incompatibility -issues. However, this is an alpha +This is the first version of MSAT +so there are no backwards incompatibility +issues. However, this is an alpha release and note that: -* Elastic constant interpolation for +* Elastic constant interpolation for trigonal symmetry does not work correctly. -* Several examples are incomplete. -* Many of the functions are derived from - older "CIJ_" code. Argument orders and - details of what must be passed have been +* Several examples are incomplete. +* Many of the functions are derived from + older "CIJ_" code. Argument orders and + details of what must be passed have been freely changed. Do read the documentation. diff --git a/msat/MS_TI.m b/msat/MS_TI.m index a03416d..f1434db 100644 --- a/msat/MS_TI.m +++ b/msat/MS_TI.m @@ -1,11 +1,11 @@ % MS_TI - generate elastic constants for a vertically transverse isotropic -% medium from specified parameter sets. Symmetry is in the 3-axis. +% medium from specified parameter sets. Symmetry is in the 3-axis. % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % % [C]=MS_TI( list_of_parameters , parameter_set_string ) % -% where parameter_set_string defines the set which precede it: +% where parameter_set_string defines the set which precede it: % %'thomsen' (default) %~~~~~~~~~~~~~~~~~~~ @@ -13,16 +13,16 @@ % [C]=MS_TI(vp,vs,rh,eps,gam,del) -or- % [C]=MS_TI(vp,vs,rh,eps,gam,del,'thomsen') % -% Inputs: -% rh : Density (kg/m2) -% vp : km/s (vertical) +% Inputs: +% rh : Density (kg/m2) +% vp : km/s (vertical) % vs : km/s (vertical) % eps, gam, del : Dimensionless % % Output: % C : Stiffness tensor (6x6 notation, GPa) % -% Given Thomsen (1986) parameters for a weakly anisotropic VTI medium, +% Given Thomsen (1986) parameters for a weakly anisotropic VTI medium, % return the elasticity matrix % %'panning' @@ -30,8 +30,8 @@ % % [C]=MS_TI(vp,vs,rh,xi,phi,eta,'panning') % -% Inputs: -% rh : Density (kg/m2) +% Inputs: +% rh : Density (kg/m2) % vp : km/s (isotropic average) % vs : km/s (isotropic average) % xi, phi, eta : Dimensionless anisotropy parameters @@ -40,7 +40,7 @@ % C : Stiffness tensor (6x6 notation, GPa) % % Calculates the elastic tensor for a VTI medium from average Vp and Vs, -% and anisotropic parameters xi, phi and eta (see, e.g., Panning and +% and anisotropic parameters xi, phi and eta (see, e.g., Panning and % Romanowicz, 2006). Derivation only valid if eta = 1 and phi = 1. % %'global' @@ -48,8 +48,8 @@ % % [C]=MS_TI(vp,vs,rh,xi,phi,eta,'global') % -% Inputs: -% rh : Density (kg/m2) +% Inputs: +% rh : Density (kg/m2) % vp : km/s (Voigt isotropic average) % vs : km/s (Voigt isotropic average) % xi, phi, eta : Dimensionless anisotropy parameters @@ -66,7 +66,7 @@ % % [C]=MS_TI(A,C,L,N,F,'love') % -% Inputs: +% Inputs: % A,C,L,N,F : Love parameters (GPa) % % Output: @@ -101,73 +101,73 @@ % Anderson, D. L. (1961) "Elastic wave propagation in layered % anisotropic media" Journal of Geophysical Research 66:2953 - 2963 % -% Thomsen, L. (1986) "Weak elastic anisotropy" Geophysics +% Thomsen, L. (1986) "Weak elastic anisotropy" Geophysics % vol.51 pp.1954-1966 % -% Mark Panning and Barbara Romanowicz (2006) A three-dimensional radially -% anisotropic model of shear velocity in the whole mantle. Geophysical -% Journal International v167, 361–379. +% Mark Panning and Barbara Romanowicz (2006) A three-dimensional radially +% anisotropic model of shear velocity in the whole mantle. Geophysical +% Journal International v167, 361–379. % doi: 10.1111/j.1365-246X.2006.03100.x % -% Babuska, V. and Cara, M. (1991). Seismic Anisotropy in the Earth. Kluwer +% Babuska, V. and Cara, M. (1991). Seismic Anisotropy in the Earth. Kluwer % Academic, Boston. % -% Love, A.E.H., (1927). A Treatise on the Theory of Elasticity, +% Love, A.E.H., (1927). A Treatise on the Theory of Elasticity, % Cambridge Univ. Press, Cambridge. % % See also: MS_iso, MS_elasticDB % Copyright (c) 2011-2013, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [C]=MS_TI(varargin) - -% see if a parameter set type was selected. + +% see if a parameter set type was selected. if ischar(varargin{nargin}) pset = varargin{nargin} ; ncheck = nargin-1; else pset = 'thomsen' ; ncheck = nargin ; -end +end % check that all other inputs are scalars for icheck=1:ncheck if ~isscalar(varargin{icheck}) error('MS:TI:BadScalarInput',... 'MS_TI requires scalar inputs') ; - end + end end % call the appropriate routine. @@ -175,20 +175,20 @@ switch lower(pset) %------------------------------------------------------------------------------- case {'thomsen', 'thom'} - if length(varargin)~=7 & length(varargin)~=6 % need to check + if length(varargin)~=7 & length(varargin)~=6 % need to check error('MS:TI:ThomsenWrongArgs', ... 'Thomsen (1986) requires 6 input parameters.') ; end - vp = varargin{1} ; vs = varargin{2} ; rh = varargin{3} ; + vp = varargin{1} ; vs = varargin{2} ; rh = varargin{3} ; eps = varargin{4} ; gam = varargin{5} ; del = varargin{6} ; [C]=MS_thomsen(vp,vs,rh,eps,gam,del) ; %------------------------------------------------------------------------------- case {'panning'} - if length(varargin)~=7 % need to check + if length(varargin)~=7 % need to check error('MS:TI:PanningWrongArgs', ... 'Panning (2006) requires 6 input parameters.') ; end - vp = varargin{1} ; vs = varargin{2} ; rh = varargin{3} ; + vp = varargin{1} ; vs = varargin{2} ; rh = varargin{3} ; xi = varargin{4} ; phi = varargin{5} ; eta = varargin{6} ; [C]=MS_panning(vp,vs,rh,xi,phi,eta) ; %------------------------------------------------------------------------------- @@ -197,21 +197,21 @@ error('MS:TI:GlobalWrongArgs', ... 'global requires 6 input parameters.') ; end - vp = varargin{1} ; vs = varargin{2} ; rh = varargin{3} ; + vp = varargin{1} ; vs = varargin{2} ; rh = varargin{3} ; xi = varargin{4} ; phi = varargin{5} ; eta = varargin{6} ; [C]=MS_global(vp,vs,rh,xi,phi,eta) ; %------------------------------------------------------------------------------- case {'love'} - if length(varargin)~=6 % need to check + if length(varargin)~=6 % need to check error('MS:TI:LoveWrongArgs', ... 'Love (1926) requires 5 input parameters.') ; end - A = varargin{1} ; C_love = varargin{2} ; L = varargin{3} ; - N = varargin{4} ; F = varargin{5} ; + A = varargin{1} ; C_love = varargin{2} ; L = varargin{3} ; + N = varargin{4} ; F = varargin{5} ; [C]=MS_love(A,C_love,L,N,F) ; %------------------------------------------------------------------------------- case {'anderson'} - if length(varargin)~=7 % need to check + if length(varargin)~=7 % need to check error('MS:TI:AndersonWrongArgs', ... 'Anderson (1961) requires 6 input parameters.') ; end @@ -224,10 +224,10 @@ 'Specified parameter set is not supported.') ; %------------------------------------------------------------------------------- end % of switch - + % check resulting matrix. MS_checkC(C) ; - + end function [CC]=MS_love(A,C,L,N,F) @@ -250,39 +250,39 @@ '"panning" mode in MS_TI assumes eta = 1. Use "global" for ' ... 'correct general treatment']); end - + if phi ~= 1.0 warning('MS:TIphi', ['Warning, the derivation of the ' ... '"panning" mode in MS_TI assumes phi = 1. Use "global" for ' ... 'correct general treatment']); end - -% note: xi and phi are defined oppositely; i.e.: + +% note: xi and phi are defined oppositely; i.e.: % xi = vsv^2/vsh^2 and phi = vph^2/vpv^2 vsv = sqrt((3.*vs.^2)./(2+xi)) ; vsh = sqrt(xi.*vsv.^2) ; - + vph = sqrt((5.*vp.^2)./(4+phi)) ; vpv = sqrt(phi.*vph.^2) ; - + C11 = vph.^2.*rh ; % A C33 = vpv.^2.*rh ; % C C44 = vsv.^2.*rh ; % L C66 = vsh.^2.*rh ; % N - + C12 = C11-2.*C66 ; C13 = eta.*(C11-2.*C44) ; % F - + C22 = C11 ; C55 = C44 ; - + C = [C11 C12 C13 0 0 0 ; ... C12 C22 C13 0 0 0 ; ... C13 C13 C33 0 0 0 ; ... 0 0 0 C44 0 0 ; ... 0 0 0 0 C55 0 ; ... 0 0 0 0 0 C66 ] ; - + C = C./1e9 ; % convert to GPa end @@ -336,20 +336,20 @@ C(4,4) = vs*vs ; % 9b C(6,6) = C(4,4)*(2.0*gam +1.0) ; % 8b C(1,1) = C(3,3)*(2.0*eps +1.0) ; % 8a - + btm = 2.0*C(4,4) ; term = C(3,3) - C(4,4) ; ctm = C(4,4)*C(4,4) - (2.0*del*C(3,3)*term + term*term) ; dsrmt = (btm*btm - 4.0*ctm) ; - + if dsrmt < 0 error('MS:TI:ThomsenHiVS',... 'S-velocity too high or delta too negative for Thomsen routine.') ; end - + C(1,3) = -btm/2.0 + sqrt(dsrmt)/2.0 ; - - C(1,2) = C(1,1) - 2.0*C(6,6) ; + + C(1,2) = C(1,1) - 2.0*C(6,6) ; C(2,3) = C(1,3) ; C(5,5) = C(4,4) ; C(2,2) = C(1,1) ; @@ -374,7 +374,7 @@ Vp45 = Vp45*1e3; Vsv = Vsv*1e3; Vsh = Vsh*1e3; - + C = zeros(6); C(1,1) = Vph^2 * rho; C(3,3) = Vpv^2 * rho; @@ -386,7 +386,7 @@ (0.5*(C(1,1)-C(3,3))^2)) - C(4,4); % Fill in the gaps. C(1,2) = 0.0 ; % So we can expand - C = MS_expand(C, 'vti'); + C = MS_expand(C, 'vti'); % Convert C from Pa to GPa C = C./1e9; diff --git a/msat/MS_TI_parameters.m b/msat/MS_TI_parameters.m index ad5a850..96e83e0 100644 --- a/msat/MS_TI_parameters.m +++ b/msat/MS_TI_parameters.m @@ -1,86 +1,86 @@ -% MS_TI_parameters - TI parameters from C. +% MS_TI_parameters - TI parameters from C. % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % % Returns various parameters describing TI anisotropy given an elasticity -% matrix (C) and density (rho) in GPa and kg/m^3. +% matrix (C) and density (rho) in GPa and kg/m^3. % % [loveA, loveC, loveL, loveN, loveF, vpv, vsv, eps, gam, del ... % vpa, vsa, xi, phi, eta] = MS_TI_parameters(C, rho) % % Output: -% vpa : isotropic Voigt average P-wave -% velocity, km/s -% vsa : isotropic Voigt average S-wave +% vpa : isotropic Voigt average P-wave +% velocity, km/s +% vsa : isotropic Voigt average S-wave % velocity, km/s % vpv : vertical P-wave velocity, km/s % vsv : vertical S-wave velocity, km/s -% eps, gam, del : dimensionless Thomsen (1986) +% eps, gam, del : dimensionless Thomsen (1986) % parameters -% xi, phi, eta : dimensionless anisotropy -% parameters (e.g. Panning +% xi, phi, eta : dimensionless anisotropy +% parameters (e.g. Panning % and Romanowicz, 2006) -% loveA, loveC, loveL, loveN, loveF : Love's (1927) anisotropy +% loveA, loveC, loveL, loveN, loveF : Love's (1927) anisotropy % parameters, GPa %Notes %~~~~~ % Input units should be GPa for the elasticity matrix and kg/m^3 for the -% density - this gives output parameters in units of km/s for velocity and -% GPa for elasticity. Choosing a different unit for the elasticity will -% change the units for the Love parameters and velocities but not the +% density - this gives output parameters in units of km/s for velocity and +% GPa for elasticity. Choosing a different unit for the elasticity will +% change the units for the Love parameters and velocities but not the % dimensionless parameters. Choosing an arbitrary value for the density -% will not alter the dimensionless parameters or Love parameters, but the +% will not alter the dimensionless parameters or Love parameters, but the % velocities will be meaningless. The values reported for xi, phi and eta % do not assume eta=1 or A=C (as assumed by Panning and Romanowicz, % 2006). Compare 'Panning' and 'global' modes in MS_TI. % %References %~~~~~~~~~~ -% Thomsen, L. (1986) "Weak elastic anisotropy" Geophysics +% Thomsen, L. (1986) "Weak elastic anisotropy" Geophysics % vol.51 pp.1954-1966 % -% Mark Panning and Barbara Romanowicz (2006) A three-dimensional radially -% anisotropic model of shear velocity in the whole mantle. Geophysical -% Journal International v167, 361–379. +% Mark Panning and Barbara Romanowicz (2006) A three-dimensional radially +% anisotropic model of shear velocity in the whole mantle. Geophysical +% Journal International v167, 361–379. % doi: 10.1111/j.1365-246X.2006.03100.x % -% Love, A.E.H., (1927). A Treatise on the Theory of Elasticity, +% Love, A.E.H., (1927). A Treatise on the Theory of Elasticity, % Cambridge Univ. Press, Cambridge. % % See also: MS_TI, MS_polyaverage - + % Copyright (c) 2011-2012, James Wookey, Andrew Walker and Alan Baird % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [loveA, loveC, loveL, loveN, loveF, vpv, vsv, eps, gam, del ... @@ -92,7 +92,7 @@ error('MS:BadTIelasticity',... 'MS_TI_parameters requires VTI input') ; end - + % Pass off the calculations to subroutines. [eps, gam, del] = MS_thomsen_params(C); [loveA, loveC, loveL, loveN, loveF] = MS_love_params(C); @@ -105,22 +105,22 @@ % Convert to Pa CC = CC.*1e9 ; - % Love params in Pa and density in Kg/m^3 give + % Love params in Pa and density in Kg/m^3 give % velocites in m/s [A, C, L, N, F] = MS_love_params(CC); vph = sqrt(A/rho); vpv = sqrt(C/rho); % Thom VP vsv = sqrt(L/rho); % Thom VS vsh = sqrt(N/rho); - - % note: xi and phi are defined oppositely; i.e.: + + % note: xi and phi are defined oppositely; i.e.: % xi = vsh^2/vsv^2 and phi = vpv^2/vph^2 xi = vsh^2 / vsv^2; phi = vpv^2 / vph^2; - + eta = F/(A-2.0*L); - - % These avarages are only valid if A=C and eta=1 + + % These averages are only valid if A=C and eta=1 % which is the approximation used in Panning model % but general hexagonal symmetry does not have this % condition. So use the full form (c.f. MS_TI): @@ -138,11 +138,11 @@ end function [eps, gam, del] = MS_thomsen_params(C) - % From a VTI (unique X3) elasticity matrix, return + % From a VTI (unique X3) elasticity matrix, return % the three Thomsen parameters eps, gam and del % FIXME - do we need to do the 'vs too high' test here? - + eps=(C(1,1)-C(3,3))/(2.0*C(3,3)); gam=(C(6,6)-C(4,4))/(2.0*C(4,4)); del=((C(1,3)+C(4,4))^2.0-(C(3,3)-C(4,4))^2.0) / ... @@ -152,33 +152,33 @@ function [A, C, L, N, F] = MS_love_params(CC) - % From a VTI (uneq X3) elasticity matrix, return - % the five Love parameters A, C, L, N and F + % From a VTI (uneq X3) elasticity matrix, return + % the five Love parameters A, C, L, N and F A = CC(1,1); C = CC(3,3) ; L = CC(4,4); N = CC(6,6) ; F = CC(1,3); - + end function [check] = is_Ti(C) % Check if input elasticity matrix is VTI with unique X3 axis % return 1 if it is and 0 if not. - + thresh = 1e-6 ; - if ( (abs(C(1,4)) > thresh) || (abs(C(1,5)) > thresh) || ... + if ( (abs(C(1,4)) > thresh) || (abs(C(1,5)) > thresh) || ... (abs(C(1,6)) > thresh) || (abs(C(2,4)) > thresh) || ... (abs(C(2,5)) > thresh) || (abs(C(2,6)) > thresh) || ... (abs(C(3,4)) > thresh) || (abs(C(3,5)) > thresh) || ... - (abs(C(3,6)) > thresh) || (abs(C(4,5)) > thresh) || ... + (abs(C(3,6)) > thresh) || (abs(C(4,5)) > thresh) || ... (abs(C(4,6)) > thresh) || (abs(C(5,6)) > thresh) || ... (abs(C(1,1)-C(2,2)) > thresh) || ... (abs(C(4,4)-C(5,5)) > thresh) || ... (abs(C(2,3)-C(1,3)) > thresh) || ... - (abs(C(1,2)-(C(1,1)-2.0*C(6,6))) > thresh) ) + (abs(C(1,2)-(C(1,1)-2.0*C(6,6))) > thresh) ) check = 0; else - check = 1; + check = 1; end end diff --git a/msat/MS_VRH.m b/msat/MS_VRH.m index 6a7024f..b8b5adb 100644 --- a/msat/MS_VRH.m +++ b/msat/MS_VRH.m @@ -2,27 +2,27 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Given n elasticity matricies, densities and phase volume fractions, -% calculate the avarage of the Voigt upper and Reuss lower bound of the -% composite material. +% Given n elasticity matrices, densities and phase volume fractions, +% calculate the average of the Voigt upper and Reuss lower bound of the +% composite material. % % % [Cave,rhave]=MS_VRH(VF, C, rh, ...) % -% Usage: -% [Cave,rhave]=MS_VRH(VF, C, rh) +% Usage: +% [Cave,rhave]=MS_VRH(VF, C, rh) % The volume fractions and densities (VF and rh) can be provided as % vectors of common length n and the elasticities as a (6,6,n) -% matrix. +% matrix. % -% [Cave,rhave]=MS_VRH(VF, C1, rh1, C2, rh2, C3, rh3, ...) -% Alternitivly, VF can be a vector of volume fractions and the -% elasticity matricies and densities given as sequence of arguments -% as (6,6) matricies and scalars. There should be a C,rho argument +% [Cave,rhave]=MS_VRH(VF, C1, rh1, C2, rh2, C3, rh3, ...) +% Alternatively, VF can be a vector of volume fractions and the +% elasticity matrices and densities given as sequence of arguments +% as (6,6) matrices and scalars. There should be a C,rho argument % pair for each entry in the VF vector. % -% [Cave,rhave,Cvoigt,Creuss]=MS_VRH(VF, C, rh, ...) +% [Cave,rhave,Cvoigt,Creuss]=MS_VRH(VF, C, rh, ...) % For both input argument forms, it is possible to access the upper -% and lower bound on the composite elasticity by adding output +% and lower bound on the composite elasticity by adding output % arguments. % % Notes: @@ -33,36 +33,36 @@ % Copyright (c) 2011, James Wookey and Andrew Walker % Copyright (c) 2006, James Wookey % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [Cave,rhave,voigt_ave,reuss_ave]=MS_VRH(VF,C,r,varargin) @@ -71,25 +71,25 @@ optargs = size(varargin,2); if (optargs == 0) % VF, C and r should be arrays of size (n), (6,6,n) and (n), - % respectivly. Check this and proceed. + % respectively. Check this and proceed. np = length(VF) ;% Number of phases sc = size(C); - assert(length(sc) == 3, 'MS:VRH:args', ... - 'For three argument form, C must be size (6,6,np)') - assert(sc(1) == 6, 'MS:VRH:args', ... + assert(length(sc) == 3, 'MS:VRH:args', ... + 'For three argument form, C must be size (6,6,np)') + assert(sc(1) == 6, 'MS:VRH:args', ... 'For three argument form, C must be size (*6*,6,np)') - assert(sc(2) == 6, 'MS:VRH:args', ... + assert(sc(2) == 6, 'MS:VRH:args', ... 'For three argument form, C must be size (6,*6*,np)') - assert(sc(3) == np, 'MS:VRH:args', ... + assert(sc(3) == np, 'MS:VRH:args', ... 'For three argument form, C must be size (6,6,*np*)') - assert(length(r) == np, 'MS:VRH:args', ... + assert(length(r) == np, 'MS:VRH:args', ... 'For three argument form, r must be length np') Cs = C; rs = r; elseif (optargs > 0) % The old interface - VF should be a size (n) and we should see 2n-2 % varargs in pairs of size (6,6) for Cs and scalars for the - % densitys. Check this here then put the values into optargs == 0 + % densities. Check this here then put the values into optargs == 0 % format. np = length(VF); % Number of phases assert((np*2)-2 == (length(varargin)), 'MS:VRH:args', ... @@ -103,7 +103,7 @@ rs(i) = varargin{(i-2).*2+2} ; end end - + %--normalise VF VF = VF ./ sum(VF) ; diff --git a/msat/MS_VTI.m b/msat/MS_VTI.m index 4367921..4c5c09b 100644 --- a/msat/MS_VTI.m +++ b/msat/MS_VTI.m @@ -1,17 +1,17 @@ % MS_VTI - generate elastic constants for a vertically transverse isotropic -% medium from Thomsen parameters. Symmetry is in the 3-axis. +% medium from Thomsen parameters. Symmetry is in the 3-axis. % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Given Thomsen (1986) parameters for a weakly anisotropic -% VTI medium, return the elasticity matrx +% Given Thomsen (1986) parameters for a weakly anisotropic +% VTI medium, return the elasticity matrix % % [C]=MS_VTI(vp,vs,rh,eps,gam,del) % -% Inputs: -% rh : Density (kg/m2) -% vp : km/s -% vs : km/s +% Inputs: +% rh : Density (kg/m2) +% vp : km/s +% vs : km/s % eps, gam, del : Dimensionless % % Output: @@ -19,47 +19,47 @@ % % ** Note: this is wrapper for MS_TI, provided for back-compatibility. ** % -% References: -% Thomsen, L. (1986) "Weak elastic anisotropy" Geophysics +% References: +% Thomsen, L. (1986) "Weak elastic anisotropy" Geophysics % vol.51 pp.1954-1966 % % See also: MS_TI, MS_iso, MS_elasticDB % Copyright (c) 2011-2012, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [C]=MS_VTI(vp,vs,rh,eps,gam,del) -% use MS_TI routine. +% use MS_TI routine. [C]=MS_TI(vp,vs,rh,eps,gam,del,'thomsen') ; return diff --git a/msat/MS_VTI2.m b/msat/MS_VTI2.m index 8193cbd..92b4ca1 100644 --- a/msat/MS_VTI2.m +++ b/msat/MS_VTI2.m @@ -1,12 +1,12 @@ % MS_VTI2 - generate elastic constants for a vertically transverse isotropic -% medium from xi, phi, eta parameters. Symmetry is in the 3-axis. +% medium from xi, phi, eta parameters. Symmetry is in the 3-axis. % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % % [C]=MS_VTI2(vp,vs,rh,xi,phi,eta) % -% Inputs: -% rh : Density (kg/m2) +% Inputs: +% rh : Density (kg/m2) % vp : km/s (isotropic average) % vs : km/s (isotropic average) % xi, phi, eta : Dimensionless anisotropy parameters @@ -15,53 +15,53 @@ % C : Stiffness tensor (6x6 notation, GPa) % % Calculates the elastic tensor for a hexagonal (aka VTI) medium from -% average Vp and Vs, and anisotropic parameters xi, phi and eta. +% average Vp and Vs, and anisotropic parameters xi, phi and eta. % -% See, for example, Panning and Romanowicz (2006) for a definition of the -% parameters. +% See, for example, Panning and Romanowicz (2006) for a definition of the +% parameters. % % ** Note: this is wrapper for MS_TI, provided for back-compatibility. ** % % References: -% Mark Panning and Barbara Romanowicz (2006) A three-dimensional radially -% anisotropic model of shear velocity in the whole mantle. Geophysical -% Journal International v167, 361–379. +% Mark Panning and Barbara Romanowicz (2006) A three-dimensional radially +% anisotropic model of shear velocity in the whole mantle. Geophysical +% Journal International v167, 361–379. % doi: 10.1111/j.1365-246X.2006.03100.x % % See also: MS_TI, MS_VTI, MS_iso, MS_elasticDB % Copyright (c) 2011-2012, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [C]=MS_VTI2(vp,vs,rh,xi,phi,eta) @@ -76,33 +76,33 @@ % vp=vp*1e3; % vs=vs*1e3; % -%% note: xi and phi are defined oppositely; i.e.: +%% note: xi and phi are defined oppositely; i.e.: %% xi = vsv^2/vsh^2 and phi = vph^2/vpv^2 % vsv = sqrt((3.*vs.^2)./(2+xi)) ; % vsh = sqrt(xi.*vsv.^2) ; -% +% % vph = sqrt((5.*vp.^2)./(4+phi)) ; % vpv = sqrt(phi.*vph.^2) ; -% +% % C11 = vph.^2.*rh ; % A % C33 = vpv.^2.*rh ; % C % C44 = vsv.^2.*rh ; % L % C66 = vsh.^2.*rh ; % N -% +% % C12 = C11-2.*C66 ; % C13 = eta.*(C11-2.*C44) ; % F -% +% % C22 = C11 ; % C23 = C13 ; % C55 = C44 ; -% +% % C = [C11 C12 C13 0 0 0 ; ... % C12 C22 C13 0 0 0 ; ... % C13 C13 C33 0 0 0 ; ... % 0 0 0 C44 0 0 ; ... % 0 0 0 0 C55 0 ; ... % 0 0 0 0 0 C66 ] ; -% +% % C = C./1e9 ; % convert to GPa % %return diff --git a/msat/MS_Vrot3.m b/msat/MS_Vrot3.m index 4acf1cd..c79fc91 100644 --- a/msat/MS_Vrot3.m +++ b/msat/MS_Vrot3.m @@ -2,59 +2,59 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Rotates 3-vector(s). +% Rotates 3-vector(s). % % [VR] = MS_Vrot3(V,alp,bet,gam) % alp = clockwise about 1-axis (looking at origin, == yaw) % bet = clockwise about 2-axis (looking at origin, == -dip) % gam = clockwise about 3-axis (looking at origin, == azimuth) % -% [VR] = MS_Vrot3(...,'order',V) +% [VR] = MS_Vrot3(...,'order',V) % order: V is a 3 element vector containing the order in which to apply the 3 rotations. % Default is [1 2 3]. % % % Notes: -% The rotations are applied in order, ie: alpha, then beta then gamma -% One dimension of the input V matrix should be 3. The code tries to infer the -% orientation of the matix by testing which this is. If the matrix is 3x3, -% it is assumed that it contains row vectors (i.e., +% The rotations are applied in order, i.e.: alpha, then beta then gamma +% One dimension of the input V matrix should be 3. The code tries to infer the +% orientation of the matrix by testing which this is. If the matrix is 3x3, +% it is assumed that it contains row vectors (i.e., % [x1,y1,z1; x2,y2,y2; x3 y3 y3]) % % See also: MS_ROT3 % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %=============================================================================== @@ -67,30 +67,30 @@ iarg = 1 ; while iarg <= (length(varargin)) switch lower(varargin{iarg}) - case 'order' + case 'order' orderV = varargin{iarg+1} ; if (length(find(orderV==1))+length(find(orderV==2))+length(find(orderV==3)))~=3 error('MS:VROT3:BadOrder',... - 'Order vector must be 3-element, containing 1,2 and 3') ; + 'Order vector must be 3-element, containing 1,2 and 3') ; end if (length(orderV)~=3) error('MS:VROT3:BadOrder',... - 'Order vector must be 3-element, containing 1,2 and 3') ; - end + 'Order vector must be 3-element, containing 1,2 and 3') ; + end iarg = iarg + 2 ; - otherwise + otherwise error('MS:VROT3:UnknownOption',... - ['Unknown option: ' varargin{iarg}]) ; - end + ['Unknown option: ' varargin{iarg}]) ; + end end [nr nc] = size(Vin) ; % store this to produce output itran = 0 ; - if nr==3 & nc==3 + if nr==3 & nc==3 % ** row vector itran = 1 ; V = transpose(Vin) ; - elseif nr~=3 & nc==3 + elseif nr~=3 & nc==3 % ** row vector itran = 1 ; V = transpose(Vin) ; @@ -100,13 +100,13 @@ else error('MS:VROT3BadInputMatrix', ... 'Input vector matrix must be 3xN or Mx3') ; - end + end % ** Make rotation matrix a = alp * pi/180. ; b = bet * pi/180. ; g = gam * pi/180. ; - + R(1,:,:) = [ 1 0 0 ; 0 cos(a) sin(a) ; 0 -sin(a) cos(a) ] ; R(2,:,:) = [ cos(b) 0 -sin(b) ; 0 1 0 ; sin(b) 0 cos(b) ] ; @@ -115,13 +115,13 @@ RR = squeeze(R(orderV(3),:,:)) * ... squeeze(R(orderV(2),:,:)) * ... squeeze(R(orderV(1),:,:)); - + % ** apply it VR = RR * V; - -% ** put it back in the original shape + +% ** put it back in the original shape if itran, VR=transpose(VR);, end ; - + %=============================================================================== return %=============================================================================== diff --git a/msat/MS_anisotropy.m b/msat/MS_anisotropy.m index 5ed0490..9fbada4 100644 --- a/msat/MS_anisotropy.m +++ b/msat/MS_anisotropy.m @@ -1,61 +1,61 @@ -% MS_ANISOTROPY - Simple measures of anisotropy +% MS_ANISOTROPY - Simple measures of anisotropy % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Calculate the degree of anisotropy of an elasticity matrix. +% Calculate the degree of anisotropy of an elasticity matrix. % % [ uA, ... ] = MS_anisotropy( C, ... ) % -% Usage: -% [ uA ] = MS_anisotropy( C ) +% Usage: +% [ uA ] = MS_anisotropy( C ) % Return the Universal Elastic Anisotropy Index of Ranganathan % and Ostoja-Starzewski (2008). Valid for any elasticity matrix, -% uA is zero for an isotropic case and increases for increasing +% uA is zero for an isotropic case and increases for increasing % anisotropy. % % [ uA, lmA ] = MS_anisotropy( C ) % Also return the general measure of anisotropy proposed by % Ledbetter and Miglion (2006). This the the ratio of the fastest -% and slowest squared shear wave velocity over all propogation -% and polarization directions. Equal to one in the isotropic case, +% and slowest squared shear wave velocity over all propagation +% and polarisation directions. Equal to one in the isotropic case, % increases with increasing anisotropy. % % [ uA, lmA, zA ] = MS_anisotropy( C ) % Also return the Zenner (1948) measure of anisotropy. This is -% only valid for cubic crystals (NaN is returned if C does not +% only valid for cubic crystals (NaN is returned if C does not % represent a cubic crystal). zA is 1 for an isotropic case and -% increases or decreases with incresing anisotropy. +% increases or decreases with increasing anisotropy. % % [ uA, lmA, zA, cbA ] = MS_anisotropy( C ) % Also return the Chung-Buessem (1967) anisotropy index. This % is a single valued measure of anisotropy derived from zA. Like -% uA, this is zero for an isotropic case and increases for increasing -% anisotropy. Only valid for matricies representing cubic crystals. +% uA, this is zero for an isotropic case and increases for increasing +% anisotropy. Only valid for matrices representing cubic crystals. % % [ uA, lmA, ... ] = MS_anisotropy( C, n ) % Set the number of random directions to sample for the calculation % of lmA. Defaults to 1000, which seems to give results accurate to -% two decimal places. Ledbetter and Miglion (2006) use 10000 which -% gives results reproducable to three decimal places and a -% noticable slow down. +% two decimal places. Ledbetter and Miglion (2006) use 10000 which +% gives results reproducible to three decimal places and a +% noticeable slow down. % % Notes: % These measures of anisotropy are independent of orientation. However, % the test for cubic symmetry assumes the matrix is in an ideal -% orention. Use MS_AXES to reorentate the imput matrix for the general +% orientation. Use MS_AXES to reorientate the input matrix for the general % case. MS_NORMS can be used to provide an alternate measure of -% anisotropy. Ledbetter and Miglion (2006) claim lmA is identcal to zA -% for cubic cases but Ranganathan and Ostoja-Starzewski (2008) point -% out cases where zA < 1 while lmA > 1 by construction. +% anisotropy. Ledbetter and Miglion (2006) claim lmA is identical to zA +% for cubic cases but Ranganathan and Ostoja-Starzewski (2008) point +% out cases where zA < 1 while lmA > 1 by construction. % % References: -% Zenner, C. (1948) Elasticity and Anelasticiy of Metals. University -% of Chicago. +% Zenner, C. (1948) Elasticity and Anelasticity of Metals. University +% of Chicago. % -% Chung, D. H. and W. R. Buessem (1967) Journal of Applied Physics -% vol.38 p.5 +% Chung, D. H. and W. R. Buessem (1967) Journal of Applied Physics +% vol.38 p.5 % -% Ledbetter, H. and A. Miglion (2006) "A general elastic-anisotropy +% Ledbetter, H. and A. Miglion (2006) "A general elastic-anisotropy % measure" Journal of Applied Physics vol.100 art.num.063516 % http://dx.doi.org/10.1063/1.2338835 % @@ -67,36 +67,36 @@ % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [ uA, lmA, zA, cbA] = MS_anisotropy( C, varargin ) @@ -106,7 +106,7 @@ if nargin==2 numprop = varargin{1}; end - + uA = UniversalAnisotropyIndex(C); if (nargout == 1), return, end % Skip lmA if we don't need it lmA = LedbetterAnisotropyIndex(C, numprop); @@ -143,15 +143,15 @@ function zA = ZenerAnisotropyIndex( C ) - zA = C(4,4)*2.0 / (C(1,1) - C(1,2)); + zA = C(4,4)*2.0 / (C(1,1) - C(1,2)); -end +end function uA = UniversalAnisotropyIndex( C ) [~, ~, B_v, G_v, B_r, G_r] = MS_polyaverage( C ); uA = (5*(G_v/G_r) + (B_v/B_r)) - 6; - + end function lmA = LedbetterAnisotropyIndex( C, n ) @@ -159,16 +159,16 @@ points = randomSphere(n); % Density should not matter - we ratio velocities. [~,~,vs1,vs2,~] = MS_phasevels(C,3000,points(:,2),points(:,1)); - lmA = (max(vs1))^2 / (min(vs2))^2; - -end + lmA = (max(vs1))^2 / (min(vs2))^2; + +end function points = randomSphere( n ) - % n randomly distributed points on a sphere (polar co-ordinates, + % n randomly distributed points on a sphere (polar coordinates, % in degrees). Points(:,1) are azimuths, points(:,2) are inclinations. points = rand(n,2); points(:,1) = points(:,1)*pi*2.0; points(:,2) = acos(2.0*points(:,2)-1); points = points*(180.0/pi); points(:,2) = points(:,2) - 90.0; -end \ No newline at end of file +end \ No newline at end of file diff --git a/msat/MS_axes.m b/msat/MS_axes.m index 7759793..d7132fc 100644 --- a/msat/MS_axes.m +++ b/msat/MS_axes.m @@ -2,16 +2,16 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Calculate the principle axes of elasticity tensor C, after: +% Calculate the principle axes of elasticity tensor C, after: % Browaeys and Chevrot (GJI, v159, 667-678, 2004) -% +% % [ CR, ... ] = MS_axes(C) % -% [CR] = MS_axes(C) -% Return a rotated elasticity matrix minimising the number of -% distinct elements. This is the orientation which, on further +% [CR] = MS_axes(C) +% Return a rotated elasticity matrix minimising the number of +% distinct elements. This is the orientation which, on further % decomposition using MS_NORMS, will maximise the high symmetry -% components of the matrix. +% components of the matrix. % % [CR, RR] = MS_axes(C) % In addition, return the rotation matrix, RR, used to perform @@ -26,27 +26,27 @@ % align the axes with the axes of the dilational stiffness tensor. % % [ ... ] = MS_axes( C, 'debug' ) -% Enable debugging plots and messages. These are quite messy. +% Enable debugging plots and messages. These are quite messy. % % Notes: -% If the input matrix has isotropic, hexagonal or tetragonal -% symmetry there are multiple orentations of the principle axes. +% If the input matrix has isotropic, hexagonal or tetragonal +% symmetry there are multiple orientations of the principle axes. % In the isotropic case CR is not rotated with respect to C (and RR -% is the identity matrix). In the hexagonal and tetragonal cases, +% is the identity matrix). In the hexagonal and tetragonal cases, % X3 is defined by the distinct eigenvalue (see Browaeys and Chevrot) -% or, if 'X3_stiff', by the stiffest direction. For the monoclinic or -% triclinic cases we have to make a 'best-guess' and following -% Browraeys and Chevrot we use the bisectrix of each of the +% or, if 'X3_stiff', by the stiffest direction. For the monoclinic or +% triclinic cases we have to make a 'best-guess' and following +% Browraeys and Chevrot we use the bisectrix of each of the % eigenvectors of d and its closest match in v. Furthermore, in order -% to always give the same output orientation for the lowest symmetry -% cases, a final rotation is performed to place the maximum P-wave -% velocity in the positive quadrent of the output axis system. +% to always give the same output orientation for the lowest symmetry +% cases, a final rotation is performed to place the maximum P-wave +% velocity in the positive quadrant of the output axis system. % % References: % Browaeys, J. T. and S. Chevrot (2004) Decomposition of the elastic -% tensor and geophysical applications. Geophysical Journal +% tensor and geophysical applications. Geophysical Journal % international v159, 667-678. -% Cowin, S. C. and M. M. Mehrabadi (1987) On the identification of +% Cowin, S. C. and M. M. Mehrabadi (1987) On the identification of % material symmetry for anisotropic elastic materials. Quartely % Journal of Mechanics and Applied Mathematics v40, 451-476. % @@ -54,36 +54,36 @@ % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [ varargout ] = MS_axes( C, varargin ) @@ -105,17 +105,17 @@ case 'debug' debug = 1; iarg = iarg + 1 ; - otherwise + otherwise error('MS:AXES:UnknownOption',... - ['Unknown option: ' varargin{iarg}]) ; - end + ['Unknown option: ' varargin{iarg}]) ; + end end -det_thresh = 100 * sqrt(eps) ; % threshold on flagging an error on the - % orthogonality of the best guess axes +det_thresh = 100 * sqrt(eps) ; % threshold on flagging an error on the + % orthogonality of the best guess axes -% construct D and V matrices -d= [... +% construct D and V matrices +d= [... (C(1,1)+C(1,2)+C(1,3)) (C(1,6)+C(2,6)+C(3,6)) (C(1,5)+C(2,5)+C(3,5)) ; ... (C(1,6)+C(2,6)+C(3,6)) (C(1,2)+C(2,2)+C(3,2)) (C(1,4)+C(2,4)+C(3,4)) ; ... (C(1,5)+C(2,5)+C(3,5)) (C(1,4)+C(2,4)+C(3,4)) (C(1,3)+C(2,3)+C(3,3)) ; ... @@ -126,9 +126,9 @@ (C(1,6)+C(2,6)+C(4,5)) (C(6,6)+C(2,2)+C(4,4)) (C(2,4)+C(3,4)+C(5,6)) ; ... (C(1,5)+C(3,5)+C(4,6)) (C(2,4)+C(3,4)+C(5,6)) (C(5,5)+C(4,4)+C(3,3)) ; ... ] ; - -% calculate eigenvectors and eigenvalues of D and V -[vecd,val]=eig(d) ; vald = [val(1,1) val(2,2) val(3,3)] ; + +% calculate eigenvectors and eigenvalues of D and V +[vecd,val]=eig(d) ; vald = [val(1,1) val(2,2) val(3,3)] ; [vecv,val]=eig(v) ; valv = [val(1,1) val(2,2) val(3,3)] ; D1=vecd(:,1) ; D2=vecd(:,2) ; D3=vecd(:,3) ; @@ -144,7 +144,7 @@ end % count number of distinct eigenvalues. Maximum allowable difference is set -% to be 1/1000th of the norm of the matrix. +% to be 1/1000th of the norm of the matrix. [nud,id] = ndistinct(valv,norm(valv)./1000) ; [nuv,iv] = ndistinct(vald,norm(vald)./1000) ; @@ -161,20 +161,20 @@ irot = 0 ; case 2 if X3_distinct -% ** hexagonal or tetragonal tensor, only one is defined, other ones are -% any two othogonal vectors. X3 is defined by the distinct eigenvalue +% ** hexagonal or tetragonal tensor, only one is defined, other ones are +% any two orthogonal vectors. X3 is defined by the distinct eigenvalue % (see Browaeys and Chevrot). X3=vecd(:,id)' ; % ** check that X3 has changed - if (X3(1)==0 & X3(2)==0) + if (X3(1)==0 & X3(2)==0) irot=0; - else -% ** now set the other two vectors. + else +% ** now set the other two vectors. % we want X2 to be horizontal ... X2=cross(X3,[X3(1) X3(2) 0]) ; X2=X2./norm(X2); % now have a definition for X1 - X1=cross(X3,X2) ; X1=X1./norm(X1) ; + X1=cross(X3,X2) ; X1=X1./norm(X1) ; irot=1; end else @@ -188,20 +188,20 @@ end case 3 % orthorhombic or lower symmetry -% first figure out how many common vectors there are +% first figure out how many common vectors there are neq = 0; for i=1:3 for j=1:3 neq = neq + veceq(vecd(:,i),vecv(:,j),0.01) ; end end -% for if neq=3, then symmetry is orthorhombic +% for if neq=3, then symmetry is orthorhombic if (neq==3) % significant axes are the three eigenvectors X1=vecd(:,1)' ; X2=vecd(:,2)' ; X3=vecd(:,3)' ; - + % [X1,X2,X3] = makeRH(X1,X2,X3) ; % make sure they form a RH set. irot = 1 ; @@ -213,11 +213,11 @@ % monoclinic or triclinic. Here we have to make a 'best-guess'. Following % Browraeys and Chevrot we use the bisectrix of each of the eigenvectors of % d and its closest match in v. - + isMonoOrTri = 1 ; - + [X1,X2,X3]=estimate_basis(D1,D2,D3,V1,V2,V3) ; - + irot = 1 ; if (X3(1)==0 & X3(2)==0), irot=0; end else @@ -225,7 +225,7 @@ % direction is along X3 and the soft direction is along X1. % Eigen vectors are sorted, so treat like orthorhombic but with % sorted eigenvectors - + % Sort the eigenvectors of D [~, ind] = sort(vald, 2, 'descend') ; vecd_out = zeros(3); @@ -233,7 +233,7 @@ vecd_out(:,i) = vecd(:,ind(i)) ; end vecd = vecd_out; - + % Rotate such that X3 is stiff X1=vecd(:,1)' ; X2=vecd(:,2)' ; @@ -241,10 +241,10 @@ irot = 1 ; if (all(all([X1' X2' X3'] == eye(3)))) irot = 0; - end - + end + % We still need to deal with the 180 degree flips - isMonoOrTri = 1 ; + isMonoOrTri = 1 ; end end otherwise @@ -254,7 +254,7 @@ % Now apply the necessary rotation. The three new axes define the rotation % matrix which turns the 3x3 unit matrix (original axes) into the best projection. % So the rotation matrix we need to apply to the elastic tensor is the inverse -% of this. +% of this. if irot % check axes @@ -264,15 +264,15 @@ warning('MS:AXES:WARNING', ... 'MS_axes: Determined axes not orthogonal: DPS = %20.18f %20.18f %20.18f',... dps(1), dps(2), dps(3)) ; - end + end end - + % construct forward rotation matrix R1 = [X1' X2' X3'] ; - + % calculate reverse rotation RR = inv(R1) ; - + if ((det(RR)+1) < det_thresh) % ** Fix rotoinversion if 0 @@ -302,7 +302,7 @@ % the result that gives the fastest P-wave velocity in the [1 1 1] direction if isMonoOrTri [CR,RR] = tryrotations(CR,RR) ; - end + end end else if warn, warning('MS:AXES:WARNING', ... @@ -319,10 +319,10 @@ case 2 varargout{1} = CR ; varargout{2} = RR ; - otherwise + otherwise error('MS:AXES:BadOutputArgs','Requires 1 or 2 output arguments.') end - + return @@ -330,7 +330,7 @@ %%% SUBFUNCTIONS %%% -function [ CRR, RRR ] = tryrotations( CR, RR ) +function [ CRR, RRR ] = tryrotations( CR, RR ) % ** try all combinations of 180 rotations around principle axes % select the one that gives the highest Vp in the [1 1 1] direction x1r = [000 180 000 000 180 000] ; @@ -342,7 +342,7 @@ MS_phasevels( MS_rot3(CR,x1r(i),x2r(i),x3r(i)), 2000, 45, 45 ) ; end [~,ind] = sort(vp) ; % select fastest - + CRR = MS_rot3(CR,x1r(ind(end)),x2r(ind(end)),x3r(ind(end))) ; a = x1r(ind(end)) * pi/180. ; R1 = [ 1 0 0 ; 0 cos(a) sin(a) ; 0 -sin(a) cos(a) ] ; @@ -356,31 +356,31 @@ function [C1,C2,C3]=estimate_basis(A1,A2,A3,B1,B2,B3) % % Estimate the best basis vectors for decomposition. This is bisectrices -% of vectors A1 and B1. -% +% of vectors A1 and B1. +% [~, ind] = max(abs([dot(A1,B1) dot(A1,B2) dot(A1,B3)])) ; eval(sprintf('X=B%1.1i;',ind)) ; if dot(A1,X)<0 C1 = bisectrix(A1,-X)' ; - else + else C1 = bisectrix(A1, X)' ; - end - + end + [dum, ind] = max(abs([dot(A2,B1) dot(A2,B2) dot(A2,B3)])) ; eval(sprintf('X=B%1.1i;',ind)) ; if dot(A2,X)<0 C2 = bisectrix(A2,-X)' ; - else + else C2 = bisectrix(A2, X)' ; - end + end [dum, ind] = max(abs([dot(A3,B1) dot(A3,B2) dot(A3,B3)])) ; eval(sprintf('X=B%1.1i;',ind)) ; if dot(A3,X)<0 C3 = bisectrix(A3,-X)' ; - else + else C3 = bisectrix(A3, X)' ; - end + end % % Enforce orthoganality, and renormalise @@ -399,15 +399,15 @@ return function [i]=veceq(x,y,thresh) -% return the number and indices of distinct entries in a 3 element vector, +% return the number and indices of distinct entries in a 3 element vector, % ignoring a difference of thresh i=1 ; - if length(find(abs(x-y)>thresh))>0, i=0 ;, end + if length(find(abs(x-y)>thresh))>0, i=0 ;, end return function [nd,i]=ndistinct(x,thresh) -% return the number and indices of distinct entries in a 3 element vector, ignoring a +% return the number and indices of distinct entries in a 3 element vector, ignoring a % difference of thresh if (abs(x(1)-x(2))thresh) % all different nd = 3 ; i = 0 ; else % one is different - nd = 2 ; + nd = 2 ; if (abs(x(1)-x(2))thresh)) ; return - - + + diff --git a/msat/MS_build_isotropic.m b/msat/MS_build_isotropic.m index d86b0a0..c8c7d2a 100644 --- a/msat/MS_build_isotropic.m +++ b/msat/MS_build_isotropic.m @@ -2,14 +2,14 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Given two isotropic moduli create an elasticity matrix for an isotropic +% Given two isotropic moduli create an elasticity matrix for an isotropic % material and optionally return all other moduli. % % % [C, ...]=MS_build_isotropic('modname1', mod1, 'modname2', mod2') % -% Usage: -% [C]=MS_build_isotropic('modname1', mod1, 'modname2', mod2') -% Given two isotropic moduli mod1 and mod2 named as strings +% Usage: +% [C]=MS_build_isotropic('modname1', mod1, 'modname2', mod2') +% Given two isotropic moduli mod1 and mod2 named as strings % 'modname1' and 'modname2' return an elasticity matrix C. % Permitted moduli are: % 'lam' - first lame parameter, in GPa @@ -19,50 +19,50 @@ % 'nu' - Poisson's ratio, dimensionless. % 'M' - 'P-wave modulus', in GPa. % -% [C, K, E, lam, mu, nu, M]=MS_build_isotropic('modname1', mod1, 'modname2', mod2') +% [C, K, E, lam, mu, nu, M]=MS_build_isotropic('modname1', mod1, 'modname2', mod2') % Also return all 6 moduli. % % Notes: % Not all combinations of moduli are valid / implemented % % References: -% Stacey F. D. and Davis, P. M. (2008) Physics of the Earth 4th ed. +% Stacey F. D. and Davis, P. M. (2008) Physics of the Earth 4th ed. % Appendix D and Section 10.2. % % See also: MS_POLYAVERAGE % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [ C, K, E, lam, mu, nu, M ] = MS_build_isotropic( varargin ) @@ -138,13 +138,13 @@ error('MS:buildiso:wrongargs', ... 'Cannot construct C from these arguments') end - + M = 2*mu+lam; E = (mu*((3*lam)+(2*mu)))/(lam+mu); K = lam + (2/3)*mu; nu = lam/(2*(lam+mu)); - + % build C C = [M lam lam 0.0 0.0 0.0; ... lam M lam 0.0 0.0 0.0; ... @@ -153,5 +153,5 @@ 0.0 0.0 0.0 0.0 mu 0.0; ... 0.0 0.0 0.0 0.0 0.0 mu ]; - + end \ No newline at end of file diff --git a/msat/MS_checkC.m b/msat/MS_checkC.m index 19a64ce..8a9f11a 100644 --- a/msat/MS_checkC.m +++ b/msat/MS_checkC.m @@ -15,17 +15,17 @@ % 'fast' - run a minimal set of checks (size and type only) % 'warn' - warn only on more sophisticated errors than size/type % 'nosymchk' - disable upper, lower symmetry checking -% 'nozerochk' - disable top left / trace zero checking -% 'nopdefchk' - disable positive definiteness check -% -% Various control parameters can be set by adding parameter,value pairs +% 'nozerochk' - disable top left / trace zero checking +% 'nopdefchk' - disable positive definiteness check +% +% Various control parameters can be set by adding parameter,value pairs % to the arguments % 'thresh',x - set numerical threshold for zero to x (default = 1e-6) % % Notes: % Currently, the following properties of the input elastic stiffness -% matrix, C, are tested: (1) The maxtrix must be of rank 2 and size (6,6). -% (2) The matrix must be symmetrical along the leading diagonal (i.e. +% matrix, C, are tested: (1) The matrix must be of rank 2 and size (6,6). +% (2) The matrix must be symmetrical along the leading diagonal (i.e. % the major symmetry of the elastic constants tensor, Cijkl == Cklij, must % be present). (3) The matrix must be positive-definite and be none zero % in the leading diagonal and top left corner. @@ -33,36 +33,36 @@ % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [isgood] = MS_checkC(C,varargin) @@ -76,7 +76,7 @@ symchk = 1 ; zerochk = 1 ; pdefchk = 1 ; - + % ** process the optional arguments iarg = 1 ; while iarg<=(length(varargin)) @@ -99,10 +99,10 @@ case 'thresh' thresh = varargin{iarg+1} ; iarg = iarg + 2 ; - otherwise - error('Unknown flag') ; - end - end + otherwise + error('Unknown flag') ; + end + end isgood = 1 ; @@ -119,12 +119,12 @@ 'Elasticity matrix error: Appears not to be a 6x6 matrix') end -% ** if fast checking is selected, we're done here. +% ** if fast checking is selected, we're done here. if fast, return, end % ** otherwise, perform more elaborate tests. - -% ** check symmetry + +% ** check symmetry if symchk D=C-C'; if (~isempty(find(abs(D)>thresh, 1))) @@ -135,8 +135,8 @@ else error('MS:CHECKCnotsym',... 'Elasticity matrix error: non-symmetric') - end - end + end + end end % ** check that enough values are set non-zero @@ -151,7 +151,7 @@ else error('MS:CHECKCbadzeros',... 'Elasticity matrix error: zeros in trace or top left') - end + end end end @@ -159,7 +159,7 @@ if pdefchk try [~]=chol(C) ; - catch ME + catch ME % Only process the matlab posdef errors... if ~strcmp(ME.identifier, 'MATLAB:posdef') rethrow(ME) @@ -172,7 +172,7 @@ error('MS:CHECKCnotposdef',... 'Elasticity matrix error: not positive definite') end - end + end end return -%======================================================================================= +%======================================================================================= diff --git a/msat/MS_cij2cijkl.m b/msat/MS_cij2cijkl.m index 9d06998..eb8435b 100644 --- a/msat/MS_cij2cijkl.m +++ b/msat/MS_cij2cijkl.m @@ -2,14 +2,14 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Converts between a a 6x6 Voigt representation and a 3x3x3x3 tensor -% representation of anisotropic elasticity. +% Converts between a a 6x6 Voigt representation and a 3x3x3x3 tensor +% representation of anisotropic elasticity. % % % [CC] = MS_cij2cijkl(C) % -% Usage: -% C must be a rank 2 array with size (6,6). The returned array C will -% be rank 4 with size (3,3,3,3). +% Usage: +% C must be a rank 2 array with size (6,6). The returned array C will +% be rank 4 with size (3,3,3,3). % % Notes: % Do not use this function for the elastic compliance as additional @@ -19,36 +19,36 @@ % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. % 2005/07/04 - fixed Vera Schulte-Pelkum's bug diff --git a/msat/MS_cijkl2cij.m b/msat/MS_cijkl2cij.m index a4b4ff6..1c06567 100644 --- a/msat/MS_cijkl2cij.m +++ b/msat/MS_cijkl2cij.m @@ -2,12 +2,12 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Converts between a 3x3x3x3 tensor representation and a 6x6 Voigt -% representation of anisotropic elasticity. +% Converts between a 3x3x3x3 tensor representation and a 6x6 Voigt +% representation of anisotropic elasticity. % % % [C] = MS_cijkl2cij(CC) % -% Usage: +% Usage: % CC must be a rank 4 array with size (3,3,3,3). The % returned array C will be rank 2 with size (6,6). The elasticity % matrix representation is used as input for almost all MSAT functions. @@ -20,36 +20,36 @@ % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [C] = MS_cijkl2cij(CC) @@ -58,7 +58,7 @@ for jm=1:3 for km=1:3 for lm=1:3 - if ( CC(im,jm,km,lm) ~= 0.0) + if ( CC(im,jm,km,lm) ~= 0.0) [iv,jv]=ijkl2ij_local(im,jm,km,lm) ; C(iv,jv) = CC(im,jm,km,lm); end @@ -68,64 +68,64 @@ end return -function [iv,jv] = ijkl2ij_local(ii,jj,kk,ll) - if (ii==1 & jj==1) +function [iv,jv] = ijkl2ij_local(ii,jj,kk,ll) + if (ii==1 & jj==1) iv=1; end - if (ii==1 & jj==2) + if (ii==1 & jj==2) iv=6; end - if (ii==1 & jj==3) + if (ii==1 & jj==3) iv=5; end - if (ii==2 & jj==1) + if (ii==2 & jj==1) iv=6; end - if (ii==2 & jj==2) + if (ii==2 & jj==2) iv=2; end - if (ii==2 & jj==3) + if (ii==2 & jj==3) iv=4; end - - if (ii==3 & jj==1) + + if (ii==3 & jj==1) iv=5; end - if (ii==3 & jj==2) + if (ii==3 & jj==2) iv=4; end - if (ii==3 & jj==3) + if (ii==3 & jj==3) iv=3; end - - if (kk==1 & ll==1) + + if (kk==1 & ll==1) jv=1; end - if (kk==1 & ll==2) + if (kk==1 & ll==2) jv=6; end - if (kk==1 & ll==3) + if (kk==1 & ll==3) jv=5; end - if (kk==2 & ll==1) + if (kk==2 & ll==1) jv=6; end - if (kk==2 & ll==2) + if (kk==2 & ll==2) jv=2; end - if (kk==2 & ll==3) + if (kk==2 & ll==3) jv=4; end - if (kk==3 & ll==1) + if (kk==3 & ll==1) jv=5; end - if (kk==3 & ll==2) + if (kk==3 & ll==2) jv=4; end - if (kk==3 & ll==3) + if (kk==3 & ll==3) jv=3; end diff --git a/msat/MS_decomp.m b/msat/MS_decomp.m index 74177f7..4f06395 100644 --- a/msat/MS_decomp.m +++ b/msat/MS_decomp.m @@ -2,9 +2,9 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Apply a decomposition of the elasticity tensor C, after: +% Apply a decomposition of the elasticity tensor C, after: % Browaeys and Chevrot (GJI, v159, 667-678, 2004) -% +% % [Ciso] = MS_decomp(C) % Isotropic projection of the elastic tensor. % @@ -13,17 +13,17 @@ % % [Ciso,Chex,Ctet,Cort,Cmon,Ctri] = MS_decomp(C) % All parts of the elastic tensor -% +% % % Notes: -% Output matricies are the partial components of the input elasticity -% matrix which maximise the norm of the high symmetry parts. This -% function assumes that C is in its optimal orientation for +% Output matrices are the partial components of the input elasticity +% matrix which maximise the norm of the high symmetry parts. This +% function assumes that C is in its optimal orientation for % decomposition (use MS_axes to make this so). % % References: % Browaeys, J. T. and S. Chevrot (2004) Decomposition of the elastic -% tensor and geophysical applications. Geophysical Journal +% tensor and geophysical applications. Geophysical Journal % international v159, 667-678. % @@ -31,44 +31,44 @@ % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [ varargout ] = MS_decomp( C ) i=nargout ; - + if (nargout==6), i=5;, end - + for i=1:5 [X]=C2X(C) ; M=Projector(i) ; @@ -79,24 +79,24 @@ end if (nargout==6), varargout{6} = C;, end - + return function M=Projector(order) -switch order +switch order case 1 % isotropic M = zeros(21,21) ; M(1:9,1:9) = [ ... - 3/15 3/15 3/15 sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 2/15 2/15 2/15 ; ... - 3/15 3/15 3/15 sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 2/15 2/15 2/15 ; ... - 3/15 3/15 3/15 sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 2/15 2/15 2/15 ; ... - sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 4/15 4/15 4/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 ; ... - sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 4/15 4/15 4/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 ; ... - sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 4/15 4/15 4/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 ; ... - 2/15 2/15 2/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 1/5 1/5 1/5 ; ... - 2/15 2/15 2/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 1/5 1/5 1/5 ; ... - 2/15 2/15 2/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 1/5 1/5 1/5 ; ... + 3/15 3/15 3/15 sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 2/15 2/15 2/15 ; ... + 3/15 3/15 3/15 sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 2/15 2/15 2/15 ; ... + 3/15 3/15 3/15 sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 2/15 2/15 2/15 ; ... + sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 4/15 4/15 4/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 ; ... + sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 4/15 4/15 4/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 ; ... + sqrt(2)/15 sqrt(2)/15 sqrt(2)/15 4/15 4/15 4/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 ; ... + 2/15 2/15 2/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 1/5 1/5 1/5 ; ... + 2/15 2/15 2/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 1/5 1/5 1/5 ; ... + 2/15 2/15 2/15 -sqrt(2)/15 -sqrt(2)/15 -sqrt(2)/15 1/5 1/5 1/5 ; ... ] ; case 2 % hexagonal M = zeros(21,21) ; @@ -143,7 +143,7 @@ function [X]=C2X(C) % after Browaeys and Chevrot (GJI, 2004) X = zeros(21,1) ; - + X(1) = C(1,1) ; X(2) = C(2,2) ; X(3) = C(3,3) ; @@ -165,13 +165,13 @@ X(19) = 2.*sqrt(2).*C(5,6) ; X(20) = 2.*sqrt(2).*C(4,6) ; X(21) = 2.*sqrt(2).*C(4,5) ; - + return function [C]=X2C(X) % after Browaeys and Chevrot (GJI, 2004) C = zeros(6,6) ; - + C(1,1) = X(1); C(2,2) = X(2); C(3,3) = X(3); @@ -193,11 +193,11 @@ C(5,6) = 1./(2.*sqrt(2)).*X(19); C(4,6) = 1./(2.*sqrt(2)).*X(20); C(4,5) = 1./(2.*sqrt(2)).*X(21); - + for i=1:6 for j=i:6 C(j,i) = C(i,j) ; end - end - + end + return diff --git a/msat/MS_effective_medium.m b/msat/MS_effective_medium.m index 893533f..1bd5f1f 100644 --- a/msat/MS_effective_medium.m +++ b/msat/MS_effective_medium.m @@ -1,18 +1,18 @@ % MS_effective_medium - generate elastic constants from various effective -% medium theories. +% medium theories. % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // -% -% Generate elastic constants for the effective medium parameters based on -% various theories, identified by the string 'theory'. Subsequent required -% arguments depend on the theory invoked. +% +% Generate elastic constants for the effective medium parameters based on +% various theories, identified by the string 'theory'. Subsequent required +% arguments depend on the theory invoked. % % Currently available theories: % %Tandon and Weng, 84 ('tandon' or 't&w') Spheroids %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -% (Isotropic host matrix with unidirectionally aligned isotropic spheroid -% inclusions) +% (Isotropic host matrix with unidirectionally aligned isotropic spheroid +% inclusions) % % % [Ceff,rh]=MS_effective_medium('t&w',vpm,vsm,rhm,vpi,vsi,rhi,del,f) or @@ -22,7 +22,7 @@ % del < 1 = smarties % del = 1 = spheres % del > 1 = cigars -% f : volume fractions of inclusions +% f : volume fractions of inclusions % vpi, vsi, rhi : isotropic parameters of the inclusions % % [Ceff,rh]=MS_effective_medium('t&w',Cm,rhm,Ci,rhi,del,f) or @@ -32,7 +32,7 @@ % del < 1 = smarties % del = 1 = spheres % del > 1 = cigars -% f : volume fractions of inclusions +% f : volume fractions of inclusions % Ci, rhi : isotropic parameters of the inclusions % % Output parameters: @@ -47,14 +47,14 @@ % Input parameters: % vpm,vsm,rhm : isotropic parameters of the matrix (km/s, kg/m3) % ar : aspect ratio of cracks -% cd : crack density +% cd : crack density % vpc, vsc, rhc : isotropic parameters of the fill material % % [Ceff,rh]=MS_effective_medium('hudson',Cm,rhm,Ci,rhi,ar,cd) or % Input parameters: % Cm,rh : elasticity and density of the matrix (GPa, kg/m3) % ar : aspect ratio of cracks -% cd : crack density +% cd : crack density % Cc, rhc : isotropic parameters of the fill material % % Output parameters: @@ -86,56 +86,56 @@ %References %~~~~~~~~~~ % -% Tandon, GP and Weng, GJ. The Effect of Aspect Ratio of Inclusions on the -% Elastic Properties of Unidirectionally Aligned Composites. Polymer +% Tandon, GP and Weng, GJ. The Effect of Aspect Ratio of Inclusions on the +% Elastic Properties of Unidirectionally Aligned Composites. Polymer % Composites, 5, pp 327-333, 1984. % -% Hudson, J. A., Overall properties of a cracked solid, Math. Proc. Camb. +% Hudson, J. A., Overall properties of a cracked solid, Math. Proc. Camb. % Phil. Soc., 88, pp 371-384. 1980 % -% Hudson, J. A., Wave speeds and attenuation of elastic waves in material +% Hudson, J. A., Wave speeds and attenuation of elastic waves in material % containing cracks, Geophys. J. R. Astr. Soc., 64, pp 133-150. 1981 -% -% Crampin, S. Effective anisotropic elastic constants for wave propagation +% +% Crampin, S. Effective anisotropic elastic constants for wave propagation % through cracked solids. Geophys. J. R. Astr. Soc., 76, pp 135-145, 1984 % -% Backus, G. E., Long-Wave Elastic Anisotropy Produced by Horizontal Layering. +% Backus, G. E., Long-Wave Elastic Anisotropy Produced by Horizontal Layering. % J. Geophys. Res., pp 4427-4440 % % See also: MS_elasticDB % Copyright (c) 2011-2012, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [Ceff,rh]=MS_effective_medium(theory, varargin) ; @@ -153,25 +153,25 @@ 'Tandon and Weng (1984) requires 6 or 8 input parameters.') ; end if length(varargin)==6 % elasticity matrix form - Cm = varargin{1} ; rhm = varargin{2} ; + Cm = varargin{1} ; rhm = varargin{2} ; Ci = varargin{3} ; rhi = varargin{4} ; del = varargin{5} ; f = varargin{6} ; % ** check the matrices MS_checkC(Cm) ; - if MS_anisotropy( Cm) > 10*sqrt(eps) % not isotropic + if MS_anisotropy( Cm) > 10*sqrt(eps) % not isotropic error('MS:EFFECTIVE_MEDIUM:TWBadC', ... 'Tandon and Weng (1984) requires isotropic inputs matrices.') ; end MS_checkC(Ci) ; - if MS_anisotropy( Ci ) > 10*sqrt(eps) % not isotropic + if MS_anisotropy( Ci ) > 10*sqrt(eps) % not isotropic error('MS:EFFECTIVE_MEDIUM:TWBadC', ... 'Tandon and Weng (1984) requires isotropic input matrices.') ; end -% ** unload the +% ** unload the vpm = sqrt(Cm(3,3)*1e3./rhm) ; vsm = sqrt(Cm(6,6)*1e3./rhm) ; vpi = sqrt(Ci(3,3)*1e3./rhi) ; vsi = sqrt(Ci(6,6)*1e3./rhi) ; else % velocity form - vpm = varargin{1} ; vsm = varargin{2} ; rhm = varargin{3} ; + vpm = varargin{1} ; vsm = varargin{2} ; rhm = varargin{3} ; vpi = varargin{4} ; vsi = varargin{5} ; rhi = varargin{6} ; del = varargin{7} ; f = varargin{8} ; end @@ -183,17 +183,17 @@ 'Hudson (1981,1982) cracks require 6 or 8 input parameters.') ; end if length(varargin)==6 % elasticity matrix form - Cm = varargin{1} ; rhm = varargin{2} ; + Cm = varargin{1} ; rhm = varargin{2} ; Cc = varargin{3} ; rhc = varargin{4} ; aspr = varargin{5} ; cden = varargin{6} ; % ** check the matrices MS_checkC(Cm) ; - if MS_anisotropy( Cm) > 10*sqrt(eps) % not isotropic + if MS_anisotropy( Cm) > 10*sqrt(eps) % not isotropic error('MS:EFFECTIVE_MEDIUM:HuBadC', ... 'Hudson (1981,1982) cracks require isotropic inputs matrices.') ; end MS_checkC(Cc) ; - if MS_anisotropy( Cc ) > 10*sqrt(eps) % not isotropic + if MS_anisotropy( Cc ) > 10*sqrt(eps) % not isotropic error('MS:EFFECTIVE_MEDIUM:HuBadC', ... 'Hudson (1981,1982) cracks require isotropic input matrices.') ; end @@ -201,9 +201,9 @@ vpm = sqrt(Cm(3,3)*1e3./rhm) ; vsm = sqrt(Cm(6,6)*1e3./rhm) ; vpc = sqrt(Cc(3,3)*1e3./rhc) ; vsc = sqrt(Cc(6,6)*1e3./rhc) ; else % velocity form - vpm = varargin{1} ; vsm = varargin{2} ; rhm = varargin{3} ; + vpm = varargin{1} ; vsm = varargin{2} ; rhm = varargin{3} ; vpc = varargin{4} ; vsc = varargin{5} ; rhc = varargin{6} ; - aspr = varargin{7} ; cden = varargin{8} ; + aspr = varargin{7} ; cden = varargin{8} ; end [Ceff,rh]=MS_hudson_cracks(vpm,vsm,rhm,vpc,vsc,rhc,aspr,cden) ; %------------------------------------------------------------------------------- @@ -213,24 +213,24 @@ 'Backus (1962) layering requires 3 or 4 input parameters.') ; end if length(varargin)==3 % elasticity matrix form - h = varargin{1} ; C = varargin{2} ; rh = varargin{3} ; - + h = varargin{1} ; C = varargin{2} ; rh = varargin{3} ; + % ** check the matrices - [dum dum nC] = size(C) ; - + [dum dum nC] = size(C) ; + if length(rh)~=nC error('MS:EFFECTIVE_MEDIUM:BaVectorLengths', ... 'Backus (1962) layering requires equal length vectors.') ; - end - + end + for iC = 1:nC Ctmp = C(:,:,iC) ; MS_checkC(Ctmp) ; - if MS_anisotropy(Ctmp) > 10*sqrt(eps) % not isotropic + if MS_anisotropy(Ctmp) > 10*sqrt(eps) % not isotropic error('MS:EFFECTIVE_MEDIUM:BaBadC', ... 'Backus (1962) layering requires isotropic input matrices.') ; end - end + end % ** unload the velocities @@ -239,19 +239,19 @@ vp = sqrt(squeeze(C(3,3,:)).*1e3./rh) ; vs = sqrt(squeeze(C(6,6,:)).*1e3./rh) ; else % velocity form - h = varargin{1} ; vp = varargin{2} ; - vs = varargin{3} ; rh = varargin{4} ; + h = varargin{1} ; vp = varargin{2} ; + vs = varargin{3} ; rh = varargin{4} ; end % ** TODO: check vector lengths -% ** reshape so all vectors are the same orientation +% ** reshape so all vectors are the same orientation nl = length(h) ; h = reshape(h,1,nl) ; vp = reshape(vp,1,nl) ; vs = reshape(vs,1,nl) ; rh = reshape(rh,1,nl) ; - + [Ceff,rh]=MS_backus_average(h,vp,vs,rh) ; %------------------------------------------------------------------------------- otherwise @@ -266,10 +266,10 @@ function [Ceff,rheff] = MS_backus_average(h,vp,vs,rh) %----------------------------------------------------------------------- % Subroutine to perform Backus Averaging of a stack of horizontal -% isotropic layers to form a homogenous VTI media. +% isotropic layers to form a homogeneous VTI media. % % Inputs: -% +% % h(1..n) : Individual thicknesses (not depths!) of the n layers % vp(1..n) : Isotropic P-wave velocities of the n layers (km/s) % vs(1..n) : Isotropic S-wave velocities of the n layers (km/s) @@ -277,12 +277,12 @@ % % Outputs: % -% Ceff(6,6) : Effective elasticity of the package. +% Ceff(6,6) : Effective elasticity of the package. % rheff : Density of the package. %----------------------------------------------------------------------- vp = vp.*1e3 ; vs = vs.*1e3 ; - + % % Sum over all the layers, weighted by the layer thickness, to generate the % Backus parameters. @@ -299,9 +299,9 @@ l1 = sum(h.*(1./(rh.*vs.^2)))./sum(h) ; m1 = sum(h.*(rh.*vs.^2))./sum(h) ; rhave = sum(h.*rh)./sum(h) ; -% +% % Form Backus coefficients -% +% a = a1 + 1./a2 .* a3.^2 ; b = b1 + 1./b2 .* b3.^2 ; c = 1./c1 ; @@ -309,8 +309,8 @@ l = 1./l1 ; m = m1 ; % -% Form the effective matrix. -% +% Form the effective matrix. +% Ceff = [a b f 0 0 0 ; ... b a f 0 0 0 ; ... f f c 0 0 0 ; ... @@ -321,19 +321,19 @@ % convert to GPa Ceff = Ceff ./ 1e9 ; - + end function [CC,rh]=MS_tandon_and_weng(vp,vs,rho,vpi,vsi,rhoi,del,c) -% based on original FORTRAN code by Mike Kendall. +% based on original FORTRAN code by Mike Kendall. % weighted average density rh = (1.0-c)*rho + c*rhoi ; - vp = vp * 1e3 ; % convert to m/s + vp = vp * 1e3 ; % convert to m/s vs = vs * 1e3 ; % convert to m/s - vpi = vpi * 1e3 ; % convert to m/s + vpi = vpi * 1e3 ; % convert to m/s vsi = vsi * 1e3 ; % convert to m/s amu = vs*vs*rho ; @@ -386,11 +386,11 @@ s55 = s66 ; % % Tandon and Weng's B terms (after equation 17). - B1 = c*D1 + D2 + (1.0-c)*(D1*s11 + 2.0*s21) ; - B2 = c + D3 + (1.0-c)*(D1*s12 + s22 + s23) ; - B3 = c + D3 + (1.0-c)*(s11 + (1.0+D1)*s21) ; - B4 = c*D1 + D2 + (1.0-c)*(s12 + D1*s22 + s23) ; - B5 = c + D3 + (1.0-c)*(s12 + s22 + D1*s23) ; + B1 = c*D1 + D2 + (1.0-c)*(D1*s11 + 2.0*s21) ; + B2 = c + D3 + (1.0-c)*(D1*s12 + s22 + s23) ; + B3 = c + D3 + (1.0-c)*(s11 + (1.0+D1)*s21) ; + B4 = c*D1 + D2 + (1.0-c)*(s12 + D1*s22 + s23) ; + B5 = c + D3 + (1.0-c)*(s12 + s22 + D1*s23) ; % % Tandon and Weng's A terms (after equation 20). A1 = D1*(B4 + B5) - 2.0*B2 ; @@ -400,7 +400,7 @@ A5 = (1.0 - D1)/(B4 - B5) ; A = 2.0*B2*B3 - B1*(B4+B5) ; % -% Tandon and Weng (1984) equations (25) (28) (31) (32) +% Tandon and Weng (1984) equations (25) (28) (31) (32) E11 = E0 /(1.0+c*(A1+2.0*anu*A2)/A) ; E22 = E0 ... /(1.0+c*(-2.0*anu*A3 + (1.0-anu)*A4 + (1.0+anu)*A5*A)/(2.0*A)) ; @@ -421,17 +421,17 @@ % % Cij - Sayers' (1992) equations (24)-(29). -% Conversion -% - CC(2,2) = amu23 + aK23 ; - CC(3,3) = CC(2,2) ; - CC(1,1) = E11 + 4.0*anu12tst*aK23 ; - CC(2,3) = -amu23 + aK23 ; - CC(1,2) = 2.0*anu31*aK23 ; - CC(1,3) = CC(1,2) ; - CC(5,5) = amu12 ; - CC(6,6) = CC(5,5) ; - CC(4,4) = (CC(2,2)-CC(2,3))/2.0 ; +% Conversion +% + CC(2,2) = amu23 + aK23 ; + CC(3,3) = CC(2,2) ; + CC(1,1) = E11 + 4.0*anu12tst*aK23 ; + CC(2,3) = -amu23 + aK23 ; + CC(1,2) = 2.0*anu31*aK23 ; + CC(1,3) = CC(1,2) ; + CC(5,5) = amu12 ; + CC(6,6) = CC(5,5) ; + CC(4,4) = (CC(2,2)-CC(2,3))/2.0 ; % Fill out matrix by symmetry % make symmetrical @@ -442,24 +442,24 @@ end % convert to GPa -CC = CC./1e9 ; +CC = CC./1e9 ; end function [cc,rhoeff]=MS_hudson_cracks(vp,vs,rho,vpc,vsc,rhoc,aspr,cden) -% based on original FORTRAN code by Mike Kendall. +% based on original FORTRAN code by Mike Kendall. % convert to m/s - vp = vp * 1e3 ; - vs = vs * 1e3 ; + vp = vp * 1e3 ; + vs = vs * 1e3 ; vpc = vpc * 1e3 ; vsc = vsc * 1e3 ; -% calculate volume fraction +% calculate volume fraction fv = cden*aspr*pi ; rhoeff = (1.0-fv)*rho + fv*rhoc ; - + % amu=shear modulus (mu), alam=lambda, bm=bulk modulus (kappa) % trailing "c" denotes crack property. amu = vs*vs*rho ; @@ -467,7 +467,7 @@ alam = vp*vp*rho - 2.0*amu ; alamc = vpc*vpc*rhoc - 2.0*amuc ; bmc = alamc + amuc*2.0/3.0 ; - + % Equation (4) of Crampin (1984, GJRAS) term1 = alam + 2.0*amu ; term2 = 3.0*alam + 4.0*amu ; @@ -478,7 +478,7 @@ % U11 = (4.0/3.0)*(term1/term3)/(1.0+AK) ; U33 = (16.0/3.0)*(term1/term2)/(1.0+AM) ; - + % Equation (2) of Crampin (1984, GJRAS) term5= -cden/amu ; c111 = term1*term1*U11*term5 ; @@ -490,7 +490,7 @@ c112 = alam*term1*U11*term5 ; c113 = alam*term1*U11*term5 ; c123 = alam*alam*U11*term5 ; - + % Equation (3) of Crampin (1984, GJRAS) term6= cden*cden/15.0 ; qterm= 15.0*alam*alam/amu/amu + 28.0*alam/amu + 28.0 ; @@ -526,12 +526,12 @@ cc(1,2)=(c12+c112+c212) ; cc(1,3)=(c13+c113+c213) ; cc(2,3)=(c23+c123+c223) ; - + cc(2,1)=cc(1,2) ; cc(3,1)=cc(1,3) ; cc(3,2)=cc(2,3) ; - -% convert to GPa + +% convert to GPa cc = cc./1e9 ; end diff --git a/msat/MS_effective_splitting_N.m b/msat/MS_effective_splitting_N.m index 4de44b1..6a4ba8b 100644 --- a/msat/MS_effective_splitting_N.m +++ b/msat/MS_effective_splitting_N.m @@ -1,5 +1,5 @@ % MS_EFFECTIVE_SPLITTING_N - N-layer effective splitting operator calculation. -% +% % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % % [fast_eff,tlag_eff]=MS_effective_splitting_N(f, spol, fast, tlag, ...) @@ -7,104 +7,104 @@ % Common Inputs: % f (scalar) : Dominant frequency of wave (Hz) % spol (scalar) : initial source polarisation (degrees) -% fast (scalar/vector) : fast direction(s) of layer(s) to be +% fast (scalar/vector) : fast direction(s) of layer(s) to be % included (s) % tlag (scalar/vector) : lag time(s) of layer(s) to be included % (degrees) % % Fast and tlag can be scalars or vectors but must all be the same length. -% +% % Usage: % [fast_eff,tlag_eff]=MS_effective_splitting_N(f, spol, fast, tlag) -% or +% or % [fast_eff,tlag_eff]=MS_effective_splitting_N(f, spol, fast, tlag, ... % 'mode', 'S&S') % % Calculate effective splitting parameters using the method of Silver % and Savage (1994). CAUTION! This is quick but is known to fail if the delay % time becomes large compared to the dominant frequency of the wave. It -% also gives unstable results when the source polarisation is near the -% effective fast direction. This would, however probably be seen as a +% also gives unstable results when the source polarisation is near the +% effective fast direction. This would, however probably be seen as a % null result anyway. -% +% % [fast_eff,tlag_eff]=MS_effective_splitting_N(f, spol, fast, tlag, ... % 'mode', 'GaussianWavelet') % -% Calculate effective splitting parameters by first applying the -% splitting operators in sequence to an unsplit first-derivative -% Gaussian wavelet then searching for the effective splitting operator -% that minimises the second eigenvalue of the covariance matrix -% of the result. This is the ray theory approach described by -% Bonnin et al. (2012). +% Calculate effective splitting parameters by first applying the +% splitting operators in sequence to an unsplit first-derivative +% Gaussian wavelet then searching for the effective splitting operator +% that minimises the second eigenvalue of the covariance matrix +% of the result. This is the ray theory approach described by +% Bonnin et al. (2012). % % [fast_eff,tlag_eff]=MS_effective_splitting_N(f, spol, fast, tlag, ... % 'mode', 'GaussianWavelet', 'PlotWavelet') % % Plot the resulting wavelet when in GaussianWavelet mode. % -% References: +% References: % M. Bonnin, A. Tommasi, R. Hassani, S. Chevrot, J. Wookey, G. Barruol % (2012) "Numerical modelling of the upper-mantle anisotropy beneath -% a migrating strike-slip plate boundary: the San Andreas Fault +% a migrating strike-slip plate boundary: the San Andreas Fault % system" Geophysical Journal International, v191 pp 436-458. % http://dx.doi.org/10.1111/j.1365-246X.2012.05650.x % Silver, P. G. and Savage, M. K. 1994 "The interpretation of shear-wave -% splitting parameters in the presence of two anisotropic layers" -% Geophysical Journal International, v119 pp 949-963. +% splitting parameters in the presence of two anisotropic layers" +% Geophysical Journal International, v119 pp 949-963. % Copyright (c) 2011-2013 James Wookey and Andrew Walker % Copyright (c) 2005-2011, James Wookey % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %=============================================================================== function [fast_eff,tlag_eff]=MS_effective_splitting_N(f,spol,fast,tlag, varargin) %=============================================================================== -% check inputs are the same size +% check inputs are the same size if ~isequal(length(fast),length(tlag)) error('MS:ListsMustMatch', ... - 'Input fast and tlag vectors must be of the same length') + 'Input fast and tlag vectors must be of the same length') end - + mode = 's&s'; plotwave = 0; - + iarg = 1 ; while iarg <= (length(varargin)) switch lower(varargin{iarg}) case 'mode' - mode = lower(varargin{iarg+1}) ; + mode = lower(varargin{iarg+1}) ; iarg = iarg + 2; case 'plotwavelet' plotwave = 1; @@ -114,8 +114,8 @@ ['Unknown option: ' varargin{iarg}]) ; end end - - if strcmp(mode, 's&s') + + if strcmp(mode, 's&s') [fast_eff,tlag_eff]=MS_effective_splitting_N_SS(f,spol,fast,tlag); elseif strcmp(mode, 'gaussianwavelet') [fast_eff,tlag_eff]=MS_effective_splitting_N_GW(f,spol,... @@ -127,7 +127,7 @@ end function [fast_eff,tlag_eff]=MS_effective_splitting_N_SS(f,spol,fast,tlag) - + % check for just one layer if length(fast)==1 fast_eff = fast ; @@ -154,43 +154,43 @@ % unwind the fast directions fast = MS_unwind_pm_90(fast) ; - -%**process + +%**process w = 2.0 .* pi .* f ; th = w .* tlag ./ 2. ; al = 2.*(fast-spol) .* pi/180.0 ; - + S = prod(cos(th)) ; Cc = S.*sum((tan(th).*cos(al))) ; Cs = S.*sum((tan(th).*sin(al))) ; - + n=length(fast) ; - + ap = 0; app = 0; - + for i=1:n-1 for j=i+1:n ap = ap + (tan(th(i)).*tan(th(j)).*cos(al(i)-al(j))) ; app = app + (tan(th(i)).*tan(th(j)).*sin(al(i)-al(j))) ; end end - + ap = S.*(1-ap) ; app = S.*app ; ala = atan ( (app.^2.+Cs.^2.) ./ (app.*ap + Cs.*Cc) ) ; tha = atan ( (app) ./ (Cs.*cos(ala)-Cc.*sin(ala)) ) ; - + fast_eff = spol + (ala.*180./pi) ./ 2. ; - tlag_eff = 2.*tha./w ; - + tlag_eff = 2.*tha./w ; + fast_eff = MS_unwind_pm_90(fast_eff) ; -%**handle zero tlags +%**handle zero tlags if (tlag_eff < 0) fast_eff = MS_unwind_pm_90(fast_eff+90) ; tlag_eff = abs(tlag_eff) ; - end + end end @@ -209,16 +209,16 @@ [T00,T90] = MS_split_trace(time,T00,T90,fast(i),tlag(i)); end end - + [fast_eff, tlag_eff] = MS_measure_trace_splitting(time, T00, T90, ... 15, 0.5.*min(tlag), sum(tlag)); - + fast_eff = MS_unwind_pm_90(fast_eff) ; if (tlag_eff < 0) fast_eff = MS_unwind_pm_90(fast_eff+90) ; tlag_eff = abs(tlag_eff) ; - end - + end + if plotwave [~, T00or, T90or] = MS_make_trace(spol,f, sum(tlag)); [T00us, T90us] = MS_split_trace(time,T00,T90,fast_eff,-tlag_eff); @@ -231,11 +231,11 @@ function [ fastA , tlagA ] = aggregate( fast , tlag, varargin ) % Agglomerate splitting operators which are (near) parallel or -% perpendicular. +% perpendicular. % - + threshold = 1 ; - + % process the optional arguments iarg = 1 ; while iarg <= (length(varargin)) @@ -243,28 +243,28 @@ case 'threshold' % parameter definition (value required) threshold = varargin{iarg+1} ; iarg = iarg + 2 ; - otherwise + otherwise error('MS:EFFECTIVE_SPLITTING_N:UnknownOption',... - ['Unknown option: ' varargin{iarg}]) ; + ['Unknown option: ' varargin{iarg}]) ; end - end + end % new arrays fast_agg = zeros(size(fast))+NaN ; tlag_agg = zeros(size(fast))+NaN ; - + N = length(fast) ; - + iRef = 1 ; iAgg = 1 ; iComp = 2 ; - + fast_agg(1) = fast(1) ; tlag_agg(1) = tlag(1) ; - - % process the fast directions. If the reference direction and the - % comparison direction are (nearly) identical, sum the tlags. If they - % differ by (nearly) 90 degrees, take the difference. + + % process the fast directions. If the reference direction and the + % comparison direction are (nearly) identical, sum the tlags. If they + % differ by (nearly) 90 degrees, take the difference. while iComp<=N if abs(fast(iRef)-fast(iComp)) thresh & abs(RR) < (1-thresh)) ; if ~isempty(ind) OUT = sprintf([OUT, ' Principle axes appear to be in a different', ... ' orientation to this matrix.\n']); OUT = sprintf([OUT, '\n rotation matrix =\n\n']); - OUT = sprintf([OUT, '%6.3f %6.3f %6.3f\n%6.3f %6.3f %6.3f\n%6.3f %6.3f %6.3f\n'],... - RR(1,1),RR(1,2),RR(1,3),RR(2,1),RR(2,2),RR(2,3),RR(3,1),RR(3,2),RR(3,3)); + OUT = sprintf([OUT, '%6.3f %6.3f %6.3f\n%6.3f %6.3f %6.3f\n%6.3f %6.3f %6.3f\n'],... + RR(1,1),RR(1,2),RR(1,3),RR(2,1),RR(2,2),RR(2,3),RR(3,1),RR(3,2),RR(3,3)); else OUT = sprintf([OUT, ' Elasticity matrix appears unrotated.\n']); - end + end catch ME OUT = sprintf([OUT, ' Principle axis check failed.\n\n']); end end - + % ** Velocity information if inf_vels OUT = sprintf([OUT, '\n---VELOCITY INFORMATION \n\n']); CR = MS_axes(C, 'nowarn') ; [Ciso] = MS_decomp(CR) ; - + OUT = sprintf([OUT, ' Isotropic velocities: Vp = %6.3f , Vs = %6.3f\n\n'], ... - 1e-3.*sqrt((Ciso(3,3)*1e9)./rh), 1e-3.*sqrt((Ciso(4,4)*1e9)./rh)) ; - - + 1e-3.*sqrt((Ciso(3,3)*1e9)./rh), 1e-3.*sqrt((Ciso(4,4)*1e9)./rh)) ; + + azi = [ 0 -90 0 ] ; inc = [ 0 0 90] ; - + [pol,avs,vs1,vs2,vp] = MS_phasevels(C,rh,inc,azi) ; - + OUT = sprintf([OUT, ' Direction VP VS1 VS2 VSAni \n']) ; OUT = sprintf([OUT, ' X1 %6.3f %6.3f %6.3f %6.3f \n'], ... vp(1),vs1(1),vs2(1),avs(1)) ; OUT = sprintf([OUT, ' X2 %6.3f %6.3f %6.3f %6.3f \n'], ... vp(2),vs1(2),vs2(2),avs(2)) ; OUT = sprintf([OUT, ' X3 %6.3f %6.3f %6.3f %6.3f \n'], ... - vp(3),vs1(3),vs2(3),avs(3)) ; - - - + vp(3),vs1(3),vs2(3),avs(3)) ; + + + end switch nargout case 0 - fprintf(OUT) + fprintf(OUT) case 1 varargout(1) = {OUT} ; otherwise error('MS:BADOUTPUT', ... 'MS_info requires 0-1 output arguments.') ; - end - + end + %=============================================================================== return %=============================================================================== diff --git a/msat/MS_interpolate.m b/msat/MS_interpolate.m index 82fa426..58f3ffc 100644 --- a/msat/MS_interpolate.m +++ b/msat/MS_interpolate.m @@ -1,34 +1,34 @@ -% MS_INTERPOLATE - Symmetry preserving elasticity interpolation +% MS_INTERPOLATE - Symmetry preserving elasticity interpolation % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Symmetry aware linear interpolation between two elasticity matrices. +% Symmetry aware linear interpolation between two elasticity matrices. % % % [ Cint, RhoInt ] = MS_interpolate( C1, rho1, C2, rho2, frac) % -% Usage: -% [ Cint, RhoInt ] = MS_interpolate( C1, rho1, C2, rho2, frac) +% Usage: +% [ Cint, RhoInt ] = MS_interpolate( C1, rho1, C2, rho2, frac) % Returns an elasticity matrix interpolated frac distance -% between elasticity matricies C1 and C2. Frac = 1 gives -% the elasticity of C1, frac = 0 gives the elasticity of +% between elasticity matrices C1 and C2. Frac = 1 gives +% the elasticity of C1, frac = 0 gives the elasticity of % C2. % % % Notes: -% A common approach to the interpolation of elasticity matricies -% is to interpolate elements component-wise. This fails for cases -% where the elasticity matricies are just rotated versions of each -% other. The approach taken here is to first rotate the two matricies +% A common approach to the interpolation of elasticity matrices +% is to interpolate elements component-wise. This fails for cases +% where the elasticity matrices are just rotated versions of each +% other. The approach taken here is to first rotate the two matrices % into a common orientation (the one generated by MS_axes is chosen) -% before interpolating element-wise (Voigt-Reuss-Hill is used). The -% two rotations into the common orientation are then interpolated -% and the interpolated matrix rotated back the the starting +% before interpolating element-wise (Voigt-Reuss-Hill is used). The +% two rotations into the common orientation are then interpolated +% and the interpolated matrix rotated back the the starting % orientation. Shoemake's (1985) slerp approach is used to interpolate -% the orientations. Rotation matricies are converted to quaternions +% the orientations. Rotation matrices are converted to quaternions % (and back again) using John Fuller's SpinCalc function. % % References: -% Shoemake, K (1985) "Animating rotation with quaternion curves" ACM +% Shoemake, K (1985) "Animating rotation with quaternion curves" ACM % SIGGRAPH Computer Graphics vol.19 pp.245-254. % % See also: MS_AXES, MS_VRH @@ -36,29 +36,29 @@ % (C) James Wookey and Andrew Walker, 2011-2015 function [ Cint, rhoint ] = MS_interpolate(C1, rho1, C2, rho2, frac) - % Rotate C1 and C2 onto principal axis system and store - % roation matries + % Rotate C1 and C2 onto principal axis system and store + % rotation matrices [C1R, RR1] = MS_axes(C1, 'nowarn', 'X3_stiff'); [C2R, RR2] = MS_axes(C2, 'nowarn', 'X3_stiff'); - - % Avarage C1R and C2R using Voigt + + % Average C1R and C2R using Voigt [~,rhoint,CintR] = MS_VRH([frac, 1-frac], C1R, rho1, C2R, rho2); % Interpolate between forward rotations (C1->CR1 and C2->CR2) % using quaternion representation of rotations q1 = SpinCalc('DCMtoQ',RR1, 0.001, 1); - q2 = SpinCalc('DCMtoQ',RR2, 0.001, 1); + q2 = SpinCalc('DCMtoQ',RR2, 0.001, 1); qint = slerp(q1, q2, 1-frac); Rint = SpinCalc('QtoDCM',qint, 0.001, 1); - + % Apply backwards rotation Cint = MS_rotR(CintR, Rint'); end function [ qm ] = slerp (qa, qb, t) - % Interpolate between quaternions qa and qb seperated by t. + % Interpolate between quaternions qa and qb separated by t. qm = [0 0 0 0]; - + cht = qa(4)*qb(4) + qa(1)*qb(1) + qa(2)*qb(2) + qa(3)*qb(3); if (abs(cht) >= 1.0) @@ -86,35 +86,35 @@ % % Copyright (c) 2011, John Fuller % All rights reserved. -% -% Redistribution and use in source and binary forms, with or without -% modification, are permitted provided that the following conditions are +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are % met: -% -% * Redistributions of source code must retain the above copyright +% +% * Redistributions of source code must retain the above copyright % notice, this list of conditions and the following disclaimer. -% * Redistributions in binary form must reproduce the above copyright -% notice, this list of conditions and the following disclaimer in +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in % the documentation and/or other materials provided with the distribution -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE % POSSIBILITY OF SUCH DAMAGE. % % From: % http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-con % vert-between-dcm-euler-angles-quaternions-and-euler-vectors % -% CHANGES: Make all warning and errors generate textural errors -% (don't generate dialoge box). +% CHANGES: Make all warning and errors generate textural errors +% (don't generate dialogue box). function OUTPUT=SpinCalc(CONVERSION,INPUT,tol,ichk) %Function for the conversion of one rotation input type to desired output. @@ -141,9 +141,9 @@ %CONVERSION - Single string value that dictates the type of desired % conversion. The conversion strings are listed below. % -% 'DCMtoEA###' 'DCMtoEV' 'DCMtoQ' **for cases that involve +% 'DCMtoEA###' 'DCMtoEV' 'DCMtoQ' **for cases that involve % 'EA###toDCM' 'EA###toEV' 'EA###toQ' euler angles, ### should be -% 'EVtoDCM' 'EVtoEA###' 'EVtoQ' replaced with the proper +% 'EVtoDCM' 'EVtoEA###' 'EVtoQ' replaced with the proper % 'QtoDCM' 'QtoEA###' 'QtoEV' order desired. EA321 would % 'EA###toEA###' be Z(yaw)-Y(pitch)-X(roll). % @@ -151,14 +151,14 @@ % CONVERSION string, formatted as follows: % % DCM - 3x3xN multidimensional matrix which pre-multiplies a coordinate -% frame column vector to calculate its coordinates in the desired +% frame column vector to calculate its coordinates in the desired % new frame. % % EA### - [psi,theta,phi] (Nx3) row vector list dictating to the first angle % rotation (psi), the second (theta), and third (phi) (DEGREES) % % EV - [m1,m2,m3,MU] (Nx4) row vector list dictating the components of euler -% rotation vector (original coordinate frame) and the Euler +% rotation vector (original coordinate frame) and the Euler % rotation angle about that vector (MU) (DEGREES) % % Q - [q1,q2,q3,q4] (Nx4) row vector list defining quaternion of @@ -202,7 +202,7 @@ if i_type~=4 && o_type~=4, %if input/output are NOT Euler angles CC=[INPUT_TYPE,'to',OUTPUT_TYPE]; if strcmpi(CONVERSION,CC)==0; - error('Error: Invalid entry for CONVERSION input string'); + error('Error: Invalid entry for CONVERSION input string'); end else if i_type==4, %if input type is Euler angles, determine the order of rotations @@ -211,15 +211,15 @@ rot_2_in=floor((EULER_order_in-rot_1_in*100)/10); %second rotation rot_3_in=(EULER_order_in-rot_1_in*100-rot_2_in*10); %third rotation if rot_1_in<1 || rot_2_in<1 || rot_3_in<1 || rot_1_in>3 || rot_2_in>3 || rot_3_in>3, - error('Error: Invalid input Euler angle order type (conversion string).'); %check that all orders are between 1 and 3 + error('Error: Invalid input Euler angle order type (conversion string).'); %check that all orders are between 1 and 3 elseif rot_1_in==rot_2_in || rot_2_in==rot_3_in, - error('Error: Invalid input Euler angle order type (conversion string).'); %check that no 2 consecutive orders are equal (invalid) + error('Error: Invalid input Euler angle order type (conversion string).'); %check that no 2 consecutive orders are equal (invalid) end %check input dimensions to be 1x3x1 if size(INPUT,2)~=3 || size(INPUT,3)~=1 - error('Error: Input euler angle data vector is not Nx3') + error('Error: Input euler angle data vector is not Nx3') end - %identify singularities + %identify singularities if rot_1_in==rot_3_in, %Type 2 rotation (first and third rotations about same axis) if INPUT(:,2)<=zeros(size(INPUT,1),1) | INPUT(:,2)>=180*ones(size(INPUT,1),1), %confirm second angle within range error('Error: Second input Euler angle(s) outside 0 to 180 degree range') @@ -236,7 +236,7 @@ error('Warning: Input Euler angle(s) rotation near a singularity. Second angle near -90 or 90 degrees.') end end - end + end end if o_type==4, %if output type is Euler angles, determine order of rotations EULER_order_out=str2double(CONVERSION(1,length-2:length)); @@ -244,11 +244,11 @@ rot_2_out=floor((EULER_order_out-rot_1_out*100)/10); %second rotation rot_3_out=(EULER_order_out-rot_1_out*100-rot_2_out*10); %third rotation if rot_1_out<1 || rot_2_out<1 || rot_3_out<1 || rot_1_out>3 || rot_2_out>3 || rot_3_out>3, - error('Error: Invalid output Euler angle order type (conversion string).'); %check that all orders are between 1 and 3 + error('Error: Invalid output Euler angle order type (conversion string).'); %check that all orders are between 1 and 3 elseif rot_1_out==rot_2_out || rot_2_out==rot_3_out, error('Error: Invalid output Euler angle order type (conversion string).'); %check that no 2 consecutive orders are equal end - end + end if i_type==4 && o_type~=4, %if input are euler angles but not output CC=['EA',num2str(EULER_order_in),'to',OUTPUT_TYPE]; %construct program conversion string for checking against user input elseif o_type==4 && i_type~=4, %if output are euler angles but not input @@ -268,7 +268,7 @@ switch INPUT_TYPE case 'DCM' if size(INPUT,1)~=3 || size(INPUT,2)~=3 %check DCM dimensions - error('Error: DCM matrix is not 3x3xN'); + error('Error: DCM matrix is not 3x3xN'); end N=size(INPUT,3); %number of orientations %Check if matrix is indeed orthogonal @@ -282,7 +282,7 @@ end end if abs(det(INPUT(:,:,ii))+1)<0.05, %if determinant is near -1, DCM is improper - error('Error: Input DCM(s) improper'); + error('Error: Input DCM(s) improper'); end if DCM_flag==1, error('Warning: Input DCM matrix determinant(s) off from 1 by more than tolerance.') @@ -302,15 +302,15 @@ if DCM_flag==1, fprintf('Warning: Input DCM(s) matrix not orthogonal to precision tolerance.') end - end - clear perturbed DCM_flag + end + clear perturbed DCM_flag Q=NaN(4,N); for ii=1:N, denom=NaN(4,1); denom(1)=0.5*sqrt(1+INPUT(1,1,ii)-INPUT(2,2,ii)-INPUT(3,3,ii)); denom(2)=0.5*sqrt(1-INPUT(1,1,ii)+INPUT(2,2,ii)-INPUT(3,3,ii)); denom(3)=0.5*sqrt(1-INPUT(1,1,ii)-INPUT(2,2,ii)+INPUT(3,3,ii)); - denom(4)=0.5*sqrt(1+INPUT(1,1,ii)+INPUT(2,2,ii)+INPUT(3,3,ii)); + denom(4)=0.5*sqrt(1+INPUT(1,1,ii)+INPUT(2,2,ii)+INPUT(3,3,ii)); %determine which Q equations maximize denominator switch find(denom==max(denom),1,'first') %determines max value of qtests to put in denominator case 1 @@ -339,19 +339,19 @@ clear denom case 'EV' %Euler Vector Input Type if size(INPUT,2)~=4 || size(INPUT,3)~=1 %check dimensions - error('Error: Input euler vector and rotation data matrix is not Nx4') + error('Error: Input euler vector and rotation data matrix is not Nx4') end N=size(INPUT,1); MU=INPUT(:,4)*pi/180; %assign mu name for clarity if sqrt(INPUT(:,1).^2+INPUT(:,2).^2+INPUT(:,3).^2)-ones(N,1)>tol*ones(N,1), %check that input m's constitute unit vector - error('Input euler vector(s) components do not constitute a unit vector') + error('Input euler vector(s) components do not constitute a unit vector') end if MU2*pi*ones(N,1), %check if rotation about euler vector is between 0 and 360 error('Input euler rotation angle(s) not between 0 and 360 degrees') end Q=[INPUT(:,1).*sin(MU/2),INPUT(:,2).*sin(MU/2),INPUT(:,3).*sin(MU/2),cos(MU/2)]; %quaternion clear m1 m2 m3 MU - case 'EA' + case 'EA' psi=INPUT(:,1)*pi/180; theta=INPUT(:,2)*pi/180; phi=INPUT(:,3)*pi/180; N=size(INPUT,1); %number of orientations %Pre-calculate cosines and sines of the half-angles for conversion. @@ -385,24 +385,24 @@ elseif EULER_order_in==321, Q=[c1.*c2.*s3-s1.*s2.*c3,c1.*s2.*c3+s1.*c2.*s3,s1.*c2.*c3-c1.*s2.*s3,c1.*c2.*c3+s1.*s2.*s3]; else - error('Error: Invalid input Euler angle order type (conversion string)'); + error('Error: Invalid input Euler angle order type (conversion string)'); end clear c1 s1 c2 s2 c3 s3 c13 s13 c1_3 s1_3 c3_1 s3_1 psi theta phi case 'Q' if size(INPUT,2)~=4 || size(INPUT,3)~=1 - error('Error: Input quaternion matrix is not Nx4'); + error('Error: Input quaternion matrix is not Nx4'); end - N=size(INPUT,1); %number of orientations + N=size(INPUT,1); %number of orientations if ichk==1, if abs(sqrt(INPUT(:,1).^2+INPUT(:,2).^2+INPUT(:,3).^2+INPUT(:,4).^2)-ones(N,1))>tol*ones(N,1) error('Warning: Input quaternion norm(s) deviate(s) from unity by more than tolerance') - end + end end Q=INPUT; end clear INPUT INPUT_TYPE EULER_order_in -%Normalize quaternions in case of deviation from unity. User has already +%Normalise quaternions in case of deviation from unity. User has already %been warned of deviation. Qnorms=sqrt(sum(Q.*Q,2)); Q=[Q(:,1)./Qnorms,Q(:,2)./Qnorms,Q(:,3)./Qnorms,Q(:,4)./Qnorms]; @@ -491,7 +491,7 @@ phi=atan2(2.*(Q(:,1).*Q(:,4)+Q(:,3).*Q(:,2)),(Q(:,4).^2-Q(:,1).^2-Q(:,2).^2+Q(:,3).^2)); Euler_type=1; else - error('Error: Invalid output Euler angle order type (conversion string).'); + error('Error: Invalid output Euler angle order type (conversion string).'); end if(isreal([psi,theta,phi]))==0, error('Error: Unreal Euler output. Input resides too close to singularity. Please choose different output type.') diff --git a/msat/MS_iso.m b/msat/MS_iso.m index d79e33e..73d1c8e 100644 --- a/msat/MS_iso.m +++ b/msat/MS_iso.m @@ -2,9 +2,9 @@ % % [C]=MS_iso(vp,vs,rh) % -% Inputs: -% rh : Density (kg/m3) -% vp : p-wave velocity (km/s) +% Inputs: +% rh : Density (kg/m3) +% vp : p-wave velocity (km/s) % vs : s-wave velocity (km/s) % % Output: @@ -14,11 +14,11 @@ vp=vp*1e3; vs=vs*1e3; - + C=zeros(6,6) ; C(3,3) = vp*vp ; C(6,6) = vs*vs ; - + C=MS_expand(C,'iso') ; % convert to GPa diff --git a/msat/MS_list.m b/msat/MS_list.m index 55696d4..815f176 100644 --- a/msat/MS_list.m +++ b/msat/MS_list.m @@ -4,52 +4,52 @@ % % CIJ_list(C,rho) % -% Usage: +% Usage: % CIJ_list(C,rho) -% For a given 6x6 elasticity matrix, C, and density, rho, print +% For a given 6x6 elasticity matrix, C, and density, rho, print % the constants. % -% Notes: -% The 'list' format consists of three numbers per line. The first two +% Notes: +% The 'list' format consists of three numbers per line. The first two % are integers representing the location in the elasticity matrix in % Voigt notation, the third is the value of the elastic constant. After % the 36 lines of elastic constants a line containing the density is -% printed with dummy indices '7 7'. This function exists to allow +% printed with dummy indices '7 7'. This function exists to allow % MSAT to be interfaced with legacy code. % % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function MS_list(C,rho) @@ -58,6 +58,6 @@ function MS_list(C,rho) for j=i:6 fprintf('%1i %1i %e\n',i,j,C(i,j)) end - end + end fprintf('%1i %1i %f\n',7,7,rho) end diff --git a/msat/MS_load.m b/msat/MS_load.m index ffad3ad..d907d1f 100644 --- a/msat/MS_load.m +++ b/msat/MS_load.m @@ -1,28 +1,28 @@ % MS_LOAD - Load a set of elastic constants from a file. % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // -% +% % [ ... ] = MS_load( fname, ... ) % -% Usage: -% [C] = MS_load(fname) -% Load the elastic constants in file 'fname'. See file format below. +% Usage: +% [C] = MS_load(fname) +% Load the elastic constants in file 'fname'. See file format below. % -% [C,r] = MS_load(fname,...) -% Load the elastic constants and density in file 'fname'. See file +% [C,r] = MS_load(fname,...) +% Load the elastic constants and density in file 'fname'. See file % format below. % -% [C,...] = MS_load(fname,...,'format',fmt) -% Specify format for file. See below for descriptions. Available options +% [C,...] = MS_load(fname,...,'format',fmt) +% Specify format for file. See below for descriptions. Available options % are: % 'simple' : Formatted text file (default) % 'ematrix' : Format read by EMATRIX (D. Mainprice). % -% [C,...] = MS_load(fname,...,'symmetry', mode) +% [C,...] = MS_load(fname,...,'symmetry', mode) % Fill out elastic tensor based on symmetry, defined by mode. This can % take the following values: % 'none' - nothing attempted, unspecified Cijs are zero (default) -% 'auto' - assume symmetry based on number of Cijs specified +% 'auto' - assume symmetry based on number of Cijs specified % 'iso' - isotropic (nCij=2) ; C33 and C66 must be specified. % 'hex' - hexagonal (nCij=5) ; C11, C33, C44, C66 and C13 must be % specified, x3 is symmetry axis @@ -30,18 +30,18 @@ % 'cubic' - cubic (nCij=3) ; C33, C66 and C12 must be specified % % [C,...] = MS_load(fname,...,'eunit',unit) -% Specify elasticity unit; this is used to convert to GPa (msat's +% Specify elasticity unit; this is used to convert to GPa (msat's % default operating unit) % 'GPa' - elastic constants are already in GPa (default) % 'Mbar' - elastic constants are in Mbar % 'Pa' - elastic constants are in Pascals % 'bar' - elastic constants are in bar -% Note: when using a density normalised tensor, specify the unit +% Note: when using a density normalised tensor, specify the unit % *before* normalisation (i.e., a unit of pressure). % % % [C,...] = MS_load(fname,...,'dunit',unit) -% Specify density unit; this is used to convert to kg/m3 (msat's +% Specify density unit; this is used to convert to kg/m3 (msat's % default operating unit) % 'kgm3' - density is already in kg/m3 (default) % 'gcc' - density is in g/cc @@ -50,14 +50,14 @@ % Elasticities are specified in density normalised form. This option % requires a density to be specified, the elasticities are returned with % the normalisation reversed (default format for msat). The density -% normalisation is assumed to have been performed using the density +% normalisation is assumed to have been performed using the density % specified in the file (so, obviously, one is required) without any -% different unit scalings. That is, the values of the elastic -% constants are read from the file and multiplied by the value of the +% different unit scalings. That is, the values of the elastic +% constants are read from the file and multiplied by the value of the % density read from the file before any unit conversion is performed. -% It is *highly* advisable to check (for example using MS_phasevels) -% that sensible numbers result. The default is to assume that the -% input is not density normalised. +% It is *highly* advisable to check (for example using MS_phasevels) +% that sensible numbers result. The default is to assume that the +% input is not density normalised. % % [C,...] = MS_load(fname,...,'force') % Disable post-load checking. You're on your own, buddy. @@ -66,66 +66,66 @@ % ----------------------- % % * 'simple' (default) -% +% % In this mode MS_load expects an ascii file containing lines of the form: % % I J C(I,J) % -% Elasticity tensor components are specified by their indices (i,j). Any -% number other than 1-6 in the i or j column denotes that a density is -% being given. +% Elasticity tensor components are specified by their indices (i,j). Any +% number other than 1-6 in the i or j column denotes that a density is +% being given. % % So, for olivine, the file might look like: -% -% +% +% % 1 1 320.5 % 1 2 68.1 % 1 3 71.6 % ... % 6 6 78.7 % 0 0 3325 -% -% Text following a '%' in any line is ignored (useful for header lines or +% +% Text following a '%' in any line is ignored (useful for header lines or % comments) % % * 'ematrix' % -% Elastic constants in the format read by EMATRIX (D. Mainprice). +% Elastic constants in the format read by EMATRIX (D. Mainprice). % % See also: MS_LOAD_LIST, MS_ELASTICDB, MS_EXPAND % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %=============================================================================== @@ -133,7 +133,7 @@ %=============================================================================== eunit = 'default' ; dunit = 'default' ; - + aij = 0 ; smode = 'none' ; force = 0 ; @@ -166,12 +166,12 @@ case 'symmetry' smode = varargin{iarg+1} ; iarg = iarg + 2 ; - otherwise - error(['Unknown option: ' varargin{iarg}]) ; - end - end + otherwise + error(['Unknown option: ' varargin{iarg}]) ; + end + end -% +% switch lower(format) case 'simple' [ C, nec, rh ] = MS_load_simple( fname ) ; @@ -181,7 +181,7 @@ ' no symmetry based expansion' ' was requested']) ; end case 'ematrix' -% ** forbid expansion from ematrix files. +% ** forbid expansion from ematrix files. if ~strcmp(smode,'none'), error('MS:LOAD:ExpandForbidden',... 'Symmetry expansion is not supported from this file format.') ; end @@ -189,7 +189,7 @@ otherwise error('MS:LOAD:BadFileFormat',... ['Specified file format "' format '" is not supported.']) ; - end + end % ** set default units if this hasn't already been done. switch lower(eunit) @@ -198,7 +198,7 @@ otherwise % do nothing end - + switch lower(dunit) case 'default' dunit = 'kgm3' ; @@ -243,7 +243,7 @@ otherwise error('MS:LOAD:BadEunit','Unsupported elasticity unit.') end - + switch lower(dunit) case 'kgm3' case 'gcc' @@ -260,8 +260,8 @@ catch ME error('MS:LOAD:CheckFailed', ... ['Final matrix check failed with error message: ' ME.message]) ; - end - end + end + end % ** set the output arguments switch nargout @@ -297,10 +297,10 @@ a = load(fname) ; catch ME error(['File load failed with error: ' ME.message]) ; - end + end [nline ncol] = size(a) ; - + if ncol~=3, error('MS:LOAD_SIMPLE:BadFormat',... 'File appears not to be in the specified format') ;, end @@ -312,7 +312,7 @@ jj = a(ind,2) ; ec = a(ind,3) ; -% ** count +% ** count [nec ndum] = size(ec) ; % ** get density @@ -323,16 +323,16 @@ elseif nline==nec % ** no density is specified rh = NaN ; - else + else error('MS:LOAD_SIMPLE:MultipleDensities',... 'Multiple densities specified (only one permitted).') end - + C = zeros(6,6) ; for i=1:nec C(ii(i),jj(i)) = ec(i) ; end - + return %=============================================================================== @@ -342,7 +342,7 @@ function [C, rh, eunit_out, dunit_out] = MS_load_ematrix(fname, eunit, dunit) %=============================================================================== % ** default units for ematrix files is Mbar & g/cc. Redefine defaults if user -% has not explicitly defined units in call. +% has not explicitly defined units in call. switch lower(eunit) case 'default' eunit_out = 'Mbar' ; @@ -357,7 +357,7 @@ dunit_out = dunit ; end -% ** no density is specified in these files. +% ** no density is specified in these files. rh = NaN ; % ** read the file @@ -372,7 +372,7 @@ % ** the good stuff TS = textscan(fid,'%f %f %f %f %f %f',6, 'CollectOutput', 1) ; C = TS{1} ; - + fclose(fid) ; %=============================================================================== return diff --git a/msat/MS_load_list.m b/msat/MS_load_list.m index c413967..17ab5bd 100644 --- a/msat/MS_load_list.m +++ b/msat/MS_load_list.m @@ -5,58 +5,58 @@ % [x,C,rho] = MS_load_list(fname) % % Usage: -% As above, x is the independent variable (the first column in the file, -% of length n) C is an array 6*6*n where n is the number of tensors +% As above, x is the independent variable (the first column in the file, +% of length n) C is an array 6*6*n where n is the number of tensors % loaded rho is a vector of length n, the last column in the file -% currently, only 21 constant elastic files can be loaded. Lines in +% currently, only 21 constant elastic files can be loaded. Lines in % the file should be of the form: -% x, c11,c12,...,c16,c22,...,c26,c33,...,c66,rho +% x, c11,c12,...,c16,c22,...,c26,c33,...,c66,rho % % See also: MS_LOAD, MS_ELASTICDB % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -function [x,C,rho] = MS_load_list(fname) +function [x,C,rho] = MS_load_list(fname) ecdata=load(fname) ; [n nec] = size(ecdata) ; -nec = nec - 2; % two columns for +nec = nec - 2; % two columns for if nec~=21 error('Only 21 elastic constants allowed') ; @@ -79,7 +79,7 @@ end end rho(irow) = ecdata(irow,23) ; - + end return diff --git a/msat/MS_make_trace.m b/msat/MS_make_trace.m index 77fc712..160dce5 100644 --- a/msat/MS_make_trace.m +++ b/msat/MS_make_trace.m @@ -1,57 +1,57 @@ % MS_MAKE_TRACE - Create a pair of orthogonal traces -% +% % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % % [time, T00, T90] = MS_make_trace(spol, dfreq, max_tlag) % % Inputs: -% dfreq (scalar) : Dominant frequency of trace (Hz) +% dfreq (scalar) : Dominant frequency of trace (Hz) % spol (scalar) : source polarisation direction (degrees) % max_tlag (scalar) : maximum lag time to be accommodated on trace (s) % % Outputs: % time (vector) : Series of time points where amplitudes are known (s) -% T00 (vector) : Series of amplitudes of transverse wave #1. +% T00 (vector) : Series of amplitudes of transverse wave #1. % T90 (vector) : Series of amplitudes of transverse wave #2. % -% MS_make_trace creates a time series of the amplitude of displacement in -% two orthogonal directions (e.g. of waves or wavelets) stored in time, +% MS_make_trace creates a time series of the amplitude of displacement in +% two orthogonal directions (e.g. of waves or wavelets) stored in time, % T00 and T90. In the current version only a (first-derivative) Gaussian -% wavelet can be generated. Future additional optional arguments will +% wavelet can be generated. Future additional optional arguments will % allow other choices. % Copyright (c) 2013, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [time, T00, T90] = MS_make_trace(spol, dfreq, max_tlag) @@ -65,7 +65,7 @@ function [time,amp0,amp90] = FDGaussian_wavelet(spol,dfreq,max_tlag) % generate a (first-derivative) Gaussian wavelet centred on 0, time base is - % set so the maximum tlag can be accomodated. This is defined as + % set so the maximum tlag can be accommodated. This is defined as % -(max_tlag+2*T):T/100:(max_tlag+2*T) ; % calculate time base @@ -76,7 +76,7 @@ % calculate wavelet sig = T/6 ; amp = -(time./(sig.^3*sqrt(2.*pi))).*exp(-time.^2./(2.*sig.^2)) ; - + % normalise and project amplitude amp = amp./max(amp) ; amp0 = amp.*cosd(spol) ; diff --git a/msat/MS_measure_trace_splitting.m b/msat/MS_measure_trace_splitting.m index 7c62cb0..f9b4f74 100644 --- a/msat/MS_measure_trace_splitting.m +++ b/msat/MS_measure_trace_splitting.m @@ -1,5 +1,5 @@ % MS_MEASURE_TRACE_SPLITTING - Measure SWS for a pair of orthogonal traces -% +% % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % % [fast, tlag] = MS_measure_trace_splitting(time, T00, T90, d_fast, ... @@ -8,9 +8,9 @@ % Inputs: % time (vector) : Series of time points where amplitudes are known (s) % T00 (vector) : Series of amplitudes of transverse wave #1 before -% splitting applied. +% splitting applied. % T90 (vector) : Series of amplitudes of transverse wave #2 before -% splitting applied. +% splitting applied. % d_fast (scalar) : Spacing of grid search for fast direction (degrees) % d_tlag (scalar) : Spacing of grid search lag time (s) % max_tlag (scalar) : Maximum lag time in grid search @@ -22,55 +22,55 @@ % Given a two traces (T00 and T90) on a common time axis (time) find % the splitting operator (fast and tlag) that minimises the second % eigenvalue of the covariance matrix. This is done in two steps. First -% using an approximate grid search (spacing and time limits set by +% using an approximate grid search (spacing and time limits set by % d_fast, d_tlag and max_tlag) then by using the Matlab built -% in simplex optimiser from the best grid point. -% +% in simplex optimiser from the best grid point. +% % Options: -% +% % * MS_measure_trace_splitting( ... 'errorsurf') % Draw a contour plot of the error surface generated during the grid % search for the best splitting parameters. % * MS_measure_trace_splitting( ... 'optimoptions', options) % Provide a structure of optimisation options to pass into the simplex -% optimiser. Use optimist to generate this. e.g. for looser tolerances +% optimiser. Use optimist to generate this. e.g. for looser tolerances % use MS_measure_trace_splitting( ... 'optimoptions', ... -% optimset('TolFun', 1.0e-3, 'TolX', 1.0e-3)). +% optimset('TolFun', 1.0e-3, 'TolX', 1.0e-3)). % Default options are: optimset('Display','none','TolFun',1.0e-5, ... % 'TolX', 1.0e-5). % Copyright (c) 2013, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -80,7 +80,7 @@ % Given a two traces (T00 and T90) on a common time axis (time) find % the splitting operator (fast and tlag) that minimises the second % eigenvalue of the covariance matrix. This is done in two steps. First - % using an approximate grid search (spacing and time limits set by + % using an approximate grid search (spacing and time limits set by % d_fast, d_tlag and max_tlag) then by using the Matlab built % in simplex optimiser from the best grid point. @@ -88,29 +88,29 @@ errorsurf = 0; % Plot an error surface? optimoptions=optimset('Display','none', ... 'TolFun', 1.0e-5, 'TolX', 1.0e-5); - + while iarg <= (length(varargin)) switch lower(varargin{iarg}) case 'errorsurf' - errorsurf = 1 ; + errorsurf = 1 ; iarg = iarg + 1; case 'optimoptions' optimoptions = varargin{iarg+1}; iarg = iarg + 2; - otherwise + otherwise error('MS:measure_trace_splitting', ... - ['Unknown option: ' varargin{iarg}]) ; + ['Unknown option: ' varargin{iarg}]) ; end end - + if errorsurf - misfits = zeros(ceil(180.0./d_fast), ceil(max_tlag./d_tlag)); + misfits = zeros(ceil(180.0./d_fast), ceil(max_tlag./d_tlag)); tlags = 0.0:d_tlag:max_tlag; fasts = 0.0:d_fast:180.0; end i = 0; j = 0; - + % Do the grid search best_misfit = 100; for fast = 0.0:d_fast:180.0 @@ -129,7 +129,7 @@ end j = 0; end - + % Simplex minimisation [new_split_op, misfit] = fminsearch(... @(split_op) splitting_function(split_op, time, ... @@ -137,35 +137,35 @@ if (misfit < best_misfit) best_split_op = new_split_op; end - + if errorsurf figure; contour(tlags, fasts, misfits); colorbar; end - + % Unpack results fast = best_split_op(1); - tlag = best_split_op(2); + tlag = best_split_op(2); end function misfit = splitting_function(split_op, time, T00, T90) - % Apply a spliting operator to two traces and calculate the misfit in a + % Apply a splitting operator to two traces and calculate the misfit in a % way that can be used by measure_splitting_function - + % Unpack args fast = split_op(1); tlag = split_op(2); - % Calculate the traces with the revered split + % Calculate the traces with the reversed split [T00sp,T90sp] = MS_split_trace(time,T00,T90,fast,-tlag) ; - % measure second eignvalue of the resulting wavelet + % measure second eigenvalue of the resulting wavelet % calculate the covariance matrix COVM = cov(T90sp,T00sp) ; % take the eigenvalues [~,D] = eig(COVM) ; - % calculate normalised misfit. + % calculate normalised misfit. misfit = min([D(1,1) D(2,2)])./ max([D(1,1) D(2,2)]) ; - % We should never have a negative minimum eigenvalue - but + % We should never have a negative minimum eigenvalue - but % this is seen (only on Matlab 2013a) in one of the test cases % so we set negative values to be zero. if (misfit < 0.0) diff --git a/msat/MS_norms.m b/msat/MS_norms.m index 0b46361..726dba5 100644 --- a/msat/MS_norms.m +++ b/msat/MS_norms.m @@ -3,9 +3,9 @@ % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % % Calculate the percentages of the original matrix norm represented by the -% individual decompositions of an elasticity tensor C, after: +% individual decompositions of an elasticity tensor C, after: % Browaeys and Chevrot (GJI, v159, 667-678, 2004) -% +% % [P] = MS_norms(C,Ciso) % Isotropic part (scalar) % @@ -14,7 +14,7 @@ % % [P] = MS_norms(C,Ciso,Chex,Ctet,Cort,Cmon,Ctri) % All parts of the elastic tensor (vector) -% +% % % Notes: % Input components of of C must first be calculated using MS_decomp. @@ -23,45 +23,45 @@ % % References: % Browaeys, J. T. and S. Chevrot (2004) Decomposition of the elastic -% tensor and geophysical applications. Geophysical Journal +% tensor and geophysical applications. Geophysical Journal % international v159, 667-678. % % See also: MS_AXES, MS_DECOMP % Copyright (c) 2011-2015 James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + function [ P ] = MS_norms( varargin ) Cref = varargin{1} ; @@ -88,7 +88,7 @@ function [X]=C2X(C) % after Browaeys and Chevrot (GJI, 2004) X = zeros(21,1) ; - + X(1) = C(1,1) ; X(2) = C(2,2) ; X(3) = C(3,3) ; @@ -110,5 +110,5 @@ X(19) = 2.*sqrt(2).*C(5,6) ; X(20) = 2.*sqrt(2).*C(4,6) ; X(21) = 2.*sqrt(2).*C(4,5) ; - + end diff --git a/msat/MS_phasevels.m b/msat/MS_phasevels.m index 9d1d678..588fa58 100644 --- a/msat/MS_phasevels.m +++ b/msat/MS_phasevels.m @@ -2,31 +2,31 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Calculate the phase velocity details for an elsticity matrix. +% Calculate the phase velocity details for an elasticity matrix. % % [ pol, avs, vs1, vs2, vp, ...] = MS_phasevels( C, rh, inc, azi ) % -% Usage: -% [ pol, avs, vs1, vs2, vp ] = MS_phasevels( C, rh, inc, azi ) +% Usage: +% [ pol, avs, vs1, vs2, vp ] = MS_phasevels( C, rh, inc, azi ) % Calculate phase velocities from elasticity matrix C (in GPa) and -% density rh (in kg/m^3) for a propogation direction defined by -% an inclination and azimuth (both in degrees, see below). Output +% density rh (in kg/m^3) for a propagation direction defined by +% an inclination and azimuth (both in degrees, see below). Output % details are given below. % -% [ pol, avs, vs1, vs2, vp, SF, SS ] = MS_phasevels( C, rh, inc, azi ) +% [ pol, avs, vs1, vs2, vp, SF, SS ] = MS_phasevels( C, rh, inc, azi ) % Additionally output fast and slow S-wave polarisation in vector % form. % % Notes: -% Azi is defined as the angle in degrees from the +ve 1-axis in x1-x2 +% Azi is defined as the angle in degrees from the +ve 1-axis in x1-x2 % plane with +ve being clockwise when looking at origin from the % 3-axis. Inc is defined as the angle in degrees from the x1-x2 plane % towards x3 with zero being in the x1-x2 plane. Inc and azi may be % scalars, or vectors of the same size. Outputs are: % -% 'pol' = angle in plane normal to raypath of FSW -% (deg, zero is x3 direction, +ve c'wise looking along -% raypath at origin) +% 'pol' = angle in plane normal to ray path of FSW +% (deg, zero is x3 direction, +ve c'wise looking along +% ray path at origin) % 'avs' = shear-wave anisotropy % 'vs1' = fast shear-wave velocity (km/s) % 'vs2' = slow shear-wave velocity (km/s) @@ -36,51 +36,51 @@ % In the case of no S-wave splitting (vs1 and vs2 are equal to within % eps^1/2) pol is set to NaN. Optional outputs SF and SS are arrays of % size (length(inc),3), with each row corresponding to a polarisation -% vector. This implementation is based on EMATRIX6 by D. Mainprice. +% vector. This implementation is based on EMATRIX6 by D. Mainprice. % Re-coded in MATLAB by James Wookey but now avoids transforming % from the 6x6 elasticity matrix into the 3x3x3x3 tensor form using the % method outlined in Winterstein (1990). -% +% % Reference: Mainprice D. (1990). An efficient % FORTRAN program to calculate seismic anisotropy from % the lattice preferred orientation of minerals. -% Computers & Gesosciences, vol16, pp385-393. -% Winterstein D. F. (1990). Velocity anisotropy terminology -% for geophysicists. Geophysics, vol 55, pp1070-1088. +% Computers & Geosciences, vol16, pp385-393. +% Winterstein D. F. (1990). Velocity anisotropy terminology +% for geophysicists. Geophysics, vol 55, pp1070-1088. % Copyright (c) 2011-2012, James Wookey and Andrew Walker % Copyright (c) 2007-2011, James Wookey % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [pol,avs,vs1,vs2,vp, S1P, S2P] = MS_phasevels(C,rh,inc,azi) @@ -89,8 +89,8 @@ error('MS:ListsMustMatch', ... 'AZI and INC must be scalars or vectors of the same dimension'); end - -% ** convert inc, azi to column vectors if necessary + +% ** convert inc, azi to column vectors if necessary inc = reshape(inc,length(inc),1) ; azi = reshape(azi,length(azi),1) ; @@ -98,12 +98,12 @@ % Check that C is valid (if check not suppressed) MS_checkC(C); - + % ** convert GPa to MB file units (Mbars), density to g/cc C(:,:) = C(:,:) * 0.01 ; rh = rh ./ 1e3 ; - + avs = zeros(size(azi)) ; vp = zeros(size(azi)) ; vs1 = zeros(size(azi)) ; @@ -112,7 +112,7 @@ S1 = zeros(length(azi),3) ; S1P = zeros(length(azi),3) ; S2P = zeros(length(azi),3) ; - + % ** Handle isotropic case quickly if isIsotropic(C, isotol) vp(:) = sqrt(( ((1.0/3.0)*(C(1,1)+2*C(1,2)))+ ... @@ -130,12 +130,12 @@ cazi = azi(ipair) ; cinc = inc(ipair) ; -% ** create the cartesian vector +% ** create the Cartesian vector XI = cart2(cinc,cazi) ; -% ** compute phase velocities +% ** compute phase velocities [V,EIGVEC]=velo(XI,rh,C) ; - + % ** pull out the eigenvectors P = EIGVEC(:,1) ; S1 = EIGVEC(:,2) ; @@ -154,20 +154,20 @@ end S2 = EIGVEC(:,3) ; -% ** calculate projection onto propagation plane +% ** calculate projection onto propagation plane S1N = V_cross(XI,S1) ; S1P(ipair,:) = V_cross(XI,S1N); S2N = V_cross(XI,S2) ; S2P(ipair,:) = V_cross(XI,S2N); % ** rotate into y-z plane to calculate angles -% (use functions optimised for the two needed +% (use functions optimised for the two needed % rotations, see below). [S1PR] = V_rot_gam(S1P(ipair,:),cazi) ; [S1PRR] = V_rot_bet(S1PR,cinc) ; - + ph = atan2(S1PRR(2),S1PRR(3)) .* 180/pi ; % ** transform angle to between -90 and 90 @@ -182,44 +182,44 @@ vp(ipair) = V(1) ; vs1(ipair) = V(2) ; vs2(ipair) = V(3) ; - + pol(ipair) = ph ; end % ipair = 1:length(inc_in) % If any directions have zero avs (within machine accuracy) % set pol to NaN - array wise: isiso = real(avs > sqrt(eps)) ; % list of 1.0 and 0.0. - pol = pol .* (isiso./isiso) ; % times by 1.0 or NaN. + pol = pol .* (isiso./isiso) ; % times by 1.0 or NaN. S1P(:,1) = S1P(:,1) .* (isiso./isiso); S1P(:,2) = S1P(:,2) .* (isiso./isiso); S1P(:,3) = S1P(:,3) .* (isiso./isiso); - + return -%======================================================================================= +%======================================================================================= function [c] = V_cross(a, b) % This is ~10 times quicker than the Matlab cross() function % for me (AMW). We assume the arguments are both 3-vectors and % avoid the checks and reshaping needed for the more general case. - % (According to the prfiler, this moves cross from the most expensive - % child function costing ~50% of the time to the third most expensive + % (According to the profiler, this moves cross from the most expensive + % child function costing ~50% of the time to the third most expensive % child costing ~10% of the time). c = [a(2).*b(3)-a(3).*b(2) a(3).*b(1)-a(1).*b(3) a(1).*b(2)-a(2).*b(1)]; - + return %======================================================================================= -% Rather useing a general case rotation about three angles we use two +% Rather using a general case rotation about three angles we use two % special case rotations around the c and b axes. This saves time as -% we don't need to convert 0 degrees to radians six times per call to +% we don't need to convert 0 degrees to radians six times per call to % phasevels, or do two double matrix multiplications. This saves ~60% % of the time spent in vector rotation (and, with the cross thing above) -% reduces the 10000 evaulations needed for MS_anisotropy lma from ~19 +% reduces the 10000 evaluations needed for MS_anisotropy lma from ~19 % secs to ~10 secs. function [VR] = V_rot_gam(V,gam) @@ -229,7 +229,7 @@ RR = [ cos(g) sin(g) 0 ; -sin(g) cos(g) 0 ; 0 0 1 ] ; VR = V * RR ; - + return function [VR] = V_rot_bet(V,bet) @@ -240,20 +240,20 @@ RR = [ cos(b) 0 -sin(b) ; 0 1 0 ; sin(b) 0 cos(b) ] ; VR = V * RR ; - + return -%======================================================================================= +%======================================================================================= -%======================================================================================= +%======================================================================================= function [X] = cart2(inc,azm) -%======================================================================================= -%c convert from spherical to cartesian co-ordinates +%======================================================================================= +%c convert from spherical to Cartesian coordinates %c north x=100 west y=010 up z=001 %c irev=+1 positive vector x %c irev=-1 negative vector x % NB: pre-converting azm and inc to radians and using -% cos and sin directly (instead to cosd and sind) +% cos and sin directly (instead to cosd and sind) % is ~10x faster making the function ~4x faster. azmr = azm.*(pi/180.0); incr = inc.*(pi/180.0); @@ -264,14 +264,14 @@ X=[caz*cinc -saz*cinc sinc] ; %c normalise to direction cosines r=sqrt(X(1)*X(1)+X(2)*X(2)+X(3)*X(3)) ; - + X = X./r ; return -%======================================================================================= +%======================================================================================= -%======================================================================================= +%======================================================================================= function [V,EIGVEC]=velo(X,rh,C) -%======================================================================================= +%======================================================================================= % PHASE-VELOCITY SURFACES IN AN ANISOTROPIC MEDIUM % revised April 1991 % X(3) - DIRECTION OF INTEREST @@ -279,29 +279,29 @@ % V - PHASE VELOCITIES (1,2,3= P,S,SS) % EIGVEC(3,3) - eigenvectors stored by columns % -% Translated to MATLAB by James Wookey -% Revised, Andrew Walker 2012. +% Translated to MATLAB by James Wookey +% Revised, Andrew Walker 2012. -% Form the 3x3 Christoffel tensor without converting the elasticity -% from 6x6 to 3x3x3x3 form using the formula from page 1076 of +% Form the 3x3 Christoffel tensor without converting the elasticity +% from 6x6 to 3x3x3x3 form using the formula from page 1076 of % Winterstein 1990. This is > twice as fast as the quickest way I % have found going via the full tensor form. gamma = [X(1) 0.0 0.0 0.0 X(3) X(2) ; ... 0.0 X(2) 0.0 X(3) 0.0 X(1) ; ... 0.0 0.0 X(3) X(2) X(1) 0.0 ]; T = gamma * C * gamma'; - + % determine the eigenvalues of symmetric tij [EIVEC EIVAL] = eig(T) ; % calculate velocities and sort -% note that we could get a significant speedup if +% note that we could get a significant speed up if % we could avoid the sort - LAPACK usually does sort -% in order of incresing eigenvectors but I've found -% cases where this does not happen (and we swap P and +% in order of increasing eigenvectors but I've found +% cases where this does not happen (and we swap P and % S wave velocities). Note that MATLAB does not "guarantee -% that the eignevalues are not returned in sorted order" -% http://www.mathworks.com/matlabcentral/newsreader/view_original/394371 +% that the eigenvalues are not returned in sorted order" +% http://www.mathworks.com/matlabcentral/newsreader/view_original/394371 % so we have to sort here... V_RAW = (sqrt([EIVAL(1,1) EIVAL(2,2) EIVAL(3,3)]./rh))*10. ; [V IND] = sort(V_RAW,2,'descend') ; @@ -311,10 +311,10 @@ end return -%======================================================================================= +%======================================================================================= function [ l ] = isIsotropic( C, tol ) - + % Are we isotropic - assume matrix is symmetrical at this point. l = (abs(C(1,1)-C(2,2)) < tol) & (abs(C(1,1)-C(3,3)) < tol) & ... (abs(C(1,2)-C(1,3)) < tol) & (abs(C(1,2)-C(2,3)) < tol) & ... @@ -324,5 +324,5 @@ (abs(C(3,4)) < tol) & (abs(C(3,5)) < tol) & (abs(C(3,6)) < tol) & ... (abs(C(4,5)) < tol) & (abs(C(4,6)) < tol) & (abs(C(5,6)) < tol) & ... (((C(1,1)-C(1,2))/2.0)-C(4,4) < tol); - + return diff --git a/msat/MS_plot.m b/msat/MS_plot.m index 1573827..23e1e4f 100644 --- a/msat/MS_plot.m +++ b/msat/MS_plot.m @@ -2,44 +2,44 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Given an elasticity matrix and density, produce pole figures showing -% the P- and S-wave anisotropy. +% Given an elasticity matrix and density, produce pole figures showing +% the P- and S-wave anisotropy. % % % MS_plot(C, rh, ...) % -% Usage: -% MS_plot(C, rh) +% Usage: +% MS_plot(C, rh) % Produce three pole figures showing P-wave velocity, S-wave % anisotropy and fast S-wave polarisation direction % -% MS_plot(..., 'fontsize', f) +% MS_plot(..., 'fontsize', f) % Set minimum fontsize in plots to f. % -% MS_plot(..., 'wtitle', S) +% MS_plot(..., 'wtitle', S) % Set the (window) title to be string S. If a minus sign is prepended % to this title, the figure number is also suppressed (the minus sign -% is not shown). +% is not shown). % -% MS_plot(..., 'cmap', CM) -% Redefine the colormap. CM can either be a (nx3) matrix containing a -% colormap, or a string describing a function to generate such a +% MS_plot(..., 'cmap', CM) +% Redefine the colormap. CM can either be a (nx3) matrix containing a +% colormap, or a string describing a function to generate such a % matrix (such as the built-in MATLAB colormap functions). E.g.: % MS_plot(C,rh,'cmap','cool(64)') - uses the MATLAB function cool % to generate a cyan-to-purple colourmap. -% The default is 'jet', reversed so blue is fast/high, as is -% conventional for seismic velocity colorscales. +% The default is 'jet', reversed so blue is fast/high, as is +% conventional for seismic velocity colour scales. % % MS_plot(..., 'reverse') -% Unreverse the sense of the colour map. Default (no argument) is -% for blue to be fast/high as is conventional for seismic velocity -% colorscales. Setting this option results in red being fast/high. +% Unreverse the sense of the colour map. Default (no argument) is +% for blue to be fast/high as is conventional for seismic velocity +% colour scales. Setting this option results in red being fast/high. % % MS_plot(..., 'projection',P) % Set the projection of the pole figure to that specified in P. -% Currently supported options are: +% Currently supported options are: % 'sphere' : Spherical projection (default). % 'angle' : An angle preserving stereographic projection. -% 'area' : Lambert area preserving projection. +% 'area' : Lambert area preserving projection. % % MS_plot(..., 'lower') % Plot the lower hemisphere rather than the upper hemisphere. @@ -48,11 +48,11 @@ % MS_plot(..., 'avscontours', ascvect) % MS_plot(..., 'scontours', scvect) % Set the contour levels for the P-wave velocity, S-wave -% anisotropy and (optional) S-wave velocity plots. The values of -% pcvect, ascvect and scvect can be scalars indicating the number -% of contour lines to use or vectors, where each value represents -% a different contour line. Thus, the minimum, maximum values and -% spacing of contours can easily be set using the syntax +% anisotropy and (optional) S-wave velocity plots. The values of +% pcvect, ascvect and scvect can be scalars indicating the number +% of contour lines to use or vectors, where each value represents +% a different contour line. Thus, the minimum, maximum values and +% spacing of contours can easily be set using the syntax % [minval:spacing:maxval] for pcvect ascvect or scvect. % % MS_plot(..., 'limitsonpol') @@ -66,7 +66,7 @@ % white "background" marker with a length set by s1 (defaults to % 0.18) and width set by w1 (defaults to 3.0) and an inner black % marker with width set by w2 (defaults to 2.0) and length set by -% s2 (defaults to 0.18). A useful "neet" alternitive to the +% s2 (defaults to 0.18). A useful "neet" alternatively to the % default is s1 = 0.18, s2 = 0.16, w1 = 2.0 and w2 = 1.0. % % MS_plot(..., 'plotmap', pmap) @@ -83,16 +83,16 @@ % % MS_plot(..., 'pdata', azimuth, inclination, vp) % MS_plot(..., 'sdata', azimuth, inclination, polarisation, avs) -% Add data points to the P-wave velocity ('VP') or S-wave +% Add data points to the P-wave velocity ('VP') or S-wave % polarisation plot ('AVSPOL'), respectively. This can be used, % for example, to compare an elastic model with shear-wave % splitting measurements. In each case data points relate -% to a ray propagating in a direction described by the azimuth -% and inclination. The point is coloured according to either +% to a ray propagating in a direction described by the azimuth +% and inclination. The point is coloured according to either % the P-wave velocity, vp, or S-wave anisotropy, avs, in km/s -% or %. In the case of S-wave anisotropy, the fast polarisation -% direction is also shown. Each argument (azimuth, inclination, -% vp, polarisation and avs) is an array and each must have the +% or %. In the case of S-wave anisotropy, the fast polarisation +% direction is also shown. Each argument (azimuth, inclination, +% vp, polarisation and avs) is an array and each must have the % same number of elements. By default only data points which % have a positive inclination angle are plotted on a upper % hemisphere plot, and negative are only plotted on a lower @@ -101,56 +101,56 @@ % (see below). % % MS_plot(..., 'transform') -% Where data specified (through use of the 'sdata' or 'pdata' -% flag) fall on the unplotted hemisphere (i.e., the lower +% Where data specified (through use of the 'sdata' or 'pdata' +% flag) fall on the unplotted hemisphere (i.e., the lower % hemisphere by default) these data are remapped to the antipodal % position on the plotted hemisphere. The default behaviour -% is to suppress plotting of these data with a warning. +% is to suppress plotting of these data with a warning. % % MS_plot(..., 'band', axis, angle) -% Draw a circle onto the sphere constant angle around the -% specified axis (1,2 or 3). iaxis and angle can be a scalar -% or vector and must have an equal number of entries. +% Draw a circle onto the sphere constant angle around the +% specified axis (1,2 or 3). iaxis and angle can be a scalar +% or vector and must have an equal number of entries. % For example, [1 1 1] [20 30 40] will draw circles on the -% sphere at a constant 20, 30 and 40 degrees from the 1-axis. -% +% sphere at a constant 20, 30 and 40 degrees from the 1-axis. +% % MS_plot(..., 'quiet') -% Don't write isotropic velocities to the terminal. +% Don't write isotropic velocities to the terminal. % % See also: MS_SPHERE, MS_PHASEVELS % Copyright (c) 2011-2016 James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -158,22 +158,22 @@ function MS_plot(C,rh,varargin) %========================================================================= -% ** Set defaults, these can be overriden in the function call +% ** Set defaults, these can be overridden in the function call % ** configure contouring options cvect = 10 ; % number of contours VPcvect = cvect ; AVScvect = cvect ; VScvect = cvect ; - -% ** Put markers on SWS pol plot. + +% ** Put markers on SWS pol plot. limitsonpol = 0; - + % ** Scaling for SWS plo plot. qwhite_scale = 0.18; qblack_scale = 0.18; qwhite_width = 3.0; qblack_width = 2.0; - + % ** configure font options fntsz = 12; @@ -181,29 +181,29 @@ function MS_plot(C,rh,varargin) projection = 'sphere' ; % ** set lower hemisphere (upper hemisphere is default) - ilower = 0 ; + ilower = 0 ; % ** set data remapping - itransform = 0 ; + itransform = 0 ; -% ** configure colormap options +% ** configure colourmap options cmap = jet(64) ; - icmapflip = 1 ; % reverse the sense of the colourscale - + icmapflip = 1 ; % reverse the sense of the colour scale + % ** Write to matlab terminal? silentterm = 0 ; % ** default window title wtitle = 'MSAT polefigure.' ; - + % ** map of what we want to plot plotmap = {'VP', 'AVS', 'AVSPOL'}; sdata_plot = 0; % no sdata overlay - pdata_plot = 0; % no pdata overlay + pdata_plot = 0; % no pdata overlay % ** set default for band plot - band_plot=0 ; - + band_plot=0 ; + % ** process the optional arguments iarg = 1 ; while iarg <= (length(varargin)) @@ -283,11 +283,11 @@ function MS_plot(C,rh,varargin) band_axis = varargin{iarg+1}; band_angle = varargin{iarg+2}; band_plot = 1; - iarg = iarg + 3; - otherwise - error(['Unknown option: ' varargin{iarg}]) ; - end - end + iarg = iarg + 3; + otherwise + error(['Unknown option: ' varargin{iarg}]) ; + end + end % What to plot - work out size and shape for later. assert(iscellstr(plotmap), 'MS:PLOT:BADPLOTMAP', ... @@ -295,7 +295,7 @@ function MS_plot(C,rh,varargin) plotsize = size(plotmap); nrow = plotsize(1); ncol = plotsize(2); - + % check the inputs: C assert(MS_checkC(C)==1, 'MS:PLOT:badC', 'MS_checkC error MS_plot') ; @@ -329,13 +329,13 @@ function MS_plot(C,rh,varargin) if band_plot assert(length(band_axis)==length(band_angle),... 'MS:PLOT:band_mismatch', ... - 'To plot bands, angle and axis arrays must be the same size.') ; + 'To plot bands, angle and axis arrays must be the same size.') ; end - + % ** buggy MATLAB contourf (version 7.1-7.3) % % in these versions of MATLAB, the contourf routine doesn't seem able to -% to cope with the spherical geometry surfaces. I therefore use +% to cope with the spherical geometry surfaces. I therefore use % contouf('v6',...) instead % vstr = ver ; @@ -343,28 +343,28 @@ function MS_plot(C,rh,varargin) buggyMATLAB = 1; else buggyMATLAB = 0; - end + end % ** set the viewing angle view_angle = [-90,90] ; % 1-North 2-West 3-Out of screen rad = pi./180 ; deg = 180./pi ; - + % Set up inc-az grids... if ilower [INC,AZ] = meshgrid([-90:6:0],[0:6:360]) ; else [INC,AZ] = meshgrid([90:-6:0],[0:6:360]) ; - end + end % Invoke MS_phasevels to get wave velocities etc. [~,~,vs1,vs2,vp, S1P] = MS_phasevels(C,rh,... reshape(INC,61*16,1),reshape(AZ,61*16,1)); - + % reverse so sph2cart() works properly AZ = -AZ; - + % Reshape results back to grids VS1 = reshape(vs1,61,16); VS2 = reshape(vs2,61,16); @@ -372,12 +372,12 @@ function MS_plot(C,rh,varargin) VS1_x = reshape(S1P(:,1),61,16); VS1_y = reshape(S1P(:,2),61,16); VS1_z = reshape(S1P(:,3),61,16); - + % aVS data dVS = (VS1-VS2) ; VSmean = (VS1+VS2)./2.0 ; AVS = 100.0*(dVS./VSmean) ; - + % ** output average velocities VPiso=mean(mean(VP)) ; VSiso=mean([mean(mean(VS1)) mean(mean(VS2))]) ; @@ -394,12 +394,12 @@ function MS_plot(C,rh,varargin) wtitle(2:end),'NumberTitle','off') ; else figure('Position',[1 1 win_width win_height],'name',wtitle) ; - end - + end + % ** Setup a seismic colourmap (i.e. red->green->blue) if icmapflip cmap = flipud(cmap) ; - end + end % ** generate X/Y matrices for plotting [X,Y,Z] = sph2cart(AZ.*rad,INC.*rad,ones(size(AZ))) ; @@ -412,24 +412,24 @@ function MS_plot(C,rh,varargin) for i = 1:ncol k = k + 1; subplot(nrow,ncol,k) - + switch lower(plotmap{j,i}) case 'vp' % VP velocity plot contour_pole(X, Y, VP, view_angle, VPcvect, ... cmap, fntsz, buggyMATLAB, 'V_P (km/s)') - + [VPmin, VPmax] = max_min_pole(AZ, INC, VP); - + if pdata_plot add_data(pdata_azi, pdata_inc, 0, pdata_mag, 0, ... projection, ilower, itransform); end - + if band_plot plot_bands(band_axis,band_angle, projection, ilower) ; - end - + end + % ** add some information to the plot VPlabel1 = sprintf(['Min. V_P =%6.2f, max.' ... ' V_P =%6.2f'],VPmin,VPmax) ; @@ -440,37 +440,37 @@ function MS_plot(C,rh,varargin) VPlabel2 = sprintf('Anisotropy =%6.1f%%',VPani) ; text(-1.3,0.8,VPlabel2,'FontSize',fntsz, ... 'FontWeight','bold') ; - + case 'avs' % dVS anisotropy plot contour_pole(X, Y, AVS, view_angle, AVScvect,... cmap, fntsz, ... buggyMATLAB, 'dV_S (%)') - + [AVSmin, AVSmax] = max_min_pole(AZ, INC, AVS); if band_plot plot_bands(band_axis,band_angle, projection, ilower) ; - end - + end + % ** add some information to the plot AVSlabel1 = sprintf(['V_S anisotropy, min' ... ' =%6.2f, max =%6.2f'],AVSmin,AVSmax) ; text(-1.15,1.0,AVSlabel1,'FontSize',fntsz,... 'FontWeight','bold') ; - + case 'vs1' % VS1 anisotropy plot contour_pole(X, Y, VS1, view_angle, VScvect,... cmap, fntsz, ... buggyMATLAB, 'V_{S1} (km/s)') - + [VS1min, VS1max] = max_min_pole(AZ, INC, VS1); if band_plot plot_bands(band_axis,band_angle, projection, ilower) ; - end - + end + % ** add some information to the plot VS1label1 = sprintf(['Min. V_{S1} =%6.2f, max.' ... ' V_{S1} =%6.2f'],VS1min,VS1max) ; @@ -481,19 +481,19 @@ function MS_plot(C,rh,varargin) VS1label2 = sprintf('Anisotropy =%6.1f%%',VS1ani) ; text(-1.3,0.8,VS1label2,'FontSize',fntsz, ... 'FontWeight','bold') ; - + case 'vs2' % VS2 anisotropy plot contour_pole(X, Y, VS2, view_angle, VScvect,... cmap, fntsz, ... buggyMATLAB, 'V_{S2} (km/s)') - + [VS2min, VS2max] = max_min_pole(AZ, INC, VS1); if band_plot plot_bands(band_axis,band_angle, projection, ilower) ; - end - + end + % ** add some information to the plot VS2label1 = sprintf(['Min. V_{S2} =%6.2f, max.' ... ' V_{S2} =%6.2f'],VS1min,VS1max) ; @@ -507,38 +507,38 @@ function MS_plot(C,rh,varargin) if band_plot plot_bands(band_axis,band_angle, projection, ilower) ; - end + end + - case 'avspol' % Fast shear-wave polarisation plot contour_pole(X, Y, AVS, view_angle, AVScvect, cmap, ... fntsz, buggyMATLAB, 'Fast-shear polarisation') - + if band_plot plot_bands(band_axis,band_angle, projection, ilower) ; - end + end if (limitsonpol) [~, ~] = max_min_pole(AZ, INC, AVS); end - + pol_pole(VS1_x,VS1_y,VS1_z, X, Y, Z, AZ, INC, ... qwhite_scale, qblack_scale, qwhite_width, ... qblack_width, projection, ilower); - + if sdata_plot add_data(sdata_azi, sdata_inc, sdata_pol, ... sdata_mag, 1, projection, ilower, itransform); end - + otherwise error('MS:PLOT:BADPLOTMAP', ['An element of the '... 'plotmap was not recognised']); end end end - + end %=============================================================================== @@ -548,33 +548,33 @@ function MS_plot(C,rh,varargin) % % normalise a 3 vector % - VMAG = sqrt( A.^2 + B.^2 + C.^2 ) ; + VMAG = sqrt( A.^2 + B.^2 + C.^2 ) ; AN = A./VMAG ; BN = B./VMAG ; CN = C./VMAG ; - + end %=============================================================================== %=============================================================================== function [xr,yr,zr] = rotate_pm_vector(x,y,z,az,in) %=============================================================================== -% +% % Rotate the particle motion vector so propagation direction is vertical % (to plot in a 2D way) % rad = pi./180; V=[x,y,z]' ; - -% ** build up rotation matrices + +% ** build up rotation matrices gamma = az .* rad ; - + % ** first rotation (about Z) R1 = [ cos(gamma), sin(gamma), 0 ;... -sin(gamma), cos(gamma), 0 ;... 0 , 0 , 1 ] ; - + % ** second rotation (about Y) beta = (90-in).*rad ; R2 = [ cos(beta), 0 , -sin(beta) ;... @@ -589,7 +589,7 @@ function MS_plot(C,rh,varargin) % ** apply rotation VR = R3 * R2 * (R1 * V) ; - xr = VR(1) ; + xr = VR(1) ; yr = VR(2) ; zr = VR(3) ; @@ -599,7 +599,7 @@ function MS_plot(C,rh,varargin) %=============================================================================== function [imin,jmin,Zmin,imax,jmax,Zmax] = minmax2d(Z) %=============================================================================== -% +% % Find the maximum and minimum values in a (2d) matrix and return their % values and indices % @@ -621,7 +621,7 @@ function add_data(data_azi, data_inc, data_pol, data_mag, with_pol, ... 'hemisphere.\n',' Use ''transform'' flag to ' ... 'transform and plot these points.'] ; - % Suppress data as appropriate + % Suppress data as appropriate if ~itransform if ilower ind = find(data_inc<=0) ; @@ -649,9 +649,9 @@ function add_data(data_azi, data_inc, data_pol, data_mag, with_pol, ... data_pol(ind) = -data_pol(ind) ; end - % set index to include all points + % set index to include all points ind = 1:length(data_inc) ; - end + end % drop extraneous data data_azi = data_azi(ind) ; @@ -664,7 +664,7 @@ function add_data(data_azi, data_inc, data_pol, data_mag, with_pol, ... % Data points [X,Y,Z] = sph2cart(data_azi.*rad, data_inc.*rad, ones(size(data_azi))); - + % if required, apply stereographic transform [X,Y]=apply_projection(X,Y,Z,projection,ilower) ; @@ -683,31 +683,31 @@ function add_data(data_azi, data_inc, data_pol, data_mag, with_pol, ... V_y(i) = vecout(2); V_z(i) = vecout(3); end - + % ** transform vectors [V_x,V_y,V_z] = vnormalise2(V_x,V_y,V_z) ; [XN,YN,ZN] = vnormalise2(X,Y,Z) ; A = zeros(3,nsdata) ; B = zeros(3,nsdata) ; - + A(1,:) = XN ; A(2,:) = YN ; A(3,:) = ZN ; - + B(1,:) = V_x ; B(2,:) = V_y ; B(3,:) = V_z ; - + C=cross(A,B) ; D=cross(A,C) ; - + VR_x = D(1,:) ; VR_y = D(2,:) ; VR_z = D(3,:) ; - + [VR_x,VR_y,VR_z] = vnormalise2(VR_x,VR_y,VR_z) ; - + % ** rotate the particle motion vector so the normal to sphere is vertical VR_xR = zeros(1,nsdata); VR_yR = zeros(1,nsdata); @@ -716,15 +716,15 @@ function add_data(data_azi, data_inc, data_pol, data_mag, with_pol, ... [VR_xR(ip),VR_yR(ip),VR_zR(ip)] = ... rotate_pm_vector(... VR_x(ip),VR_y(ip),VR_z(ip),... - data_azi(ip),data_inc(ip)+180*ilower); - end - + data_azi(ip),data_inc(ip)+180*ilower); + end + h=quiver(X,Y,VR_xR,VR_yR,0.1,'w.') ; set(h,'LineWidth',3.0) ; h=quiver(X,Y,-VR_xR,-VR_yR,0.1,'w.') ; set(h,'LineWidth',3.0) ; - + %pol_pole(V_X', V_Y', V_Z', X, Y, Z, data_azi, data_inc, ... % 0.20, 0.20, 5.0, 3.0) @@ -732,9 +732,9 @@ function add_data(data_azi, data_inc, data_pol, data_mag, with_pol, ... % Pivot arrays to prevent data_mag looking like a colour. scatter(X',Y',25,data_mag','.') scatter(X,Y,26,'wo') - + end - + function contour_pole(X, Y, vals, view_angle, cvect, cmap, fntsz, ... buggyMATLAB, titletext) @@ -754,13 +754,13 @@ function contour_pole(X, Y, vals, view_angle, cvect, cmap, fntsz, ... else surf(X,Y,zeros(size(vals)),vals) ; shading flat ; - end + end view(view_angle) colormap(cmap) ; daspect([1 1 1]); colorbar('FontSize',fntsz) ; axis off - + title(titletext,'FontSize',fntsz+4,'FontWeight','bold') ; hold on @@ -771,13 +771,13 @@ function contour_pole(X, Y, vals, view_angle, cvect, cmap, fntsz, ... rad = pi./180 ; - % get min and max values and positions + % get min and max values and positions [imin,jmin,VALmin,imax,jmax,VALmax] = minmax2d(VAL) ; - - [VALmin_x,VALmin_y]=sph2cart(AZ(imin,jmin)*rad,INC(imin,jmin)*rad,1) ; - [VALmax_x,VALmax_y]=sph2cart(AZ(imax,jmax)*rad,INC(imax,jmax)*rad,1) ; - % mark the max. min. values + [VALmin_x,VALmin_y]=sph2cart(AZ(imin,jmin)*rad,INC(imin,jmin)*rad,1) ; + [VALmax_x,VALmax_y]=sph2cart(AZ(imax,jmax)*rad,INC(imax,jmax)*rad,1) ; + + % mark the max. min. values h=plot(VALmax_x,VALmax_y,'ws') ; set(h,'MarkerFaceColor','black'); h=plot(VALmin_x,VALmin_y,'wo') ; @@ -787,52 +787,52 @@ function contour_pole(X, Y, vals, view_angle, cvect, cmap, fntsz, ... function pol_pole(V_x,V_y,V_z, X, Y, Z, AZ, INC, ... qwhite_scale, qblack_scale, qwhite_width, qblack_width, ... projection, ilower) - + % ** transform vectors [V_x,V_y,V_z] = vnormalise2(V_x,V_y,V_z) ; [XN,YN,ZN] = vnormalise2(X,Y,Z) ; A = zeros(3,61,16) ; B = zeros(3,61,16) ; - + A(1,:,:) = XN ; A(2,:,:) = YN ; A(3,:,:) = ZN ; - + B(1,:,:) = V_x ; B(2,:,:) = V_y ; B(3,:,:) = V_z ; - + C=cross(A,B) ; D=cross(A,C) ; - + VR_x(:,:) = D(1,:,:) ; VR_y(:,:) = D(2,:,:) ; VR_z(:,:) = D(3,:,:) ; - + [VR_x,VR_y,VR_z] = vnormalise2(VR_x,VR_y,VR_z) ; - + % ** define subset of polarisations to plot switch lower(projection) case 'sphere' cl = [ 1 3 5 7 9 11 15 ] ; drw = [ 60 10 5 3 2 2 2 ] ; np=136 ; - case 'angle' + case 'angle' cl = [ 1 3 5 7 9 11 12 13 14 15 16] ; drw = [60 10 5 3 2 2 2 2 2 2 2] ; np=260 ; case 'area' cl = [ 1 2 4 6 8 10 12 14 16] ; drw = [60 20 5 3 2 2 2 2 2] ; - np=195 ; + np=195 ; end ii=0 ; ip=0 ; ind1 = zeros(1,np) ; ind2 = zeros(1,np) ; - + for iinc=cl ii=ii+1 ; for iaz=1:drw(ii):61 @@ -840,8 +840,8 @@ function pol_pole(V_x,V_y,V_z, X, Y, Z, AZ, INC, ... ind1(ip) = iaz ; ind2(ip) = iinc ; end - end - + end + % ** rotate the particle motion vector so the normal to sphere is vertical for ip = 1:np [VR_xR(ind1(ip),ind2(ip)),VR_yR(ind1(ip),... @@ -849,8 +849,8 @@ function pol_pole(V_x,V_y,V_z, X, Y, Z, AZ, INC, ... rotate_pm_vector(... VR_x(ind1(ip),ind2(ip)),VR_y(ind1(ip),... ind2(ip)),VR_z(ind1(ip),ind2(ip)),... - AZ(ind1(ip),ind2(ip)),INC(ind1(ip),ind2(ip))+(180*ilower)); - end + AZ(ind1(ip),ind2(ip)),INC(ind1(ip),ind2(ip))+(180*ilower)); + end % ** form the subsets X2 = zeros(1,np) ; @@ -867,10 +867,10 @@ function pol_pole(V_x,V_y,V_z, X, Y, Z, AZ, INC, ... U2(i)=VR_xR(ind1(i),ind2(i)) ; V2(i)=VR_yR(ind1(i),ind2(i)) ; W2(i)=VR_zR(ind1(i),ind2(i)) ; - end - -% ** plot the vectors (changed to 2D to allow plotting with contourf surface) -% h=quiver3(X2,Y2,Z2,U2,V2,W2,0.18,'k.') ; + end + +% ** plot the vectors (changed to 2D to allow plotting with contourf surface) +% h=quiver3(X2,Y2,Z2,U2,V2,W2,0.18,'k.') ; h=quiver(X2,Y2,U2,V2,qwhite_scale,'w.') ; set(h,'LineWidth',qwhite_width) ; @@ -891,7 +891,7 @@ function pol_pole(V_x,V_y,V_z, X, Y, Z, AZ, INC, ... RR = [ cos(g) sin(g) 0 ; -sin(g) cos(g) 0 ; 0 0 1 ] ; VR = V * RR ; - + end function [VR] = V_rot_bet(V,bet) @@ -902,20 +902,20 @@ function pol_pole(V_x,V_y,V_z, X, Y, Z, AZ, INC, ... RR = [ cos(b) 0 -sin(b) ; 0 1 0 ; sin(b) 0 cos(b) ] ; VR = V * RR ; - + end function plot_bands(baxis, bangles, projection, ilower) -% Plot bands on the pole figures. +% Plot bands on the pole figures. for iband=1:length(baxis) % generate a set of points around the 3-axis - + r=ones(1,73) ; th = 0:5:360 ; ph = ones(1,73) .* (90-bangles(iband)) ; [x,y,z]=sph2cart(th.*pi/180,ph.*pi/180,r) ; - + % rotate appropriately if baxis(iband) == 1 VR = V_rot_bet([x ; y ; z]',90) ; @@ -923,13 +923,13 @@ function plot_bands(baxis, bangles, projection, ilower) elseif baxis(iband) == 2 VR = V_rot_bet([x ; y ; z]',90) ; VRR = V_rot_gam(VR,90) ; - x=VRR(:,1) ; y=VRR(:,2) ; z=VRR(:,3) ; + x=VRR(:,1) ; y=VRR(:,2) ; z=VRR(:,3) ; elseif baxis(iband) == 3 % nothing required - else + else error('MS:PLOT:BADBANDAXIS', ... 'Bad axis specified to plot band.'); - end + end % ** if required, apply stereographic transform, but pretend % x3 is upper hemisphere even if it is not @@ -938,8 +938,8 @@ function plot_bands(baxis, bangles, projection, ilower) else [x,y]=apply_projection(x,y,z,projection,ilower) ; end - - % mask negative Z points - taking casere of some lower hemisphere oddness. + + % mask negative Z points - taking casere of some lower hemisphere oddness. if ilower && (baxis(iband) ~= 3) index = find(z<=0); px = x(index); @@ -957,11 +957,11 @@ function plot_bands(baxis, bangles, projection, ilower) px = x(index); py = y(index); end - + plot(px,py,'w-','LineWidth',1.5) end - - + + end function [vec] = force_row_vec(vec) @@ -987,7 +987,7 @@ function plot_bands(baxis, bangles, projection, ilower) function [XP,YP]=apply_projection(X,Y,Z,projection,ilower) % -% Function to apply projections to the polefigure. +% Function to apply projections to the pole figure. % lsign = (ilower*2)-1 ; @@ -997,12 +997,12 @@ function plot_bands(baxis, bangles, projection, ilower) YP=Y ; case 'angle' XP=X./(1-lsign*Z) ; - YP=Y./(1-lsign*Z) ; - case 'area' + YP=Y./(1-lsign*Z) ; + case 'area' XP = (sqrt(2./(1-lsign*Z)).*X)./sqrt(2) ; YP = (sqrt(2./(1-lsign*Z)).*Y)./sqrt(2) ; otherwise error(['Unknown projection: ' projection]) - end + end end diff --git a/msat/MS_plot_trace.m b/msat/MS_plot_trace.m index f8cc085..08d62b1 100644 --- a/msat/MS_plot_trace.m +++ b/msat/MS_plot_trace.m @@ -1,68 +1,69 @@ % MS_PLOT_TRACE - Plot one or more pairs of orthogonal traces -% +% % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % % MS_plot_trace(time, T00, T90, ...) % % Inputs: % time (row vector) : Series of time points where amplitudes -% are known (s) +% are known (s) % T00 (row vector / matrix) : Series of amplitudes in first direction. -% T90 (row vector / matrix) : Series of amplitudes in second +% T90 (row vector / matrix) : Series of amplitudes in second % direction. % % Usage: -% MS_plot_trace(time, T00, T90): If T00 and T90 are row vectors, plot % amplitudes of a single trace as two curves on time axis. For +% MS_plot_trace(time, T00, T90): If T00 and T90 are row vectors, plot +% amplitudes of a single trace as two curves on time axis. For % multiple traces T00 and T90 for each trace can be 'stacked' to % form a matrix, e.g. MS_plot_trace(time,[T00a;T90b],[T00a;T90b]), % but note that these must be on a common time axis. Subplots are % then used to draw each trace. -% MS_plot_trace(time, T00, T90, 'plots', plotstring): Alter the kind -% and/or number of plots for each trace. The variable plotstring -% is a series of single letter codes, each letter causes -% MS_plot_trace to generate a different kind of plot (again -% subplots may be used for multiple kinds of plot). Permitted -% letter codes are 'w': the default plot type described above; +% MS_plot_trace(time, T00, T90, 'plots', plotstring): Alter the kind +% and/or number of plots for each trace. The variable plotstring +% is a series of single letter codes, each letter causes +% MS_plot_trace to generate a different kind of plot (again +% subplots may be used for multiple kinds of plot). Permitted +% letter codes are 'w': the default plot type described above; % 'd': plot of particle displacement, i.e. T00 vs T90. % MS_plot_trace(time, T00, T90, 'headings', {'first trace name'; ... % 'second trace name'}): Give names to each trace in the plot. % Copyright (c) 2013, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -function [] = MS_plot_trace(time, T00, T90, varargin) +function [] = MS_plot_trace(time, T00, T90, varargin) % Plot some possibly useful diagnostics; assert(all(size(T00)==size(T90)), 'MS:PLOT_TRACE:invalidargs',... @@ -71,11 +72,11 @@ assert(length(T00(1,:))==length(time), 'MS:PLOT_TRACE:invalidargs',... ['The length of T00(1,:) and the time axis must match in ' ... 'MS_plot_trace']); - + % defaults plots = 'w'; withheadings = 0; - + % process the optional arguments iarg = 1 ; while iarg <= (length(varargin)) @@ -96,15 +97,15 @@ ['Unknown option in MS_plot_trace: ' varargin{iarg}]); end end - + % How many types of plot (width) n = size(plots); n = n(2); - + % How many pairs of traces (height) m = size(T00); m = m(1); - + figure pnum = 0; for i = 1:n @@ -121,11 +122,11 @@ ['Unknown plot type in MS_plot_trace: ' plots(1,i)]); end if (withheadings && (i == 1)) - title(headings(j,:)); + title(headings(j,:)); end end end - + end function [] = plot_wavelet(time,T00,T90) diff --git a/msat/MS_poisson.m b/msat/MS_poisson.m index b718ea7..ad9c31b 100644 --- a/msat/MS_poisson.m +++ b/msat/MS_poisson.m @@ -2,30 +2,30 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Calculate Poisson's ration from an elsticity matrix. +% Calculate Poisson's ration from an elasticity matrix. % % nu = MS_poisson( C, m, n ) % -% Usage: -% nu = MS_poisson( C, m, n ) +% Usage: +% nu = MS_poisson( C, m, n ) % Calculate Poisson's ration for anisotropic media given an % elasticity matrix, C, longitudinal direction described by -% a unit vector, n, and transverse direction given by the +% a unit vector, n, and transverse direction given by the % unit vector m. % % Notes: -% Poisson's ratio, nu, is normally described as the negative ratio of -% a (typically) compressive strain normal a direction of extensional +% Poisson's ratio, nu, is normally described as the negative ratio of +% a (typically) compressive strain normal a direction of extensional % strain. In an isotropic material nu takes a single value between -1.0 % an 0.5 (positive values around 0.2 or 0.3 are common). For the general % anisotropic case Poisson's ratio depends on the longitudinal extension % direction and the direction perpendicular to this (the transverse -% direction) where the compression (positive nu) or extension (negative +% direction) where the compression (positive nu) or extension (negative % nu) is measured. This function allows nu to be calculated as a function -% of these two directions, given as unit vectors. The approach follows +% of these two directions, given as unit vectors. The approach follows % equation 3 of Wojciechowski (2005) % -% +% % Reference: Wojciechowski, K. W. (2005) "Poisson's ratio of anisotropic % systems" COMPUTATIONAL METHODS IN SCIENCE AND TECHNOLOGY 11, 73-79. % @@ -33,36 +33,36 @@ % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [ nu ] = MS_poisson( C, m, n ) @@ -78,7 +78,7 @@ 'Unit vectors M and N are not orthogonal') ; S4 = MS_cij2cijkl(inv(C)); - + Smmnn = 0.0; Snnnn = 0.0; for i = 1:3 @@ -104,7 +104,7 @@ 'Unit vector error: Appears not to be numeric.'); end s = size(V); - if (length(s) ~= 2) || ... + if (length(s) ~= 2) || ... ~(((s(1) == 1) && (s(2) == 3)) || ((s(1) == 3) && (s(2) == 1))) error('MS:CHECKUNITNotVec', ... 'Unit vector error: Not a 3-d row or column vector.'); @@ -114,6 +114,6 @@ 'Unit vector error: Length not equal to 1.'); end isgood = 1; - + end \ No newline at end of file diff --git a/msat/MS_polyaverage.m b/msat/MS_polyaverage.m index c477dbb..6f9bdc8 100644 --- a/msat/MS_polyaverage.m +++ b/msat/MS_polyaverage.m @@ -1,15 +1,15 @@ -% MS_POLYAVERAGE - Isotropic elasticity for polycrystal +% MS_POLYAVERAGE - Isotropic elasticity for polycrystal % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Calculate the bulk and shear moduli of an isotropic polycrystal. +% Calculate the bulk and shear moduli of an isotropic polycrystal. % % [ K_vrh, G_vrh, ... ] = MS_polyaverage( C ) % -% Usage: -% [ K_vrh, G_vrh ] = MS_polyaverage( C ) -% Return Voigt-Reuss-Hill average bulk (K) and shear (G) moduli of -% an isotropic aggregate composed of randomly orentated ansiotropic +% Usage: +% [ K_vrh, G_vrh ] = MS_polyaverage( C ) +% Return Voigt-Reuss-Hill average bulk (K) and shear (G) moduli of +% an isotropic aggregate composed of randomly orientated anisotropic % crystals described by the elasticity matrix C. % % [ K_vrh, G_vrh, K_v, G_v, K_r, G_r ] = MS_polyaverage( C ) @@ -27,40 +27,40 @@ % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [ K_vrh, G_vrh, K_v, G_v, K_r, G_r ] = MS_polyaverage( C ) - + K_v = (1.0/9.0) * (C(1,1) + C(2,2) + C(3,3)) + ... (2.0/9.0) * (C(1,2) + C(1,3) + C(2,3)); G_v = (1.0/15.0) * (C(1,1) + C(2,2) + C(3,3) - ... @@ -73,8 +73,8 @@ G_r = 15.0 / ( 4.0 * (S(1,1) + S(2,2) + S(3,3)) - ... 4.0 * (S(1,2) + S(1,3) + S(2,3)) + ... 3.0 * (S(4,4) + S(5,5) + S(6,6)) ); - - K_vrh = (K_v+K_r)/2.0; + + K_vrh = (K_v+K_r)/2.0; G_vrh = (G_v+G_r)/2.0; end \ No newline at end of file diff --git a/msat/MS_rot3.m b/msat/MS_rot3.m index c2fc526..531b81e 100644 --- a/msat/MS_rot3.m +++ b/msat/MS_rot3.m @@ -2,23 +2,23 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Rotates an elasticity matrix around the three axes. +% Rotates an elasticity matrix around the three axes. % -% Usage: -% [CR] = MS_rot3(C,alp,bet,gam) -% C: input 6x6 elasticity matrix +% Usage: +% [CR] = MS_rot3(C,alp,bet,gam) +% C: input 6x6 elasticity matrix % alp: clockwise rotation about 1-axis, looking at origin % bet: clockwise rotation about 2-axis, looking at origin % gam: clockwise rotation about 3-axis, looking at origin % -% [CR] = MS_rot3(...,'order',V) +% [CR] = MS_rot3(...,'order',V) % order: V is a 3 element vector containing the order in which to apply the 3 rotations. % Default is [1 2 3]. % % Notes: -% Angles are given in degrees and correspond to yaw, -dip and aximuth, -% respectvly. The rotations are applied in order, ie: alpha, then beta -% then gamma (by default). The variables C, alp, bet and gam can be +% Angles are given in degrees and correspond to yaw, -dip and azimuth, +% respectively. The rotations are applied in order, ie: alpha, then beta +% then gamma (by default). The variables C, alp, bet and gam can be % arrays or scalars but (1) the angles must all be the % same length and (2) either C or all the angles must be scalars unless % they are the same length. @@ -26,36 +26,36 @@ % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [CR] = MS_rot3(C,alp,bet,gam,varargin) @@ -66,30 +66,30 @@ iarg = 1 ; while iarg <= (length(varargin)) switch lower(varargin{iarg}) - case 'order' + case 'order' orderV = varargin{iarg+1} ; if (length(find(orderV==1))+length(find(orderV==2))+length(find(orderV==3)))~=3 error('MS:ROT3:BadOrder',... - 'Order vector must be 3-element, containing 1,2 and 3') ; + 'Order vector must be 3-element, containing 1,2 and 3') ; end if (length(orderV)~=3) error('MS:ROT3:BadOrder',... - 'Order vector must be 3-element, containing 1,2 and 3') ; - end + 'Order vector must be 3-element, containing 1,2 and 3') ; + end iarg = iarg + 2 ; - otherwise + otherwise error('MS:ROT3:UnknownOption',... - ['Unknown option: ' varargin{iarg}]) ; - end + ['Unknown option: ' varargin{iarg}]) ; + end end % How many angles - are lists correct length. numrs = size(alp, 1); assert(numrs == size(bet, 1), 'MS:ListsMustMatch',... - 'The number of alp angles must be the same as the number of bet angles') + 'The number of alp angles must be the same as the number of bet angles') assert(numrs == size(gam, 1), 'MS:ListsMustMatch',... 'The number of alp angles must be the same as the number of gam angles') - + a = alp * pi/180. ; b = bet * pi/180. ; @@ -98,7 +98,7 @@ numdimCs = ndims(C); if ((numrs == 1) && (numdimCs == 2)) % Two matrix scalar case - CR = rot_3_scalar(C, a, b, g, orderV); + CR = rot_3_scalar(C, a, b, g, orderV); elseif ((numrs > 1) && (numdimCs == 2)) % Many rotations and one matrix case CR = zeros(6,6,numrs); @@ -112,7 +112,7 @@ CR(:,:,i) = rot_3_scalar(C(:,:,i), a, b, b, orderV); end elseif ((numrs > 1) && (numdimCs == 3)) - % List of rotatiosn and matrices case + % List of rotation and matrices case assert((numrs == size(C, 3)), 'MS:ListsMustMatch', ... 'The length of the lists of rotations and matrices must match'); CR = zeros(6,6,size(C, 3)); @@ -120,16 +120,16 @@ CR(:,:,i) = rot_3_scalar(C(:,:,i), a(i), b(i), g(i), orderV); end end - + end function [CR] = rot_3_scalar(C, a, b, g, orderV) - try + try MS_checkC(C) ; catch ME error('MS:ROT3BadInputMatrix', ... - ['Invalid input elasticity matrix: ' ME.message]) ; + ['Invalid input elasticity matrix: ' ME.message]) ; end R = zeros(3,3,3) ; @@ -141,7 +141,7 @@ RR = squeeze(R(orderV(3),:,:)) * ... squeeze(R(orderV(2),:,:)) * ... squeeze(R(orderV(1),:,:)); - + % Delegate the rotation CR = MS_rotR(C, RR) ; diff --git a/msat/MS_rotEuler.m b/msat/MS_rotEuler.m index c990ba1..8bce8f1 100644 --- a/msat/MS_rotEuler.m +++ b/msat/MS_rotEuler.m @@ -123,7 +123,7 @@ 'The number of phi1 angles must be the same as the number of theta angles') assert(numEs == size(phi2, 1), 'MS:ListsMustMatch',... 'The number of phi1 angles must be the same as the number of phi2 angles') - + % Convert all angles to radians phi1r = phi1*(pi/180.0); thetar = theta*(pi/180.0); @@ -148,7 +148,7 @@ phi2r, transpose); end elseif ((numEs > 1) && (numdimCs == 3)) - % List of rotatiosn and matrices case + % List of rotation and matrices case assert((numEs == size(C, 3)), 'MS:ListsMustMatch', ... 'The length of the lists of rotations and matrices must match'); CC = zeros(6,6,size(C, 3)); @@ -179,7 +179,7 @@ % Form rotation matrix for Bunge convention of % Euler angles, see eq 24 (pg81) of "Preferred % orientation in deformed meals and rocks... H-K Wenk (ed)" - % Note that this is for the passive roation. + % Note that this is for the passive rotation. g = [cp1*cp2 - sp1*sp2*cth, sp1*cp2 + cp1*sp2*cth, sp2*sth ; ... -1*cp1*sp2 - sp1*cp2*cth, -1*sp1*sp2 + cp1*cp2*cth, cp2*sth; ... sp1*sth, -1*cp1*sth, cth]; diff --git a/msat/MS_rotM.m b/msat/MS_rotM.m index 3c22766..1d93f94 100644 --- a/msat/MS_rotM.m +++ b/msat/MS_rotM.m @@ -1,4 +1,4 @@ -% MS_ROTM - Create a cartesian rotation matrix. +% MS_ROTM - Create a Cartesian rotation matrix. % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % @@ -8,50 +8,50 @@ % alp - clockwise about 1-axis (looking at origin, == yaw) % bet - clockwise about 2-axis (looking at origin, == -dip) % gam - clockwise about 3-axis (looking at origin, == azimuth) -% angles are in ** degrees **, they should be scalars. +% angles are in ** degrees **, they should be scalars. % % Output: is M, a 3x3 rotation matrix % -% [M] = MS_rotM(...,'order',V) +% [M] = MS_rotM(...,'order',V) % order: V is a 3 element vector containing the order in which to apply the 3 rotations. % Default is [1 2 3]. % -% Notes: +% Notes: % The rotations are applied in order, ie: alpha, then beta then gamma (by default). % % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [ M ] = MS_rotM( alp, bet, gam, varargin ) @@ -63,21 +63,21 @@ iarg = 1 ; while iarg <= (length(varargin)) switch lower(varargin{iarg}) - case 'order' + case 'order' orderV = varargin{iarg+1} ; if (length(find(orderV==1))+length(find(orderV==2))+length(find(orderV==3)))~=3 error('MS:ROTM:BadOrder',... - 'Order vector must be 3-element, containing 1,2 and 3') ; + 'Order vector must be 3-element, containing 1,2 and 3') ; end if (length(orderV)~=3) error('MS:ROTM:BadOrder',... - 'Order vector must be 3-element, containing 1,2 and 3') ; - end + 'Order vector must be 3-element, containing 1,2 and 3') ; + end iarg = iarg + 2 ; - otherwise + otherwise error('MS:ROTM:UnknownOption',... - ['Unknown option: ' varargin{iarg}]) ; - end + ['Unknown option: ' varargin{iarg}]) ; + end end a = alp * pi/180. ; diff --git a/msat/MS_rotR.m b/msat/MS_rotR.m index 3dc7f5d..1384d0b 100644 --- a/msat/MS_rotR.m +++ b/msat/MS_rotR.m @@ -6,18 +6,18 @@ % % % [ CR ] = MS_rotR( C, R ) % -% Usage: +% Usage: % For a three-by-three rotation matrix, R, rotate the elasticity matrix, -% C to give a rotated matrix CR. +% C to give a rotated matrix CR. % % Notes: -% The rotation is performed without transforming the elasticity +% The rotation is performed without transforming the elasticity % matrix to the full tensor form following the method described in -% Bowers. This eleminates eight nested loops and replaces them with pure -% matrix-matrix operations, which is (~30 times) faster in Matlab. +% Bowers. This eliminates eight nested loops and replaces them with pure +% matrix-matrix operations, which is (~30 times) faster in Matlab. % Unlike the other MSAT rotation functions, C and R cannot be lists but -% must be 6x6 and 3x3 matricies, respectivly. Furthermore, the -% corectness of the input arguments are not checked. Users are encoraged +% must be 6x6 and 3x3 matrices, respectively. Furthermore, the +% correctness of the input arguments are not checked. Users are encouraged % to make use of MS_rot3 or MS_rotEuler for most rotation operations - % these make use of this function internally. % @@ -28,36 +28,36 @@ % Copyright (c) 2011, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [CR] = MS_rotR(C,R) @@ -80,10 +80,10 @@ R(2,1).*R(3,2)+R(2,2).*R(3,1) ; ... R(3,2).*R(1,3)+R(3,3).*R(1,2) ... R(3,3).*R(1,1)+R(3,1).*R(1,3) ... - R(3,1).*R(1,2)+R(3,2).*R(1,1) ; ... + R(3,1).*R(1,2)+R(3,2).*R(1,1) ; ... R(1,2).*R(2,3)+R(1,3).*R(2,2) ... R(1,3).*R(2,1)+R(1,1).*R(2,3) ... - R(1,1).*R(2,2)+R(1,2).*R(2,1)] ; + R(1,1).*R(2,2)+R(1,2).*R(2,1)] ; K = [ K1 2.*K2 ; ... K3 K4 ] ; diff --git a/msat/MS_rotRandom.m b/msat/MS_rotRandom.m index 7677f17..bd27687 100644 --- a/msat/MS_rotRandom.m +++ b/msat/MS_rotRandom.m @@ -15,12 +15,12 @@ % [ CC, ... ] = MS_rotRandom( C, 'number', n ) % % CC is a 6x6xn matrix where each orientation is drawn from a uniform -% random distribution of orientations such that, for large n, the -% avarage of the matricies in CC is isotropic. +% random distribution of orientations such that, for large n, the +% average of the matrices in CC is isotropic. % % [ CC, ... ] = MS_rotRandom( C, 'stream', PRNgenerator ) % -% As above, but allow the user to specify the random number generator +% As above, but allow the user to specify the random number generator % to be used. % % [ CC, eulers ] = MS_rotRandom( C, ... ) @@ -32,36 +32,36 @@ % Copyright (c) 2014 James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [CC, eulers] = MS_rotRandom( C, varargin ) @@ -71,34 +71,34 @@ % stream = RandStream.getDefaultStream; stream = RandStream.getGlobalStream; number = 1; - + % Process the optional arguments iarg = 1 ; while iarg <= (length(varargin)) switch lower(varargin{iarg}) - case 'number' + case 'number' number = varargin{iarg+1} ; iarg = iarg + 2 ; case 'stream' stream = varargin{iarg+1} ; iarg = iarg + 2 ; - otherwise + otherwise error('MS:ROTRAND:UnknownOption',... - ['Unknown option: ' varargin{iarg}]) ; - end + ['Unknown option: ' varargin{iarg}]) ; + end end - + % Uniform random numbers between 0 and 1. We convert these % into the Euler angles. eulers = rand(stream,3,number); % Convert phi1 and phi2 to degrees between 0 and 360. Note % that if Phi = 0 the orientation is determined by the sum of - % these two rotations, but the periodicity means the orentation + % these two rotations, but the periodicity means the orientation % is still uniformly distributed. eulers(1,:) = eulers(1,:).*360.0; eulers(3,:) = eulers(3,:).*360.0; - + % Phi can be between -90 and 90 degrees and cos(Phi) must % be unformly distributed (the metric space is phi1, cos(Phi) % phi2. So first make the number between -1 and 1 then take the @@ -108,5 +108,5 @@ % Annoying transpose - see GitHub issue #7 CC = MS_rotEuler(C, eulers(1,:)', eulers(2,:)', eulers(3,:)'); - + end diff --git a/msat/MS_save.m b/msat/MS_save.m index 566aa1b..02ad37f 100644 --- a/msat/MS_save.m +++ b/msat/MS_save.m @@ -1,33 +1,33 @@ % MS_SAVE - Write a set of elastic constants from a file. % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // -% +% % MS_save( fname, C, rho, ... ) % -% Usage: -% MS_save(fname, C, rho) -% Write the elastic constants, C, and density, rho, to file -% 'fname'. C must be provided in GPa and rho must be provided in -% kg/m3. See file format below. +% Usage: +% MS_save(fname, C, rho) +% Write the elastic constants, C, and density, rho, to file +% 'fname'. C must be provided in GPa and rho must be provided in +% kg/m3. See file format below. % -% MS_save(fname, C, rho, ..., 'format',fmt) -% Specify format for file. See below for descriptions. Available +% MS_save(fname, C, rho, ..., 'format',fmt) +% Specify format for file. See below for descriptions. Available % options are: % 'simple' : Formatted text file (default) % 'ematrix' : Format read by EMATRIX (D. Mainprice). % % MS_save(fname, C, rho, ..., 'eunit',unit) -% Specify elasticity unit; this is used to convert from GPa (msat's +% Specify elasticity unit; this is used to convert from GPa (msat's % default operating unit) % 'GPa' - elastic constants are written in GPa (default) % 'Mbar' - elastic constants are written in Mbar % 'Pa' - elastic constants are written in Pascals % 'bar' - elastic constants are written in bar -% Note: when using a density normalised tensor, specify the unit +% Note: when using a density normalised tensor, specify the unit % *before* normalisation (i.e., a unit of pressure). % % MS_save(fname, C, rho, ..., 'dunit',unit) -% Specify density unit; this is used to convert from kg/m3 (msat's +% Specify density unit; this is used to convert from kg/m3 (msat's % default operating unit) % 'kgm3' - density is written in kg/m3 (default) % 'gcc' - density is written g/cc @@ -36,8 +36,8 @@ % Elasticities are written in density normalised form. This option % requires a density to be specified. The provided elastic % constants are first converted to the unit specified by the -% 'eunit' argument (if provided) and the density converted to the -% unit specified in the by the 'dunit' argument (if provided) then +% 'eunit' argument (if provided) and the density converted to the +% unit specified in the by the 'dunit' argument (if provided) then % the elastic constants are divided by the density before being % written to the file. % @@ -45,66 +45,66 @@ % ----------------------- % % * 'simple' (default) -% +% % In this mode MS_load expects an ascii file containing lines of the form: % % I J C(I,J) % -% Elasticity tensor components are specified by their indices (i,j). Any -% number other than 1-6 in the i or j column denotes that a density is -% being given. +% Elasticity tensor components are specified by their indices (i,j). Any +% number other than 1-6 in the i or j column denotes that a density is +% being given. % % So, for olivine, the file might look like: -% -% +% +% % 1 1 320.5 % 1 2 68.1 % 1 3 71.6 % ... % 6 6 78.7 % 0 0 3325 -% -% Text following a '%' in any line is ignored (useful for header lines or +% +% Text following a '%' in any line is ignored (useful for header lines or % comments) % % * 'ematrix' % -% Elastic constants in the format read by EMATRIX (D. Mainprice). +% Elastic constants in the format read by EMATRIX (D. Mainprice). % % See also: MS_LOAD % Copyright (c) 2012, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [varargout] = MS_save(fname, C, rho, varargin) @@ -206,14 +206,14 @@ function MS_write_simple( fname, C, rho) fid = fopen(fname, 'wt'); % Should we use t here? - + for i = 1:6 for j = i:6 fprintf(fid, '%1i %1i %8e\n', i, j, C(i,j)); end end fprintf(fid, '%1i %1i %f\n', 7, 7, rho); - + fclose(fid); end @@ -221,8 +221,8 @@ function MS_write_simple( fname, C, rho) function MS_write_ematrix( fname, C, rho) error('MS:SAVE:NotImplemented', 'Writing to ematrix format is not implemented') end - - - - + + + + diff --git a/msat/MS_sphere.m b/msat/MS_sphere.m index d6dc1bb..66c989a 100644 --- a/msat/MS_sphere.m +++ b/msat/MS_sphere.m @@ -1,39 +1,39 @@ -% MS_SPHERE - Plot a spherical plot of phasevels/anisotropy from a set of +% MS_SPHERE - Plot a spherical plot of phasevels/anisotropy from a set of % elastic constants. % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Given an elasticity matrix and density, produce spherical figures showing -% the P- or S-wave anisotropy or the slowness surface. +% Given an elasticity matrix and density, produce spherical figures showing +% the P- or S-wave anisotropy or the slowness surface. % % % MS_sphere(CC,rh,mode,...) % -% Usage: -% MS_sphere(CC,rh,mode) +% Usage: +% MS_sphere(CC,rh,mode) % Mode can be 'p'(-wave), 's'(-wave), 's1' (fast s-wave) or 's2' % (slow s-wave) for velocity plots or 'slowP','slowS1' or 'slowS2' % for slowness plots (slowness is the inverse of velocity). % -% MS_sphere(CC,rh,mode,...) +% MS_sphere(CC,rh,mode,...) % Further arguments are optional, can be combined in any order and % change the behaviour of the function. Specific options are % listed below. % % MS_sphere(..., 'reverse') -% Unreverse the sense of the colour map. Default (no argument) is -% for blue to be fast/high as is conventional for seismic velocity -% colorscales. Setting this option results in red being fast/high. +% Unreverse the sense of the colour map. Default (no argument) is +% for blue to be fast/high as is conventional for seismic velocity +% colour scales. Setting this option results in red being fast/high. % % MS_sphere(..., 'sdata',azi,inc,pol,magn) -% Overlay a S-wave (splitting) dataset onto the sphere at the points. -% indicated by the azi, inc arrays. The data are in 2 vectors: pol -% (SW orientation) and mag (% anisotropy). They are plotted as coloured -% spots with vector ticks. +% Overlay a S-wave (splitting) dataset onto the sphere at the points. +% indicated by the azi, inc arrays. The data are in 2 vectors: pol +% (SW orientation) and mag (% anisotropy). They are plotted as coloured +% spots with vector ticks. % % MS_sphere(..., 'pdata',azi,inc,vel) -% Overlay a P-wave (velocity) dataset (in vel) onto the sphere at -% the points. indicated by the azi, inc arrays. They are plotted as -% coloured spots. +% Overlay a P-wave (velocity) dataset (in vel) onto the sphere at +% the points. indicated by the azi, inc arrays. They are plotted as +% coloured spots. % % MS_sphere(..., 'FSWTickLength', length) % Set the length of the Fast shear wave direction markers, default @@ -43,40 +43,40 @@ % Set the size of the Fast shear wave direction markers, default % is 4. % -% MS_sphere(..., 'cmap', CM) -% Redefine the colormap. CM can either be a (nx3) matrix containing a -% colormap, or a string describing a function to generate such a -% matrix (such as the built-in MATLAB colormap functions). E.g.: -% MS_sphere(C,rh,mode,'cmap','cool(64)') - uses the MATLAB +% MS_sphere(..., 'cmap', CM) +% Redefine the colourmap. CM can either be a (nx3) matrix containing a +% colourmap, or a string describing a function to generate such a +% matrix (such as the built-in MATLAB colourmap functions). E.g.: +% MS_sphere(C,rh,mode,'cmap','cool(64)') - uses the MATLAB % function cool to generate a cyan-to-purple colourmap. -% The default is 'jet', reversed so blue is fast/high, as is -% conventional for seismic velocity colorscales. +% The default is 'jet', reversed so blue is fast/high, as is +% conventional for seismic velocity colour scales. % % MS_sphere(..., 'velmesh', levels) % Choose the number of points used to mesh the velocity contours -% expressed in terms of the number of times the mesh spacing is +% expressed in terms of the number of times the mesh spacing is % halved. Default is 3. % % MS_sphere(..., 'polmesh', levels) -% Choose the number of points used to mesh the fast shear wave -% markers. Expressed in terms of the number of times the mesh spacing is +% Choose the number of points used to mesh the fast shear wave +% markers. Expressed in terms of the number of times the mesh spacing is % halved. Default is 2. % % MS_sphere(..., 'dirs', array) -% Directions of interest, this should be a vector of azi, +% Directions of interest, this should be a vector of azi, % inc pairs, e.g., [az1 in1 az2 in2 az3 in3 az4 in4]. % -% MS_sphere(..., 'dlen', lenght) +% MS_sphere(..., 'dlen', length) % Set length of doi vectors. Default is 1.5 % % MS_sphere(..., 'nolabels') -% Supress printing of the text labels. +% Suppress printing of the text labels. % % MS_sphere(..., 'noaxes') -% Supress printing of the direction axes. +% Suppress printing of the direction axes. % % MS_sphere(..., 'nocbar') -% Supress printing of the colour bar. +% Suppress printing of the colour bar. % % MS_sphere(..., 'nofig') % Suppress the figure command, so plot can be sub-plotted. @@ -89,36 +89,36 @@ % Portions of this function are: % Copyright (c) 1989 - 2002, Darren Weber, Jon Leech and Jim Buddenhagen. % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. % NB: redistributors must also comply with the GPL. See below. @@ -142,14 +142,14 @@ function MS_sphere(CC,rh,mode,varargin) polmesh = 2; cax = NaN ; % define to use minval = Inf ; % define to use -maxval = Inf ; +maxval = Inf ; % Changing defaults for case of slowness surfaces before the optional arguments are processed if ischar(mode) if sum(strcmpi({'slowp','slows1','slows2'},mode))==1 cmap=copper(64) ; % So we can tell the difference between V and slowness end -end +end % ** process the optional arguments iarg = 1 ; @@ -175,7 +175,7 @@ function MS_sphere(CC,rh,mode,varargin) pd_azi = varargin{iarg+1} ; pd_inc = varargin{iarg+2} ; pd_vel = varargin{iarg+3} ; - iarg = iarg + 4 ; + iarg = iarg + 4 ; case 'sdata' iplot_sdata = 1 ; sd_azi = varargin{iarg+1} ; @@ -213,10 +213,10 @@ function MS_sphere(CC,rh,mode,varargin) minval = varargin{iarg + 1}; maxval = varargin{iarg + 2}; iarg = iarg + 3; - otherwise - error(['Unknown option: ' varargin{iarg}]) ; - end - end + otherwise + error(['Unknown option: ' varargin{iarg}]) ; + end + end % check the inputs: CC assert(MS_checkC(CC)==1, 'MS:SPHERE:badC', 'MS_checkC error MS_sphere') ; @@ -238,7 +238,7 @@ function MS_sphere(CC,rh,mode,varargin) else error('MS:SPHERE:badmode', ... 'Mode must be ''S''(-wave) or ''P''(-wave) ') -end +end % check input pars if mod(length(dirs),2)~=0 @@ -258,7 +258,7 @@ function MS_sphere(CC,rh,mode,varargin) % ** Setup a seismic colourmap (i.e. red->green->blue) if icmapflip cmap = flipud(cmap) ; -end +end % unpack the specified directions of interest daz=dirs(1:2:length(dirs)).*pi/180 ; @@ -318,10 +318,10 @@ function MS_sphere(CC,rh,mode,varargin) if ~isnan(cax), caxis(cax), end % plot the shear-wave polarisation -if sum(strcmpi({'s','s1','s2','slows1','slows2'},mode))==1 +if sum(strcmpi({'s','s1','s2','slows1','slows2'},mode))==1 [x, y, z, ~, az, inc] = get_mesh(polmesh); -% find the closest points to each specified direction +% find the closest points to each specified direction [xd,yd,zd] = sph2cart(-daz,din,ones(size(daz))) ; for idir=1:ndir @@ -334,11 +334,11 @@ function MS_sphere(CC,rh,mode,varargin) az(ind) = daz(idir)*180/pi ; inc(ind) = din(idir)*180/pi ; end - + [~,avs,vs1,vs2,vp, SF, SS] = MS_phasevels(CC,rh,inc,az) ; % calculate PM vectors nv = length(x) ; - if sum(strcmpi(mode,{'s','s1','slows1'}))==1 + if sum(strcmpi(mode,{'s','s1','slows1'}))==1 for iv=1:nv if strcmpi(mode, 'slows1') slow = 1./vs1(iv); @@ -346,10 +346,10 @@ function MS_sphere(CC,rh,mode,varargin) xslow = x(iv) .* nslow; yslow = y(iv) .* nslow; zslow = z(iv) .* nslow; - XI=1.01.*[xslow yslow zslow] ; + XI=1.01.*[xslow yslow zslow] ; else XI=1.01.*[x(iv) y(iv) z(iv)] ; - end + end X1 = XI-FSWTickLength.*SF(iv,:); X2 = XI+FSWTickLength.*SF(iv,:); plot3(XI(1),XI(2),XI(3),'ko','MarkerSize',FSWMarkerSize,'MarkerFaceColor','k') @@ -363,10 +363,10 @@ function MS_sphere(CC,rh,mode,varargin) xslow = x(iv) .* nslow; yslow = y(iv) .* nslow; zslow = z(iv) .* nslow; - XI=1.01.*[xslow yslow zslow] ; + XI=1.01.*[xslow yslow zslow] ; else XI=1.01.*[x(iv) y(iv) z(iv)] ; - end + end X1 = XI-FSWTickLength.*SS(iv,:); X2 = XI+FSWTickLength.*SS(iv,:); plot3(XI(1),XI(2),XI(3),'wo','MarkerSize',FSWMarkerSize,'MarkerFaceColor','w') @@ -394,8 +394,8 @@ function MS_sphere(CC,rh,mode,varargin) text(xd*1.01,yd*1.01,zd*1.01,... sprintf('[%6.1f,%6.1f]', ... daz(i).*180./pi,din(i).*180./pi),'FontSize',12) ; - end -end + end +end % do the data overlay. @@ -406,14 +406,14 @@ function MS_sphere(CC,rh,mode,varargin) pd_azi = reshape(pd_azi,1,prod(size(pd_azi))) ; pd_inc = reshape(pd_inc,1,prod(size(pd_inc))) ; pd_vel = reshape(pd_vel,1,prod(size(pd_vel))) ; - + if (length(pd_azi)~=length(pd_inc)) | ... (length(pd_azi)~=length(pd_vel)) error('MS:SPHERE:pdata_mismatch', 'P-wave data arrays must be the same size.') ; end - + npdata = length(pd_azi) ; - + % create a colour for each data point. [Cxmin Cxmax] = caxis ; % get the current colour axis Cx = linspace(Cxmin,Cxmax,length(colormap)) ; @@ -422,9 +422,9 @@ function MS_sphere(CC,rh,mode,varargin) pd_col = [ interp1(Cx,Cy(:,1),pd_vel)', ... interp1(Cx,Cy(:,2),pd_vel)', ... interp1(Cx,Cy(:,3),pd_vel)'] ; - -% add each data point - for i=1:npdata + +% add each data point + for i=1:npdata [xd,yd,zd] = ... sph2cart(-pd_azi(i).*pi/180,pd_inc(i).*pi/180,1.02) ; % position of marker. h=plot3(xd,yd,zd,'ko','MarkerSize',12) ; @@ -440,21 +440,21 @@ function MS_sphere(CC,rh,mode,varargin) sd_inc = reshape(sd_inc,1,prod(size(sd_inc))) ; sd_pol = reshape(sd_pol,1,prod(size(sd_pol))) ; sd_mag = reshape(sd_mag,1,prod(size(sd_mag))) ; - + if (length(sd_azi)~=length(sd_inc)) | ... (length(sd_azi)~=length(sd_pol)) | ... - (length(sd_azi)~=length(sd_mag)) + (length(sd_azi)~=length(sd_mag)) error('MS:SPHERE:sdata_mismatch', 'S-wave data arrays must be the same size.') ; end - + nsdata = length(sd_azi) ; - + % create a colour for each data point. [Cxmin Cxmax] = caxis ; % get the current colour axis Cx = linspace(Cxmin,Cxmax,length(colormap)) ; Cy = colormap ; -% create an array of unrotated ticks. +% create an array of unrotated ticks. sd_col = [ interp1(Cx,Cy(:,1),sd_mag)', ... interp1(Cx,Cy(:,2),sd_mag)', ... interp1(Cx,Cy(:,3),sd_mag)'] ; @@ -465,24 +465,24 @@ function MS_sphere(CC,rh,mode,varargin) sd_vec2 = [ zeros(nsdata,1), ... -2*FSWTickLength.*sind(sd_pol)' , ... - -2*FSWTickLength.*cosd(sd_pol)'] ; - -% add each data point - for i=1:nsdata + -2*FSWTickLength.*cosd(sd_pol)'] ; + +% add each data point + for i=1:nsdata [xd,yd,zd] = ... sph2cart(-sd_azi(i).*pi/180,sd_inc(i).*pi/180,1.01) ; % position of marker. - + % add the orientation tick. sd_tick1 = V_rot_gam(V_rot_bet(sd_vec1(i,:),-sd_inc(i)),-sd_azi(i)) ; sd_tick2 = V_rot_gam(V_rot_bet(sd_vec2(i,:),-sd_inc(i)),-sd_azi(i)) ; - + plot3([sd_tick1(1) sd_tick2(1)]+xd,... [sd_tick1(2) sd_tick2(2)]+yd,... [sd_tick1(3) sd_tick2(3)]+zd,'k-','LineWidth',3) ; - + % add the coloured marker. h=plot3(xd,yd,zd,'ko','MarkerSize',12,'LineWidth',3) ; - set(h,'MarkerFaceColor',sd_col(i,:)) ; % recolour according to cmap. + set(h,'MarkerFaceColor',sd_col(i,:)) ; % recolour according to cmap. end end @@ -513,7 +513,7 @@ function MS_sphere(CC,rh,mode,varargin) return -% Tooling to build the triangulation... +% Tooling to build the triangulation... function [x, y, z, tri, az, inc ] = get_mesh(level) @@ -522,7 +522,7 @@ function MS_sphere(CC,rh,mode,varargin) y = FV.vertices(:,2); z = FV.vertices(:,3); tri = FV.faces; - + % cartesian to spherical conversion. r = sqrt(x.^2 + y.^2 + z.^2); phi = atan2(y,x); @@ -530,16 +530,16 @@ function MS_sphere(CC,rh,mode,varargin) az = -phi*(180.0/pi); inc = -(theta*(180.0/pi)-90.0); - + return function [FV] = sphere_tri(shape,maxlevel,r,winding) % sphere_tri - generate a triangle mesh approximating a sphere -% +% % Usage: FV = sphere_tri(shape,Nrecurse,r,winding) -% +% % shape is a string, either of the following: % 'ico' starts with icosahedron (most even, default) % 'oct' starts with octahedron @@ -549,33 +549,33 @@ function MS_sphere(CC,rh,mode,varargin) % % r is the radius of the sphere (default 1) % -% winding is 0 for clockwise, 1 for counterclockwise (default 0). The +% winding is 0 for clockwise, 1 for counter-clockwise (default 0). The % matlab patch command gives outward surface normals for clockwise % order of vertices in the faces (viewed from outside the surface). % -% FV has fields FV.vertices and FV.faces. The vertices -% are listed in clockwise order in FV.faces, as viewed +% FV has fields FV.vertices and FV.faces. The vertices +% are listed in clockwise order in FV.faces, as viewed % from the outside in a RHS coordinate system. -% +% % The function uses recursive subdivision. The first % approximation is an platonic solid, either an icosahedron, -% octahedron or a tetrahedron. Each level of refinement -% subdivides each triangle face by a factor of 4 (see also -% mesh_refine). At each refinement, the vertices are +% octahedron or a tetrahedron. Each level of refinement +% subdivides each triangle face by a factor of 4 (see also +% mesh_refine). At each refinement, the vertices are % projected to the sphere surface (see sphere_project). -% +% % A recursion level of 3 or 4 is a good sphere surface, if % gouraud shading is used for rendering. -% +% % The returned struct can be used in the patch command, eg: -% +% % % create and plot, vertices: [2562x3] and faces: [5120x3] % FV = sphere_tri('ico',4,1); % lighting phong; shading interp; figure; % patch('vertices',FV.vertices,'faces',FV.faces,... % 'facecolor',[1 0 0],'edgecolor',[.2 .2 .6]); % axis off; camlight infinite; camproj('perspective'); -% +% % See also: mesh_refine, sphere_project % @@ -597,7 +597,7 @@ function MS_sphere(CC,rh,mode,varargin) if ~exist('shape','var') || isempty(shape), shape = 'ico'; end -% - AMW - fprintf('...creating sphere tesselation based on %s\n',shape); +% - AMW - fprintf('...creating sphere tessellation based on %s\n',shape); % default maximum subdivision level if ~exist('maxlevel','var') || isempty(maxlevel) || maxlevel < 0, @@ -620,26 +620,26 @@ function MS_sphere(CC,rh,mode,varargin) switch shape, case 'tetra', - + % Vertices of a tetrahedron sqrt_3 = 0.5773502692; - + tetra.v = [ sqrt_3, sqrt_3, sqrt_3 ; % +X, +Y, +Z - PPP -sqrt_3, -sqrt_3, sqrt_3 ; % -X, -Y, +Z - MMP -sqrt_3, sqrt_3, -sqrt_3 ; % -X, +Y, -Z - MPM sqrt_3, -sqrt_3, -sqrt_3 ]; % +X, -Y, -Z - PMM - + % Structure describing a tetrahedron tetra.f = [ 1, 2, 3; 1, 4, 2; 3, 2, 4; 4, 1, 3 ]; - + FV.vertices = tetra.v; FV.faces = tetra.f; - + case 'oct', - + % Six equidistant points lying on the unit sphere oct.v = [ 1, 0, 0 ; % X -1, 0, 0 ; % -X @@ -647,7 +647,7 @@ function MS_sphere(CC,rh,mode,varargin) 0, -1, 0 ; % -Y 0, 0, 1 ; % Z 0, 0, -1 ]; % -Z - + % Join vertices to create a unit octahedron oct.f = [ 1 5 3 ; % X Z Y - First the top half 3 5 2 ; % Y Z -X @@ -657,16 +657,16 @@ function MS_sphere(CC,rh,mode,varargin) 3 2 6 ; % Y Z -Z 2 4 6 ; % -X Z -Z 4 1 6 ]; % -Y Z -Z - + FV.vertices = oct.v; FV.faces = oct.f; - + case 'ico', - + % Twelve vertices of icosahedron on unit sphere tau = 0.8506508084; % t=(1+sqrt(5))/2, tau=t/sqrt(1+t^2) one = 0.5257311121; % one=1/sqrt(1+t^2) , unit sphere - + ico.v( 1,:) = [ tau, one, 0 ]; % ZA ico.v( 2,:) = [ -tau, one, 0 ]; % ZB ico.v( 3,:) = [ -tau, -one, 0 ]; % ZC @@ -679,7 +679,7 @@ function MS_sphere(CC,rh,mode,varargin) ico.v(10,:) = [ 0 , -tau, one ]; % XB ico.v(11,:) = [ 0 , -tau, -one ]; % XC ico.v(12,:) = [ 0 , tau, -one ]; % XD - + % Structure for unit icosahedron ico.f = [ 5, 8, 9 ; 5, 10, 8 ; @@ -701,7 +701,7 @@ function MS_sphere(CC,rh,mode,varargin) 7, 12, 2 ; 8, 10, 3 ; 7, 3, 11 ]; - + FV.vertices = ico.v; FV.faces = ico.f; end @@ -710,18 +710,18 @@ function MS_sphere(CC,rh,mode,varargin) % ----------------- % refine the starting shapes with subdivisions if maxlevel, - + % Subdivide each starting triangle (maxlevel) times for level = 1:maxlevel, - + % Subdivide each triangle and normalize the new points thus % generated to lie on the surface of a sphere radius r. FV = mesh_refine_tri4(FV); FV.vertices = sphere_project(FV.vertices,r); - + % An alternative might be to define a min distance % between vertices and recurse or use fminsearch - + end end @@ -743,8 +743,8 @@ function MS_sphere(CC,rh,mode,varargin) % FV.vertices - mesh vertices (Nx3 matrix) % FV.faces - faces with indices into 3 rows % of FV.vertices (Mx3 matrix) -% -% For each face, 3 new vertices are created at the +% +% For each face, 3 new vertices are created at the % triangle edge midpoints. Each face is divided into 4 % faces and returned in FV. % @@ -756,20 +756,20 @@ function MS_sphere(CC,rh,mode,varargin) % / \ / \ [a,B,b] % /____\/____\ [c,b,C] % A c C [a,b,c] -% +% % It is assumed that the vertices are listed in clockwise order in % FV.faces (A,B,C above), as viewed from the outside in a RHS coordinate % system. -% +% % See also: mesh_refine, sphere_tri, sphere_project -% +% % ---this method is not implemented, but the idea here remains... -% This can be done until some minimal distance (D) of the mean +% This can be done until some minimal distance (D) of the mean % distance between vertices of all triangles is achieved. If % no D argument is given, the function refines the mesh once. -% Alternatively, it could be done until some minimum mean +% Alternatively, it could be done until some minimum mean % area of faces is achieved. As is, it just refines once. @@ -784,10 +784,10 @@ function MS_sphere(CC,rh,mode,varargin) % - AMW - fprintf('...refining mesh (tri4)...') % NOTE -% The centroid is located one third of the way from each vertex to -% the midpoint of the opposite side. Each median divides the triangle -% into two equal areas; all the medians together divide it into six -% equal parts, and the lines from the median point to the vertices +% The centroid is located one third of the way from each vertex to +% the midpoint of the opposite side. Each median divides the triangle +% into two equal areas; all the medians together divide it into six +% equal parts, and the lines from the median point to the vertices % divide the whole into three equivalent triangles. % Each input triangle with vertices labelled [A,B,C] as shown @@ -815,39 +815,39 @@ function MS_sphere(CC,rh,mode,varargin) F2 = zeros(Nface*4,3); for f = 1:Nface, - + % Get the triangle vertex indices NA = FV.faces(f,1); NB = FV.faces(f,2); NC = FV.faces(f,3); - + % Get the triangle vertex coordinates A = FV.vertices(NA,:); B = FV.vertices(NB,:); C = FV.vertices(NC,:); - + % Now find the midpoints between vertices a = (A + B) ./ 2; b = (B + C) ./ 2; c = (C + A) ./ 2; - + % Find the length of each median %A2blen = sqrt ( sum( (A - b).^2, 2 ) ); %B2clen = sqrt ( sum( (B - c).^2, 2 ) ); %C2alen = sqrt ( sum( (C - a).^2, 2 ) ); - + % Store the midpoint vertices, while % checking if midpoint vertex already exists [FV, Na] = mesh_find_vertex(FV,a); [FV, Nb] = mesh_find_vertex(FV,b); [FV, Nc] = mesh_find_vertex(FV,c); - + % Create new faces with orig vertices plus midpoints F2(f*4-3,:) = [ NA, Na, Nc ]; F2(f*4-2,:) = [ Na, NB, Nb ]; F2(f*4-1,:) = [ Nc, Nb, NC ]; F2(f*4-0,:) = [ Na, Nb, Nc ]; - + end % Replace the faces matrix @@ -864,7 +864,7 @@ function MS_sphere(CC,rh,mode,varargin) RR = [ cos(g) sin(g) 0 ; -sin(g) cos(g) 0 ; 0 0 1 ] ; VR = V * RR ; - + return function [VR] = V_rot_bet(V,bet) @@ -875,7 +875,7 @@ function MS_sphere(CC,rh,mode,varargin) RR = [ cos(b) 0 -sin(b) ; 0 1 0 ; sin(b) 0 cos(b) ] ; VR = V * RR ; - + return %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -904,9 +904,9 @@ function MS_sphere(CC,rh,mode,varargin) function V = sphere_project(v,r,c) % sphere_project - project point X,Y,Z to the surface of sphere radius r -% +% % V = sphere_project(v,r,c) -% +% % Cartesian inputs: % v is the vertex matrix, Nx3 (XYZ) % r is the sphere radius, 1x1 (default 1) @@ -914,9 +914,9 @@ function MS_sphere(CC,rh,mode,varargin) % % XYZ are converted to spherical coordinates and their radius is % adjusted according to r, from c toward XYZ (defined with theta,phi) -% +% % V is returned as Cartesian 3D coordinates -% +% % $Revision: 1.8 $ $Date: 2004/03/29 21:15:36 $ diff --git a/msat/MS_split_trace.m b/msat/MS_split_trace.m index 689226c..50e3148 100644 --- a/msat/MS_split_trace.m +++ b/msat/MS_split_trace.m @@ -1,5 +1,5 @@ % MS_SPLIT_TRACE - Apply splitting operator to a pair of orthogonal traces -% +% % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % % [T00sp,T90sp] = MS_split_trace(time,T00,T90,fast,tlag) @@ -7,9 +7,9 @@ % Inputs: % time (vector) : Series of time points where amplitudes are known (s) % T00 (vector) : Series of amplitudes of transverse wave #1 before -% splitting applied. +% splitting applied. % T90 (vector) : Series of amplitudes of transverse wave #2 before -% splitting applied. +% splitting applied. % fast (scalar) : polarisation direction of fast wave (degrees) % tlag (scalar) : lag time splitting operator to be applied (s) % @@ -19,61 +19,61 @@ % T90sp (vector) : Series of amplitudes of transverse wave #2 after % splitting applied. % -% MS_split_trace applies a shear wave splitting operator (fast and tlag) -% to a time series of the amplitude of displacement in two orthogonal +% MS_split_trace applies a shear wave splitting operator (fast and tlag) +% to a time series of the amplitude of displacement in two orthogonal % directions (e.g. of waves or wavelets) stored in time, T00 and T90. The % displacements are first rotated into the fast direction before being time % shifted by forwards (for the fast wave) or backwards (for the slow wave) % by half of the lag time and interpolated onto the same time series. The -% resulting displacements are then rotated back into the original frame. +% resulting displacements are then rotated back into the original frame. % The fast direction is measured clockwise from the direction of T00 -% with a 90 degree fast orientation being parallel with T90. +% with a 90 degree fast orientation being parallel with T90. % Copyright (c) 2013, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function [T00sp,T90sp] = MS_split_trace(time,T00,T90,fast,tlag) % Apply a splitting operator to a pair of orthogonal traces. - + % rotate to fast reference frame [ F, S ] = RF_rotate(T00,T90,fast) ; - + % shift both components tlag/2 in opposite directions F = tshift(time,F,+tlag/2) ; S = tshift(time,S,-tlag/2) ; - + % rotate back to original reference frame [ T00sp, T90sp ] = RF_rotate(F,S,-fast) ; end @@ -84,17 +84,17 @@ end function [T00R,T90R] = RF_rotate(T00,T90,theta) - % Apply a rotation to a pair of orthogonal traces (this is a reference + % Apply a rotation to a pair of orthogonal traces (this is a reference % frame rotation) % form 2 row matrix D = [T90 ; T00] ; - + % rotation matrix R = [cosd(theta) -sind(theta); sind(theta) cosd(theta)] ; - + DR = R*D ; - + T00R = DR(2,:) ; - T90R = DR(1,:) ; + T90R = DR(1,:) ; end diff --git a/msat/MS_splitting_misfit.m b/msat/MS_splitting_misfit.m index c33bdde..d584178 100644 --- a/msat/MS_splitting_misfit.m +++ b/msat/MS_splitting_misfit.m @@ -3,8 +3,8 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Usage: -% [misfit] = MS_splitting_misfit(fast1,tlag1,fast2,tlag2,spol,dfreq) +% Usage: +% [misfit] = MS_splitting_misfit(fast1,tlag1,fast2,tlag2,spol,dfreq) % Calculate the misfit between splitting operators [fast1,tlag1] % and [fast2,tlag2], using the default mode (see below). SPOL is % the initial source polarisation, dfreq is the dominant frequency. @@ -17,55 +17,55 @@ % % [misfit] = MS_splitting_misfit(...,'mode','lam2S') % Calculate misfit based on the residual second eigenvalue of applying -% [f1,t1] to a test wavelet, then removing [f2,t2]. This is then -% reversed, and the final misfit is the average of the two. +% [f1,t1] to a test wavelet, then removing [f2,t2]. This is then +% reversed, and the final misfit is the average of the two. % % [misfit] = MS_splitting_misfit(...,'mode','intensity') % Calculates the misfit as the difference between the splitting intensity -% (see, e.g., Long and Silver, 2009) for the two operators. +% (see, e.g., Long and Silver, 2009) for the two operators. % % [misfit] = MS_splitting_misfit(...,'mode','simple') -% A simple (normalised) arithmetic misfit. +% A simple (normalised) arithmetic misfit. % -% References: -% Long, M. D., & Silver, P. G. (2009). "Shear Wave Splitting and Mantle -% Anisotropy: Measurements, Interpretations, and New Directions". Surveys +% References: +% Long, M. D., & Silver, P. G. (2009). "Shear Wave Splitting and Mantle +% Anisotropy: Measurements, Interpretations, and New Directions". Surveys % in Geophysics, 30(4-5), 407–461. doi:10.1007/s10712-009-9075-1 % % See also: MS_EFFECTIVE_SPLITTING_N % Copyright (c) 2013, James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %=============================================================================== @@ -77,7 +77,7 @@ modeStr = 'lam2' ; idebug = 0 ; max_tlag = NaN ; % autoselect max tlag - + % process the optional arguments iarg = 1 ; while iarg <= (length(varargin)) @@ -90,25 +90,25 @@ iarg = iarg + 2 ; case 'max_tlag' % parameter definition (value required) max_tlag = varargin{iarg+1} ; - iarg = iarg + 2 ; - otherwise + iarg = iarg + 2 ; + otherwise error('MS:SPLITTING_MISFIT:UnknownOption',... - ['Unknown option: ' varargin{iarg}]) ; + ['Unknown option: ' varargin{iarg}]) ; end end - + % check outputs if nargout>1 error('MS:SPLITTING_MISFIT:TooManyOutputs','Too many outputs specified') end - + % call the appropriate mode function switch lower(modeStr) case 'simple' - [misfit]=MS_splitting_misfit_simple(fast1,tlag1,fast2,tlag2,spol,dfreq) ; + [misfit]=MS_splitting_misfit_simple(fast1,tlag1,fast2,tlag2,spol,dfreq) ; case 'intensity' - [misfit]=MS_splitting_misfit_intensity(fast1,tlag1,fast2,tlag2,spol,dfreq) ; + [misfit]=MS_splitting_misfit_intensity(fast1,tlag1,fast2,tlag2,spol,dfreq) ; case 'lam2' [misfit]=MS_splitting_misfit_lam2( ... fast1,tlag1,fast2,tlag2,spol,dfreq,max_tlag,idebug) ; @@ -117,16 +117,16 @@ fast1,tlag1,fast2,tlag2,spol,dfreq,max_tlag,idebug) ; otherwise error('MS:SPLITTING_MISFIT:UnknownMode',... - ['Unknown mode: ' modeStr]) ; + ['Unknown mode: ' modeStr]) ; end - + % assign outputs switch nargout case 1 varargout = {misfit} ; end - - + + end %=============================================================================== @@ -134,15 +134,15 @@ function [misfit] = ... MS_splitting_misfit_simple(fast1,tlag1,fast2,tlag2,spol,dfreq) %=============================================================================== -% Simple numerical misfit. Average of normalised fast angular difference and +% Simple numerical misfit. Average of normalised fast angular difference and % time lag. TLAG misfit is normalised by 1/4 of the dominant period. Also, % apply a weighting factor for the polarisation. fast_misfit = abs(MS_unwind_pm_90(fast1-fast2))./90 ; tlag_misfit = abs(tlag1-tlag2)./(0.25/dfreq) ; - + misfit = mean([fast_misfit tlag_misfit]) ; - + end %=============================================================================== @@ -150,17 +150,17 @@ function [misfit] = ... MS_splitting_misfit_intensity(fast1,tlag1,fast2,tlag2,spol,dfreq) %=============================================================================== -% Calculate the misfit between the splitting intensities predicted by the -% two [fast,tlag] operators combined with the initial source polarisations. +% Calculate the misfit between the splitting intensities predicted by the +% two [fast,tlag] operators combined with the initial source polarisations. beta1 = abs(MS_unwind_pm_90(fast1-spol)) ; S1 = tlag1 * sind(2*beta1) ; - + beta2 = abs(MS_unwind_pm_90(fast2-spol)) ; S2 = tlag2 * sind(2*beta2) ; - - misfit = abs(S1-S2) ; - + + misfit = abs(S1-S2) ; + end %=============================================================================== @@ -171,33 +171,33 @@ % generate a test wavelet. if isnan(max_tlag), max_tlag = max([tlag1 tlag2]); , end - + [time,T00,T90] = MS_make_trace(spol,dfreq,max_tlag) ; if (idebug), MS_plot_trace(time,T00,T90), end - % apply splitting operator 1 + % apply splitting operator 1 [T00sp,T90sp] = MS_split_trace(time,T00,T90,fast1,tlag1) ; - + if (idebug), MS_plot_trace(time,T00sp,T90sp), end - + % apply inverse of splitting operator 2 - [T00sp2,T90sp2] = MS_split_trace(time,T00sp,T90sp,fast2,-tlag2) ; + [T00sp2,T90sp2] = MS_split_trace(time,T00sp,T90sp,fast2,-tlag2) ; if (idebug), MS_plot_trace(time,T00sp2,T90sp2), end - - - %% measure second eignvalue of the resulting wavelet + + + %% measure second eigenvalue of the resulting wavelet % calculate the covariance matrix COVM = cov(T90sp2,T00sp2) ; - % take the eigenvalues + % take the eigenvalues [V,D] = eig(COVM) ; - - % calculate normalised misfit. - misfit = min([D(1,1) D(2,2)])./ max([D(1,1) D(2,2)]) ; - + + % calculate normalised misfit. + misfit = min([D(1,1) D(2,2)])./ max([D(1,1) D(2,2)]) ; + end %=============================================================================== @@ -206,52 +206,52 @@ MS_splitting_misfit_lam2S(fast1,tlag1,fast2,tlag2,spol,dfreq,max_tlag,idebug) %=============================================================================== -% foward +% forward % generate a test wavelet. if isnan(max_tlag), max_tlag = max([tlag1 tlag2]); , end [time,T00,T90] = MS_make_trace(spol,dfreq,max_tlag) ; - % apply splitting operator 1 + % apply splitting operator 1 [T00sp,T90sp] = MS_split_trace(time,T00,T90,fast1,tlag1) ; % apply inverse of splitting operator 2 - [T00sp2,T90sp2] = MS_split_trace(time,T00sp,T90sp,fast2,-tlag2) ; - - %% measure second eignvalue of the resulting wavelet + [T00sp2,T90sp2] = MS_split_trace(time,T00sp,T90sp,fast2,-tlag2) ; + + %% measure second eigenvalue of the resulting wavelet % calculate the covariance matrix COVM = cov(T90sp2,T00sp2) ; - % take the eigenvalues + % take the eigenvalues [V,D] = eig(COVM) ; - - % calculate normalised misfit. - misfit1 = min([D(1,1) D(2,2)])./ max([D(1,1) D(2,2)]) ; + + % calculate normalised misfit. + misfit1 = min([D(1,1) D(2,2)])./ max([D(1,1) D(2,2)]) ; %% reverse - + [time,T00,T90] = MS_make_trace(spol,dfreq,max_tlag) ; - % apply splitting operator 2 + % apply splitting operator 2 [T00sp,T90sp] = MS_split_trace(time,T00,T90,fast2,tlag2) ; - + % apply inverse of splitting operator 1 - [T00sp2,T90sp2] = MS_split_trace(time,T00sp,T90sp,fast1,-tlag1) ; - - %% measure second eignvalue of the resulting wavelet + [T00sp2,T90sp2] = MS_split_trace(time,T00sp,T90sp,fast1,-tlag1) ; + + %% measure second eigenvalue of the resulting wavelet % calculate the covariance matrix COVM = cov(T90sp2,T00sp2) ; - % take the eigenvalues + % take the eigenvalues [V,D] = eig(COVM) ; - - % calculate normalised misfit. - misfit2 = min([D(1,1) D(2,2)])./ max([D(1,1) D(2,2)]) ; - + + % calculate normalised misfit. + misfit2 = min([D(1,1) D(2,2)])./ max([D(1,1) D(2,2)]) ; + % result is the average of the two misfit = (misfit1+misfit2)/2 ; - + end %=============================================================================== diff --git a/msat/MS_unwind_pm_90.m b/msat/MS_unwind_pm_90.m index ac27404..e7e2f79 100644 --- a/msat/MS_unwind_pm_90.m +++ b/msat/MS_unwind_pm_90.m @@ -2,48 +2,48 @@ % % // Part of MSAT - The Matlab Seismic Anisotropy Toolkit // % -% Utility function to find the equivelent angle between -90 and 90 degrees -% assuming 180 defgree periodicity. +% Utility function to find the equivalent angle between -90 and 90 degrees +% assuming 180 degree periodicity. % % % [angle] = unwind_pm_90(angle_in) % -% Usage: -% for a given value of angle_in return a value greater than -% -90 and less than or equal to +90 by repetedly adding or subtracting +% Usage: +% for a given value of angle_in return a value greater than +% -90 and less than or equal to +90 by repeatedly adding or subtracting % 180. Angle can be a scalar or a vector. % Copyright (c) 2011, 2014 James Wookey and Andrew Walker % All rights reserved. -% -% Redistribution and use in source and binary forms, -% with or without modification, are permitted provided +% +% Redistribution and use in source and binary forms, +% with or without modification, are permitted provided % that the following conditions are met: -% -% * Redistributions of source code must retain the -% above copyright notice, this list of conditions +% +% * Redistributions of source code must retain the +% above copyright notice, this list of conditions % and the following disclaimer. -% * Redistributions in binary form must reproduce -% the above copyright notice, this list of conditions -% and the following disclaimer in the documentation +% * Redistributions in binary form must reproduce +% the above copyright notice, this list of conditions +% and the following disclaimer in the documentation % and/or other materials provided with the distribution. -% * Neither the name of the University of Bristol nor the names -% of its contributors may be used to endorse or promote -% products derived from this software without specific +% * Neither the name of the University of Bristol nor the names +% of its contributors may be used to endorse or promote +% products derived from this software without specific % prior written permission. -% -% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS -% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED -% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY -% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS +% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS % SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %=============================================================================== @@ -54,20 +54,20 @@ error('MS:unwind_pm_90:BadInput',... 'Input is required to be a numeric scalar/vector') ; end - + angle = angle_in ; - -% shift to -180 -> 180 + +% shift to -180 -> 180 angle = angle - 180.*fix(angle./180) ; % refine: too small ind = find(angle<=-90); - if ~isempty(ind), angle(ind) = angle(ind) + 180 ; , end + if ~isempty(ind), angle(ind) = angle(ind) + 180 ; , end + +% or too large + ind = find(angle>90); + if ~isempty(ind), angle(ind) = angle(ind) - 180 ; , end -% or too large - ind = find(angle>90); - if ~isempty(ind), angle(ind) = angle(ind) - 180 ; , end - return %===============================================================================