├── .gitignore ├── LICENSE ├── Notebooks └── dem2shaded_relief.ipynb ├── PlotDatalib ├── CalcDefaultFringe.m ├── GenerateNamesFromDataStructure.m ├── IREA_cm.m ├── PlotData.m ├── PlotData_DataModelResidual.m ├── PlotData_wrapper.m ├── PlotProfile.m ├── PlotRGB_Demjpg_N.m ├── PlotThreeDimField.m ├── add_colorbar.m ├── add_shade2Data.m ├── beachball.m ├── blueredN.m ├── cmaps │ ├── IREA_cm.mat │ ├── dismph.mat │ └── dismphN.mat ├── dislocplot_surfaceintersection.m ├── dismphF.m ├── maxmin.m ├── plot_NaNbackground.m ├── plot_disloc3d.m ├── plot_model_parameters.m ├── plot_mogi3d.m ├── plot_penny3d.m └── process_symboloptions.m ├── README.md ├── README_INSTALL ├── TODO_list ├── _config.yml ├── addpath_geodmod.m ├── deformation_sources ├── ConstantPressureDike.m ├── LinearPressureDike.m ├── LinearPressureDike_old.m ├── MogiLayers.m ├── README ├── Yang_paperfigs.m ├── dc3d4.m ├── dikedemo.m ├── disloc1topo.m ├── disloc3d3.m ├── dislocLayers.m ├── fault.m ├── lockedandcreep.m ├── mctigue.m ├── midpoint.m ├── mogi.m ├── mogitopo.m ├── multidisloc.m ├── penny │ ├── Q.m │ ├── Qr.m │ ├── README │ ├── RtWt.m │ ├── UzUr.m │ ├── calc_crack.m │ ├── fpkernel.m │ ├── fred.m │ ├── fredholm.m │ ├── intgr.m │ ├── intgrUz.m │ ├── intgrV.m │ └── umax.dat ├── penny_source.m ├── penny_sourcetopo.m ├── slipcol.mat ├── squaredisloc.m ├── unitvector.m ├── visco1d.m ├── yang │ ├── README │ ├── demo.m │ ├── fcn_yangM.m │ ├── load_par.m │ ├── yang.m │ └── yang_spheroid.m ├── yang_source.m └── yang_sourcetopo.m ├── examples ├── Darwin.min ├── Darwin_dike.min ├── Darwin_fringe.min ├── Darwin_gibbs.min ├── Darwin_gridsearch.min ├── Darwin_layers.min ├── Darwin_pennyshapedcrack.min ├── Darwin_topo_approximation.min ├── Darwin_yang.min ├── Forward_disloc.min ├── Forward_mogi.min ├── HaitiMulti.min ├── ML.min ├── ML2002-2005.min ├── MLGPSonly.min ├── ML_Const.min ├── ML_FactorNonLin.min ├── ML_PhaseRamp.min ├── ML_gibbs.min ├── ML_noPhaseRamp.min ├── Wells.min ├── Wells_fault.min ├── basemap_hawaii.min └── test_geodmod.m ├── icemod ├── DEADJOE ├── azimuth_range_topo2vel.m └── demmailos2vel.m ├── inver ├── anneal.m ├── anneal_parfortry.m ├── estimate_inversion_time.m ├── gibbslib │ ├── calc_Tc.m │ ├── find_robustTc.m │ ├── generate_Tsched.m │ ├── gibbs.m │ ├── pg.m │ ├── plot_gibbs.m │ └── plot_robustTc.m ├── gridsearch.m └── plot_gridsearch.m ├── legacy └── magma_sources │ ├── ConstantPressureDike.m │ ├── LinearPressureDike.m │ ├── LinearPressureDike_old.m │ ├── README │ ├── Yang_paperfigs.m │ ├── dikedemo.m │ ├── disloc1topo.m │ ├── mctigue.m │ ├── midpoint.m │ ├── mogi.m │ ├── mogi_source.m │ ├── mogitopo.m │ ├── penny │ ├── Q.m │ ├── Qr.m │ ├── README │ ├── RtWt.m │ ├── UzUr.m │ ├── calc_crack.m │ ├── fpkernel.m │ ├── fred.m │ ├── fredholm.m │ ├── intgr.m │ ├── intgrUz.m │ ├── intgrV.m │ └── umax.dat │ ├── penny_source.m │ ├── penny_sourcetopo.m │ ├── slipcol.mat │ ├── unitvector.m │ ├── yang │ ├── README │ ├── demo.m │ ├── fcn_yangM.m │ ├── load_par.m │ ├── yang.m │ └── yang_spheroid.m │ ├── yang_source.m │ └── yang_sourcetopo.m ├── maintenancelib ├── SaveProject.m ├── dbstopend.m └── gclean.m ├── masterfile ├── CheckToolboxes.m ├── README ├── README_programming ├── geodmod.m ├── geodmod_version ├── pubgeodmod.m └── save_functions.m ├── mex ├── DM_Disloc.c ├── DM_Disloc.mexglx ├── DM_Disloc.mexmaci64 ├── README ├── S1.mat ├── dc3d.f ├── discalc.m ├── disloc.mexsol ├── disloc1.c ├── disloc1.mexa64 ├── disloc1.mexglx ├── disloc1.mexlx ├── disloc1.mexmaci ├── disloc1.mexmaci64 ├── disloc1.mexsol ├── disloc1.mexw32 ├── disloc3d.f ├── disloc3d.f.sav ├── disloc3d.m ├── disloc3d.mexglx ├── disloc3d.mexsol ├── disloc3d.mexsol_sav ├── disloc_mex_instructions.txt ├── displot.m └── test_disloc3d.m ├── mimiclib ├── ChangeDate.m ├── CheckInOut.m ├── DefaultOptions.m ├── FilterKeyword.m ├── GPSlib │ ├── GPS2eun.m │ ├── GPS2local.m │ ├── GPS_ITRF2local.m │ ├── GPS_llh2enu.m │ ├── GPS_tmsr2rate.m │ ├── GPStmsr2GPSrate.m │ ├── Geo2Radar.m │ ├── GetInSARvalues.m │ ├── Read_GPS.m │ └── gps2los.m ├── ListFiles.m ├── LoadData.m ├── LoadData_old.m ├── ReadKeywordfile.m ├── Read_IREA.m ├── Read_Seismicity.m ├── SortIgram.m ├── Timeseries2Motion.m ├── YYYYmmDD2DecimalYear.m ├── add_struct.m ├── bracketedstring2cell.m ├── extract_ProjectName.m ├── extract_hardwired_satparameters.m ├── imcapture.m ├── ll2local.m ├── logmessage.m ├── logplot.m ├── lola2xy.m ├── makeSTD.m ├── make_kml_string.m ├── make_kmz.m ├── manuw │ └── extractregion.m ├── process_defaultoptions.m ├── qtsjonni2qtgeodmod.m ├── read_options_fromfile.m ├── readfile.m ├── resize_igram.m ├── save_enu_roi_pac.m ├── tobereplacedlib │ ├── L2YX.m │ ├── LL2ind_igram.m │ ├── YX2L.m │ ├── cal2jd.m │ ├── date2j.m │ ├── dealfalk.m │ ├── doy2jd.m │ ├── ecef2lla.m │ ├── ell2xyz.m │ ├── getPolygon.m │ ├── get_polygon.m │ ├── getfields.m │ ├── isalpha.m │ ├── isodd.m │ ├── jd2cal.m │ ├── list2str.m │ ├── mmax.p │ ├── mmin.p │ ├── nanmedfilt2.m │ ├── nummatch.m │ ├── randint.m │ ├── resampledata.m │ ├── resize.m │ ├── smooth.m │ ├── str2list.m │ ├── val.m │ ├── y2yymmdd.m │ ├── yr2jd.m │ ├── yymmdd2y.m │ └── yyyy_ddd2y.m └── toolboxfiles_map │ ├── addOptimguiOutputFcn.m │ ├── almanac.m │ ├── axes2ecc.m │ ├── azimuth.m │ ├── bwareaopen.m │ ├── bwlabeln.m │ ├── bwlabelnmex.cpp │ ├── bwlabelnmex.mexa64 │ ├── bwlabelnmex.mexa64.csf │ ├── bwlabelnmex.mexglx │ ├── bwlabelnmex.mexglx.csf │ ├── bwlabelnmex.mexmaci │ ├── bwlabelnmex.mexmaci.csf │ ├── checkbounds.m │ ├── checkellipsoid.m │ ├── combntns.m │ ├── conndef.m │ ├── convertlat.m │ ├── deg2rad.m │ ├── demcmap.m │ ├── distance.m │ ├── ecc2flat.m │ ├── ecc2n.m │ ├── epsm.m │ ├── flat2ecc.m │ ├── fromDegrees.m │ ├── fromRadians.m │ ├── geoidtst.m │ ├── ignoreComplex.m │ ├── iptcheckconn.m │ ├── iptcheckinput.cpp │ ├── iptcheckinput.h │ ├── iptcheckinput.m │ ├── iptcheckinput.mexa64 │ ├── iptcheckinput.mexa64.csf │ ├── iptcheckinput.mexglx │ ├── iptcheckinput.mexglx.csf │ ├── iptcheckinput.mexmaci │ ├── iptcheckinput.mexmaci.csf │ ├── iptcheckmap.m │ ├── iptchecknargin.m │ ├── iptcheckstrs.m │ ├── lsqnonlin.m │ ├── medfilt2.m │ ├── meridianarc.m │ ├── minaxis.m │ ├── nanmean.m │ ├── normfit.m │ ├── npi2pi.m │ ├── num2ordinal.m │ ├── optimguiswitchyard.m │ ├── optimplotconstrviolation.m │ ├── optimplotfirstorderopt.m │ ├── optimplotresnorm.m │ ├── optimplotstepsize.m │ ├── optimset.m │ ├── optimtool.m │ ├── optimtooloutput.m │ ├── ordfilt2.m │ ├── padarray.m │ ├── private │ ├── abstractAngleConv.m │ ├── checkinput.m │ ├── checkinput_mex.mexa64 │ ├── checkinput_mex.mexa64.csf │ ├── checkinput_mex.mexglx │ ├── checkinput_mex.mexglx.csf │ ├── checkinput_mex.mexmaci │ ├── checkinput_mex.mexmaci.csf │ ├── checknargin.m │ ├── checkstrs.m │ ├── checkstruct.m │ ├── expandScalarInputs.m │ ├── formJacobian.p │ ├── geodesicinv.m │ ├── lsqfcnchk.m │ ├── lsqncommon.m │ ├── mkconstarray.m │ ├── optimabout.m │ ├── optimguiGeneratemfile.m │ ├── optimguiImportOptions.m │ ├── optimguiImportProblem.m │ ├── optimguiclosing.m │ ├── optimguirun.m │ ├── optimhelpviewer.m │ ├── ordf.c │ ├── ordf.mexa64 │ ├── ordf.mexa64.csf │ ├── ordf.mexglx │ ├── ordf.mexglx.csf │ ├── ordf.mexmaci │ ├── ordf.mexmaci.csf │ ├── ordf_hist.h │ ├── ordf_ordfilt2.h │ ├── ordf_select.h │ ├── parseDistAzInputs.m │ ├── regionpropsmex.cpp │ ├── regionpropsmex.h │ ├── regionpropsmex.mexa64 │ ├── regionpropsmex.mexa64.csf │ ├── regionpropsmex.mexglx │ ├── regionpropsmex.mexglx.csf │ ├── regionpropsmex.mexmaci │ ├── regionpropsmex.mexmaci.csf │ ├── resetOptimtool.m │ └── resetOptimtoolHashTable.m │ ├── rcurve.m │ ├── readOptimHashTable.m │ ├── reckon.m │ ├── regionprops.m │ ├── rsphere.m │ ├── toRadians.m │ ├── unitsratio.m │ └── zero22pi.m ├── modellib ├── DM_Quiver.m ├── ForwardModel.m ├── ForwardModel_forBasemap.m ├── GenerateSummary.m ├── GenericObjectiveFunction.m ├── GenericObjectiveFunction_old.m ├── GetFactorNonLin.m ├── InitializeDataset.m ├── InitializeInverseopt.m ├── InitializeModelopt.m ├── InverseLin.m ├── InverseLinDistrib.m ├── InverseNonLin.m ├── MakeDesignMatrix.m ├── MakeStringForPlot.m ├── MakeStringLinearInversionInfo.m ├── ModifyBoundsAndParNames.m ├── ModifyDatasetLin.m ├── ModifyDatasetNonLin.m ├── Plot3Dfaults_sjonni.m ├── PlotModel.m ├── PrepareDataModelResidual_local_AndPlot.m ├── PrepareDataModelResidual_lola_AndPlot.m ├── README ├── RmsCalculation_sjonni.m ├── Solution2ModifiedOptions.m ├── TimeDependentGenericObjectiveFunction.m ├── datasetstruct2GPSstruct.m ├── datasetstructure2data.m ├── datasetstructure2datastructure.m ├── displacement2rangechange.m ├── displotmulti.m ├── distlib │ ├── BlockDiag.m │ ├── Extend2Surface.m │ ├── MakeFaultPatches.m │ ├── MakeKernel.m │ ├── MakeRadarKern.m │ ├── MakeSmoothingMatrix.m │ ├── abs_disp.m │ ├── flakes.m │ ├── flakes2D.m │ ├── fnnls.m │ ├── modelwt2.m │ └── patchfault.m ├── extract_hgt_from_dem.m ├── find_coord_index.m ├── initialize_multidislocopt.m ├── modelpar2invpar.m ├── modelpar_lola2xy.m ├── multidislocpar2dislocpar.m ├── phaseramp_dummy.m ├── plot_surfaceintersection.m ├── readfrom_dataset_structure.m └── tmp_makeGadd.m ├── plotlib ├── PlotDistribModel.m ├── PlotSurface3D.m ├── PlotTheModel.m ├── PlotTimeCoverage.m ├── dislocplot.m ├── ellipse.m └── viewdirections3d_generate.m ├── preparelib ├── CheckDatatype.m ├── CheckDownloadData.m ├── Data2Igram.m ├── Data2Motion.m ├── Data2Timeseries.m ├── Dem2Basemap.m ├── GenerateLOSVec.m ├── GenerateNames.m ├── Igram2Motion.m ├── MakeDataset.m ├── MakeFaults.m ├── MakeFocals.m ├── MakeGPS.m ├── MakeProfile.m ├── MakeQuakes.m ├── MakeSAR.m ├── Motion2ThreeDfield.m ├── Prepare.m ├── RemoveBadIgrams.m ├── SUGGESTIONS_FALK ├── SampleSar.m ├── SimpleAverage.m ├── StackRandFalk.m ├── SubtractForwardModel.m ├── add_mask_to_igram.m ├── add_rating_to_igram.m ├── add_tforstack_to_igram.m ├── convert_unit.m ├── initialize_markers.m ├── quadtreelib │ ├── check_quadtree.m │ ├── fit_bilinplane.m │ ├── getchunck.m │ ├── matfill.m │ ├── plot_quadtree.m │ ├── quadtree.m │ └── quadtree_part.m ├── remove_mean.m └── xy2utm.m └── tobereplacedlib ├── PlotFigureTitle.m └── plot_igram.m /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.DS_Store 3 | *.last_dir_out 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2006-2019, Falk Amelung 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /PlotDatalib/CalcDefaultFringe.m: -------------------------------------------------------------------------------- 1 | function [fringe]=CalcDefaultFringe(data, PlotUnit) 2 | %CalcDefaultFringe - calculates fringe spacing so that 1 fringe corresponds to wavelength/2 3 | % 4 | %usage: [satparameters]=extract_hardwired_satparameters(in_name,parameter); 5 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6 | 7 | wavelength = extract_hardwired_satparameters(data.DataSet,'wavelength'); 8 | 9 | switch PlotUnit 10 | case {'m'} 11 | fringe = wavelength/2; 12 | case {'m/yr'} 13 | fringe = wavelength/2/data.TotalTime; 14 | case {'radian'} 15 | fringe = 2*pi; 16 | otherwise 17 | errordlg(sprintf(['PlotUnit ' PlotUnit ' not yet supported for fringes'])) ; error('user error -- exiting'); 18 | end 19 | -------------------------------------------------------------------------------- /PlotDatalib/IREA_cm.m: -------------------------------------------------------------------------------- 1 | function dism=IREA_cm 2 | 3 | 4 | load ([getenv('GEODMOD_HOME'),'/PlotDatalib/cmaps/IREA_cm.mat']) 5 | dism = ireacm; -------------------------------------------------------------------------------- /PlotDatalib/PlotData_DataModelResidual.m: -------------------------------------------------------------------------------- 1 | function []=PlotData_DataModelResidual(data,opt,rows) 2 | % PlotData_DataModelResidual - calls PlotData such that Data, Model and Residual is plotted in 3 rows 3 | % 4 | % usage: PlotData_DataModelResidual(data,opt) 5 | % TODO: Needs 4th row to plot profile 6 | if ~exist('opt','var') opt =[]; end 7 | if ~exist('rows','var') rows=4 ; end 8 | 9 | N_SAR = sum([data(:).SAR]); 10 | N_GPSonly = sum([data(:).GPSonly]); 11 | 12 | Npx=round(N_SAR/rows)+N_GPSonly; %subplot windows horizontal 13 | Npy=rows; %subplot windows vertical 14 | opt.Quakes = 'off' ; 15 | opt.gpsfile = 'off' ; 16 | opt.Coord = 'off'; 17 | 18 | if N_GPSonly && ~N_SAR 19 | Npy = 1; 20 | end 21 | 22 | for i=1:length(data) 23 | tmpopt=opt; 24 | if i< length(data) tmpopt.colorbaropt.Location='off'; end 25 | if i==length(data) tmpopt.colorbaropt.Location='OutsideLowerRight'; end 26 | if strfind(data(i).DataSet,'Topography') tmpopt.CLim=0; end 27 | %remove vectors unless we plot Data or Model 28 | if isempty(strfind(data(i).DataSet,'Data')) && isempty(strfind(data(i).DataSet,'Model')) && isempty(strfind(data(i).DataSet,'Topography')) 29 | tmpopt.VectorsBlack=0; tmpopt.VectorsRed=0; 30 | end 31 | %if isempty(strfind(data(i).DataSet,'Data')) && isempty(strfind(data(i).DataSet,'Model')) tmpopt.VectorsBlack=0; tmpopt.VectorsRed=0; end 32 | 33 | eval(sprintf( 'subplot(Npy,Npx,%d)' ,i)) 34 | 35 | PlotData(data(i),tmpopt) 36 | end 37 | -------------------------------------------------------------------------------- /PlotDatalib/PlotData_wrapper.m: -------------------------------------------------------------------------------- 1 | function []=PlotData_wrapper(data,opt) 2 | % PlotData - calls PlotData multiple times depending on size of data 3 | % 4 | % usage: PlotData_wrapper(data,opt) 5 | if ~exist('opt','var') opt=[]; end 6 | 7 | if length(data)==1 8 | PlotData(data,opt) 9 | elseif length(data)==2 10 | subplot(1,2,1) 11 | PlotData(data(1),opt) 12 | subplot(1,2,2) 13 | PlotData(data(2),opt) 14 | else 15 | N_igrams=length(data); 16 | Npx=ceil(sqrt(N_igrams)); %subplot windows horizontal 17 | Npy=ceil((N_igrams/Npx)); %subplot windows vertical 18 | opt.Coord='off'; 19 | 20 | for i=1:N_igrams 21 | eval(sprintf( 'subplot(Npy,Npx,%d)' ,i)) 22 | PlotData(data(i),opt) 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /PlotDatalib/PlotThreeDimField.m: -------------------------------------------------------------------------------- 1 | function []=PlotData_DataModelResidual(enu,opt) 2 | % PlotData_DataModelResidual - calls PlotData such that Data, Model and Residual is plotted in 3 rows 3 | % 4 | % usage: PlotData_DataModelResidual(data,opt) 5 | % TODO: Needs 4th row to plot profile 6 | if ~exist('opt','var') opt=[]; end 7 | 8 | 9 | opt.Quakes = 'off' ; 10 | opt.gpsfile = 'off' ; 11 | opt.Coord = 'off'; 12 | 13 | PlotData(enu(3),opt) 14 | keyboard 15 | 16 | -------------------------------------------------------------------------------- /PlotDatalib/blueredN.m: -------------------------------------------------------------------------------- 1 | function dism=bluered 2 | 3 | 4 | load ([getenv('GEODMOD_HOME'),'/PlotDatalib/cmaps/bluered.mat']) 5 | dism=bluered; 6 | -------------------------------------------------------------------------------- /PlotDatalib/cmaps/IREA_cm.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/PlotDatalib/cmaps/IREA_cm.mat -------------------------------------------------------------------------------- /PlotDatalib/cmaps/dismph.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/PlotDatalib/cmaps/dismph.mat -------------------------------------------------------------------------------- /PlotDatalib/cmaps/dismphN.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/PlotDatalib/cmaps/dismphN.mat -------------------------------------------------------------------------------- /PlotDatalib/dismphF.m: -------------------------------------------------------------------------------- 1 | function dism=dismphF 2 | load dismphN.mat 3 | %load dismph.mat 4 | dism=dismphN; 5 | -------------------------------------------------------------------------------- /PlotDatalib/maxmin.m: -------------------------------------------------------------------------------- 1 | %Max value of array p1: 2 | function [Maxf,minf]= maxmin (file); 3 | 4 | maxp1=max(file); %by columns 5 | Maxf=max(maxp1); 6 | 7 | minp1=min(file); %by columns 8 | minf=min(minp1); -------------------------------------------------------------------------------- /PlotDatalib/plot_NaNbackground.m: -------------------------------------------------------------------------------- 1 | 2 | function plot_NaNbackground(data,opt) 3 | 4 | % 5 | % Plot data containg NaNs. Only data will be used to scale the colorscale 6 | % 7 | % data : data! 8 | % 9 | % opt: 10 | % 11 | % cmap : Colormap 12 | % background_color : Example -> [0] for white (default) 13 | % 14 | % 15 | % Noel Gourmelen - March 2009 16 | % 17 | 18 | defaultopt=struct( ... 19 | 'cmap' , 'off' , ... 20 | 'background_color' , 'off' ) ; 21 | 22 | 23 | if ~exist('opt','var') [opt]=read_options_fromfile([mfilename '.min'],[]); end ; 24 | [opt] = process_defaultoptions(opt,defaultopt); display(opt) 25 | f=fieldnames(opt) ; 26 | for i=1:length(f) 27 | eval([char(f{i}) '= opt.(f{i}) ;' ]) ; 28 | end 29 | 30 | z = data ; 31 | 32 | 33 | NaNi = find(isnan(data)==1) ; 34 | if ~cmap cmap = colormap ; end 35 | if ~background_color background_color = [0] ; end 36 | 37 | cmap=[background_color;cmap] ; 38 | 39 | if isempty(NaNi) 40 | sprintf('Contains no NaNs') ; 41 | else 42 | data(NaNi(1)) = min(data(:)) - ( max(data(:)) -min(data(:)) ) / length(cmap) ; 43 | end 44 | 45 | imagesc(data) ; colormap(cmap) 46 | -------------------------------------------------------------------------------- /PlotDatalib/plot_disloc3d.m: -------------------------------------------------------------------------------- 1 | function [s]=plot_disloc3D(par,what) 2 | %plot_disloc3D - plots dislocation in 3D using fill 3 | % 4 | %usage: []=PlotTheModel(par,what) 5 | % 6 | % par dislocation model parameters 7 | % 8 | % Falk Amelung, July 2008 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | % process default options, and set variables to options % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | s = []; 13 | if isempty(par) return ; end 14 | %logmessage(sprintf('[]=%s(%s)',mfilename,inputname(1))); 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | load slipcol % Load colormap 17 | viewdir = [par(5)+10 20]; % default azimuth clode to strike 18 | 19 | % convert par into the patchmodel format if necessary 20 | 21 | if size(par,2) == 10 % already in N-by-10 format 22 | pm = par ; 23 | elseif mod(size(par,1),10)==0 && size(par,2)==1 % in 10*N-by-1 format 24 | N_disloc = size(par,1)/10; 25 | pm = reshape(par',10,N_disloc)'; 26 | end 27 | 28 | % 29 | switch what 30 | case 'ss' 31 | s = pm(:,8); 32 | partype = 'Strike-Slip'; 33 | case 'ds' 34 | s = pm(:,9); 35 | partype = 'Dip-Slip'; 36 | case 'op' 37 | s = pm(:,10); 38 | partype = 'Opening'; 39 | case 'mag' 40 | s = sqrt(pm(:,8).^2 + pm(:,9).^2); 41 | rake = 180-rad2deg(atan2(pm(:,9),pm(:,8))); 42 | partype = 'Slip Magnitude'; 43 | otherwise 44 | errordlg('argument needs to be ss,ds,op,mag'); error('user error -- exiting'); 45 | end 46 | 47 | [fx,fy,fz] = flakes(pm'); 48 | fill3(fx,fy,-fz,s','LineStyle','-'); 49 | %axis image; 50 | 51 | str = sprintf( 'Predicted %s Distribution',partype); 52 | %str= sprintf( 'Predicted %s Distribution, roughness = %4.2f cm/km',ParType{i},roughness*100); 53 | 54 | title(str); 55 | 56 | hold on 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /PlotDatalib/plot_mogi3d.m: -------------------------------------------------------------------------------- 1 | function [s]=plot_mogi3D(par) 2 | %plot_disloc3D - plots mogi source in 3D using fill 3 | % 4 | %usage: []=PlotTheModel(par,what) 5 | % 6 | % par dislocation model parameters 7 | % 8 | % Falk Amelung, July 2008 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | % process default options, and set variables to options % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | s = []; 13 | if isempty(par) return ; end 14 | logmessage(sprintf('[]=%s(%s)',mfilename,inputname(1))); 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | 17 | unit = 1; 18 | [x,y,z] = sphere; 19 | x = x.*unit; 20 | y = y.*unit; 21 | z = z.*unit; 22 | 23 | x = par(1) + x; 24 | y = par(2) + y; 25 | z = par(3) + z; 26 | 27 | surface(x,y,-z,'FaceColor','red'); 28 | 29 | s = par(4); 30 | 31 | hold on 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /PlotDatalib/plot_penny3d.m: -------------------------------------------------------------------------------- 1 | function [s]=plot_penny3D(par) 2 | %plot_disloc3D - plots mogi source in 3D using fill 3 | % 4 | %usage: []=PlotTheModel(par,what) 5 | % 6 | % par dislocation model parameters 7 | % 8 | % Falk Amelung, July 2008 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | % process default options, and set variables to options % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | s = []; 13 | if isempty(par) return ; end 14 | logmessage(sprintf('[]=%s(%s)',mfilename,inputname(1))); 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | 17 | radius = par(4); 18 | [x,y,z] = sphere; 19 | x = x.*radius ; 20 | y = y.*radius; 21 | z = z.*radius/10; 22 | 23 | x = par(1) + x; 24 | y = par(2) + y; 25 | z = par(3) + z; 26 | 27 | surface(x,y,-z,'FaceColor','red'); 28 | 29 | s = par(5); 30 | 31 | hold on 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /addpath_geodmod.m: -------------------------------------------------------------------------------- 1 | %%%%%%% Script to set the paths for GeodMod %%%%%%%%%%%%%% 2 | %% in your startup.m file you should have: 3 | % 4 | %disp('Setting paths for geodmod...') 5 | %run( [ getenv('GEODMOD_HOME') filesep 'addpath_geodmod'] ) 6 | % 7 | 8 | disp('Added to path:') 9 | 10 | if ~contains(path,'mimiclib') 11 | libdir = [ getenv('GEODMOD_HOME') filesep 'mimiclib' ]; if exist(libdir,'dir'); addpath(genpath(libdir),'-end'); logmessage(libdir); end % geodmod/mimiclib (in releases) 12 | libdir = [ fileparts(getenv('GEODMOD_HOME')) filesep 'mimiclib']; if exist(libdir,'dir'); addpath(genpath(libdir),'-end'); logmessage(libdir); end % mimic/mimiclib (at RSMAS) 13 | end 14 | 15 | libdir = [ getenv('GEODMOD_HOME') filesep 'masterfile' ]; addpath(genpath(libdir),'-end'); logmessage(libdir) 16 | libdir = [ getenv('GEODMOD_HOME') filesep 'preparelib' ]; addpath(genpath(libdir),'-end'); logmessage(libdir) 17 | libdir = [ getenv('GEODMOD_HOME') filesep 'modellib' ]; addpath(genpath(libdir),'-end'); logmessage(libdir) 18 | libdir = [ getenv('GEODMOD_HOME') filesep 'PlotDatalib' ]; addpath(genpath(libdir),'-end'); logmessage(libdir) 19 | libdir = [ getenv('GEODMOD_HOME') filesep 'plotlib' ]; addpath(genpath(libdir),'-end'); logmessage(libdir) 20 | libdir = [ getenv('GEODMOD_HOME') filesep 'maintenancelib' ]; addpath(genpath(libdir),'-end'); logmessage(libdir) 21 | libdir = [ getenv('GEODMOD_HOME') filesep 'deformation_sources' ]; addpath(genpath(libdir),'-end'); logmessage(libdir) 22 | libdir = [ getenv('GEODMOD_HOME') filesep 'mex' ]; addpath(genpath(libdir),'-end'); logmessage(libdir) 23 | libdir = [ getenv('GEODMOD_HOME') filesep 'inver' ]; addpath(genpath(libdir),'-end'); logmessage(libdir) 24 | libdir = [ getenv('GEODMOD_HOME') filesep 'examples' ]; addpath(genpath(libdir),'-end'); logmessage(libdir) 25 | 26 | %opengl software; logmessage('opengl set to software (at RSMAS)'); 27 | CheckToolboxes(); 28 | 29 | %set(0, 'defaultfigurewindowstyle', 'docked'); 30 | -------------------------------------------------------------------------------- /deformation_sources/README: -------------------------------------------------------------------------------- 1 | Yuri Fialko wrote: 2 | > 3 | > Hi Falk, 4 | > The penny crack code can be downloaded from my anonymous ftp site, 5 | > topex.ucsd.edu/pub/fialko/penny 6 | > The scripts should be self-explanatory. You may get the Yang code 7 | > at the same site, pub/fialko/yang. A word of caution: Yang et al. 8 | > solutions are not accurate when the source size is of the order 9 | > of the source depth (they seem to work fine in the point source 10 | > approximation). 11 | > Let me know if there are any problems. I'd appreciate a pre/re- 12 | > print of your work on Marchena. 13 | 14 | > A few comments about the matlab code that implements Yang's 15 | > solutions: 16 | > 1) in the yang.m routine (line 70) 17 | > I usually use the following equation for C0: 18 | > 19 | > C0=z00/sinth; 20 | > 21 | > instead of 22 | > 23 | > C0=y0*costh+z00*sinth; % check this! 24 | > 25 | > The latter is the formula given in the paper, but the former is actually 26 | > needed to reproduce the figures in the Yang et al. paper (it also 27 | > makes more sense). 28 | > 29 | > 2) In the fcn_yangM.m routine (line 26), 30 | > phi=as(7) is the strike, and theta=as(8) is the plunge of the major 31 | > axis of the ellipsoid (comments are permuted). 32 | 33 | -------------------------------------------------------------------------------- /deformation_sources/mctigue.m: -------------------------------------------------------------------------------- 1 | function U = mctigue(m,obs,mu,nu) 2 | 3 | %MCTIGUE Calculate surface deformation due to a pressurized finite sphere. 4 | % 5 | % U = mctigue(m,obs,nu) calculate surface displacement field at 6 | % observation points due to a pressurized finite sphere. The result is 7 | % similar to Mogi source, but this function include higher order terms. 8 | % 9 | %INPUT: 10 | % m(1) east 11 | % m(2) north 12 | % m(3) depth(+) 13 | % m(4) radius 14 | % m(5) excess pressure, same unit as mu 15 | % 16 | % obs 2 x number of observation points 17 | % mu shear modulus 18 | % nu Poisson's ratio 19 | % 20 | %OUTPUT: 21 | % U surface displacement, 3 x size(obs,2) 22 | % 23 | % 24 | % Sang-Ho Yun, September 29, 2005 25 | % 26 | % 27 | % For information on the basis for this code see: 28 | % 29 | % MCTIGUE, D. F., 1987. Elastic stress and deformation near a finite 30 | % spherical magma body: resolution of the point source paradox. JGR 31 | % 92(B12), p.12931-40. 32 | % 33 | % Williams, C. A., Wadge, G., 1998. The effects of topography on magma 34 | % chamber deformation models: Application to Mt. Etna and radar 35 | % interferometry. GRL, 25(10), p.1549-52. 36 | 37 | if (nargin == 0) 38 | help mctigue; 39 | return; 40 | end 41 | 42 | if size(obs,1)~=2 43 | error('The dimension of obs should be 2 x n'); 44 | end 45 | 46 | east = m(1); 47 | north = m(2); 48 | d = m(3); 49 | a = m(4); 50 | p = m(5); 51 | 52 | x = obs(1,:) - east; 53 | y = obs(2,:) - north; 54 | [th,r] = cart2pol(x,y); 55 | rho = r/d; 56 | aod = a/d; 57 | 58 | aod3 = aod^3; 59 | aod6 = aod^6; 60 | denom1 = rho.^2 + 1; 61 | denom2 = 7-5*nu; 62 | 63 | common1 = p*(1-nu)./(mu*denom1.^1.5); 64 | common2 = aod3 - 0.5*aod6*(1+nu)/denom2 + 3.75*aod6*(2-nu)/denom2./denom1; 65 | Uz = d*common1.*common2; 66 | Ur = r.*common1.*common2; 67 | 68 | [Ux,Uy] = pol2cart(th,Ur); 69 | 70 | U = [Ux; Uy; Uz]; -------------------------------------------------------------------------------- /deformation_sources/midpoint.m: -------------------------------------------------------------------------------- 1 | function [mp]=midpoint(m) 2 | %MIDPOINT mp=MIDPOINT(m) 3 | % 4 | %Returns coordinates at the mid-point of dislocation m. 5 | %Models should be stored columnwise for vectorized output. 6 | 7 | %Parse inputs 8 | 9 | if nargin ~=1 10 | help midpoint 11 | end 12 | 13 | [i,j]=size(m); 14 | 15 | if j>i & min([i j])==1 16 | m=m'; 17 | end 18 | 19 | %Calculate midpoints 20 | 21 | theta=(90-m(5,:))*pi/180; 22 | delta=m(4,:)*pi/180; 23 | W=m(2,:)/2; 24 | mp(1,:)=m(6,:)-W.*cos(delta).*sin(theta); 25 | mp(2,:)=m(7,:)+W.*cos(delta).*cos(theta); 26 | mp(3,:)=m(3,:)-W.*sin(delta); 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /deformation_sources/multidisloc.m: -------------------------------------------------------------------------------- 1 | function [u] = multidisloc(multidisloc_par, coord, multidislocopt) 2 | %multidisloc - multiple dislocations 3 | % 4 | %Computes surface displacements due to 2 dislocation sources 5 | % 6 | %Inputs: 7 | %Output: 8 | % u = matrix of displacements: Ux, Uy, Uz 9 | % 10 | % 10/2008 Falk Amelung 11 | 12 | x_unit = 'km'; 13 | nu = 0.25; 14 | N_disloc = multidislocopt.N_disloc; 15 | u_third = 0; 16 | 17 | [disloc_par] = multidislocpar2dislocpar(multidisloc_par,multidislocopt,x_unit); 18 | 19 | u_first = disloc1(disloc_par(1:10), coord,nu); 20 | u_second = disloc1(disloc_par(11:20),coord,nu); 21 | 22 | if (N_disloc==3) u_third = disloc1(disloc_par(21:30),coord,nu); end 23 | 24 | u = u_first + u_second + u_third; 25 | -------------------------------------------------------------------------------- /deformation_sources/penny/Qr.m: -------------------------------------------------------------------------------- 1 | function [K]=Qr(h,t,n) 2 | % Kernels calculation 3 | K=[]; 4 | h2=h^2; 5 | t2=t.^2; 6 | h4=h^4; 7 | t4=t.^4; 8 | h6=h^6; 9 | t6=t.^6; 10 | h8=h^8; 11 | t8=t.^8; 12 | ht2=h2+t2; 13 | 14 | switch n 15 | case 1 %Q1 16 | K=2*(h6-h2*t4+t4*h2+h4*(2*t2+h2))./((2*h2)^(1.5)*(h4+t4-t2.*ht2+h2*(3*t2+h2))); 17 | 18 | case 2 %Q2 19 | K=8*(h8+t8+h6*ht2-h4*t2.*ht2+h2*t4.*ht2-t6.*ht2)./(ht2*(2*h2)^(3.5)); 20 | 21 | case 3 %Q3 22 | rad=sqrt(4*h2*t2+(h2-t2).^2); 23 | K=2*(-h6-h4*t2+h2*t4+t6+(h4+t4).*rad)./(ht2.^2.*(t2-h2+rad).^(1.5)); 24 | 25 | end %switch n 26 | -------------------------------------------------------------------------------- /deformation_sources/penny/README: -------------------------------------------------------------------------------- 1 | Input and function calls are described in script calc_crack.m 2 | Also, see/run UzUr.m 3 | YF 8/22/2001 4 | -------------------------------------------------------------------------------- /deformation_sources/penny/UzUr.m: -------------------------------------------------------------------------------- 1 | clear all; clf reset; 2 | global NumLegendreTerms 3 | n=2; eps=1e-4; 4 | h1=log(0.2); 5 | h2=log(10); 6 | h=h1:(h2-h1)/50:h2; 7 | h=exp(h); 8 | [n1,n2]=size(h); 9 | fid=fopen('umax.dat','w'); 10 | fprintf('\n'); 11 | for e=1:n2 12 | fprintf('Working on case %d (out of %d)',e,n2); 13 | [fi,psi,t,Wt]=fredholm(h(e),n,eps); 14 | line(t,fi), hold on 15 | line(t,psi), hold on 16 | r=0.001:0.1:2; 17 | [Uz,Ur]=intgr(r,fi,psi,h(e),Wt,t); 18 | clf 19 | line(r,-Uz), hold on 20 | line(r,Ur), hold on 21 | mu(e)=max(abs(Uz)); 22 | mh(e)=max(abs(Ur)); 23 | fprintf(fid,'%d %d %d \n',h(e),mu(e),mh(e)); 24 | for ii=1:33, fprintf('\b'); end 25 | end 26 | fprintf('\n'); 27 | status=fclose(fid); 28 | -------------------------------------------------------------------------------- /deformation_sources/penny/calc_crack.m: -------------------------------------------------------------------------------- 1 | % Matlab routine for calculating surface displacements due to a 2 | % uniformly pressurized horizontal penny-shaped crack 3 | % for details, see the 2001 GJI paper. 4 | % v. 1.0 Yuri Fialko 7/11/2000 5 | 6 | % The following parameters need to be user-supplied: 7 | nis=2; % number of sub-intervals on [0,1] on which integration is done 8 | % using a 16-point Gauss quadrature (i.e., total of nis*16 points) 9 | eps=1e-5; % solution accuracy for Fredholm integral equations (stop 10 | % iterations when relative change is less than eps) 11 | h=1; % dimensionless crack depth (Depth/Radius ratio) 12 | r=[0:0.1:3]; % observation points at the surface 13 | 14 | % Solve a coupled system of Fredholm eqs. of 2nd kind for basis functions fi,psi 15 | % t and Wt are nodes and weights of the num. integration quadrature 16 | [fi,psi,t,Wt]=fredholm(h,nis,eps); 17 | 18 | [Uv,Ur]=intgr(r,fi,psi,h,Wt,t); %calculate vertical and radial displ. 19 | 20 | -------------------------------------------------------------------------------- /deformation_sources/penny/fred.m: -------------------------------------------------------------------------------- 1 | function [fi,psi,t,Wt]=fred(h,m,er) 2 | % fi,psi: basis functions 3 | % t: interval of integration 4 | % m: size(t) 5 | %er=1e-7; 6 | lamda=2/pi; 7 | RtWt; 8 | NumLegendreTerms=length(Rt); 9 | for k=1:m 10 | for i=1:NumLegendreTerms 11 | d1=1/m; 12 | t1=d1*(k-1); 13 | r1:=d1*k; 14 | j=NumLegendreTerms*(k-1)+i; 15 | t(j)=Rt(j)*(r1-t1)*0.5+(r1+t1)*0.5; 16 | end 17 | end 18 | %[t,Wt]=SimpRtWt(m); 19 | fi1=-lamda*t; 20 | psi1=zeros(size(t)); 21 | fi=zeros(size(t)); 22 | psi=zeros(size(t)); 23 | res=1e9; 24 | % start iterating 25 | %e=0:1/7:1; 26 | %for i=1:7 27 | %y=fpkernel(h,e(i),t,4); 28 | % line(t,y), hold on 29 | %end 30 | %print out.ps 31 | %end 32 | %return 33 | 34 | while res > er 35 | for i=1:m+1 36 | fi(i)=-t(i)+sum(Wt.*(fi1.*fpkernel(h,t(i),t,1)+..., 37 | psi1.*fpkernel(h,t(i),t,3))); 38 | psi(i)=sum(Wt.*(psi1.*fpkernel(h,t(i),t,2)+..., 39 | fi1.*fpkernel(h,t(i),t,4))); 40 | end 41 | fi=fi*lamda; psi=psi*lamda; 42 | % find maximum relative change 43 | [fim,im]=max(abs(fi1-fi)); 44 | fim=fim/abs(fi(im)); 45 | [psim,im]=max(abs(psi1-psi)); 46 | psim=psim/abs(psi(im)); 47 | res=max([fim psim]); 48 | fi1=fi; 49 | psi1=psi; 50 | end %while 51 | 52 | function [t,Wt] =SimpRtWt(m); % nodes and weights for Simpson integration 53 | t=0:1/m:1; 54 | Wt=2/3/m*ones(size(t)); 55 | I=1:m+1; 56 | ev=find(mod(I,2)==0); 57 | Wt(ev)=4/3/m; 58 | Wt(1)=1/3/m; 59 | Wt(m+1)=1/3/m; 60 | 61 | -------------------------------------------------------------------------------- /deformation_sources/penny/intgr.m: -------------------------------------------------------------------------------- 1 | function [Uz,Ur]=intgr(r,fi,psi,h,Wt,t) 2 | % function [Uz,Ur]=intgr(r,fi,psi,h,Wt,t) 3 | % Uz(r),Ur(r) - vertical and radial displacements 4 | % fi,psi: basis functions 5 | % t: interval of integration 6 | 7 | [s1,s2]=size(r); 8 | 9 | % To speed up, use matrix operation instead of loop, Yunjun, 2015-11-10 10 | rr = repmat(reshape(r,s1*s2,1),size(t)); 11 | tt = repmat(t, s1*s2,1); 12 | Wt2 = repmat(Wt, s1*s2,1); 13 | fi2 = repmat(fi, s1*s2,1); 14 | psi2 = repmat(psi,s1*s2,1); 15 | 16 | Qf = Q(h,tt,rr,1:8); 17 | Uz = sum(Wt2.*fi2.*(Qf(:,:,1) + h*Qf(:,:,2) + psi2.*Qf(:,:,1)./tt - Qf(:,:,3)),2); 18 | Ur = sum(Wt2.*(psi2.*((Qf(:,:,4) - h*Qf(:,:,5))./tt - Qf(:,:,6) + h*Qf(:,:,7)) - h*fi2.*Qf(:,:,8)),2); 19 | Uz = reshape(Uz,s1,s2); 20 | Ur = reshape(Ur,s1,s2); 21 | 22 | 23 | % Uz=zeros(size(r)); 24 | % Ur=Uz; 25 | % for i=1:s1 26 | % for j=1:s2 27 | % Uz(i,j)= sum(Wt.*(fi.*(Qy(h,t,r(i,j),1)+h*Qy(h,t,r(i,j),2))+..., 28 | % psi.*(Qy(h,t,r(i,j),1)./t-Qy(h,t,r(i,j),3)))); 29 | % Ur(i,j)= sum(Wt.*(psi.*((Qy(h,t,r(i,j),4)-h*Qy(h,t,r(i,j),5))./t-..., 30 | % Qy(h,t,r(i,j),6)+h*Qy(h,t,r(i,j),7))-..., 31 | % h*fi.*Qy(h,t,r(i,j),8))); 32 | % end 33 | % end 34 | -------------------------------------------------------------------------------- /deformation_sources/penny/intgrUz.m: -------------------------------------------------------------------------------- 1 | function [Uz]=intgrUz(r,fi,psi,h,Wt,t) 2 | % Uz(r) - vertical displacements 3 | % fi(t),psi(t): basis functions 4 | % t: interval of integration 5 | [s1,s2]=size(r); 6 | Uz=zeros(size(r)); 7 | 8 | for i=1:s1 9 | for j=1:s2 10 | Uz(i,j)= sum(Wt.*(fi.*(Q(h,t,r(i,j),1)+h*Q(h,t,r(i,j),2))+..., 11 | psi.*(Q(h,t,r(i,j),1)./t-Q(h,t,r(i,j),3)))); 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /deformation_sources/penny/intgrV.m: -------------------------------------------------------------------------------- 1 | %function [V,Vs]=intgrV(fi,psi,h,Wt,t) 2 | function [V]=intgrV(fi,h,Wt,t) 3 | % V,Vs - volume of crack, volume of surface uplift 4 | % fi,psi: basis functions 5 | % t: interval of integration 6 | %large=1e10; 7 | V = sum(Wt.*fi.*t); 8 | %Vs = sum(Wt.*fi.*(t-h*(h-t)./(h^2+t.^2))); 9 | %V1 = sum(Wt.*(fi.*Q(0,t,0,41))); 10 | %V2 = sum(Wt.*(fi.*Q(0,t,large,41))); 11 | %V=V2-V1; 12 | %I1=sqrt(2)*h*t.*Qr(h,t,1) 13 | %I2=(h*Qr(h,t,3)-t.*Qr(h,t,2))/sqrt(2) 14 | %I3=(h*Qr(h,t,2)+t.*Qr(h,t,3))/sqrt(2) 15 | %Vs = sum(Wt.*(fi.*(I1+h*I2)+psi.*(I1./t-I3))) 16 | %Vs2 = sum(Wt.*(fi.*(Q(h,t,large,41)+h*Q(h,t,large,51))+..., 17 | % psi.*(Q(h,t,large,41)./t-Q(h,t,large,61)))); 18 | %Vs=Vs2-Vs1; 19 | -------------------------------------------------------------------------------- /deformation_sources/penny_source.m: -------------------------------------------------------------------------------- 1 | function [u] = penny_crack(param,coord) 2 | % penny_crack - displacement due to a penny-shaped crack 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | % function [u] = penny_crack(param,coord) 5 | % 6 | % Surface Displacements Due to Penny-Shaped Crack 7 | % FA, Mar 2002. Using code of Yuri Fialko (Fialko et al., GJI 2001) 8 | % FA, May 2005. Changes do that the last model parameter is the linear one (strength) 9 | % 10 | % Input: 11 | % param 4*1 parameters for mogi source 12 | % param(1) : x-coordinate of source (km) 13 | % param(2) : y-coordinate of source (km) 14 | % param(3) : depth source (km) 15 | % param(4) : radius of source 16 | % param(5) : strength of source 17 | % coord 2*N array with x,y coordinates of datavec 18 | % where the model displacement will be computed 19 | % Output: 20 | % u 3*N array with displacement coordinates [ux uy uz] 21 | % 22 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 23 | 24 | nis=2; eps=1e-5; r=[0.001:0.1:3]; 25 | 26 | x=param(1) ; 27 | y=param(2) ; 28 | h=param(3) ; % depth of crack 29 | r=param(4) ; % radius of crack 30 | f=param(5) ; % strength 31 | xvec=coord(1,:); 32 | yvec=coord(2,:); 33 | 34 | d=sqrt( (xvec-x).^2 + (yvec-y).^2 ); 35 | theta=atan2(yvec-y,xvec-x); 36 | 37 | h=h/r; d=d/r; 38 | [fi,psi,t,Wt]=fredholm(h,nis,eps); 39 | [Uv,Ur]=intgr(d,fi,psi,h,Wt,t); 40 | 41 | ux = Ur.*cos(theta); 42 | uy = Ur.*sin(theta); 43 | 44 | u=[ux ; uy; -Uv].*f; 45 | 46 | -------------------------------------------------------------------------------- /deformation_sources/slipcol.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/deformation_sources/slipcol.mat -------------------------------------------------------------------------------- /deformation_sources/squaredisloc.m: -------------------------------------------------------------------------------- 1 | function [u]=squaredisloc(par, coord, nu) 2 | %disloc1topo - computes surface displacements for a dislocation source with topographic approximation 3 | % 4 | % [u]=disloc1topo(disloc, coord, nu, hgt, deltahgt) 5 | % 6 | %Inputs: 7 | % par = dislocation parameter 8 | % coord = Matrix of local station coordinates , stored columnwise, 9 | % i.e., east in first row, north in second row 10 | % nu = Poisson's ratio 11 | % 12 | %Output: 13 | % u = matrix of displacements: Ux, Uy, Uz 14 | % 15 | %given positive. Keep your length units consistent! If you mix km and m you may get 16 | %unexpected results, particularly with the strains and tilts. 17 | % 18 | %21-09-2005 Falk Amelung. 19 | 20 | %Check arguments 21 | %if nargin < 5 | nargin > 5 | nargout > 1 error('Usage: [u]=disloc1topo(disloc, xloc, nu, hgt, deltahgt).'); end 22 | %if size(par,1)~=10 error('First argument must be a 10 element dislocation geometry and slip vector.'); end 23 | %if size(coord,1)~=2 error('Second argument must be a 2xn matrix of station coordinates.'); end 24 | 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | npar=zeros(1,10)'; 28 | npar(2:10)=par(:); 29 | npar(1)=par(1); 30 | u = disloc1(npar, coord, nu); 31 | end 32 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33 | -------------------------------------------------------------------------------- /deformation_sources/unitvector.m: -------------------------------------------------------------------------------- 1 | function u=unitvector(m) 2 | %UNITVECTOR u=unitvector(m) 3 | % 4 | %Returns a unit vector perpendicular to the plane of 5 | %dislocation m. Models should be stored columnwise 6 | %for vectorized output. 7 | 8 | %Parse inputs 9 | 10 | if nargin ~=1 11 | help unitvector 12 | end 13 | 14 | [i,j]=size(m); 15 | 16 | if j>i & min([i j])==1 17 | m=m'; 18 | end 19 | 20 | %Calculate unit vector 21 | 22 | theta=(90-m(5,:))*pi/180; 23 | delta=m(4,:)*pi/180; 24 | sd=sin(delta); 25 | cd=cos(delta); 26 | st=sin(theta); 27 | ct=cos(theta); 28 | cd(abs(cd)<1e-15)=0; 29 | sd(abs(sd)<1e-15)=0; 30 | ct(abs(ct)<1e-15)=0; 31 | st(abs(st)<1e-15)=0; 32 | u(1,:)=st.*sd; 33 | u(2,:)=-ct.*sd; 34 | u(3,:)=cd; -------------------------------------------------------------------------------- /deformation_sources/visco1d.m: -------------------------------------------------------------------------------- 1 | function [u]=visco1d(par, coord, visco1dopt) 2 | %visco1d - computes surface displacements for a dislocation source with topographic approximation 3 | % 4 | % [u]=disloc1topo(disloc, coord, nu, hgt, deltahgt) 5 | % 6 | %Inputs: 7 | % par = dislocation parameter 8 | % coord = Matrix of local station coordinates , stored columnwise, 9 | % i.e., east in first row, north in second row 10 | % nu = Poisson's ratio 11 | % 12 | %Output: 13 | % u = matrix of displacements: Ux, Uy, Uz 14 | % 15 | %ATTENTION INSTEAD OF VISCO1D A MOGI SOURCE IS CALLED WITH OPENING USED AS STRENGTH 16 | 17 | nu = visco1dopt.nu ; 18 | 19 | mogipar(1) = par(6); % east 20 | mogipar(2) = par(7); % north 21 | mogipar(3) = par(3); % depth 22 | mogipar(4) = par(10); % opening is used as strength 23 | 24 | [u] = mogi(mogipar(1:4),coord,nu); 25 | 26 | basemap = visco1dopt.basemap ; 27 | coord_ll = ll2local(coord,basemap,-1); 28 | -------------------------------------------------------------------------------- /deformation_sources/yang/README: -------------------------------------------------------------------------------- 1 | Falk, March 2002: 2 | yang_source.m is slightly modifed from Yuri's fcn_yangM.m so that it can called 3 | like our other functions 4 | -------------------------------------------------------------------------------- /deformation_sources/yang/demo.m: -------------------------------------------------------------------------------- 1 | % This is demonstration of surface deformations due to a prolate 2 | % shperoid of an arbitrary orientation 3 | % Yuri Fialko (fialko@gps.caltech.edu), 2/8/00 4 | 5 | % LOAD INPUTS 6 | clear all; 7 | eps=1e-10; % small number 8 | load_par; 9 | 10 | [ux,uy,uz]=fcn_yangM(as,x(:),y(:),matrl,tp(:)); % calculate surface displ. 11 | ux=reshape(ux,size(x)); 12 | uy=reshape(uy,size(x)); 13 | uz=reshape(uz,size(x)); 14 | uxsub = ux(1:dhx:ndat,1:dhy:mdat); % subsample horiz. displ. for output 15 | uysub = uy(1:dhx:ndat,1:dhy:mdat); 16 | 17 | %plot model 18 | fig1 = figure(1); 19 | clf 20 | set(fig1,'Name','Surface deformation',... 21 | 'PaperPosition',[0.25 1.5 6 6],... 22 | 'Position',[10 20 600 600],'number','off'); 23 | cmin=min(min(uz)); 24 | cmax=max(max(uz)); 25 | caxis([cmin,cmax]) 26 | axis('equal') 27 | pcolor(x,y,uz), shading flat, colormap(jet), hold on 28 | quiver(xsub,ysub,uxsub,uysub,'k'), hold on 29 | xlabel('W-E distance, km') 30 | ylabel('S-N distance, km') 31 | title(['Vert. (color) and Horiz. (arrows) displacements, cm']); 32 | colorbar('h') 33 | hold off 34 | -------------------------------------------------------------------------------- /deformation_sources/yang/fcn_yangM.m: -------------------------------------------------------------------------------- 1 | function [U1,U2,U3]=fcn_yangM(as,x,y,matrl,tp) 2 | % Calculate range displacement 3 | mu=matrl(2); 4 | nu=matrl(3); 5 | 6 | % Store some commonly used parameters 7 | coeffs(1)=1/(16*mu*(1-nu)); 8 | coeffs(2)=3-4*nu; 9 | coeffs(3)=4*(1-nu)*(1-2*nu); 10 | 11 | [ix,iy]=size(x); 12 | U1r=zeros(ix,iy); 13 | U2r=zeros(ix,iy); 14 | U1=zeros(ix,iy); 15 | U2=zeros(ix,iy); 16 | U3=zeros(ix,iy); 17 | 18 | % explicitly assign source parameters 19 | %as 20 | xs = as(1); % center x 21 | ys = as(2); % center y 22 | z0 = as(3); % center depth (positive) 23 | P = as(4); % excess pressure, mu*10^(-5) Pa 24 | a = as(5); % major axis, km 25 | b = as(6); % minor axis, km 26 | phi = as(7); % plunge, rad (0-pi) 27 | theta = as(8); % strike, rad (0-2*pi) 28 | xn=x-xs; 29 | yn=y-ys; 30 | e_theta(1)=sin(theta); 31 | e_theta(2)=cos(theta); 32 | cosp=cos(phi); 33 | sinp=sin(phi); 34 | c=sqrt(a^2-b^2); 35 | minx=min(min(x)); 36 | maxx=max(max(x)); 37 | miny=min(min(y)); 38 | maxy=max(max(y)); 39 | % if xs < minx | xs > maxx | ys < miny | ys > maxy % source is outside the grid 40 | % P=0; 41 | % end 42 | 43 | % Speroid quantities 44 | [sph]=spheroid(a,b,c,matrl,phi,theta,P); 45 | 46 | % Rotate points 47 | xp=xn*cosp + yn*sinp; 48 | yp=yn*cosp - xn*sinp; 49 | 50 | % Calculate model at integration limits 51 | xi=c; 52 | [Up1,Up2,Up3]=yang(sph,xi,z0,xp,yp,0,matrl,e_theta,coeffs,tp); 53 | xi=-xi; 54 | [Um1,Um2,Um3]=yang(sph,xi,z0,xp,yp,0,matrl,e_theta,coeffs,tp); 55 | 56 | % Sum 57 | U1r=-Up1+Um1; 58 | U2r=-Up2+Um2; 59 | % Rotate horiz. displacements back to the orig. coordinate system: 60 | U1=U1r*cosp-U2r*sinp+U1; 61 | U2=U1r*sinp+U2r*cosp+U2; 62 | U3=Up3-Um3+U3; 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /deformation_sources/yang/load_par.m: -------------------------------------------------------------------------------- 1 | path='.'; % path to where the data is 2 | gotodir=['cd ' path]; 3 | eval(gotodir); 4 | 5 | x0 = 0; % origin coordinates, km 6 | y0 = 0; 7 | dx = 0.5; % grid size, km 8 | dy = 0.5; 9 | ; 10 | ndat=100; % number of points in the grid for x & y 11 | mdat=100; 12 | xx=x0:dx:(mdat-1)*dx+x0; 13 | yy=y0:dy:(ndat-1)*dy+y0; 14 | [x,y]=meshgrid(xx,yy); 15 | tp=zeros(size(x)); % no topo 16 | 17 | as=zeros(1,8); % model vector (see fcn_yangM.m) 18 | as(1)=20; 19 | as(2)=30; 20 | as(3)=15; 21 | as(4)=10; 22 | as(5)=12; 23 | as(6)=4; 24 | as(7)=pi/180*40; 25 | as(8)=pi/180*30; 26 | 27 | 28 | dhx=round(ndat/10); % subsampled grid: 29 | dhy=round(mdat/10); 30 | xsub = x(1:dhx:ndat,1:dhy:mdat); 31 | ysub = y(1:dhx:ndat,1:dhy:mdat); 32 | 33 | % Elastic constants: 34 | matrl(1)=1; % 1st Lame constant 35 | matrl(2)=matrl(1); % shear modulus (2nd Lame constant) 36 | matrl(3)=0.25; % Poisson's ratio 37 | -------------------------------------------------------------------------------- /deformation_sources/yang/yang_spheroid.m: -------------------------------------------------------------------------------- 1 | function [sph]=spheroid(a,b,c,matrl,phi,theta,P) 2 | % Calculate spheroid parameters and save in output vector sph 3 | 4 | lamda=matrl(1); 5 | mu=matrl(2); 6 | nu=matrl(3); 7 | % Model expressions 8 | ac=(a-c)/(a+c); 9 | L1=log(ac); 10 | %L1=log((a-c)/(a+c)); 11 | iia=2/a/c^2 + L1/c^3; 12 | iiaa=2/3/a^3/c^2 + 2/a/c^4 + L1/c^5; 13 | coef1=-2*pi*a*b^2; 14 | Ia=coef1*iia; 15 | Iaa=coef1*iiaa; 16 | u=8*pi*(1-nu); 17 | Q=3/u; 18 | R=(1-2*nu)/u; 19 | a11=2*R*(Ia-4*pi); 20 | a12=-2*R*(Ia+4*pi); 21 | a21=Q*a^2*Iaa + R*Ia - 1; 22 | a22=-(Q*a^2*Iaa + Ia*(2*R-Q)); 23 | coef2=3*lamda+2*mu; 24 | w=1/(a11*a22-a12*a21); 25 | e11=(3*a22-a12)*P*w/coef2; 26 | e22=(a11-3*a21)*P*w/coef2; 27 | Pdila=2*mu*(e11-e22); 28 | Pstar=lamda*e11 + 2*(lamda+mu)*e22; 29 | a1=-2*b^2*Pdila; 30 | b1=3*b^2*Pdila/c^2 + 2*(1-2*nu)*Pstar; % !PL version had (1-nu) in the 2nd term! 31 | 32 | sph(1) = a; 33 | sph(2) = b; 34 | sph(3) = c; 35 | sph(4) = phi; 36 | sph(5) = theta; 37 | sph(6) = Pstar; 38 | sph(7) = Pdila; 39 | sph(8) = a1; 40 | sph(9) = b1; 41 | sph(10) = P; 42 | -------------------------------------------------------------------------------- /examples/Forward_disloc.min: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | dir_out_parent = strcat(getenv('GEODMOD_TESTBENCH')) 3 | prepareopt.demfile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'ML2002-2005_oneifgram/Dem/hawaii_filled_0.00056.dem.asc.hgt') 4 | prepareopt.ShadedRelieffile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'ML2002-2005_oneifgram/Dem/hawaii_filled_0.00056.dem.jpeg') 5 | prepareopt.CLim = [-0.05 0.05] 6 | prepareopt.subset.ji = [ 1250 650 400 600] ;% LL 7 | %modelopt.N_mogi = 1 8 | %modelopt.par.lola = [-155.6 19.45 10 20 ] 9 | modelopt.N_disloc = 1 10 | modelopt.par.lola(1:10,1) = [4.77 4.75 2.21 -89.9 32.1 -155.5 19.4 1.0 0.0 1.0 ] 11 | %plotthemodelopt.plotdataopt.googleearthopt.DoIt = 'on' 12 | -------------------------------------------------------------------------------- /examples/Forward_mogi.min: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | dir_out_parent = strcat(getenv('GEODMOD_TESTBENCH')) 3 | prepareopt.demfile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'MLGPSonly/Dem/hawaii_filled_0.00056.dem.asc.hgt') 4 | prepareopt.ShadedRelieffile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'MLGPSonly/Dem/hawaii_filled_0.00056.dem.jpeg') 5 | prepareopt.CLim = [-0.05 0.05] 6 | prepareopt.subset.ji = [ 1250 650 400 600] ;% LL 7 | modelopt.N_mogi = 1 8 | modelopt.par.lola = [-155.6 19.45 10 20 ] 9 | 10 | %modelopt.N_disloc = 1 11 | %modelopt.par.lola = [4.77 4.75 2.21 -89.9 32.1 -155.5 19.4 1.0 0.0 1.0 ] 12 | %plotthemodelopt.plotdataopt.googleearthopt.DoIt = 'on' 13 | -------------------------------------------------------------------------------- /examples/MLGPSonly.min: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | dir_out_parent = strcat(getenv('GEODMOD_TESTBENCH')) 3 | prepareopt.demfile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'MLGPSonly/Dem/hawaii_filled_0.00056.dem.asc.hgt') 4 | prepareopt.ShadedRelieffile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'MLGPSonly/Dem/hawaii_filled_0.00056.dem.jpeg') 5 | prepareopt.linefile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'MLGPSonly/Lines/hawaii_lines_new') 6 | %prepareopt.subset.ji = [ 1 1 2525 2393] % LL 7 | prepareopt.subset.ji = [1250 650 512 512] % LL 8 | prepareopt.Shadefac = 0.1 9 | prepareopt.CLim = [-0.05 0.05] 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11 | makegpsopt.GPStxtfile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'MLGPSonly/Data/GPS/GPS_BenBrooks_03-05full.txt') 12 | makegpsopt.filetype = rates 13 | makedatasetopt.GPShorz = true 14 | makedatasetopt.GPSvert = false 15 | makedatasetopt.sigphi = 1 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | modelopt.N_disloc = 1 18 | inverseopt.disloc_bounds.xy (1:10,1) = [ 4.0 4.0 1.0 -89.9 25.0 10.0 10.0 0.0 0.0 999 ] 19 | inverseopt.disloc_bounds.xy (1:10,2) = [ 12.0 12.0 5.0 -89.9 35.0 20.0 20.0 0.0 0.0 999 ] 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21 | inverseopt.algorithm = Anneal 22 | inverseopt.FollowGradient = on 23 | inverseopt.rstate = 1 24 | inverseopt.annealopt = 0 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | plotthemodelopt.DoIt = on 27 | %plotthemodelopt.SaveModelEnu = test2002 28 | -------------------------------------------------------------------------------- /examples/basemap_hawaii.min: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | dir_out_parent = strcat(getenv('GEODMOD_TESTBENCH')) 3 | prepareopt.demfile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'ML2002-2005/Dem/hawaii_filled_0.00056.dem.asc.hgt') 4 | prepareopt.ShadedRelieffile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'ML2002-2005/Dem/hawaii_filled_0.00056.dem.jpeg') 5 | prepareopt.linefile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'ML2002-2005/Lines/hawaii_lines_new') 6 | prepareopt.quakefile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'ML2002-2005/Quakes/hawaii-quakes-20020512-20051231_falk_modified.txt') 7 | %prepareopt.GPStxtfile = strcat(getenv('GEODMOD_TESTDATA'),filesep, 'ML2002-2005/Data/GPS_BenBrooks_03-05full.txt') 8 | prepareopt.ShadeOnly = 'on' 9 | prepareopt.CLim = [-0.05 0.05] 10 | prepareopt.symbopt.Quakes.dep_ranges =[20 70] ; 11 | prepareopt.symbopt.Quakes.dep_symbols ={'yo'} ; ; 12 | prepareopt.symbopt.Quakes.mag_ranges =[2.2 3.0 9] ; 13 | prepareopt.symbopt.Quakes.mag_symbols ={{'MarkerSize',0.1} {'MarkerSize',0.2}} ; 14 | %prepareopt.Cmap = dismphF 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | makesaropt.data2igramopt.DoIt = false 17 | makesaropt.data2igramopt.subset.ji = [900 400 1300 1600] ;% LL for ML and Kilauea 18 | plotthemodelopt.DoIt = 'off' 19 | -------------------------------------------------------------------------------- /examples/test_geodmod.m: -------------------------------------------------------------------------------- 1 | function []=test_geodmod(what) 2 | %test_geodmod - test geodmod distribution 3 | % 4 | % usage: test_geodmod 5 | % usage: test_geodmod 'all' 6 | % 7 | % Function to test geodmod distribution. Assumes Data (DEM, interferograms, GPS, linefiles, 8 | % quakefiles, etc) are available in the GEODMOD_TESTDATA directory. Files are written to 9 | % the GEODMOD_TESTBENCH directory and removed after completion 10 | % 11 | % Without any arguments it runs Darwin.min, Forward_mogi.min, MLGPSonly and 12 | % basemap_hawaii.min 13 | % 14 | % For 'all' it also runs ML2002-2005, Darwin_pennyshapedcrack, Darwin_yang. 15 | % 16 | % Quick testing by running: 17 | % 18 | % geodmod Darwin.min 19 | % geodmod Forward_mogi.min 20 | % geodmod MLGPSonly.min 21 | % geodmod basemap_hawaii.min 22 | % geodmod ML2002-2005.min 23 | % geodmod Darwin_pennyshapedcrack 24 | % geodmod Darwin_yang 25 | % 26 | 27 | all=false ; 28 | if nargin==1 && (strcmp(what,'all') || strcmp(what,'All')) % all=true if all tests are run 29 | all=true ; 30 | end 31 | disp(all) 32 | 33 | 34 | list = {'Darwin' 'Forward_mogi' 'MLGPSonly' 'basemap_hawaii' 'Wells'}; 35 | others = {'ML2002-2005' 'Darwin_pennyshapedcrack' 'Darwin_yang'}; 36 | 37 | if all list={list{:} others{:}}; end 38 | 39 | for i=1:length(list) 40 | dirname = fullfile(getenv('GEODMOD_TESTBENCH'),list{i}) ; 41 | filename = [getenv('GEODMOD_HOME') filesep 'distribution_testing' filesep list{i} '.min' ] ; 42 | if exist(dirname,'dir') rmdir(dirname,'s'); end 43 | logmessage(['Test #' num2str(i) ', running.... geodmod ' filename]) 44 | 45 | geodmod(filename,'plot_save=0'); 46 | 47 | gclean all 48 | end 49 | 50 | clear all ; close all % needed fo that no error messages in batch mode 51 | system('rm -f .last_dir_out'); 52 | -------------------------------------------------------------------------------- /inver/gibbslib/calc_Tc.m: -------------------------------------------------------------------------------- 1 | function [Tc] = calc_Tc(gibbsopt,objfunc,bounds,dataset,objfuncopt,sqrflag) ; 2 | %calc_Tc - calculate critical temperature for Gibbs Sampling 3 | % 4 | %FA, May, 2007 5 | f=fieldnames(gibbsopt) ; for i=1:length(f) eval([char(f{i}) '= gibbsopt.(f{i}) ;' ]) ; end 6 | if TcStart==TcEnd 7 | Tc=gibbsopt.TcStart ; 8 | str=sprintf('ManualTc: %6.3f' ,Tc); 9 | else 10 | [junk,Tsched_robust] = generate_Tsched(gibbsopt) ; 11 | gibbsopt.robustTc = true ; 12 | gibbsopt.Tsched = Tsched_robust; 13 | gibbsopt.runs = 5 ; 14 | 15 | [mhat,modelsTc,energyTc]=gibbs(objfunc,bounds,gibbsopt,dataset,objfuncopt,sqrflag); 16 | [Tc]=find_robustTc(modelsTc,energyTc,gibbsopt); 17 | out_name=[gibbsopt.sfile '_robustTc']; 18 | logplot('plot_robustTc',out_name,modelsTc,energyTc,gibbsopt) 19 | str=sprintf('RobustTc: %6.3f' ,Tc); 20 | end 21 | 22 | logmessage(str); 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /inver/gibbslib/find_robustTc.m: -------------------------------------------------------------------------------- 1 | function [Tc,strTc]=find_robustTc(models,energy,opt) 2 | %calc_robustTc(FUN,bounds,optTc,varargin) 3 | % 4 | % FA may 2002, based on code from Peter Cervelli. 5 | % FA may 2007, quick+dirty update 6 | 7 | %Check OPTIONS 8 | if isempty(opt) 9 | error('calc_robust: needs opt'); 10 | else 11 | grid =opt.igrid ; 12 | matrix=opt.matrix; 13 | Tsched=opt.Tsched; 14 | runs =opt.runs ; 15 | robustTc=opt.robustTc ; 16 | end 17 | 18 | Tlist=fliplr(unique(Tsched)); 19 | mean_energy1=zeros(length(Tlist),runs); 20 | mean_energy2=zeros(length(Tlist)); 21 | for r=1:runs 22 | for i=1:length(Tlist) 23 | list=find(Tsched==Tlist(i)); 24 | mean_energy1(i,r)=sum(energy(list,r)')/length(list) ; 25 | end 26 | end 27 | mean_energy2=mean(mean_energy1,2); 28 | i=find(mean_energy2(:)==min(mean_energy2(:))); 29 | Tc=log10(Tlist(i)); 30 | 31 | -------------------------------------------------------------------------------- /inver/gibbslib/generate_Tsched.m: -------------------------------------------------------------------------------- 1 | function [Tsched,Tsched_robust] = generate_Tsched(opt) ; 2 | %generate_Tsched - generate cooling schedules based on gibbsopt 3 | % 4 | %FA, May, 2007 5 | f=fieldnames(opt) ; for i=1:length(f) eval([char(f{i}) '= opt.(f{i}) ;' ]) ; end 6 | 7 | Tsched_robust=logspace(TcStart, TcEnd, TcRobustNum); 8 | Tsched_robust=reshape( repmat(Tsched_robust,CoolSweeps,1) ,1,CoolSweeps*length(Tsched_robust) ); 9 | 10 | %Tsched = logspace(Tc+1.5,Tc,CoolNum) ; 11 | if ~exist('Tc','var') Tc=TcStart ; end 12 | Tsched = logspace(Tc+1.5,Tc,CoolNum+1) ; Tsched(end)=[]; 13 | tmp = repmat(Tsched,CoolSweeps,1); 14 | Tsched = [tmp(:)' ones(1,GsSweeps)*10^Tc]; 15 | str=sprintf(' TcTstart %f TcEnd %f TcRobustNum %d CoolSweeps %d CoolNum=%d, GsSweeps=%d',TcStart,TcEnd,TcRobustNum,CoolNum,CoolSweeps,GsSweeps); 16 | %logmessage(str); 17 | 18 | -------------------------------------------------------------------------------- /inver/gibbslib/plot_robustTc.m: -------------------------------------------------------------------------------- 1 | function plot_robustTc(models,energy,opt) 2 | %calc_robustTc(FUN,bounds,optTc,varargin) 3 | % 4 | % FA may 2002, based on code from Peter Cervelli. 5 | 6 | %Check OPTIONS 7 | if isempty(opt) 8 | error('calc_robust: needs opt'); 9 | else 10 | grid =opt.igrid ; 11 | matrix=opt.matrix; 12 | Tsched=opt.Tsched; 13 | runs =opt.runs ; 14 | %rstate=opt.rstate ; 15 | robustTc=opt.robustTc ; 16 | end 17 | 18 | Tlist=fliplr(unique(Tsched)); 19 | mean_energy1=zeros(length(Tlist),runs); 20 | mean_energy2=zeros(length(Tlist)); 21 | for r=1:runs 22 | for i=1:length(Tlist) 23 | list=find(Tsched==Tlist(i)); 24 | mean_energy1(i,r)=sum(energy(list,r)')/length(list) ; 25 | end 26 | end 27 | mean_energy2=mean(mean_energy1,2); 28 | 29 | i=find(mean_energy2(:)==min(mean_energy2(:))); 30 | Tc=log10(Tlist(i)); 31 | strTc=sprintf('Tc: 10^%6.3f ', Tc ); 32 | 33 | 34 | % plot 35 | number=size(mean_energy1,2)+1; 36 | mpl=ceil(sqrt(number)); npl=ceil(number/mpl); 37 | 38 | for r=1:number-1 39 | h=subplot(mpl,npl,r) ; 40 | loglog(Tlist,mean_energy1(:,r)) ; xlabel('Temperature'); ylabel('energy'); 41 | title_str=sprintf('Run: %d',r);title(title_str) 42 | % semilogy(mean_energy1(:,r)) ; axis tight 43 | set(h,'XGrid','on','YGrid','on') 44 | end 45 | h=subplot(mpl,npl,r+1) ; 46 | loglog(Tlist,mean_energy2) ; xlabel('Temperature'); ylabel('mean energy') 47 | title_str=sprintf('Mean Energy over all runs: %d',r);title(title_str) 48 | title(['Mean Energy over all Runs ' strTc]) 49 | set(h,'XGrid','on','YGrid','on') 50 | 51 | -------------------------------------------------------------------------------- /legacy/magma_sources/README: -------------------------------------------------------------------------------- 1 | Yuri Fialko wrote: 2 | > 3 | > Hi Falk, 4 | > The penny crack code can be downloaded from my anonymous ftp site, 5 | > topex.ucsd.edu/pub/fialko/penny 6 | > The scripts should be self-explanatory. You may get the Yang code 7 | > at the same site, pub/fialko/yang. A word of caution: Yang et al. 8 | > solutions are not accurate when the source size is of the order 9 | > of the source depth (they seem to work fine in the point source 10 | > approximation). 11 | > Let me know if there are any problems. I'd appreciate a pre/re- 12 | > print of your work on Marchena. 13 | 14 | > A few comments about the matlab code that implements Yang's 15 | > solutions: 16 | > 1) in the yang.m routine (line 70) 17 | > I usually use the following equation for C0: 18 | > 19 | > C0=z00/sinth; 20 | > 21 | > instead of 22 | > 23 | > C0=y0*costh+z00*sinth; % check this! 24 | > 25 | > The latter is the formula given in the paper, but the former is actually 26 | > needed to reproduce the figures in the Yang et al. paper (it also 27 | > makes more sense). 28 | > 29 | > 2) In the fcn_yangM.m routine (line 26), 30 | > phi=as(7) is the strike, and theta=as(8) is the plunge of the major 31 | > axis of the ellipsoid (comments are permuted). 32 | 33 | -------------------------------------------------------------------------------- /legacy/magma_sources/mctigue.m: -------------------------------------------------------------------------------- 1 | function U = mctigue(m,obs,mu,nu) 2 | 3 | %MCTIGUE Calculate surface deformation due to a pressurized finite sphere. 4 | % 5 | % U = mctigue(m,obs,nu) calculate surface displacement field at 6 | % observation points due to a pressurized finite sphere. The result is 7 | % similar to Mogi source, but this function include higher order terms. 8 | % 9 | %INPUT: 10 | % m(1) east 11 | % m(2) north 12 | % m(3) depth(+) 13 | % m(4) radius 14 | % m(5) excess pressure, same unit as mu 15 | % 16 | % obs 2 x number of observation points 17 | % mu shear modulus 18 | % nu Poisson's ratio 19 | % 20 | %OUTPUT: 21 | % U surface displacement, 3 x size(obs,2) 22 | % 23 | % 24 | % Sang-Ho Yun, September 29, 2005 25 | % 26 | % 27 | % For information on the basis for this code see: 28 | % 29 | % MCTIGUE, D. F., 1987. Elastic stress and deformation near a finite 30 | % spherical magma body: resolution of the point source paradox. JGR 31 | % 92(B12), p.12931-40. 32 | % 33 | % Williams, C. A., Wadge, G., 1998. The effects of topography on magma 34 | % chamber deformation models: Application to Mt. Etna and radar 35 | % interferometry. GRL, 25(10), p.1549-52. 36 | 37 | if (nargin == 0) 38 | help mctigue; 39 | return; 40 | end 41 | 42 | if size(obs,1)~=2 43 | error('The dimension of obs should be 2 x n'); 44 | end 45 | 46 | east = m(1); 47 | north = m(2); 48 | d = m(3); 49 | a = m(4); 50 | p = m(5); 51 | 52 | x = obs(1,:) - east; 53 | y = obs(2,:) - north; 54 | [th,r] = cart2pol(x,y); 55 | rho = r/d; 56 | aod = a/d; 57 | 58 | aod3 = aod^3; 59 | aod6 = aod^6; 60 | denom1 = rho.^2 + 1; 61 | denom2 = 7-5*nu; 62 | 63 | common1 = p*(1-nu)./(mu*denom1.^1.5); 64 | common2 = aod3 - 0.5*aod6*(1+nu)/denom2 + 3.75*aod6*(2-nu)/denom2./denom1; 65 | Uz = d*common1.*common2; 66 | Ur = r.*common1.*common2; 67 | 68 | [Ux,Uy] = pol2cart(th,Ur); 69 | 70 | U = [Ux; Uy; Uz]; -------------------------------------------------------------------------------- /legacy/magma_sources/midpoint.m: -------------------------------------------------------------------------------- 1 | function [mp]=midpoint(m) 2 | %MIDPOINT mp=MIDPOINT(m) 3 | % 4 | %Returns coordinates at the mid-point of dislocation m. 5 | %Models should be stored columnwise for vectorized output. 6 | 7 | %Parse inputs 8 | 9 | if nargin ~=1 10 | help midpoint 11 | end 12 | 13 | [i,j]=size(m); 14 | 15 | if j>i & min([i j])==1 16 | m=m'; 17 | end 18 | 19 | %Calculate midpoints 20 | 21 | theta=(90-m(5,:))*pi/180; 22 | delta=m(4,:)*pi/180; 23 | W=m(2,:)/2; 24 | mp(1,:)=m(6,:)-W.*cos(delta).*sin(theta); 25 | mp(2,:)=m(7,:)+W.*cos(delta).*cos(theta); 26 | mp(3,:)=m(3,:)-W.*sin(delta); 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /legacy/magma_sources/penny/Q.m: -------------------------------------------------------------------------------- 1 | function [K]=Q(h,t,r,n) 2 | % Kernels calculation 3 | K=[]; 4 | E=h^2+r^2-t.^2; 5 | D=(E.^2+4*h^2*t.^2).^(0.5); 6 | D3=D.^3; 7 | %i=sqrt(-1); 8 | 9 | switch n 10 | case 1 %Q1 11 | K=sqrt(2)*h*t./(D.*sqrt(D+E)); 12 | 13 | case 2 %Q2 14 | K=1/sqrt(2)./D3.*(h*sqrt(D-E).*(2*E+D)-t.*sqrt(D+E).*(2*E-D)); 15 | 16 | case 3 %Q3 17 | K=1/sqrt(2)./D3.*(h*sqrt(D+E).*(2*E-D)+t.*sqrt(D-E).*(2*E+D)); 18 | 19 | case 4 %Q4 20 | K=t/r-sqrt(D-E)/r/sqrt(2); 21 | % K=imag(sqrt(E+2*i*h.*t)/r); 22 | 23 | case 5 %Q5 24 | K=-(h*sqrt(D-E)-t.*sqrt(D+E))./D/r/sqrt(2); 25 | 26 | case 6 %Q6 27 | K=1/r-(h*sqrt(D+E)+t.*sqrt(D-E))./D/r/sqrt(2); 28 | % K=1/r-real((h-i*t)/r./sqrt(E-2*i*h.*t)); 29 | 30 | case 7 %Q7 31 | K=r*sqrt(D+E).*(2*E-D)./D3/sqrt(2); 32 | % K=real(r.*(E-2*i*h.*t).^(-3/2)); 33 | 34 | case 8 %Q8 35 | K=r*sqrt(D-E).*(2*E+D)./D3/sqrt(2); 36 | % K=imag(r.*(E-2*i*h.*t).^(-3/2)); 37 | 38 | case 41 %Q4*r 39 | K=t-sqrt(D-E)/sqrt(2); 40 | % K=imag(sqrt(E+2*i*h.*t)/r); 41 | 42 | case 51 %Q5*r 43 | K=-(h*sqrt(D-E)-t.*sqrt(D+E))./D/sqrt(2); 44 | 45 | case 61 %Q6*r 46 | K=1-(h*sqrt(D+E)+t.*sqrt(D-E))./D/sqrt(2); 47 | 48 | end %switch n 49 | -------------------------------------------------------------------------------- /legacy/magma_sources/penny/Qr.m: -------------------------------------------------------------------------------- 1 | function [K]=Qr(h,t,n) 2 | % Kernels calculation 3 | K=[]; 4 | h2=h^2; 5 | t2=t.^2; 6 | h4=h^4; 7 | t4=t.^4; 8 | h6=h^6; 9 | t6=t.^6; 10 | h8=h^8; 11 | t8=t.^8; 12 | ht2=h2+t2; 13 | 14 | switch n 15 | case 1 %Q1 16 | K=2*(h6-h2*t4+t4*h2+h4*(2*t2+h2))./((2*h2)^(1.5)*(h4+t4-t2.*ht2+h2*(3*t2+h2))); 17 | 18 | case 2 %Q2 19 | K=8*(h8+t8+h6*ht2-h4*t2.*ht2+h2*t4.*ht2-t6.*ht2)./(ht2*(2*h2)^(3.5)); 20 | 21 | case 3 %Q3 22 | rad=sqrt(4*h2*t2+(h2-t2).^2); 23 | K=2*(-h6-h4*t2+h2*t4+t6+(h4+t4).*rad)./(ht2.^2.*(t2-h2+rad).^(1.5)); 24 | 25 | end %switch n 26 | -------------------------------------------------------------------------------- /legacy/magma_sources/penny/README: -------------------------------------------------------------------------------- 1 | Input and function calls are described in script calc_crack.m 2 | Also, see/run UzUr.m 3 | YF 8/22/2001 4 | -------------------------------------------------------------------------------- /legacy/magma_sources/penny/UzUr.m: -------------------------------------------------------------------------------- 1 | clear all; clf reset; 2 | global NumLegendreTerms 3 | n=2; eps=1e-4; 4 | h1=log(0.2); 5 | h2=log(10); 6 | h=h1:(h2-h1)/50:h2; 7 | h=exp(h); 8 | [n1,n2]=size(h); 9 | fid=fopen('umax.dat','w'); 10 | fprintf('\n'); 11 | for e=1:n2 12 | fprintf('Working on case %d (out of %d)',e,n2); 13 | [fi,psi,t,Wt]=fredholm(h(e),n,eps); 14 | line(t,fi), hold on 15 | line(t,psi), hold on 16 | r=0.001:0.1:2; 17 | [Uz,Ur]=intgr(r,fi,psi,h(e),Wt,t); 18 | clf 19 | line(r,-Uz), hold on 20 | line(r,Ur), hold on 21 | mu(e)=max(abs(Uz)); 22 | mh(e)=max(abs(Ur)); 23 | fprintf(fid,'%d %d %d \n',h(e),mu(e),mh(e)); 24 | for ii=1:33, fprintf('\b'); end 25 | end 26 | fprintf('\n'); 27 | status=fclose(fid); 28 | -------------------------------------------------------------------------------- /legacy/magma_sources/penny/calc_crack.m: -------------------------------------------------------------------------------- 1 | % Matlab routine for calculating surface displacements due to a 2 | % uniformly pressurized horizontal penny-shaped crack 3 | % for details, see the 2001 GJI paper. 4 | % v. 1.0 Yuri Fialko 7/11/2000 5 | 6 | % The following parameters need to be user-supplied: 7 | nis=2; % number of sub-intervals on [0,1] on which integration is done 8 | % using a 16-point Gauss quadrature (i.e., total of nis*16 points) 9 | eps=1e-5; % solution accuracy for Fredholm integral equations (stop 10 | % iterations when relative change is less than eps) 11 | h=1; % dimensionless crack depth (Depth/Radius ratio) 12 | r=[0:0.1:3]; % observation points at the surface 13 | 14 | % Solve a coupled system of Fredholm eqs. of 2nd kind for basis functions fi,psi 15 | % t and Wt are nodes and weights of the num. integration quadrature 16 | [fi,psi,t,Wt]=fredholm(h,nis,eps); 17 | 18 | [Uv,Ur]=intgr(r,fi,psi,h,Wt,t); %calculate vertical and radial displ. 19 | 20 | -------------------------------------------------------------------------------- /legacy/magma_sources/penny/fpkernel.m: -------------------------------------------------------------------------------- 1 | function [K]=fpkernel(h,t,r,n) 2 | % Kernels calculation 3 | p=4*h^2; 4 | K=[]; 5 | %[dumb,nr]=size(r); 6 | %[dumb,nt]=size(t); 7 | 8 | switch n 9 | case 1 %KN 10 | K=p*h*(KG(t-r,p)-KG(t+r,p)); 11 | 12 | case 2 %KN1 13 | Dlt=1e-6; 14 | a=t+r; 15 | b=t-r; 16 | y=a.^2; 17 | z=b.^2; 18 | g=2*p*h*(p^2+6*p*(t.^2+r.^2)+5*(a.*b).^2); 19 | s=((p+z).*(p+y)).^2; 20 | s=g./s; 21 | trbl=-4*h/(p+t.^2)*ones(size(t)); 22 | rs=find(r>Dlt); 23 | if t er 35 | for i=1:m+1 36 | fi(i)=-t(i)+sum(Wt.*(fi1.*fpkernel(h,t(i),t,1)+..., 37 | psi1.*fpkernel(h,t(i),t,3))); 38 | psi(i)=sum(Wt.*(psi1.*fpkernel(h,t(i),t,2)+..., 39 | fi1.*fpkernel(h,t(i),t,4))); 40 | end 41 | fi=fi*lamda; psi=psi*lamda; 42 | % find maximum relative change 43 | [fim,im]=max(abs(fi1-fi)); 44 | fim=fim/abs(fi(im)); 45 | [psim,im]=max(abs(psi1-psi)); 46 | psim=psim/abs(psi(im)); 47 | res=max([fim psim]); 48 | fi1=fi; 49 | psi1=psi; 50 | end %while 51 | 52 | function [t,Wt] =SimpRtWt(m); % nodes and weights for Simpson integration 53 | t=0:1/m:1; 54 | Wt=2/3/m*ones(size(t)); 55 | I=1:m+1; 56 | ev=find(mod(I,2)==0); 57 | Wt(ev)=4/3/m; 58 | Wt(1)=1/3/m; 59 | Wt(m+1)=1/3/m; 60 | 61 | -------------------------------------------------------------------------------- /legacy/magma_sources/penny/fredholm.m: -------------------------------------------------------------------------------- 1 | function [fi,psi,t,Wt]=fredholm(h,m,er); 2 | % function [fi,psi,t,Wt]=fredholm(h,m,er) 3 | % fi,psi: basis functions 4 | % t: interval of integration 5 | % m: size(t) 6 | %er=1e-7; 7 | lamda=2/pi; 8 | RtWt; 9 | NumLegendreTerms=length(Root); 10 | t=zeros(1,m*NumLegendreTerms); 11 | Wt=t; 12 | for k=1:m 13 | for i=1:NumLegendreTerms 14 | d1=1/m; 15 | t1=d1*(k-1); 16 | r1=d1*k; 17 | j=NumLegendreTerms*(k-1)+i; 18 | t(j)=Root(i)*(r1-t1)*0.5+(r1+t1)*0.5; 19 | Wt(j)=0.5/m*Weight(i); 20 | end 21 | end 22 | fi1=-lamda*t; 23 | psi1=zeros(size(t)); 24 | fi=zeros(size(t)); 25 | psi=zeros(size(t)); 26 | res=1e9; 27 | 28 | while res > er 29 | for i=1:m*NumLegendreTerms 30 | fi(i)=-t(i)+sum(Wt.*(fi1.*fpkernel(h,t(i),t,1)+..., 31 | psi1.*fpkernel(h,t(i),t,3))); 32 | psi(i)=sum(Wt.*(psi1.*fpkernel(h,t(i),t,2)+..., 33 | fi1.*fpkernel(h,t(i),t,4))); 34 | end 35 | fi=fi*lamda; psi=psi*lamda; 36 | % find maximum relative change 37 | [fim,im]=max(abs(fi1-fi)); 38 | fim=fim/abs(fi(im)); 39 | [psim,im]=max(abs(psi1-psi)); 40 | psim=psim/abs(psi(im)); 41 | res=max([fim psim]); 42 | fi1=fi; 43 | psi1=psi; 44 | end %while 45 | 46 | %function [t,Wt] =SimpRtWt(m); % nodes and weights for Simpson integration 47 | % t=0:1/m:1; 48 | % Wt=2/3/m*ones(size(t)); 49 | % I=1:m+1; 50 | % ev=find(mod(I,2)==0); 51 | % Wt(ev)=4/3/m; 52 | % Wt(1)=1/3/m; 53 | % Wt(m+1)=1/3/m; 54 | 55 | -------------------------------------------------------------------------------- /legacy/magma_sources/penny/intgr.m: -------------------------------------------------------------------------------- 1 | function [Uz,Ur]=intgr(r,fi,psi,h,Wt,t); 2 | % function [Uz,Ur]=intgr(r,fi,psi,h,Wt,t) 3 | % Uz(r),Ur(r) - vertical and radial displacements 4 | % fi,psi: basis functions 5 | % t: interval of integration 6 | 7 | [s1,s2]=size(r); 8 | Uz=zeros(size(r)); 9 | Ur=Uz; 10 | 11 | for i=1:s1 12 | for j=1:s2 13 | Uz(i,j)= sum(Wt.*(fi.*(Q(h,t,r(i,j),1)+h*Q(h,t,r(i,j),2))+..., 14 | psi.*(Q(h,t,r(i,j),1)./t-Q(h,t,r(i,j),3)))); 15 | Ur(i,j)=sum(Wt.*(psi.*((Q(h,t,r(i,j),4)-h*Q(h,t,r(i,j),5))./t-..., 16 | Q(h,t,r(i,j),6)+h*Q(h,t,r(i,j),7))-..., 17 | h*fi.*Q(h,t,r(i,j),8))); 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /legacy/magma_sources/penny/intgrUz.m: -------------------------------------------------------------------------------- 1 | function [Uz]=intgrUz(r,fi,psi,h,Wt,t) 2 | % Uz(r) - vertical displacements 3 | % fi(t),psi(t): basis functions 4 | % t: interval of integration 5 | [s1,s2]=size(r); 6 | Uz=zeros(size(r)); 7 | 8 | for i=1:s1 9 | for j=1:s2 10 | Uz(i,j)= sum(Wt.*(fi.*(Q(h,t,r(i,j),1)+h*Q(h,t,r(i,j),2))+..., 11 | psi.*(Q(h,t,r(i,j),1)./t-Q(h,t,r(i,j),3)))); 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /legacy/magma_sources/penny/intgrV.m: -------------------------------------------------------------------------------- 1 | %function [V,Vs]=intgrV(fi,psi,h,Wt,t) 2 | function [V]=intgrV(fi,h,Wt,t) 3 | % V,Vs - volume of crack, volume of surface uplift 4 | % fi,psi: basis functions 5 | % t: interval of integration 6 | %large=1e10; 7 | V = sum(Wt.*fi.*t); 8 | %Vs = sum(Wt.*fi.*(t-h*(h-t)./(h^2+t.^2))); 9 | %V1 = sum(Wt.*(fi.*Q(0,t,0,41))); 10 | %V2 = sum(Wt.*(fi.*Q(0,t,large,41))); 11 | %V=V2-V1; 12 | %I1=sqrt(2)*h*t.*Qr(h,t,1) 13 | %I2=(h*Qr(h,t,3)-t.*Qr(h,t,2))/sqrt(2) 14 | %I3=(h*Qr(h,t,2)+t.*Qr(h,t,3))/sqrt(2) 15 | %Vs = sum(Wt.*(fi.*(I1+h*I2)+psi.*(I1./t-I3))) 16 | %Vs2 = sum(Wt.*(fi.*(Q(h,t,large,41)+h*Q(h,t,large,51))+..., 17 | % psi.*(Q(h,t,large,41)./t-Q(h,t,large,61)))); 18 | %Vs=Vs2-Vs1; 19 | -------------------------------------------------------------------------------- /legacy/magma_sources/penny_source.m: -------------------------------------------------------------------------------- 1 | function [u] = penny_crack(param,coord) 2 | % penny_crack - displacement due to a penny-shaped crack 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | % function [u] = penny_crack(param,coord) 5 | % 6 | % Surface Displacements Due to Penny-Shaped Crack 7 | % FA, Mar 2002. Using code of Yuri Fialko (Fialko et al., GJI 2001) 8 | % FA, May 2005. Changes do that the last model parameter is the linear one (strength) 9 | % 10 | % Input: 11 | % param 4*1 parameters for mogi source 12 | % param(1) : x-coordinate of source (km) 13 | % param(2) : y-coordinate of source (km) 14 | % param(3) : depth source (km) 15 | % param(4) : radius of source 16 | % param(5) : strength of source 17 | % coord 2*N array with x,y coordinates of datavec 18 | % where the model displacement will be computed 19 | % Output: 20 | % u 3*N array with displacement coordinates [ux uy uz] 21 | % 22 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 23 | 24 | nis=2; eps=1e-5; r=[0.001:0.1:3]; 25 | 26 | x=param(1) ; 27 | y=param(2) ; 28 | h=param(3) ; % depth of crack 29 | r=param(4) ; % radius of crack 30 | f=param(5) ; % strength 31 | xvec=coord(1,:); 32 | yvec=coord(2,:); 33 | 34 | d=sqrt( (xvec-x).^2 + (yvec-y).^2 ); 35 | theta=atan2(yvec-y,xvec-x); 36 | 37 | h=h/r; d=d/r; 38 | [fi,psi,t,Wt]=fredholm(h,nis,eps); [Uv,Ur]=intgr(d,fi,psi,h,Wt,t); 39 | 40 | ux = Ur.*cos(theta); 41 | uy = Ur.*sin(theta); 42 | 43 | u=[ux ; uy; -Uv].*f; 44 | -------------------------------------------------------------------------------- /legacy/magma_sources/slipcol.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/legacy/magma_sources/slipcol.mat -------------------------------------------------------------------------------- /legacy/magma_sources/unitvector.m: -------------------------------------------------------------------------------- 1 | function u=unitvector(m) 2 | %UNITVECTOR u=unitvector(m) 3 | % 4 | %Returns a unit vector perpendicular to the plane of 5 | %dislocation m. Models should be stored columnwise 6 | %for vectorized output. 7 | 8 | %Parse inputs 9 | 10 | if nargin ~=1 11 | help unitvector 12 | end 13 | 14 | [i,j]=size(m); 15 | 16 | if j>i & min([i j])==1 17 | m=m'; 18 | end 19 | 20 | %Calculate unit vector 21 | 22 | theta=(90-m(5,:))*pi/180; 23 | delta=m(4,:)*pi/180; 24 | sd=sin(delta); 25 | cd=cos(delta); 26 | st=sin(theta); 27 | ct=cos(theta); 28 | cd(abs(cd)<1e-15)=0; 29 | sd(abs(sd)<1e-15)=0; 30 | ct(abs(ct)<1e-15)=0; 31 | st(abs(st)<1e-15)=0; 32 | u(1,:)=st.*sd; 33 | u(2,:)=-ct.*sd; 34 | u(3,:)=cd; -------------------------------------------------------------------------------- /legacy/magma_sources/yang/README: -------------------------------------------------------------------------------- 1 | Falk, March 2002: 2 | yang_source.m is slightly modifed from Yuri's fcn_yangM.m so that it can called 3 | like our other functions 4 | -------------------------------------------------------------------------------- /legacy/magma_sources/yang/demo.m: -------------------------------------------------------------------------------- 1 | % This is demonstration of surface deformations due to a prolate 2 | % shperoid of an arbitrary orientation 3 | % Yuri Fialko (fialko@gps.caltech.edu), 2/8/00 4 | 5 | % LOAD INPUTS 6 | clear all; 7 | eps=1e-10; % small number 8 | load_par; 9 | 10 | [ux,uy,uz]=fcn_yangM(as,x(:),y(:),matrl,tp(:)); % calculate surface displ. 11 | ux=reshape(ux,size(x)); 12 | uy=reshape(uy,size(x)); 13 | uz=reshape(uz,size(x)); 14 | uxsub = ux(1:dhx:ndat,1:dhy:mdat); % subsample horiz. displ. for output 15 | uysub = uy(1:dhx:ndat,1:dhy:mdat); 16 | 17 | %plot model 18 | fig1 = figure(1); 19 | clf 20 | set(fig1,'Name','Surface deformation',... 21 | 'PaperPosition',[0.25 1.5 6 6],... 22 | 'Position',[10 20 600 600],'number','off'); 23 | cmin=min(min(uz)); 24 | cmax=max(max(uz)); 25 | caxis([cmin,cmax]) 26 | axis('equal') 27 | pcolor(x,y,uz), shading flat, colormap(jet), hold on 28 | quiver(xsub,ysub,uxsub,uysub,'k'), hold on 29 | xlabel('W-E distance, km') 30 | ylabel('S-N distance, km') 31 | title(['Vert. (color) and Horiz. (arrows) displacements, cm']); 32 | colorbar('h') 33 | hold off 34 | -------------------------------------------------------------------------------- /legacy/magma_sources/yang/fcn_yangM.m: -------------------------------------------------------------------------------- 1 | function [U1,U2,U3]=fcn_yangM(as,x,y,matrl,tp) 2 | % Calculate range displacement 3 | mu=matrl(2); 4 | nu=matrl(3); 5 | 6 | % Store some commonly used parameters 7 | coeffs(1)=1/(16*mu*(1-nu)); 8 | coeffs(2)=3-4*nu; 9 | coeffs(3)=4*(1-nu)*(1-2*nu); 10 | 11 | [ix,iy]=size(x); 12 | U1r=zeros(ix,iy); 13 | U2r=zeros(ix,iy); 14 | U1=zeros(ix,iy); 15 | U2=zeros(ix,iy); 16 | U3=zeros(ix,iy); 17 | 18 | % explicitly assign source parameters 19 | %as 20 | xs = as(1); % center x 21 | ys = as(2); % center y 22 | z0 = as(3); % center depth (positive) 23 | P = as(4); % excess pressure, mu*10^(-5) Pa 24 | a = as(5); % major axis, km 25 | b = as(6); % minor axis, km 26 | phi = as(7); % plunge, rad (0-pi) 27 | theta = as(8); % strike, rad (0-2*pi) 28 | xn=x-xs; 29 | yn=y-ys; 30 | e_theta(1)=sin(theta); 31 | e_theta(2)=cos(theta); 32 | cosp=cos(phi); 33 | sinp=sin(phi); 34 | c=sqrt(a^2-b^2); 35 | minx=min(min(x)); 36 | maxx=max(max(x)); 37 | miny=min(min(y)); 38 | maxy=max(max(y)); 39 | % if xs < minx | xs > maxx | ys < miny | ys > maxy % source is outside the grid 40 | % P=0; 41 | % end 42 | 43 | % Speroid quantities 44 | [sph]=spheroid(a,b,c,matrl,phi,theta,P); 45 | 46 | % Rotate points 47 | xp=xn*cosp + yn*sinp; 48 | yp=yn*cosp - xn*sinp; 49 | 50 | % Calculate model at integration limits 51 | xi=c; 52 | [Up1,Up2,Up3]=yang(sph,xi,z0,xp,yp,0,matrl,e_theta,coeffs,tp); 53 | xi=-xi; 54 | [Um1,Um2,Um3]=yang(sph,xi,z0,xp,yp,0,matrl,e_theta,coeffs,tp); 55 | 56 | % Sum 57 | U1r=-Up1+Um1; 58 | U2r=-Up2+Um2; 59 | % Rotate horiz. displacements back to the orig. coordinate system: 60 | U1=U1r*cosp-U2r*sinp+U1; 61 | U2=U1r*sinp+U2r*cosp+U2; 62 | U3=Up3-Um3+U3; 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /legacy/magma_sources/yang/load_par.m: -------------------------------------------------------------------------------- 1 | path='.'; % path to where the data is 2 | gotodir=['cd ' path]; 3 | eval(gotodir); 4 | 5 | x0 = 0; % origin coordinates, km 6 | y0 = 0; 7 | dx = 0.5; % grid size, km 8 | dy = 0.5; 9 | ; 10 | ndat=100; % number of points in the grid for x & y 11 | mdat=100; 12 | xx=x0:dx:(mdat-1)*dx+x0; 13 | yy=y0:dy:(ndat-1)*dy+y0; 14 | [x,y]=meshgrid(xx,yy); 15 | tp=zeros(size(x)); % no topo 16 | 17 | as=zeros(1,8); % model vector (see fcn_yangM.m) 18 | as(1)=20; 19 | as(2)=30; 20 | as(3)=15; 21 | as(4)=10; 22 | as(5)=12; 23 | as(6)=4; 24 | as(7)=pi/180*40; 25 | as(8)=pi/180*30; 26 | 27 | 28 | dhx=round(ndat/10); % subsampled grid: 29 | dhy=round(mdat/10); 30 | xsub = x(1:dhx:ndat,1:dhy:mdat); 31 | ysub = y(1:dhx:ndat,1:dhy:mdat); 32 | 33 | % Elastic constants: 34 | matrl(1)=1; % 1st Lame constant 35 | matrl(2)=matrl(1); % shear modulus (2nd Lame constant) 36 | matrl(3)=0.25; % Poisson's ratio 37 | -------------------------------------------------------------------------------- /legacy/magma_sources/yang/yang_spheroid.m: -------------------------------------------------------------------------------- 1 | function [sph]=spheroid(a,b,c,matrl,phi,theta,P) 2 | % Calculate spheroid parameters and save in output vector sph 3 | 4 | lamda=matrl(1); 5 | mu=matrl(2); 6 | nu=matrl(3); 7 | % Model expressions 8 | ac=(a-c)/(a+c); 9 | L1=log(ac); 10 | %L1=log((a-c)/(a+c)); 11 | iia=2/a/c^2 + L1/c^3; 12 | iiaa=2/3/a^3/c^2 + 2/a/c^4 + L1/c^5; 13 | coef1=-2*pi*a*b^2; 14 | Ia=coef1*iia; 15 | Iaa=coef1*iiaa; 16 | u=8*pi*(1-nu); 17 | Q=3/u; 18 | R=(1-2*nu)/u; 19 | a11=2*R*(Ia-4*pi); 20 | a12=-2*R*(Ia+4*pi); 21 | a21=Q*a^2*Iaa + R*Ia - 1; 22 | a22=-(Q*a^2*Iaa + Ia*(2*R-Q)); 23 | coef2=3*lamda+2*mu; 24 | w=1/(a11*a22-a12*a21); 25 | e11=(3*a22-a12)*P*w/coef2; 26 | e22=(a11-3*a21)*P*w/coef2; 27 | Pdila=2*mu*(e11-e22); 28 | Pstar=lamda*e11 + 2*(lamda+mu)*e22; 29 | a1=-2*b^2*Pdila; 30 | b1=3*b^2*Pdila/c^2 + 2*(1-2*nu)*Pstar; % !PL version had (1-nu) in the 2nd term! 31 | 32 | sph(1) = a; 33 | sph(2) = b; 34 | sph(3) = c; 35 | sph(4) = phi; 36 | sph(5) = theta; 37 | sph(6) = Pstar; 38 | sph(7) = Pdila; 39 | sph(8) = a1; 40 | sph(9) = b1; 41 | sph(10) = P; 42 | -------------------------------------------------------------------------------- /maintenancelib/dbstopend.m: -------------------------------------------------------------------------------- 1 | function []=dbstopend(fname); 2 | %dbstopend - invokes debugger at last line of file 3 | % 4 | %usage: []=dbstopend('PreparePlot'); 5 | % 6 | % Falk Amelung, June 2007 7 | % 8 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9 | fullname=which(fname); 10 | [q,str]=unix(['wc -l ' fullname]) ; 11 | cstr=str2list(str); 12 | str=['dbstop in ' fname ' at ' cstr{1}]; 13 | disp(str) 14 | eval(str) 15 | -------------------------------------------------------------------------------- /masterfile/CheckToolboxes.m: -------------------------------------------------------------------------------- 1 | function [out_flag]=CheckToolboxes(); 2 | %CheckToolboxes - checks for existence of matlab toolboxes required by geodmod 3 | % 4 | %usage: [out_flag]=CheckToolboxes(); 5 | % 6 | %Output: out_flag (true if all toolboxes exist, false otherwise) 7 | % 8 | % Falk Amelung, October 2008 9 | % 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11 | list = {'image_toolbox' 'map_toolbox' 'optimization_toolbox' 'satistics_toolbox'}; 12 | 13 | out_flag= true; 14 | 15 | for i=1:length(list); 16 | if ~license('test',list{1}) 17 | txt_str=['geodmod needs: ' list{i} '. You may see errors ....'] ; 18 | errordlg(txt_str); error([txt_str 'user error -- exiting']); 19 | out_flag=false; 20 | return 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /masterfile/README_programming: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | Oct 4 2006: Many function are setting for required input currently 3 | defaultopt=struct( ... 4 | 'demfile' , 'off' , ... 5 | 'ShadedRelieffile' , 'off' , ... 6 | This is confusing because these fields need to be filled for the function to work. 7 | We should think about something like 8 | defaultopt=struct( ... 9 | 'demfile' , 'required' 10 | This may entail the modification of process_defaultoptions.m 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | -------------------------------------------------------------------------------- /masterfile/geodmod_version: -------------------------------------------------------------------------------- 1 | version_3_3_1 2 | -------------------------------------------------------------------------------- /masterfile/pubgeodmod.m: -------------------------------------------------------------------------------- 1 | function []=pubgeodmod(fname,outdir) 2 | %pubgeodmod - generates an html file based on a *min file 3 | % 4 | % usage: pubgeodmod file.min [dir] 5 | % 6 | % e.g.: geodmod Lengai_1fault.min 7 | % pubgeodmod Lengai_1fault.min '/RAID1/amelung/models/html' 8 | % 9 | % Options given 10 | % 11 | % 'dir_in' Input directory (contains e.g. RsatA3) [default 'off'] 12 | % 'plotdataopt' plot options [default 'off' ] 13 | % 14 | % Saves data as igram structure. 15 | % If corfile is given it is used 16 | % 17 | % V1.0 Falk Amelung, October 2006 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19 | [pathstr,name,ext] = fileparts(fname) ; 20 | fname_for_publish = fullfile(pathstr,[name '.m']) ; 21 | fname_html = fullfile(pathstr,[name '.html']) ; 22 | 23 | if exist('outdir','var') 24 | opts.outputDir = outdir; 25 | full_fname_html = fullfile(opts.outputDir,fname_html) ; 26 | else 27 | opts.outputDir = name; 28 | full_fname_html = fullfile(pwd,opts.outputDir,fname_html) ; 29 | end 30 | 31 | disp('To view html:') 32 | disp(['firefox ' full_fname_html]); 33 | 34 | if ~exist(opts.outputDir,'dir') mkdir(opts.outputDir) ; end 35 | %logmessage(sprintf('output directory: %s ',opts.outputDir)); 36 | 37 | fid = fopen(fname_for_publish,'w'); 38 | fprintf(fid,'type %s \n',fname) ; 39 | fprintf(fid,'geodmod %s \n',fname) ; 40 | fclose(fid) ; 41 | 42 | disp('publishing to html....') 43 | disp('when finished, view with:') 44 | disp(['firefox ' full_fname_html]); 45 | publish(fname_for_publish,opts); 46 | 47 | delete(fname_for_publish) 48 | -------------------------------------------------------------------------------- /mex/DM_Disloc.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/DM_Disloc.mexglx -------------------------------------------------------------------------------- /mex/DM_Disloc.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/DM_Disloc.mexmaci64 -------------------------------------------------------------------------------- /mex/README: -------------------------------------------------------------------------------- 1 | mex -setup (I think, try mex file.f -n to see whether your compiler is in the path) 2 | 3 | mex disloc3d.f dc3d.f 4 | 5 | ############################################# 6 | disloc3d doen not compile properly under linux 7 | 8 | The test program 9 | 10 | test_disloc3d (which does twice the same thing) should produce: 11 | 12 | ns = 13 | [] 14 | ans = 15 | [] 16 | ans = 17 | [] 18 | ans = 19 | [] 20 | ans = 21 | 1.0e+04 * 22 | 2.2202 2.2202 23 | 24 | as it does it under solaris 25 | 26 | -------------------------------------------------------------------------------- /mex/S1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/S1.mat -------------------------------------------------------------------------------- /mex/discalc.m: -------------------------------------------------------------------------------- 1 | function [X,Y]= discalc(disgeom) 2 | % discalc - Calculates surface projection of the dislocation 3 | % Input: Dislocation Geometry in a Global E-N-Up coordinate system 4 | % disgeom(1) = len = fault length in strike direction (km) 5 | % disgeom(2) = wid = fault width in dip direction (km) 6 | % disgeom(3) = dep = fault depth (km) 7 | % disgeom(4) = dip = dip angle (degrees) 8 | % disgeom(5) = strik = strike, clockwise from N (degrees) 9 | % disgeom(6) = delE = East offset of midpoint from origin (km) 10 | % disgeom(7) = delN = North offset of midpoint from origin (km) 11 | % disgeom(8) = ss = strike slip motion (m) 12 | % disgeom(9) = ds = dip slip motion (m) 13 | % disgeom(10) = op = opening motion (m) 14 | % 15 | % Output: LowerLeft,LowerRight,UpperLeft,UpperRight 16 | % 17 | len =disgeom(1); wid = disgeom(2); dep = disgeom(3); delE=disgeom(6); delN=disgeom(7); 18 | i = sqrt(-1); 19 | dipr = disgeom(4)*pi/180; 20 | % 21 | % corners in local coordinates 22 | ll = -0.5*len +i*0; lr = 0.5*len + i*0; 23 | ul = -0.5*len +i*wid*cos(dipr); ur = 0.5*len + i*wid*cos(dipr); 24 | % 25 | %transform corners to global coordinates 26 | strkr = (90-disgeom(5))*pi/180; 27 | % 28 | ll = (delE+delN*i) + ll*exp(i*strkr); 29 | lr = (delE+delN*i) + lr*exp(i*strkr); 30 | ul = (delE+delN*i) + ul*exp(i*strkr); 31 | ur = (delE+delN*i) + ur*exp(i*strkr); 32 | X = [real(ll), real(lr) , real(ul) , real(ur)] ; 33 | Y = [imag(ll), imag(lr) , imag(ul) , imag(ur)] ; 34 | 35 | %plot( [real(ll), real(lr)], [imag(ll), imag(lr)] ), axis('equal'); 36 | %plot( [real(ll), real(ul)], [imag(ll), imag(ul)] ), axis(axis); 37 | %plot( [real(ul), real(ur)], [imag(ul), imag(ur)], 'g' ), axis(axis); 38 | %plot( [real(ur), real(lr)], [imag(ur), imag(lr)] ), axis(axis); 39 | -------------------------------------------------------------------------------- /mex/disloc.mexsol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/disloc.mexsol -------------------------------------------------------------------------------- /mex/disloc1.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/disloc1.mexa64 -------------------------------------------------------------------------------- /mex/disloc1.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/disloc1.mexglx -------------------------------------------------------------------------------- /mex/disloc1.mexlx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/disloc1.mexlx -------------------------------------------------------------------------------- /mex/disloc1.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/disloc1.mexmaci -------------------------------------------------------------------------------- /mex/disloc1.mexmaci64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/disloc1.mexmaci64 -------------------------------------------------------------------------------- /mex/disloc1.mexsol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/disloc1.mexsol -------------------------------------------------------------------------------- /mex/disloc1.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/disloc1.mexw32 -------------------------------------------------------------------------------- /mex/disloc3d.m: -------------------------------------------------------------------------------- 1 | %DISLOC3D [U,D,S,flag]=disloc3d(m,x,mu,nu) 2 | % 3 | %Returns the deformation at point 'x', given dislocation 4 | %model 'm'. 'mu' specifies the shear modulus and 'nu' 5 | %specifies Poisson's ratio. 6 | % 7 | %Both 'm' and 'x' can be matrices, holding different models 8 | %and observation coordinates in the columns. In this case, 9 | %the function returns the deformation at the points specified 10 | %in the columns of 'x' from the sum of all the models in the 11 | %columns of 'm'. 'x' must be 3xi (i = number of observation 12 | %coordinates) and 'm' must be 10xj (j = number of models). 13 | % 14 | %The coordinate system is as follows: east = positive X, 15 | %north = positive Y, and up = positive Z. Observation 16 | %coordinates with positive Z values return a warning. 17 | % 18 | %The outputs are 'U', the three displacement components: 19 | %east, north, and up (on the rows); 'D', the nine 20 | %spatial derivatives of the displacement: Uxx, Uxy, Uxz, 21 | %Uyx, Uyy, Uyz, Uzx, Uzy, and Uzz (on the rows); and 'S' 22 | %the 6 independent stress components: Sxx, Sxy, Sxz, Syy, 23 | %Syz, and Szz (on the rows). All these outputs have 24 | %the same number of columns as 'x'. 25 | % 26 | %Output 'flag' is set for a singularity. 27 | % 28 | %The dislocation model is specified as: length, width, 29 | %depth, dip, strike, east, north, strike-slip, dip-slip, 30 | %and opening. The coordinates (depth, east, and north) 31 | %specify a point at the middle of the bottom edge of 32 | %the fault for positive dips and the middle of the top 33 | %edge for negative dips. 34 | % 35 | %Mind your units! E.g., if the lengths are given in km and the 36 | %slips in m, the derivatives will be biased 37 | -------------------------------------------------------------------------------- /mex/disloc3d.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/disloc3d.mexglx -------------------------------------------------------------------------------- /mex/disloc3d.mexsol: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/disloc3d.mexsol -------------------------------------------------------------------------------- /mex/disloc3d.mexsol_sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mex/disloc3d.mexsol_sav -------------------------------------------------------------------------------- /mex/disloc_mex_instructions.txt: -------------------------------------------------------------------------------- 1 | Instructions for making disloc1.mex files for new machines. 2 | 3 | 1. log onto the machine you want to use. 4 | 5 | 2. type 'mex -setup' 6 | 7 | 3. type '2', hit enter 8 | 9 | 4. open matlab 10 | 11 | 5. go into the folder geodmod/mex/ 12 | 13 | 6. type 'mex disloc1.c'. 14 | 15 | -------------------------------------------------------------------------------- /mex/displot.m: -------------------------------------------------------------------------------- 1 | function displot(disgeom) 2 | % displot - Plot surface projection of the dislocation. 3 | % Input: Dislocation Geometry in a Global E-N-Up coordinate system 4 | % disgeom(1) = len = fault length in strike direction (km) 5 | % disgeom(2) = wid = fault width in dip direction (km) 6 | % disgeom(3) = dep = fault depth (km) 7 | % disgeom(4) = dip = dip angle (degrees) 8 | % disgeom(5) = strik = strike, clockwise from N (degrees) 9 | % disgeom(6) = delE = East offset of midpoint from origin (km) 10 | % disgeom(7) = delN = North offset of midpoint from origin (km) 11 | % disgeom(8) = ss = strike slip motion (m) 12 | % disgeom(9) = ds = dip slip motion (m) 13 | % disgeom(10) = op = opening motion (m) 14 | %% 15 | len =disgeom(1); wid = disgeom(2); dep = disgeom(3); delE=disgeom(6); delN=disgeom(7); 16 | i = sqrt(-1); 17 | dipr = disgeom(4)*pi/180; 18 | % 19 | % corners in local coordinates 20 | ll = -0.5*len +i*0; lr = 0.5*len + i*0; 21 | ul = -0.5*len +i*wid*cos(dipr); ur = 0.5*len + i*wid*cos(dipr); 22 | % 23 | %transform corners to global coordinates 24 | strkr = (90-disgeom(5))*pi/180; 25 | % 26 | ll = (delE+delN*i) + ll*exp(i*strkr); 27 | lr = (delE+delN*i) + lr*exp(i*strkr); 28 | ul = (delE+delN*i) + ul*exp(i*strkr); 29 | ur = (delE+delN*i) + ur*exp(i*strkr); 30 | % 31 | plot( [real(ll), real(lr)], [imag(ll), imag(lr)],'LineWidth',2 ), axis('equal'); 32 | plot( [real(ll), real(ul)], [imag(ll), imag(ul)],'LineWidth',2 ), axis(axis); 33 | plot( [real(ul), real(ur)], [imag(ul), imag(ur)], 'g','LineWidth',2 ), axis(axis); 34 | plot( [real(ur), real(lr)], [imag(ur), imag(lr)],'LineWidth',2 ), axis(axis); 35 | -------------------------------------------------------------------------------- /mex/test_disloc3d.m: -------------------------------------------------------------------------------- 1 | j=8; 2 | i=63; 3 | load S1 4 | [U,D,sigma,flag1]=disloc3d(PM(:,i),x,mu,0.25); 5 | t=[nhat'*sigma([1 2 3],:) 6 | nhat'*sigma([2 4 5],:) 7 | nhat'*sigma([3 5 6],:)]; 8 | S1(:,i)=(nhat'*t)'; 9 | pm1=PM; 10 | x1=x; 11 | sigma1=sigma; 12 | t1=t; 13 | load S1 14 | [U,D,sigma,flag2]=disloc3d(PM(:,i),x,mu,0.25); 15 | t=[nhat'*sigma([1 2 3],:) 16 | nhat'*sigma([2 4 5],:) 17 | nhat'*sigma([3 5 6],:)]; 18 | S2(:,i)=(nhat'*t)'; 19 | pm2=PM; 20 | x2=x; 21 | sigma2=sigma; 22 | t2=t; 23 | find((pm1-pm2)~=0)' 24 | find((x1-x2)~=0)' 25 | find((flag1-flag2)~=0)' 26 | find((sigma1-sigma2)~=0)' 27 | [sigma1(1), sigma2(1)] 28 | 29 | -------------------------------------------------------------------------------- /mimiclib/ChangeDate.m: -------------------------------------------------------------------------------- 1 | function [outname]=ChangeDates(Innames) 2 | 3 | % 4 | % change dates format 5 | % 6 | month=Innames(3:5); 7 | if (month == 'JAN') 8 | monthout='01'; 9 | elseif (month == 'FEB') 10 | monthout='02'; 11 | elseif (month == 'MAR') 12 | monthout='03'; 13 | elseif (month == 'APR') 14 | monthout='04'; 15 | elseif (month =='MAY') 16 | monthout='05'; 17 | elseif (month == 'JUN') 18 | monthout='06'; 19 | elseif (month == 'JUL') 20 | monthout='07'; 21 | elseif (month =='AUG') 22 | monthout='08'; 23 | elseif (month =='SEP') 24 | monthout='09'; 25 | elseif (month =='OCT') 26 | monthout='10'; 27 | elseif (month =='NOV') 28 | monthout='11'; 29 | elseif (month=='DEC') 30 | monthout='12'; 31 | end 32 | 33 | outname=[Innames(1:2),monthout,Innames(6:7)]; 34 | -------------------------------------------------------------------------------- /mimiclib/CheckInOut.m: -------------------------------------------------------------------------------- 1 | function [out_flag]=CheckInOut(in_list,out_list); 2 | %CheckInOut - checks for existence of input and output file 3 | % 4 | %usage: [out_flag]=CheckInOut(in_file,out_file); 5 | % 6 | %Input: in_file, outfile 7 | % 8 | %Output: out_flag (true if file exists, else false) 9 | % 10 | % skips checking if string is empty (e.g. in_file='') 11 | % 12 | % Falk Amelung, September 2006 13 | % 14 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15 | [st,i]=dbstack ; 16 | %logmessage(sprintf('',2)); 17 | 18 | % 19 | % First check out_list 20 | % 21 | if ~iscell(out_list) out_list=cellstr(out_list); end 22 | out_flag=false; 23 | for i=1:length(out_list) 24 | out_file=out_list{i}; 25 | if ~isempty(out_file) 26 | if exist(out_file,'file') || exist([out_file '.mat'],'file') 27 | out_flag=true; 28 | logmessage(sprintf('out_file found: %s --- skipping %s',out_file,st(2).name),2); 29 | return 30 | else 31 | out_flag=false; 32 | logmessage(sprintf('will generate: %s',out_file),2); 33 | end 34 | end 35 | end 36 | 37 | % 38 | % Now check infiles 39 | % 40 | if ~iscell(in_list) in_list=cellstr(in_list); end 41 | for i=1:length(in_list) 42 | in_file=in_list{i}; 43 | if ~isempty(in_file) 44 | if exist(in_file,'file') 45 | logmessage(sprintf('in_file found: %s',in_file),2); 46 | else 47 | logmessage(sprintf('exiting --- file %s does not exist',in_file)); 48 | error(sprintf('user error %s->%s: exiting --- file %s does not exist',st(2).name,mfilename,in_file)); 49 | end 50 | end 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /mimiclib/DefaultOptions.m: -------------------------------------------------------------------------------- 1 | function [S]=DefaultOptions(fname,defaultopt); 2 | %DefaultOptions - assigns dir names according to RSMAS naming convention 3 | % 4 | %usage: [S] = DefaultOptions(fname,options); 5 | % 6 | %Input: fname text file containing options (*.min file) 7 | % 8 | %Output: S new structure with options 9 | % 10 | % 11 | % TODO: needs revamping so that it does all the option processing for tssar, SelectPairs and geodmod 12 | % read_options_from_file should be eliminated and al;so the command option processing should be done here 13 | % 14 | %FA, Oct 2009 15 | 16 | S = []; 17 | [path,name,ext] = fileparts(fname); 18 | if isempty(ext) fname = fullfile(path,[name '.min']); end % FA 10/2009: should check whether *template or *min file exist and use fname 19 | 20 | S = ReadKeywordfile(fname,'='); 21 | 22 | if ~exist('ProcessDir','var') ProcessDir = getenv('PROCESSDIR'); end 23 | if ~exist('TssarDir','var') TssarDir = getenv('TSSARDIR') ; end 24 | if isfield(S,'dir_out_parent') ProcessDir = S.dir_out_parent ; end 25 | if isfield(S,'dir_out_parent') TssarDir = S.dir_out_parent ; end 26 | 27 | if ~isfield(S.inputdataopt,'interf') S.inputdataopt.interf = [ ProcessDir filesep 'process' filesep name filesep 'DONE/P*/geo_*-*_*_*.unw' ] ; end 28 | if ~isfield(S.inputdataopt,'bllist') S.inputdataopt.bllist = [ TssarDir filesep name filesep 'DONE/bl_list.txt' ] ; end 29 | if ~isfield(S.inputdataopt,'topo') if isfield(S,'DEMg') S.inputdataopt.topo = S.DEMg; else S.inputdataopt.topo = S.DEM; end ; end 30 | 31 | -------------------------------------------------------------------------------- /mimiclib/GPSlib/GPS_llh2enu.m: -------------------------------------------------------------------------------- 1 | function [GPSdist] = GPS_llh2enu(GPS); 2 | 3 | % 4 | % reads GPS structure and transform into distance changes 5 | % 6 | % [GPSdist] = GPS_llh2enu(GPSlat); 7 | % 8 | % GPSlat is GPS structure from Read_GPS with coordinates change 9 | % 10 | % Use of GRS80 ellipsoide 11 | % 12 | % N. Gourmelen, February 2006 13 | % 14 | % 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | % process default options, and set variables to options % 17 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 18 | 19 | GPSdist = GPS ; 20 | 21 | for ni=1:length(GPS) 22 | 23 | latlength = distance(GPS(ni).lat(1),mean(GPS(ni).lon),GPS(ni).lat(size(GPS(ni).lat,1)),mean(GPS(ni).lon),almanac('earth','grs80')) ; 24 | lonlength = distance(mean(GPS(ni).lat),GPS(ni).lon(1),mean(GPS(ni).lat),GPS(ni).lon(size(GPS(ni).lon,1)),almanac('earth','grs80')) ; 25 | 26 | latratio = latlength/abs(GPS(ni).lat(1)-GPS(ni).lat(size(GPS(ni).lat,1))) ; if isnan(latratio) latratio = 0 ; end 27 | lonratio = lonlength/abs(GPS(ni).lon(1)-GPS(ni).lon(size(GPS(ni).lon,1))) ; if isnan(lonratio) lonratio = 0 ; end 28 | 29 | GPSdist(ni).n = ( (GPS(ni).lat - mean(GPS(ni).lat) ) * latratio)*1000 ; 30 | GPSdist(ni).e = ( (GPS(ni).lon - mean(GPS(ni).lon) ) * lonratio)*1000 ; 31 | GPSdist(ni).u = GPS(ni).height - mean(GPS(ni).height) ; 32 | GPSdist(ni).error_e = GPS(ni).error_lon * lonratio * 1000 ; 33 | GPSdist(ni).error_n = GPS(ni).error_lat * latratio * 1000 ; 34 | GPSdist(ni).error_u = GPSdist(ni).error_height * 1000 ; 35 | GPSdist(ni).lat = mean(GPS(ni).lat) ; 36 | GPSdist(ni).lon = mean(GPS(ni).lon) ; 37 | GPSdist(ni).height = mean(GPS(ni).height) ; 38 | GPSdist(ni).Unit = 'm' ; 39 | end 40 | 41 | GPSdist = rmfield(GPSdist,'error_lat') ; GPSdist = rmfield(GPSdist,'error_lon') ; 42 | -------------------------------------------------------------------------------- /mimiclib/GPSlib/Geo2Radar.m: -------------------------------------------------------------------------------- 1 | function [indata] = Geo2Radar(indata,opt); 2 | 3 | % 4 | % Add radar coordinates to the dtaa structure 5 | % 6 | % [outdata]=Read_IREA(indata,opt) 7 | % 8 | % 9 | % indata : Input file 10 | % 11 | % 12 | % opt contains 13 | % 14 | % 'gps' : Location of GPS files 15 | % 16 | % 'gpsradcoor' : name of the file containing the date list 17 | % 18 | % 19 | % N. Gourmelen, April 2009 20 | % 21 | 22 | 23 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 24 | % process default options, and set variables to options % 25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 26 | 27 | defaultopt=struct( ... 28 | 'gps' , 'off' , ... 29 | 'radcoor' , 'off' ) ; 30 | 31 | 32 | if ~exist('opt','var') [opt]=read_options_fromfile([mfilename '.min'],[]); end ; 33 | [opt]=process_defaultoptions(opt,defaultopt); display(opt) 34 | f=fieldnames(opt) ; 35 | for i=1:length(f) 36 | eval([char(f{i}) '= opt.(f{i}) ;' ]) ; 37 | end 38 | 39 | if gpsradcoor 40 | [filepath,file,ext] = fileparts(gps) ; 41 | fid = fopen([filepath,'/',gpsradcoor],'r') ; 42 | C = textscan(fid,'%s%f%f') ; 43 | 44 | for ni = 1:length(indata) 45 | tmpi = find(strcmp(C{1},indata(ni).GPS_station)==1) ; 46 | jC = C{2} ; iC = C{3} ; 47 | if ~isempty(tmpi) 48 | indata(ni).nj = jC(tmpi) ; indata(ni).ni = iC(tmpi) ; 49 | else 50 | indata(ni).nj = -1 ; indata(ni).ni = -1 ; 51 | end 52 | end 53 | end 54 | 55 | 56 | -------------------------------------------------------------------------------- /mimiclib/GPSlib/gps2los.m: -------------------------------------------------------------------------------- 1 | function [GPS]=gps2los(GPS,lookangle) 2 | 3 | % 4 | % Compute L.O.S. component of GPS on a structure (see Read_GPS.m for format) 5 | % 6 | % [losrate]=gps2los(GPS) 7 | % 8 | % 9 | % N. Gourmelen, March 2007 10 | % 11 | 12 | if nargin == 1 13 | vect = [cos(11/360*2*pi)*cos(67/360*2*pi) -cos(79/360*2*pi)*cos(67/360*2*pi) cos(23/360*2*pi)]; 14 | elseif isstruct(lookangle) 15 | vect = GenerateLosvector(lookangle(1).sat,lookangle(1).y_first,lookangle(1).sat_height); 16 | else 17 | vect = lookangle; 18 | end 19 | 20 | for ni=1:length(GPS) 21 | 22 | if isfield(GPS(ni),'e_rate') 23 | 24 | GPS(ni).los=[GPS(ni).e_rate GPS(ni).n_rate GPS(ni).height_rate]*vect';GPS(ni).horlos=[GPS(ni).e_rate GPS(ni).n_rate]*vect(1:2)'; 25 | GPS(ni).error_los=sqrt(GPS(ni).e_error.^2*cos(11/360*2*pi).^2*cos(67/360*2*pi).^2+GPS(ni).n_error.^2*cos(79/360*2*pi).^2*cos(67/360*2*pi).^2+GPS(ni).height_error.^2*cos(23/360*2*pi).^2); 26 | 27 | elseif isfield(GPS(ni),'e') 28 | 29 | GPS(ni).los=[GPS(ni).e GPS(ni).n GPS(ni).u]*vect';GPS(ni).horlos=[GPS(ni).e GPS(ni).n]*vect(1:2)'; 30 | if isfield(GPS(ni),'error_e') 31 | GPS(ni).error_los=sqrt(GPS(ni).error_e.^2*cos(11/360*2*pi).^2*cos(67/360*2*pi).^2+GPS(ni).error_n.^2*cos(79/360*2*pi).^2*cos(67/360*2*pi).^2+GPS(ni).error_u.^2*cos(23/360*2*pi).^2); 32 | end 33 | 34 | end 35 | 36 | GPS(ni).lookangle=vect; 37 | 38 | end 39 | 40 | 41 | -------------------------------------------------------------------------------- /mimiclib/ListFiles.m: -------------------------------------------------------------------------------- 1 | function [outfiles] = ListFiles(infiles) 2 | % 3 | % List files linewise. Used instead of dir( ) when input string contains 4 | % [0-9]. 5 | % 6 | % test by running 7 | % a=ListFiles('/RAID6/insar_lab/testdata_geodmod/ML2002-2005/Data/RsatD1/geo*[0-9].unw') 8 | % 9 | % Note: We need to use ls() instead of dir() because dir('geo*[0-9].unw') does not work. 10 | % 11 | % Windows-linux problem: Under linux ls returns the entire path. Under Windows it just returns the filename. This is why 12 | % we strip the path from the file and than put it back. 13 | % 14 | % Note: I did not understand the matlab help command regarding windows specific ls output. 15 | % Note: matlab help says that the output of the fileparts is filespecific. For saftey and compatibility it 16 | % extracts versn though I never saw that versn was not empty 17 | % 18 | % FA March 2008: Adjusted for Windows 19 | 20 | tmpstr = ls(infiles) ; 21 | tmpcellarray1 = textscan(tmpstr,'%s') ; tmpcellarray2= tmpcellarray1{1} ; 22 | 23 | tmp = dir(infiles); 24 | 25 | [pathstr,name,ext] = fileparts(infiles); 26 | 27 | for ni=1:size(tmp,1) 28 | outfiles(ni).name = fullfile(pathstr,tmp(ni).name); 29 | end 30 | -------------------------------------------------------------------------------- /mimiclib/SortIgram.m: -------------------------------------------------------------------------------- 1 | function [qigram,n_igrams]=SortIgram(igram) 2 | % SortIgram - Sort interferograms in igram structure 3 | % 4 | % Sort interferograms 5 | % 6 | N=length(igram) ; 7 | 8 | % first zero out all fields 9 | t=zeros(N,2); 10 | if isfield(igram(1),'t1') 11 | for i=1:N 12 | t(i,:)=[igram(i).t1 igram(i).t2]; 13 | end 14 | elseif isfield(igram(1),'t') 15 | for i=1:N 16 | t(i,:)=[igram(i).t]; 17 | end 18 | end 19 | 20 | [nt,ind]=sortrows(t); 21 | 22 | for i=1:N 23 | nigram(i)=igram(ind(i)); % changed March 2005 24 | % nigram(i).data=igram(ind(i)).data; 25 | % nigram(i).t1=igram(ind(i)).t1; 26 | % nigram(i).t2=igram(ind(i)).t2; 27 | % nigram(i).delt=igram(ind(i)).delt; 28 | % if isfield(igram,'date1') nigram(i).date1=igram(ind(i)).date1; end 29 | % if isfield(igram,'date2') nigram(i).date2=igram(ind(i)).date2; end 30 | % if isfield(igram,'par') nigram(i).par=igram(ind(i)).par; end 31 | % if isfield(igram,'atmo') nigram(i).atmo=igram(ind(i)).atmo; end 32 | % if isfield(igram,'atmo') nigram(i).atmo=igram(ind(i)).atmo; end 33 | % if isfield(igram,'noatmo') nigram(i).noatmo=igram(ind(i)).noatmo; end 34 | end 35 | 36 | % remove double data and put data back into igram 37 | [junk,ind]=unique(nt,'rows'); 38 | for i=1:length(ind) 39 | qigram(i)=nigram(ind(i)); 40 | end 41 | n_igrams=length(qigram); 42 | -------------------------------------------------------------------------------- /mimiclib/YYYYmmDD2DecimalYear.m: -------------------------------------------------------------------------------- 1 | function [DecYear]=YYYYmmDD2DecimalYear(datestring); 2 | % YYYYmmDD2DecimalYear - Converts a datestring in roi_pac format to decimal year (e.g. 3 | % 4 | % Falk Amelung, December 2008 5 | % 6 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7 | 8 | 9 | for i=1:size(datestring,1) 10 | year = str2num(datestring(i,1:4)) ; 11 | month = str2num(datestring(i,5:6)) ; 12 | day = str2num(datestring(i,7:8)) ; 13 | DecYear(i) = year+(datenum(year,month,day) - datenum(year,1,1) ) / 365.25; 14 | end 15 | 16 | DecYear = DecYear'; 17 | -------------------------------------------------------------------------------- /mimiclib/add_struct.m: -------------------------------------------------------------------------------- 1 | function [OutStruct]=add_struct(struct1,struct2) 2 | 3 | % 4 | % Function to add one structure (struct2) to another one (struct1) 5 | % 6 | % [OutStruct]=add_struct(struct1,struct2) 7 | % 8 | % N Gourmelen - August 2007 9 | % 10 | 11 | if nargin < 2 12 | exit ('Error, not enough arguments'); 13 | end 14 | 15 | fields=fieldnames(struct2); 16 | 17 | for ni=1:length(fields) 18 | 19 | struct1.(genvarname(list2str(fields(ni))))=struct2.(genvarname(list2str(fields(ni)))); 20 | 21 | end 22 | 23 | OutStruct=struct1; 24 | -------------------------------------------------------------------------------- /mimiclib/bracketedstring2cell.m: -------------------------------------------------------------------------------- 1 | function [list]=bracketedstring2cell(instring) 2 | %bracketedstring2cell - splits a brackedted string separated by blanks into a cell 3 | % 4 | %usage: [list]=bracketed_dates_2_two_dates(instring); 5 | % 6 | %Input: instring string of the form '[ 030101 080115 ]' 7 | % 8 | %Output: date1,date2 strings of the form '030101' '080115' 9 | % 10 | % Falk Amelung, January 2009 11 | % 12 | % TODO: It actually should return dates in the form [2003.12 2008.18] as this is the form used for time_span 13 | % and then we have to make SelectPairs working with this. 14 | % TODO: Even better would be a function that reads any input related to a date and converts in a format 15 | % such as 2003.12 used throughout geodomod. Even better, we should use throughout geodmod the same matlab date 16 | % format. 17 | % 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19 | 20 | tmp = strtrim(instring(strfind(instring,'[')+1:strfind(instring,']')-1)); 21 | list = str2list(tmp); 22 | -------------------------------------------------------------------------------- /mimiclib/logmessage.m: -------------------------------------------------------------------------------- 1 | function []=logmessage(string,level); 2 | %logmessage - displays message and writes to log file 3 | % 4 | %usage: []=logmessage('Hello friend'); 5 | % 6 | % This function is meant to record messages to 7 | % various log files depending on the message level. 8 | % The writing of log files will be switched 'on'/'off' 9 | % by a global variable. A time stamp could also be controlled 10 | % by a global variable. 11 | % 12 | % In the current version the string is only written to the screen. 13 | % 14 | % Falk Amelung, September 2006 15 | % 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | [st,i]=dbstack ; 18 | if length(st) >= 3 19 | str=sprintf('%-13s>%-13s: %s', st(3).name,st(2).name,string); 20 | elseif length(st)==2 21 | str=sprintf('%-26s: %s',st(2).name,string); 22 | else 23 | str=sprintf('%-26s:', mfilename,string); 24 | end 25 | disp(str) 26 | -------------------------------------------------------------------------------- /mimiclib/makeSTD.m: -------------------------------------------------------------------------------- 1 | function [stdMap] = makeSTD(data,win) 2 | 3 | % 4 | % Compute the std of a input matrice over the area defined by the window 5 | % sixe "win" 6 | % 7 | % [stdMap] = makeSTD(data,win) 8 | % 9 | % data : input structure. (LoadData format) 10 | % 11 | % win is pixel radius of circle window 12 | % 13 | % 14 | % N. Gourmelen Jan. 2010 15 | % 16 | 17 | %%%%%%%%%%%%%%%%%%%% 18 | if ~isstruct(data) data.data = data ; end 19 | 20 | se1 = strel('disk',win) ; 21 | nhood = getnhood(se1) ; 22 | 23 | stdMap = stdfilt(data.data,nhood) ; 24 | 25 | 26 | -------------------------------------------------------------------------------- /mimiclib/make_kml_string.m: -------------------------------------------------------------------------------- 1 | function [kml_string]=make_kml_string(data); 2 | % make_kml_string - generates the contents for a kml file 3 | % 4 | % usage: []=make_kml_string(data); 5 | % 6 | % 7 | % Falk Amelung and Scott Baker, May 2007 8 | % 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | image_file = 'image_overlay.jpg'; 11 | 12 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 | %%%%%%%%%%% Get the Coordinates %%%%%%%%% 14 | north_coord = bounds(4); 15 | south_coord = bounds(6); 16 | east_coord = bounds(3); 17 | west_coord = bounds(1); 18 | 19 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 | header1 = ['\n',... 21 | '\n',... 22 | '\n',... 23 | '\n',... 24 | filename,... 25 | '\n\n',... 26 | '\n',... 27 | 'Image overaly created with geodmod',... 28 | '',... 29 | '\n',... 30 | '\n',... 31 | image_file,... 32 | '\n\n',... 33 | '\n']; 34 | 35 | coords = [ sprintf('\t%.6f',north_coord),... 36 | sprintf('\n\t%.6f', south_coord),... 37 | sprintf('\n\t%.6f', east_coord),... 38 | sprintf('\n\t%.6f', west_coord)]; 39 | 40 | footer1 = ['\n\n',... 41 | '\n',... 42 | '\n',... 43 | '\n']; 44 | 45 | kml_string = strcat(header1,coords,footer1); 46 | -------------------------------------------------------------------------------- /mimiclib/manuw/extractregion.m: -------------------------------------------------------------------------------- 1 | function [new] = extractregion(old,polyname); 2 | % extractregion - extracts a region in polygon from image using mouse or existing polygon 3 | % [new] = extractregion(old,polyname); 4 | % 5 | % Function to extract a region from an image using the mouse 6 | % saves polygon mask in 'tmp_lastregion' 7 | % region can be inserted back with INSERTREGION 8 | % 9 | % use polyname if given as polygon 10 | % 11 | 12 | if nargin==0,help extractregion;return;end; 13 | 14 | pixval off 15 | fprintf(1,'Select a polygon using the mouse...\n'); 16 | 17 | if nargin==2 18 | str=sprintf('load %s ', polyname); 19 | eval(str) 20 | else 21 | [BW,Xi,Yi] = roipoly; %Xi and Yi are the polyn. vortices 22 | end 23 | % convert binary image to indexed imag 24 | [BW,map]=gray2ind(BW); 25 | % convert indexed image to intensity image 26 | BW = ind2gray(BW,map); 27 | % create the mask 28 | BW(find(BW==0))=NaN; 29 | % mask out the zero-values 30 | new=double(BW).*old; 31 | 32 | figure; 33 | imagesc(new) ; axis image 34 | save tmp_lastregion BW 35 | -------------------------------------------------------------------------------- /mimiclib/qtsjonni2qtgeodmod.m: -------------------------------------------------------------------------------- 1 | function [dataset]=qtsjonni2qtgeodmod(inData,dataset, basemap, location) 2 | %qtsjonni2qtgeodmod - converts Sjonni's quadtree coordinates into geodmod's coordinate system 3 | % 4 | % FA Jan 2011 5 | % 6 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7 | 8 | if (nargin==3) location='Haiti'; end 9 | 10 | switch location 11 | 12 | case {'Haiti'} 13 | dataset.datavec = inData.sv'; 14 | dataset.radarlook = inData.los; 15 | dataset.cov = inData.cov; 16 | dataset.Ndata = length(dataset.datavec); 17 | 18 | dataset.coord = [round(inData.cnt(1,:)/basemap.x_posting); round(-inData.cnt(2,:)/basemap.y_posting)] ; 19 | dataset.cx = round(inData.cx/basemap.x_posting); 20 | dataset.cy = round(-inData.cy/basemap.y_posting); 21 | %dataset.cy = round((inData.cy+size(basemap.data,1)*basemap.y_posting)/basemap.y_posting); 22 | end 23 | -------------------------------------------------------------------------------- /mimiclib/save_enu_roi_pac.m: -------------------------------------------------------------------------------- 1 | function []=save_enu_roi_pac(filename,data) 2 | % save_enu_roi_pac - saves a *enu file (EastNorthUp) with a rsc file 3 | % 4 | % function []=save_enu_roi_pac(filename,data) 5 | % 6 | % writes data in typical structure format (3 datasets) into enu file 7 | % similar as hgt format but 3 interleaved datasets 8 | % NaNs are replaced by 0s. 9 | % 10 | % TODO: Could be simply modified to write a *hgt file if the 11 | % if length(data)=2, and also to take the format ('float32', 'int16') as 12 | % input option with 'float32' as the default. 13 | % 14 | if nargin==0,help save_enu_roi_pac;return;end; 15 | 16 | % filenames 17 | enufname=[filename '.enu']; 18 | rscfname=[filename '.enu' '.rsc']; 19 | 20 | % 21 | % save data 22 | % 23 | logmessage(sprintf('saving... %s', enufname)) 24 | fid1=fopen(enufname,'wb'); 25 | data(1).data(isnan(data(1).data))=0; 26 | data(2).data(isnan(data(2).data))=0; 27 | data(3).data(isnan(data(3).data))=0; 28 | 29 | Ttmp=[data(1).data';data(2).data';data(3).data']; 30 | fwrite(fid1,Ttmp,'float32'); 31 | fclose(fid1); 32 | 33 | % 34 | % save rscfile 35 | % 36 | str=char( ['WIDTH ' num2str(size(data(1).data,2))]) ; 37 | str=char(str, ['FILE_LENGTH ' num2str(size(data(1).data,1))]) ; 38 | str=char(str, ['X_FIRST ' num2str(data(1).x_first)]) ; 39 | str=char(str, ['Y_FIRST ' num2str(data(1).y_first)]) ; 40 | str=char(str, ['X_STEP ' num2str(data(1).x_step)]) ; 41 | str=char(str, ['Y_STEP ' num2str(data(1).y_step)]) ; 42 | str=char(str, ['X_UNIT ' num2str(data(1).x_unit)]) ; 43 | str=char(str, ['UNIT ' num2str(data(1).Unit)]) ; 44 | 45 | logmessage(sprintf('saving... %s', rscfname)) 46 | fid1=fopen(rscfname,'w'); 47 | for i=1:size(str,1) 48 | fprintf(fid1,'%s\n',str(i,:)); 49 | end 50 | fclose(fid1); 51 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/L2YX.m: -------------------------------------------------------------------------------- 1 | function [Y,X]=L2YX(inputf,lenght) 2 | 3 | % Gives 2D coordinates of the position in a row 4 | 5 | X=ceil(inputf/lenght); 6 | Y=inputf-((X-1)*lenght); -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/LL2ind_igram.m: -------------------------------------------------------------------------------- 1 | function [locind,locindvect,locind_saved,outind]=LL2ind_igram(igram,InvLoc) 2 | 3 | % Transform [Lat Lon] data into Indices for a given igram.data 4 | % [locind,locindvect]=LL2ind(igram,InvLoc) 5 | 6 | % N.G. November 2005 7 | 8 | if size(InvLoc,2)~=2 9 | InvLoc=InvLoc' ; 10 | end 11 | 12 | Lon0=igram(1).x_first;Lat0=igram(1).y_first; 13 | Incx=igram(1).x_step ;Incy=igram(1).y_step; 14 | 15 | locind(:,2)=round((InvLoc(:,2)-Lon0)/Incx+1); 16 | locind(:,1)=round((InvLoc(:,1)-Lat0)/Incy+1); 17 | 18 | small1=find(locind(:,1)<0); 19 | small2=find(locind(:,2)<0); 20 | big1=find(locind(:,1)>igram.file_length); 21 | big2=find(locind(:,2)>igram.width); 22 | 23 | outind=[small1; small2 ;big1; big2];outind=unique(outind); 24 | 25 | locind_saved=locind; 26 | locind(outind,:)=[]; 27 | 28 | locindvect=YX2L(locind(:,1),locind(:,2),igram.file_length); 29 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/YX2L.m: -------------------------------------------------------------------------------- 1 | function [L]=YX2L(Y,X,File_length) 2 | 3 | % Transform Y X indices to vector 4 | % 5 | % [L]=YX2L(Y,X,File_length) 6 | % 7 | 8 | L=(X-1)*File_length+Y; 9 | 10 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/cal2jd.m: -------------------------------------------------------------------------------- 1 | function jd=cal2jd(yr, mn, dy) 2 | % CAL2JD Converts calendar date to Julian date using algorithm 3 | % from "Practical Ephemeris Calculations" by Oliver Montenbruck 4 | % (Springer-Verlag, 1989). Uses astronomical year for B.C. dates 5 | % (2 BC = -1 yr). Non-vectorized version. See also DOY2JD, GPS2JD, 6 | % JD2CAL, JD2DOW, JD2DOY, JD2GPS, JD2YR, YR2JD. 7 | % Version: 24 Apr 99 8 | % Usage: jd=cal2jd(yr,mn,dy) 9 | % Input: yr - calendar year 10 | % mn - calendar month 11 | % dy - calendar day (including factional day) 12 | % Output: jd - jJulian date 13 | 14 | if nargin ~= 3 15 | warning('Incorrect number of arguments'); 16 | return; 17 | end 18 | 19 | if mn > 2 20 | y = yr; 21 | m = mn; 22 | else 23 | y = yr - 1; 24 | m = mn + 12; 25 | end 26 | date1=4+31*(10+12*1582); % Last day of Julian calendar (1582.10.04) 27 | date2=15+31*(10+12*1582); % First day of Gregorian calendar (1582.10.15) 28 | date=dy+31*(mn+12*yr); 29 | if date <= date1 30 | b = -2; 31 | elseif date >= date2 32 | b = fix(y/400) - fix(y/100); 33 | else 34 | warning('Dates between October 5 & 15, 1582 do not exist'); 35 | return; 36 | end 37 | if y > 0 38 | jd = fix(365.25*y) + fix(30.6001*(m+1)) + b + 1720996.5 + dy; 39 | else 40 | jd = fix(365.25*y-0.75) + fix(30.6001*(m+1)) + b + 1720996.5 + dy; 41 | end 42 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/date2j.m: -------------------------------------------------------------------------------- 1 | function J = date2j(yy,mm,dd) 2 | %DATE2J J = date2j(yy,mm,dd) 3 | % 4 | %Returns the Modified Julian Date (MJD) for a given year, month and day. 5 | %If only one input is passed, that input is assumed to be an nx3 matrix, 6 | %where the first, second, and third columns hold the year, month, and day, 7 | %respectively (if fourth, fifth, or sixth columns are present, they are taken 8 | %to be hours, minutes, and seconds). 1900 is added to the year values if 9 | %they are two digits and greater than 80, otherwise 2000 is added. 10 | 11 | % 12 | %Note: add 2400000.5 to the MJD to get the Julian Date (JD). 13 | 14 | % Do some argument checking 15 | if nargin == 0 16 | help date2j 17 | return 18 | end 19 | 20 | extra=0; 21 | if nargin == 1 22 | if size(yy,2)>3 23 | extra=yy(:,4)*3600; 24 | if size(yy,2)>4 25 | extra=extra+yy(:,5)*60; 26 | if size(yy,2)>5 27 | extra=extra+yy(:,6); 28 | end 29 | end 30 | end 31 | mm=yy(:,2); 32 | dd=yy(:,3); 33 | yy=yy(:,1); 34 | end 35 | 36 | 37 | yy=yy+(yy<100)*1900+(yy<80)*100; 38 | J=floor(365.25*(yy-(mm<=2)))+floor(30.6001*(mm+1+12*(mm<=2)))+dd-679019+extra/86400; 39 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/dealfalk.m: -------------------------------------------------------------------------------- 1 | function varargout = dealfalk(varargin) 2 | %DEAL Deal inputs to outputs. 3 | % same as deal but allows for variable output 4 | % e.g. 5 | % [D1,D2,D3,D4,D5]=deal(dataset.Ndata) gives an error 6 | % if dataset.Ndata has only 4 array elements but 7 | % [D1,D2,D3,D4,D5]=dealfalk(dataset.Ndata) 8 | % returns D_5=[] or D_5=0 for logical quantities 9 | 10 | % commented out some lines on Sep 12 05 because it did not work with only one input argument 11 | %if nargin==1, 12 | % varargout = varargin(ones(1,max(1,nargout))); 13 | %else 14 | tmp=cell(1,nargout); 15 | for i=1:nargin 16 | tmp{i} = varargin{i}; 17 | end 18 | varargout = tmp; 19 | if islogical(varargout{1}) % assign false to empty fields 20 | for i=1:length(varargout) 21 | if isempty(varargout{i}) varargout{i}=false; end ; 22 | end 23 | end 24 | %end 25 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/doy2jd.m: -------------------------------------------------------------------------------- 1 | function jd=doy2jd(yr,doy); 2 | % DOY2JD Converts year and day of year to Julian date. 3 | % . Non-vectorized version. See also CAL2JD, GPS2JD, 4 | % JD2CAL, JD2DOW, JD2DOY, JD2GPS, JD2YR, YR2JD. 5 | % Version: 24 Apr 99 6 | % Usage: jd=doy2jd(yr,doy) 7 | % Input: yr - year 8 | % doy - day of year 9 | % Output: jd - Julian date 10 | 11 | if nargin ~= 2 12 | warning('Incorrect number of arguments'); 13 | return; 14 | end 15 | 16 | jd = cal2jd(yr,1,0) + doy; 17 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/ecef2lla.m: -------------------------------------------------------------------------------- 1 | function [lat,lon,alt] = ecef2lla(x,y,z) 2 | 3 | % ECEF2LLA - convert earth-centered earth-fixed (ECEF) cartesian coordinates to latitude, longitude, and altitude 4 | % 5 | % USAGE: 6 | % [lat,lon,alt] = ecef2lla(x,y,z) 7 | % 8 | % lat = geodetic latitude (radians) 9 | % lon = longitude (radians) 10 | % alt = height above WGS84 ellipsoid (m) 11 | % x = ECEF X-coordinate (m) 12 | % y = ECEF Y-coordinate (m) 13 | % z = ECEF Z-coordinate (m) 14 | % 15 | % Notes: (1) This function assumes the WGS84 model. 16 | % (2) Latitude is customary geodetic (not geocentric). 17 | % (3) Inputs may be scalars, vectors, or matrices of the same 18 | % size and shape. Outputs will have that same size and shape. 19 | % (4) Tested but no warranty; use at your own risk. 20 | % (5) Michael Kleder, April 2006 21 | 22 | 23 | % WGS84 ellipsoid constants: 24 | a = 6378137; 25 | e = 8.1819190842622e-2; 26 | 27 | % calculations: 28 | b = sqrt(a^2*(1-e^2)); 29 | ep = sqrt((a^2-b^2)/b^2); 30 | p = sqrt(x.^2+y.^2); 31 | th = atan2(a*z,b*p); 32 | lon = atan2(y,x); 33 | lat = atan2((z+ep^2.*b.*sin(th).^3),(p-e^2.*a.*cos(th).^3)); 34 | N = a./sqrt(1-e^2.*sin(lat).^2); 35 | alt = p./cos(lat)-N; 36 | 37 | % return lon in range [0,2*pi) 38 | lon = mod(lon,2*pi); 39 | 40 | % correct for numerical instability in altitude near exact poles: 41 | % (after this correction, error is about 2 millimeters, which is about 42 | % the same as the numerical precision of the overall function) 43 | 44 | k=abs(x)<1 & abs(y)<1; 45 | alt(k) = abs(z(k))-b; 46 | 47 | return 48 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/ell2xyz.m: -------------------------------------------------------------------------------- 1 | function [x,y,z]=ell2xyz(lat,lon,h,a,e2) 2 | % ELL2XYZ Converts ellipsoidal coordinates to cartesian. 3 | % Vectorized. 4 | % Version: 18 Jan 96 5 | % Useage: [x,y,z]=ell2xyz(lat,lon,h,a,e2) 6 | % Input: lat - vector of ellipsoidal latitudes (radians) 7 | % lon - vector of ellipsoidal E longitudes (radians) 8 | % h - vector of ellipsoidal heights (m) 9 | % a - ref. ellipsoid major semi-axis (m) 10 | % e2 - ref. ellipsoid eccentricity squared 11 | % Output: x \ 12 | % y > vectors of cartesian coordinates in CT system (m) 13 | % z / 14 | 15 | v = a./sqrt(1-e2*sin(lat).*sin(lat)) ; 16 | x = (v+h).*cos(lat).*cos(lon) ; 17 | y = (v+h).*cos(lat).*sin(lon) ; 18 | z = (v.*(1-e2)+h).*sin(lat) ; 19 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/get_polygon.m: -------------------------------------------------------------------------------- 1 | function [outvect] = get_polygon(data) 2 | 3 | % 4 | % Gather indices of an image by mouse clic. 5 | % 6 | % [outvect] = get_polygon(data) 7 | % 8 | % 9 | % N. Gourmelen, February 2008 10 | % 11 | 12 | ni = 1 ; ny = 1 ; testval = 1; 13 | 14 | hh = figure ; set(hh,'Position',[0 100 600 450]) ; imagesc(data) ; 15 | 16 | while testval == 1 17 | [li,Li,testvaln] = ginput(1) ; 18 | outvect(ny).poly(:,ni) = round([Li;li]) ; 19 | hold on ; plot(outvect(ny).poly(2,:),outvect(ny).poly(1,:),'w-') ; 20 | ni = ni+1; 21 | 22 | if testvaln==3 23 | user_in = input('More polygon? Y/N [N]: ', 's'); 24 | if isempty(user_in) user_in = 'N' ; end 25 | if strcmp(user_in,'N') testval = 0 ; 26 | else testval = 1 ; ny = ny +1 ; ni = 1 ; end 27 | end 28 | end 29 | 30 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/getfields.m: -------------------------------------------------------------------------------- 1 | function [outfield] = getfields(structure,field,outtype); 2 | 3 | % 4 | % [outfield] = getfields(structure,field); 5 | % 6 | % structure : input structure 7 | % 8 | % field : field for which you want the values 9 | % 10 | % outtype : 'cell', 'string' (default) 11 | % 12 | % 13 | % N. Gourmelen, November 2007 14 | % 15 | 16 | for ni=1:length(structure) 17 | tmp=structure(ni).(genvarname(field)); 18 | if (nargin==3 && strcmp(outtype,'cell')) 19 | tmp={tmp}; 20 | end 21 | outfield(ni,:)=tmp; 22 | end 23 | 24 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/isalpha.m: -------------------------------------------------------------------------------- 1 | function t = isalpha(c) 2 | %ISALPHA True for letters. 3 | % 4 | % For a string C, ISALPHA(C) is 1 for letters and 0 otherwise. 5 | % 6 | % See also: ISALNUM, ISASCII, ISDIGIT, ISLOWER, ISPRTCHR, ISUPPER, 7 | % ISXDIGIT. 8 | 9 | % Author: Peter J. Acklam 10 | % Time-stamp: 2002-03-03 13:51:09 +0100 11 | % E-mail: pjacklam@online.no 12 | % URL: http://home.online.no/~pjacklam 13 | 14 | error(nargchk(1, 1, nargin)); 15 | 16 | t = isletter(c); 17 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/isodd.m: -------------------------------------------------------------------------------- 1 | function res = isodd(in) 2 | % ISODD True for odd numbers. 3 | % ISODD(IN) returns 1 if all elements of IN are odd, 4 | % and 0 otherwise. 5 | % See also ISEVEN, ISINT, REM, MOD. 6 | % 7 | 8 | % $Revision: 1.1.1.1 $ $Date: 2008-08-12 16:22:13 $ 9 | % Bert Kampes, 31-Mar-2000 10 | 11 | res=0; 12 | if(rem(in,2))res=1;end; 13 | 14 | %%% EOF 15 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/jd2cal.m: -------------------------------------------------------------------------------- 1 | function [yr,mn,dy]=jd2cal(jd) 2 | % JD2CAL Converts Julian date to calendar date using algorithm 3 | % from "Practical Ephemeris Calculations" by Oliver Montenbruck 4 | % (Springer-Verlag, 1989). Must use astronomical year for B.C. 5 | % dates (2 BC = -1 yr). Non-vectorized version. See also CAL2JD, 6 | % DOY2JD, GPS2JD, JD2DOW, JD2DOY, JD2GPS, JD2YR, YR2JD. 7 | % Version: 24 Apr 99 8 | % Usage: [yr, mn, dy]=jd2cal(jd) 9 | % Input: jd - Julian date 10 | % Output: yr - year of calendar date 11 | % mn - month of calendar date 12 | % dy - day of calendar date (including decimal) 13 | 14 | if nargin ~= 1 15 | warning('Incorrect number of arguments'); 16 | return; 17 | end 18 | if jd < 0 19 | warning('Julian date must be greater than or equal to zero'); 20 | return; 21 | end 22 | 23 | a = fix(jd+0.5); 24 | if a < 2299161 25 | c = a + 1524; 26 | else 27 | b = fix( (a-1867216.25) / 36524.25 ); 28 | c = a + b - fix(b/4) + 1525; 29 | end 30 | d = fix( (c-122.1)/365.25 ); 31 | e = fix(365.25*d); 32 | f = fix( (c-e) / 30.6001 ); 33 | dy = c - e - fix(30.6001*f) + rem((jd+0.5),a); 34 | mn = f - 1 - 12*fix(f/14); 35 | yr = d - 4715 - fix( (7+mn)/10 ); 36 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/list2str.m: -------------------------------------------------------------------------------- 1 | function [str]=list2str(cellstr) 2 | % list2str - converts cellstr into str (elements separated by blanks) 3 | % 4 | % usage: str=list2str(cellstr) 5 | % 6 | % str contains elements of cellstr separated by blanks 7 | % 8 | % FA May 2002 9 | % 10 | % see also: str2list 11 | % 12 | tmp=char(cellstr); 13 | str=[]; 14 | for i=1:size(tmp,1) 15 | tmpstr=sprintf('%s?',cellstr{i}) ; str=strcat(str,tmpstr); 16 | end 17 | 18 | str=strrep(str,'?',' '); 19 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/mmax.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/tobereplacedlib/mmax.p -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/mmin.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/tobereplacedlib/mmin.p -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/nanmedfilt2.m: -------------------------------------------------------------------------------- 1 | function b=nanmedfilt2(a,m,n,maxnan) 2 | % nanmedfilt2 - median filter ignoring NANs 3 | % 4 | % usage: newdata=nanmedfilt2(data,m,n,maxnan) 5 | % 6 | % input: data: image to filter 7 | % m,n: array size for median filtering 8 | % maxnan: maximumm number of nan pixel allowed for each median computation 9 | % (n*m fills wholes) 10 | % 11 | % output: newdata: median filtered data 12 | % 13 | % FA 18 June 2001 14 | % 15 | 16 | if nargin==0, help nanmedfilt2; end; 17 | b=a; 18 | mhalf=floor(m/2); 19 | nhalf=floor(n/2); 20 | for i=mhalf+1:size(a,1)-mhalf 21 | for j=nhalf+1:size(a,2)-nhalf 22 | tmp=ones(1,n*m); 23 | tmp1 = a(i-mhalf:i+mhalf,j-nhalf:j+nhalf) ; 24 | tmp(:) = a(i-mhalf:i+mhalf,j-nhalf:j+nhalf) ; 25 | tmp(isnan(tmp))=[]; 26 | if m*n-length(tmp) >= maxnan , tmp=nan; end % check how many nan's 27 | b(i,j)=median(median( tmp )); 28 | end 29 | end 30 | 31 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/nummatch.m: -------------------------------------------------------------------------------- 1 | function [Indices]=nummatch(Nums1,Nums2) 2 | 3 | % Find common value in two 1-column files, returns indices of value of vector 1, verctor 2 and common valuesvalue 4 | % 5 | % [Indices]=nummatch(Nums1,Nums2) 6 | % 7 | % N. Gourmelen 8 | % 9 | 10 | Indices=[]; 11 | p=0; 12 | for i=1:size(Nums1,1) 13 | 14 | d=find(Nums2==Nums1(i)); 15 | 16 | if d~=0 17 | 18 | p=p+1; 19 | Indices(p,:)=[i d Nums1(i)]; 20 | 21 | end 22 | 23 | end 24 | 25 | if p==0 26 | 27 | p=1; 28 | Indices(p,:)=[-9999 -9999 -9999]; 29 | 30 | end 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/resampledata.m: -------------------------------------------------------------------------------- 1 | function [varargout] = resampledata(resamplefac,varargin) 2 | %resampledata - resamples data on smaller or lower grid 3 | % 4 | % INPUT: 5 | % resamplefac - factor for new grid (0.2 is 5 times smaller and 2 is twicw bigger) 6 | % data - can be a regular 2D dataset, an rgb image ((:,:,3) or jpg image 7 | % 8 | % OUTPUT: 9 | % ndata1,ndata2,... - resampled data 10 | % 11 | % FA, 7/2008 12 | 13 | data = varargin{1}; 14 | xi = linspace(1,size(data,2),size(data,2)*resamplefac); 15 | yi = linspace(1,size(data,1),size(data,1)*resamplefac); 16 | %x = linspace(1,size(data,2),size(data,2)); % not necessary becaue interp2 assumes equally spaced 17 | %y = linspace(1,size(data,1),size(data,1)); % meshgrid (plaid) format 18 | %[xx,yy] = meshgrid(x,y); 19 | %[xxi,yyi]= meshgrid(xi,yi); 20 | 21 | for i=1:length(varargin) 22 | data = varargin{i}; 23 | 24 | if size(data,1)>1 % for regular 2-D data array (or 2-D-by-3 rgbim) 25 | ndata = zeros(length(xi),length(yi),size(data,3)); 26 | for j=1:size(data,3) % size(data,3) is 3 for rgb image 27 | ndata(:,:,j)= interp2(data(:,:,j),xi',yi); 28 | end 29 | else 30 | ndata = interp1(data,xi'); % for 1-D vecor (x,y-axis) 31 | end 32 | 33 | varargout(i) = {ndata}; 34 | end 35 | 36 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/smooth.m: -------------------------------------------------------------------------------- 1 | function [outdata] = smooth(indata,indistance,smoothing_distance) 2 | 3 | % 4 | % Smooth data using a window averaging set by the keyword smoothing distance 5 | % 6 | % indata : Data to smooth 7 | % indistance : Location of data 8 | % smoothing_distance : window length (same unit as indistance) 9 | % 10 | % Output: 11 | % outdata: Smoothed data, same size as indata 12 | % 13 | % N. Gourmelen, Feb 2008 14 | % 15 | 16 | ld = length(indata) ; 17 | outdata = zeros(ld,1) ; 18 | filterhalf = smoothing_distance/2 ; 19 | 20 | for ni=1:ld, 21 | position = indistance(ni) ; 22 | neighborid = find(abs(position-indistance) <= filterhalf) ; 23 | scale = filterhalf - abs(position-indistance(neighborid)) ; 24 | outdata(ni) = sum(indata(neighborid).*scale)./sum(scale) ; 25 | end 26 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/str2list.m: -------------------------------------------------------------------------------- 1 | function [strlist]=str2list(str) 2 | % str2list - converts string into a cellstr 3 | % 4 | % usage: strlist=str2list(str) 5 | % 6 | % strlist contains elements of str separated by blanks 7 | % 8 | % FA May 2002 9 | % 10 | % see also: list2str 11 | % 12 | str=strjust(str,'left'); str=deblank(str); %removes heading and trailing blanks 13 | str(findstr(str,' '))=[]; 14 | list=[1 findstr(str,' ')+1]; 15 | 16 | for i=1:length(list) 17 | if i size(file,1) | Cindices(i) > size(file,2) 16 | 17 | result(i,1)=NaN; 18 | 19 | else 20 | 21 | result(i,1)=file(Lindices(i),Cindices(i)); 22 | 23 | end 24 | 25 | end 26 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/y2yymmdd.m: -------------------------------------------------------------------------------- 1 | function [YYMMDD]=y2yymmdd(date) 2 | 3 | [yr,mm,dd] = jd2cal(yr2jd(date)); 4 | 5 | YYMMDD = [sprintf('%02.f',yr),sprintf('%02.0f',mm),sprintf('%02.0f',dd)]; 6 | YYMMDD = YYMMDD(3:end); 7 | 8 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/yr2jd.m: -------------------------------------------------------------------------------- 1 | function jd=yr2jd(yr); 2 | % YR2JD Converts year and decimal of year to Julian date. 3 | % . Non-vectorized version. See also CAL2JD, DOY2JD, 4 | % GPS2JD, JD2CAL, JD2DOW, JD2DOY, JD2GPS, YR2JD 5 | % Version: 24 Apr 99 6 | % Usage: jd=yr2jd(yr) 7 | % Input: yr - year and decimal of year 8 | % Output: jd - Julian date 9 | 10 | if nargin ~= 1 11 | warning('Incorrect number of arguments'); 12 | return; 13 | end 14 | 15 | iyr = fix(yr); 16 | jd0 = cal2jd(iyr,1,1); 17 | days = cal2jd(iyr+1,1,1) - jd0; 18 | doy = (yr-iyr)*days + 1; 19 | jd = doy2jd(iyr,doy); 20 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/yymmdd2y.m: -------------------------------------------------------------------------------- 1 | function [Y]=yyddmm2y(date) 2 | 3 | ind=str2num(date(1)); 4 | 5 | if length(date) == 8 6 | 7 | elseif ind==9 8 | date=str2num(date);date=num2str(date+19000000); 9 | 10 | else 11 | date=str2num(date);date=num2str(date+20000000); 12 | 13 | end 14 | 15 | Y=str2num(date(1:4))+(str2num(date(5:6))-1)/12+(str2num(date(7:8))-1)/365; 16 | -------------------------------------------------------------------------------- /mimiclib/tobereplacedlib/yyyy_ddd2y.m: -------------------------------------------------------------------------------- 1 | function [Y]=yyyy_ddd2y(date) 2 | 3 | for ni=1:length(date) 4 | ind=num2str(sprintf('%0.3f',date(ni))) ; 5 | Y(ni) = str2num(ind(1:4))+(str2num(ind(6:8)))/365; 6 | end -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/addOptimguiOutputFcn.m: -------------------------------------------------------------------------------- 1 | function optStruct = addOptimguiOutputFcn(optStruct,solverName) 2 | %addOptimguiOutputFcn private to OPTIMTOOL. 3 | 4 | % Copyright 2007 The MathWorks, Inc. 5 | % $Revision: 1.1.6.1 $ $Date: 2007/12/10 21:49:46 $ 6 | 7 | % Determine the appropriate field and value for the solver 8 | switch solverName 9 | case {'fmincon','fminunc','lsqnonlin','lsqcurvefit','linprog', ... 10 | 'quadprog','bintprog','fgoalattain','fminimax','fseminf', ... 11 | 'fminsearch','fzero','fminbnd','fsolve','lsqlin','lsqnonneg'} 12 | outputFcnFieldName = 'OutputFcn'; 13 | outputFcnValue = @optimtooloutput; 14 | case 'ga' 15 | outputFcnFieldName = 'OutputFcns'; 16 | outputFcnValue = @gatooloutput; 17 | case 'gamultiobj' 18 | outputFcnFieldName = 'OutputFcns'; 19 | outputFcnValue = @gamultiobjtooloutput; 20 | case 'patternsearch' 21 | outputFcnFieldName = 'OutputFcns'; 22 | outputFcnValue = @psearchtooloutput; 23 | case 'simulannealbnd' 24 | outputFcnFieldName = 'OutputFcns'; 25 | outputFcnValue = @satooloutput; 26 | case 'threshacceptbnd' 27 | outputFcnFieldName = 'OutputFcns'; 28 | outputFcnValue = @thtooloutput; 29 | end 30 | 31 | % We need to adjust 'OutputFcn(s)' field so that the output function is 32 | % called in every iteration. The GUI and solvers interact through the output 33 | % function. 34 | if isempty(optStruct.(outputFcnFieldName)) 35 | optStruct.(outputFcnFieldName) = outputFcnValue; 36 | elseif iscell(optStruct.(outputFcnFieldName)) 37 | % Add 'outputFcnValue' at the end of the array 38 | optStruct.(outputFcnFieldName){end+1} = outputFcnValue; 39 | else % Make it a cell 40 | optStruct.(outputFcnFieldName) = {optStruct.(outputFcnFieldName)}; 41 | % Add 'outputFcnValue' as output function 42 | optStruct.(outputFcnFieldName){end+1} = outputFcnValue; 43 | end 44 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/axes2ecc.m: -------------------------------------------------------------------------------- 1 | function ecc = axes2ecc(in1,in2) 2 | %AXES2ECC Eccentricity of ellipse with given axes lengths 3 | % 4 | % ECC = AXES2ECC(SEMIMAJOR,SEMIMINOR) computes the eccentricity 5 | % of an ellipse (or ellipsoid of revolution) given the semimajor 6 | % and semiminor axes. The input data can be scalar or matrices 7 | % of equal dimensions. 8 | % 9 | % ECC = AXES2ECC(VEC) assumes a 2 element vector (VEC) is supplied, 10 | % where VEC = [SEMIMAJOR SEMIMINOR]. 11 | % 12 | % See also MAJAXIS, MINAXIS, ECC2FLAT, ECC2N. 13 | 14 | % Copyright 1996-2006 The MathWorks, Inc. 15 | % $Revision: 1.9.4.3 $ $Date: 2006/05/24 03:33:34 $ 16 | 17 | checknargin(1,2,nargin,mfilename); 18 | 19 | if nargin == 1 20 | if numel(in1) ~= 2 21 | eid = sprintf('%s:%s:numelVecNot2',getcomp,mfilename); 22 | error(eid,'%s','VEC must be a 2 element vector.'); 23 | else 24 | checkinput(in1,{'double'},{'real','positive'},mfilename,'VEC',1); 25 | semimajor = in1(1); 26 | semiminor = in1(2); 27 | end 28 | elseif nargin == 2 29 | semimajor = in1; 30 | semiminor = in2; 31 | checkinput(semimajor,{'double'},{'real','positive'},mfilename,'SEMIMAJOR',1); 32 | checkinput(semiminor,{'double'},{'real','positive'},mfilename,'SEMIMINOR',2); 33 | if ~isequal(size(semimajor),size(semiminor)) 34 | eid = sprintf('%s:%s:inconsistentSizes',getcomp,mfilename); 35 | error(eid,'%s','Inconsistent input sizes.'); 36 | end 37 | end 38 | 39 | if any(semiminor > semimajor) 40 | eid = sprintf('%s:%s:invalidAxes',getcomp,mfilename); 41 | error(eid,'%s','SEMIMINOR axis may not be larger than SEMIMAJOR axis.'); 42 | end 43 | 44 | % Compute the eccentricity 45 | ecc = sqrt(semimajor.^2 - semiminor.^2) ./ semimajor; 46 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/bwlabelnmex.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/bwlabelnmex.mexa64 -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/bwlabelnmex.mexa64.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/bwlabelnmex.mexa64.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/bwlabelnmex.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/bwlabelnmex.mexglx -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/bwlabelnmex.mexglx.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/bwlabelnmex.mexglx.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/bwlabelnmex.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/bwlabelnmex.mexmaci -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/bwlabelnmex.mexmaci.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/bwlabelnmex.mexmaci.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/checkellipsoid.m: -------------------------------------------------------------------------------- 1 | function ellipsoid = checkellipsoid(ellipsoid, func_name, var_name, arg_pos) 2 | %CHECKELLIPSOID Check validity of reference ellipsoid vector 3 | % 4 | % This function is intentionally undocumented and is intended for 5 | % use only by other Mapping Toolbox functions. Its behavior may 6 | % change, or the function itself may be removed, in a future 7 | % release. 8 | % 9 | % ELLIPSOID = CHECKELLIPSOID(ELLIPSOID, FUNC_NAME, VAR_NAME, ARG_POS) 10 | % ensures that ELLIPSOID is a 1-by-2 vector of the form 11 | % 12 | % [semimajor-axis-length eccentricity] 13 | % 14 | % with 0 <= Eccentricity < 1. (A scalar input is interpreted as the 15 | % semimajor axis length and a zero eccentricity is appended in this case.) 16 | 17 | % Copyright 2007 The MathWorks, Inc. 18 | % $Revision: 1.1.6.1 $ $Date: 2007/10/10 20:50:12 $ 19 | 20 | validateattributes( ... 21 | ellipsoid, {'double'}, {'real', 'finite', 'nonnegative'}, ... 22 | func_name, var_name, arg_pos) 23 | 24 | if numel(ellipsoid) == 1 25 | % Append zero eccentricity given scalar input 26 | ellipsoid(1,2) = 0; 27 | else 28 | % Ensure a 1-by-2 vector 29 | assert(isequal(size(ellipsoid),[1 2]), ... 30 | ['map:' func_name ':ellipsoidNot1By2'], ... 31 | ['Function %s expected its %s input argument, %s,\n', ... 32 | 'to be 1-by-1 or 1-by-2.'], ... 33 | upper(func_name), num2ordinal(arg_pos), var_name); 34 | end 35 | 36 | % Ensure eccentricity < 1 37 | assert(ellipsoid(2) < 1, ... 38 | ['map:' func_name ':invalidEccentricity'], ... 39 | ['Function %s expected the second element (the eccentricity)\n', ... 40 | 'of %s to be in the range [0 1).'], ... 41 | upper(func_name), var_name); 42 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/deg2rad.m: -------------------------------------------------------------------------------- 1 | function angleInRadians = deg2rad(angleInDegrees) 2 | % DEG2RAD Convert angles from degrees to radians 3 | % 4 | % angleInRadians = DEG2RAD(angleInDegrees) converts angle units from 5 | % degrees to radians. 6 | % 7 | % See also: fromDegrees, fromRadians, toDegrees, toRadians, rad2deg. 8 | 9 | % Copyright 2007 The MathWorks, Inc. 10 | % $Revision: 1.1.6.1 $ $Date: 2007/02/11 05:47:38 $ 11 | 12 | angleInRadians = (pi/180) * angleInDegrees; 13 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/ecc2flat.m: -------------------------------------------------------------------------------- 1 | function flat = ecc2flat(parm) 2 | %ECC2FLAT Flattening of ellipse with given eccentricity 3 | % 4 | % f = ECC2FLAT(mat) computes the flattening of an ellipse (or 5 | % ellipsoid of revolution) given the eccentricity. If the 6 | % input is a column vector, then each input is assumed to be an 7 | % eccentricity. If the input has two columns, then the second 8 | % column is assumed to be the eccentricity. This allows geoid 9 | % vectors from ALMANAC to be used as inputs. If the input 10 | % is an n x m matrix, where m,n > 1, then each element is assumed 11 | % to be an eccentricity. 12 | % 13 | % See also FLAT2ECC, ECC2N, MAJAXIS, MINAXIS. 14 | 15 | % Copyright 1996-2007 The MathWorks, Inc. 16 | % $Revision: 1.9.4.4 $ $Date: 2007/11/09 20:23:29 $ 17 | % Written by: E. Byrns, E. Brown 18 | 19 | % Dimension tests 20 | if min(size(parm)) == 1 && ndims(parm) <= 2 21 | col = min(size(parm,2), 2); % Select first or second column 22 | eccent = parm(:,col); % First col if single vector input 23 | % Second col if two column inputs (eg. geoid vecs) 24 | else 25 | eccent = parm; % General matrix input 26 | end 27 | 28 | % Ensure real inputs 29 | eccent = ignoreComplex(eccent, mfilename, 'eccentricity'); 30 | 31 | % Compute the flattening 32 | flat = 1 - sqrt(1 - eccent.^2); 33 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/ecc2n.m: -------------------------------------------------------------------------------- 1 | function n = ecc2n(parm) 2 | %ECC2N n-value of ellipse with given eccentricity 3 | % 4 | % n = ECC2N(mat) computes the parameter n of an ellipse (or 5 | % ellipsoid of revolution) given the eccentricity. n is defined 6 | % as (a-b)/(a+b), where a = semimajor axis, b = semiminor axis. 7 | % If the input is a column vector, then each column element is assumed 8 | % to be an eccentricity. If the input has two columns, then the 9 | % second column is assumed to be the eccentricity. This allows 10 | % geoid vectors from ALMANAC to be used as inputs. If the 11 | % input is a n x m matrix, where m ~= 2, then each element is assumed 12 | % to be an eccentricity and the corresponding n is calculated. 13 | % 14 | % See also N2ECC, ECC2FLAT, MAJAXIS, MINAXIS. 15 | 16 | % Copyright 1996-2007 The MathWorks, Inc. 17 | % $Revision: 1.10.4.4 $ $Date: 2007/11/09 20:23:30 $ 18 | % Written by: E. Byrns, E. Brown 19 | 20 | % Dimension tests 21 | if min(size(parm)) == 1 && ndims(parm) <= 2 22 | col = min(size(parm,2), 2); % Select first or second column 23 | eccent = parm(:,col); % First col if single vector input 24 | % Second col if two column inputs (eg. geoid vecs) 25 | else 26 | eccent = parm; % General matrix input 27 | end 28 | 29 | % Ensure real inputs 30 | eccent = ignoreComplex(eccent, mfilename, 'eccentricity'); 31 | 32 | % Compute n 33 | n = (1 - sqrt(1 - eccent.^2)) ./ (1 + sqrt(1 - eccent.^2)); 34 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/epsm.m: -------------------------------------------------------------------------------- 1 | function epsilon = epsm(angleUnits) 2 | %EPSM Accuracy in angle units for certain map computations 3 | % 4 | % e = EPSM returns the accuracy, in degrees, of certain computations 5 | % performed in the Mapping Toolbox. 6 | % 7 | % e = EPSM(angleUnits) returns the accuracy in the specified angle 8 | % units, which can be 'degrees' or 'radians'. 9 | 10 | % Copyright 1996-2007 The MathWorks, Inc. 11 | % $Revision: 1.9.4.3 $ $Date: 2007/03/27 19:12:00 $ 12 | 13 | epsilon = 1.0E-6; 14 | if nargin > 0 15 | epsilon = fromDegrees(angleUnits, epsilon); 16 | end 17 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/flat2ecc.m: -------------------------------------------------------------------------------- 1 | function eccent = flat2ecc(parm) 2 | %FLAT2ECC Eccentricity of ellipse with given flattening 3 | % 4 | % e = FLAT2ECC(mat) computes the eccentricity of an ellipse (or 5 | % ellipsoid of revolution) given the flattening. If the 6 | % input is a column vector, then each input is assumed to be a 7 | % flattening. If the input has two columns, then the second 8 | % column is assumed to be the flattening. If the input is a 9 | % n x m matrix, where m ~= 2, then each element is assumed to be a 10 | % flattening and the corresponding eccentricity is calculated. 11 | % 12 | % See also ECC2FLAT, N2ECC, AXES2ECC. 13 | 14 | % Copyright 1996-2007 The MathWorks, Inc. 15 | % $Revision: 1.9.4.4 $ $Date: 2007/11/09 20:23:50 $ 16 | % Written by: E. Byrns, E. Brown 17 | 18 | % Dimension tests 19 | if min(size(parm)) == 1 && ndims(parm) <= 2 20 | col = min(size(parm,2), 2); % Select first or second column 21 | flat = parm(:,col); % First col if single vector input 22 | % Second col if two column inputs (eg. geoid vecs) 23 | else 24 | flat = parm; % General matrix input 25 | end 26 | 27 | % Ensure real inputs 28 | flat = ignoreComplex(flat, mfilename, 'flattening'); 29 | 30 | % Compute the eccentricity 31 | eccent = sqrt(2*flat - flat.^2); 32 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/fromDegrees.m: -------------------------------------------------------------------------------- 1 | function varargout = fromDegrees(toUnits, varargin) 2 | %fromDegrees Convert angles from degrees 3 | % 4 | % [angle1, angle2, ...] 5 | % = fromDegrees(toUnits, angle1InDegrees, angle2InDegrees, ...) 6 | % converts angle1InDegrees, angle2InDegrees, ... from degrees to the 7 | % specified output ("to") angle units. toUnits can be either 8 | % 'degrees' or 'radians' and may be abbreviated. The inputs 9 | % angle1InDegrees, angle2InDegrees, ... and their corresponding 10 | % outputs are numeric arrays of various sizes, with size(angleN) 11 | % matching size(angleNInDegrees). 12 | % 13 | % See also: deg2rad, fromRadians, toDegrees, toRadians. 14 | 15 | % Copyright 2007 The MathWorks, Inc. 16 | % $Revision: 1.1.6.1 $ $Date: 2007/02/11 05:47:39 $ 17 | 18 | varargout = abstractAngleConv( ... 19 | 'degrees', 'radians', @deg2rad, toUnits, varargin{:}); 20 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/fromRadians.m: -------------------------------------------------------------------------------- 1 | function varargout = fromRadians(toUnits, varargin) 2 | %fromRadians Convert angles from radians 3 | % 4 | % [angle1, angle2, ...] 5 | % = fromRadians(toUnits, angle1InRadians, angle2InRadians, ...) 6 | % converts angle1InRadians, angle2InRadians, ... from radians to the 7 | % specified output ("to") angle units. toUnits can be either 8 | % 'degrees' or 'radians' and may be abbreviated. The inputs 9 | % angle1InRadians, angle2InRadians, ... and their corresponding 10 | % outputs are numeric arrays of various sizes, with size(angleN) 11 | % matching size(angleNInRadians). 12 | % 13 | % See also: fromDegrees, rad2deg, toDegrees, toRadians. 14 | 15 | % Copyright 2007 The MathWorks, Inc. 16 | % $Revision: 1.1.6.1 $ $Date: 2007/02/11 05:47:40 $ 17 | 18 | varargout = abstractAngleConv( ... 19 | 'radians', 'degrees', @rad2deg, toUnits, varargin{:}); 20 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/ignoreComplex.m: -------------------------------------------------------------------------------- 1 | function A = ignoreComplex(A, function_name, variable_name) 2 | %IGNORECOMPLEX Convert complex input to real and issue warning. 3 | % IGNORECOMPLEX(A, FUNCTION_NAME, VARIABLE_NAME) replaces complex A with 4 | % its real part and issues a warning. 5 | 6 | % Copyright 1996-2003 The MathWorks, Inc. 7 | % $Revision: 1.1.6.1 $ $Date: 2003/08/01 18:16:39 $ 8 | 9 | if ~isnumeric(A) 10 | eid = sprintf('%s:%s:nonNumericInput', getcomp, function_name); 11 | msg = sprintf('Function %s expected its argument %s to be numeric.',... 12 | function_name, variable_name); 13 | error(eid,'%s',msg); 14 | end 15 | 16 | if ~isreal(A) 17 | wid = sprintf('%s:%s:ignoringComplexArg', getcomp, function_name); 18 | warning(wid,'Imaginary parts of complex argument %s ignored in function %s.',... 19 | upper(variable_name), upper(function_name)); 20 | A = real(A); 21 | end 22 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/iptcheckinput.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/iptcheckinput.mexa64 -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/iptcheckinput.mexa64.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/iptcheckinput.mexa64.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/iptcheckinput.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/iptcheckinput.mexglx -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/iptcheckinput.mexglx.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/iptcheckinput.mexglx.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/iptcheckinput.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/iptcheckinput.mexmaci -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/iptcheckinput.mexmaci.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/iptcheckinput.mexmaci.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/meridianarc.m: -------------------------------------------------------------------------------- 1 | function s = meridianarc(phi1, phi2, ellipsoid) 2 | %MERIDIANARC Ellipsoidal distance along meridian 3 | % 4 | % S = MERIDIANARC(PHI1, PHI2, ELLIPSOID) calculates the (signed) distance 5 | % S between latitudes PHI1 and PHI2 along a meridian on the ellipsoid 6 | % defined by the 1-by-2 vector ELLIPSOID. PHI1 and PHI2 are in radians. 7 | % S has the same units as the semimajor axis of the ellipsoid. S is 8 | % negative if phi2 is less than phi1. 9 | % 10 | % See also MERIDIANFWD. 11 | 12 | % Copyright 2004-2006 The MathWorks, Inc. 13 | % $Revision: 1.1.6.3 $ $Date: 2006/12/10 20:05:58 $ 14 | 15 | % The following provides an equivalent (but less efficient) computation: 16 | % 17 | % s = rsphere('rectifying',ellipsoid)... 18 | % * (convertlat(ellipsoid,phi2,'geodetic','rectifying','radians')... 19 | % - convertlat(ellipsoid,phi1,'geodetic','rectifying','radians')); 20 | 21 | n = ecc2n(ellipsoid(2)); 22 | n2 = n^2; 23 | 24 | % Radius of rectifying sphere 25 | r = ellipsoid(1) * (1 - n) * (1 - n2) * (1 + ((9/4) + (225/64)*n2)*n2); 26 | 27 | f1 = (3/2 - (9/16) * n2) * n; 28 | f2 = (15/16 - (15/32) * n2) * n2; 29 | f3 = (35/48) * n * n2; 30 | f4 = (315/512) * n2 * n2; 31 | 32 | % Rectifying latitudes 33 | mu1 = phi1 - f1*sin(2*phi1) + f2*sin(4*phi1) - f3*sin(6*phi1) + f4*sin(8*phi1); 34 | mu2 = phi2 - f1*sin(2*phi2) + f2*sin(4*phi2) - f3*sin(6*phi2) + f4*sin(8*phi2); 35 | 36 | s = r * (mu2 - mu1); 37 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/minaxis.m: -------------------------------------------------------------------------------- 1 | function semiminor = minaxis(in1,in2) 2 | %MINAXIS Semiminor axis of ellipse with given semimajor axis and 3 | % eccentricity 4 | % 5 | % b = MINAXIS(semimajor,e) computes the semiminor axis of an ellipse 6 | % (or ellipsoid of revolution) given the semimajor axis and eccentricity. 7 | % The input data can be scalar or matrices of equal dimensions. 8 | % 9 | % b = MINAXIS(vec) assumes a 2 element vector (vec) is supplied, 10 | % where vec = [semimajor, e]. 11 | % 12 | % See also AXES2ECC, FLAT2ECC, MAJAXIS, N2ECC. 13 | 14 | % Copyright 1996-2007 The MathWorks, Inc. 15 | % $Revision: 1.9.4.4 $ $Date: 2007/11/09 20:24:46 $ 16 | % Written by: E. Byrns, E. Brown 17 | 18 | error(nargchk(1, 2, nargin, 'struct')) 19 | 20 | if nargin == 1 21 | if ~isequal(sort(size(in1)),[1 2]) 22 | error(['map:' mfilename ':mapError'], ... 23 | 'Input must be a 2 element vector') 24 | else 25 | in1 = ignoreComplex(in1, mfilename, 'vec'); 26 | semimajor = in1(1); 27 | eccent = in1(2); 28 | end 29 | elseif nargin == 2 30 | if ~isequal(size(in1),size(in2)) 31 | error(['map:' mfilename ':mapError'], ... 32 | 'Inconsistent input dimensions') 33 | else 34 | semimajor = ignoreComplex(in1, mfilename, 'semimajor'); 35 | eccent = ignoreComplex(in2, mfilename, 'eccentricity'); 36 | end 37 | end 38 | 39 | % Compute the semiminor axis 40 | semiminor = semimajor .* sqrt(1 - eccent.^2); 41 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/nanmean.m: -------------------------------------------------------------------------------- 1 | function m = nanmean(x,dim) 2 | %NANMEAN Mean value, ignoring NaNs. 3 | % M = NANMEAN(X) returns the sample mean of X, treating NaNs as missing 4 | % values. For vector input, M is the mean value of the non-NaN elements 5 | % in X. For matrix input, M is a row vector containing the mean value of 6 | % non-NaN elements in each column. For N-D arrays, NANMEAN operates 7 | % along the first non-singleton dimension. 8 | % 9 | % NANMEAN(X,DIM) takes the mean along dimension DIM of X. 10 | % 11 | % See also MEAN, NANMEDIAN, NANSTD, NANVAR, NANMIN, NANMAX, NANSUM. 12 | 13 | % Copyright 1993-2004 The MathWorks, Inc. 14 | % $Revision: 2.13.4.3 $ $Date: 2004/07/28 04:38:41 $ 15 | 16 | % Find NaNs and set them to zero 17 | nans = isnan(x); 18 | x(nans) = 0; 19 | 20 | if nargin == 1 % let sum deal with figuring out which dimension to use 21 | % Count up non-NaNs. 22 | n = sum(~nans); 23 | n(n==0) = NaN; % prevent divideByZero warnings 24 | % Sum up non-NaNs, and divide by the number of non-NaNs. 25 | m = sum(x) ./ n; 26 | else 27 | % Count up non-NaNs. 28 | n = sum(~nans,dim); 29 | n(n==0) = NaN; % prevent divideByZero warnings 30 | % Sum up non-NaNs, and divide by the number of non-NaNs. 31 | m = sum(x,dim) ./ n; 32 | end 33 | 34 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/num2ordinal.m: -------------------------------------------------------------------------------- 1 | function string = num2ordinal(number) 2 | %NUM2ORDINAL Convert positive integer to ordinal string. 3 | % STRING = NUM2ORDINAL(NUMBER) converts a positive integer to an 4 | % ordinal string. For example, NUM2ORDINAL(4) returns the string 5 | % 'fourth' and NUM2ORDINAL(23) returns '23rd'. 6 | 7 | % Copyright 1996-2003 The MathWorks, Inc. 8 | % $Revision: 1.1.8.2 $ $Date: 2003/08/01 18:17:27 $ 9 | 10 | % I/O Spec 11 | % ======== 12 | % NUMBER Scalar positive integer 13 | % Numeric 14 | % 15 | % NUMBER is not checked for validity. 16 | 17 | if number <= 20 18 | table1 = {'first' 'second' 'third' 'fourth' 'fifth' 'sixth' 'seventh' ... 19 | 'eighth' 'ninth' 'tenth' 'eleventh' 'twelfth' 'thirteenth' ... 20 | 'fourteenth' 'fifteenth' 'sixteenth' 'seventeenth' ... 21 | 'eighteenth' 'nineteenth' 'twentieth'}; 22 | 23 | string = table1{number}; 24 | 25 | else 26 | table2 = {'th' 'st' 'nd' 'rd' 'th' 'th' 'th' 'th' 'th' 'th'}; 27 | ones_digit = rem(number, 10); 28 | string = sprintf('%d%s',number,table2{ones_digit + 1}); 29 | end 30 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/optimguiswitchyard.m: -------------------------------------------------------------------------------- 1 | function varargout = optimguiswitchyard(action,varargin) 2 | %OPTIMGUISWITCHYARD switchyard for optimtool. 3 | % Helper function for the optimtool 4 | 5 | % Copyright 2005-2007 The MathWorks, Inc. 6 | % $Revision: 1.1.6.1 $ $Date: 2007/08/03 21:30:34 $ 7 | 8 | % Calls from Java prefer the if/else version. 9 | % [varargout{1:max(nargout,1)}]=feval(action,varargin{:}); 10 | if nargout==0 11 | feval(action,varargin{:}); 12 | else 13 | [varargout{1:nargout}]=feval(action,varargin{:}); 14 | end 15 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/abstractAngleConv.m: -------------------------------------------------------------------------------- 1 | function output = abstractAngleConv(... 2 | homeUnits, alternateUnits, basicConvFcn, toOrFromUnits, varargin) 3 | % Abstraction of operations needed by the following degrees-radians 4 | % angle unit converters: fromDegrees, fromRadians, toDegrees, and 5 | % toRadians. The first three arguments should be hard-coded within a given 6 | % converter, which should then pass through its remaining arguments. The 7 | % interpretation of the first three arguments is as follows: 8 | % 9 | % homeUnits Angle units given in the function name 10 | % (e.g., 'radians' for toRadians or fromRadians) 11 | % 12 | % alternateUnits Angle units not given in function name 13 | % (e.g., 'degrees' for toRadians or fromRadians) 14 | % 15 | % basicConvFcn Function handle to deg2rad or rad2deg, depending 16 | % on both home units and direction of conversion: 17 | % 18 | % @deg2rad for fromDegrees and toRadians 19 | % @rad2deg for fromRadians and toDegrees 20 | % 21 | % Note that homeUnits and alternateUnits are defined relative to the 22 | % calling function name, so they do not have a fixed correspondence to a 23 | % more literal notion of 'fromUnits' and 'toUnits'. As a result, this 24 | % function may seem somewhat more abstract than necessary, but the 25 | % reward is efficiency -- the calling functions consist of a single line 26 | % with no string comparisons or logic of their own. 27 | 28 | % Copyright 2007 The MathWorks, Inc. 29 | % $Revision: 1.1.6.2 $ $Date: 2007/03/27 19:14:34 $ 30 | 31 | if strncmpi(toOrFromUnits, homeUnits, numel(toOrFromUnits)) 32 | output = varargin; 33 | elseif strncmpi(toOrFromUnits, alternateUnits, numel(toOrFromUnits)) 34 | output = cellfun(basicConvFcn, varargin, 'UniformOutput', false); 35 | else 36 | badAngleUnits(toOrFromUnits) 37 | end 38 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/checkinput_mex.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/checkinput_mex.mexa64 -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/checkinput_mex.mexa64.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/checkinput_mex.mexa64.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/checkinput_mex.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/checkinput_mex.mexglx -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/checkinput_mex.mexglx.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/checkinput_mex.mexglx.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/checkinput_mex.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/checkinput_mex.mexmaci -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/checkinput_mex.mexmaci.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/checkinput_mex.mexmaci.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/checkstruct.m: -------------------------------------------------------------------------------- 1 | function checkstruct(S, function_name, variable_name, argument_position) 2 | %CHECKSTRUCT Verifies that the input is a structure 3 | % CHECKSTRUCT(S, FUNCTION_NAME, VARIABLE_NAME, ARGUMENT_POSITION) 4 | % verifies that S is a structure. If it isn't, CHECKSTRUCT issues an 5 | % error message using FUNCTION_NAME, VARIABLE_NAME, and 6 | % ARGUMENT_POSITION. FUNCTION_NAME is the name of the user-level 7 | % function that is checking the struct, VARIABLE_NAME is the name of the 8 | % struct variable in the documentation for that function, and 9 | % ARGUMENT_POSITION is the position of the input argument to that 10 | % function. 11 | 12 | % See also GEOATTRIBSTRUCT, UPDATEGEOSTRUCT. 13 | 14 | % Copyright 1996-2006 The MathWorks, Inc. 15 | % $Revision: 1.1.6.2 $ $Date: 2006/06/15 20:10:54 $ 16 | 17 | % Verify that the input is a structure 18 | if ~isstruct(S) 19 | eid = sprintf('%s:%s:invalidGeoStruct', getcomp, function_name); 20 | msg = sprintf('%s %s %s %s %s, %s, %s', ... 21 | 'Function', upper(function_name), ... 22 | 'expected its', num2ordinal(argument_position), ... 23 | 'input argument', upper(variable_name), ... 24 | 'to be a structure.'); 25 | error(eid, '%s', msg); 26 | 27 | end 28 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/formJacobian.p: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/formJacobian.p -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/mkconstarray.m: -------------------------------------------------------------------------------- 1 | function out = mkconstarray(class, value, size) 2 | %MKCONSTARRAY creates a constant array of a specified numeric class. 3 | % A = MKCONSTARRAY(CLASS, VALUE, SIZE) creates a constant array 4 | % of value VALUE and of size SIZE. 5 | 6 | % Copyright 1993-2003 The MathWorks, Inc. 7 | % $Revision: 1.8.4.1 $ $Date: 2003/01/26 06:00:35 $ 8 | 9 | out = repmat(feval(class, value), size); 10 | 11 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/optimabout.m: -------------------------------------------------------------------------------- 1 | function optimabout() 2 | %OPTIMABOUT helper that displays the About Box 3 | 4 | % Copyright 2007 The MathWorks, Inc. 5 | % $Revision: 1.1.6.1 $ $Date: 2007/06/14 05:19:11 $ 6 | 7 | a = ver('optim'); 8 | str = sprintf(['Optimization Toolbox ' a.Version '\n',... 9 | 'Copyright 1990-' a.Date(end-3:end) ' The MathWorks, Inc.']); 10 | msgbox(str,'About Optimization Toolbox', 'modal'); 11 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/optimguiclosing.m: -------------------------------------------------------------------------------- 1 | function optimguiclosing() 2 | %OPTIMGUICLOSING GUI helper function to clean up 'result' appdata from 3 | % the MATLAB workspace when the GUI is closed. 4 | 5 | % Copyright 2005-2006 The MathWorks, Inc. 6 | % $Revision: 1.1.6.3 $ $Date: 2007/12/10 21:50:39 $ 7 | 8 | % Remove appdata structures used by optimtool 9 | if isappdata(0,'optimTool_results_121677') 10 | rmappdata(0,'optimTool_results_121677'); 11 | end 12 | 13 | if isappdata(0,'optimTool_Problem_Data') 14 | rmappdata(0,'optimTool_Problem_Data'); 15 | end 16 | 17 | if isappdata(0,'optimTool_Options_Data') 18 | rmappdata(0,'optimTool_Options_Data'); 19 | end 20 | 21 | if isappdata(0,'optimTool_Problem_HashTable') 22 | rmappdata(0,'optimTool_Problem_HashTable'); 23 | end 24 | 25 | if isappdata(0,'optimTool_Options_HashTable') 26 | rmappdata(0,'optimTool_Options_HashTable'); 27 | end 28 | 29 | if isappdata(0,'optim_rand_states_struct') 30 | rmappdata(0,'optim_rand_states_struct'); 31 | end 32 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/optimhelpviewer.m: -------------------------------------------------------------------------------- 1 | function optimhelpviewer() 2 | % OPTIMHELPVIEWER is a helper file for Optimtool. 3 | 4 | % Copyright 2006-2007 The MathWorks, Inc. 5 | % $Revision: 1.1.6.2 $ 6 | 7 | mapfilename = [docroot '/toolbox/optim/helptargets.map']; 8 | try 9 | helpview(mapfilename, 'optimtool'); 10 | catch 11 | message = sprintf('Unable to display help for Optimtool'); 12 | errordlg(message); 13 | end 14 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/ordf.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/ordf.mexa64 -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/ordf.mexa64.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/ordf.mexa64.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/ordf.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/ordf.mexglx -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/ordf.mexglx.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/ordf.mexglx.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/ordf.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/ordf.mexmaci -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/ordf.mexmaci.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/ordf.mexmaci.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/ordf_ordfilt2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1993-2007 The MathWorks, Inc. 3 | * $Revision: 1.2.4.2 $ $Date: 2007/06/04 21:10:12 $ 4 | * 5 | * This file contains a function body for 2-D order-statistic 6 | * filtering. 7 | */ 8 | 9 | (TYPE *pA, TYPE *pB, 10 | mwSize startRow, mwSize startCol, 11 | mwSize Mb, mwSize Nb, mwSize Ma, mwSize order, 12 | mwSignedIndex *offsets, mwSize numOffsets 13 | #ifdef ADD_OFFSET 14 | , double *add 15 | #endif /* ADD_OFFSET */ 16 | ) 17 | { 18 | TYPE *vector; 19 | TYPE *p; 20 | mwSize col; 21 | mwSize row; 22 | mwSize k; 23 | 24 | vector = (TYPE *) mxCalloc(numOffsets, sizeof(*vector)); 25 | 26 | for (col = 0; col < Nb; col++) 27 | { 28 | p = pA + (startCol+col)*Ma + startRow; 29 | for (row = 0; row < Mb; row++) 30 | { 31 | for (k = 0; k < numOffsets; k++) 32 | { 33 | #ifdef ADD_OFFSET 34 | vector[k] = *(p + offsets[k]) + add[k]; 35 | #else 36 | vector[k] = *(p + offsets[k]); 37 | #endif 38 | 39 | } 40 | *pB++ = 41 | SELECT 42 | (vector, numOffsets, order); 43 | p++; 44 | } 45 | } 46 | 47 | mxFree((void *) vector); 48 | } 49 | 50 | #undef TYPE 51 | #undef SELECT 52 | #undef ADD_OFFSET 53 | 54 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/regionpropsmex.mexa64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/regionpropsmex.mexa64 -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/regionpropsmex.mexa64.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/regionpropsmex.mexa64.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/regionpropsmex.mexglx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/regionpropsmex.mexglx -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/regionpropsmex.mexglx.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/regionpropsmex.mexglx.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/regionpropsmex.mexmaci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/regionpropsmex.mexmaci -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/regionpropsmex.mexmaci.csf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geodesymiami/GeodMod/5cfb2b9e8f2ec1d97bccfd0f8bf8f56396ffe1f1/mimiclib/toolboxfiles_map/private/regionpropsmex.mexmaci.csf -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/resetOptimtool.m: -------------------------------------------------------------------------------- 1 | function [selection, optionsModel] = resetOptimtool() 2 | % RESETOPTIMTOOL Reset OPTIMTOOL 3 | % Private to OPTIMTOOL 4 | 5 | % Copyright 2006 The MathWorks, Inc. 6 | % $Revision: 1.1.6.2 $ $Date: 2007/12/10 21:50:44 $ 7 | 8 | % createProblemStruct first two arguments are solverName and defaultSolver. 9 | % In this case, we want to set solverName to "all" so that all fields will 10 | % be cleared. The "defaultSolver" is fmincon 11 | 12 | probStruct = createProblemStruct('all', 'fmincon'); 13 | setappdata(0,'optimTool_Problem_Data',probStruct); 14 | 15 | % Create the empty options structure 16 | options = createOptionsStruct('all',struct('Display', 'off')); % This is the default for the GUI 17 | setappdata(0,'optimTool_Options_Data',options); 18 | 19 | % Remove appdata structures used by optimtool 20 | if isappdata(0,'optimTool_results_121677') 21 | rmappdata(0,'optimTool_results_121677'); 22 | end 23 | 24 | % Reset hash table for problem and options 25 | if isappdata(0,'optimTool_Problem_HashTable') 26 | rmappdata(0,'optimTool_Problem_HashTable'); 27 | end 28 | 29 | if isappdata(0,'optimTool_Options_HashTable') 30 | rmappdata(0,'optimTool_Options_HashTable'); 31 | end 32 | 33 | [selection, optionsModel] = optimguiImportOptions(1); 34 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/private/resetOptimtoolHashTable.m: -------------------------------------------------------------------------------- 1 | function resetOptimtoolHashTable(oldmodelName) 2 | %RESETOPTIMTOOLHASHTABLE reset Optimtool Java hash table stored in MATLAB 3 | % Private to OPTIMTOOL 4 | 5 | % Copyright 2006 The MathWorks, Inc. 6 | % $Revision: 1.1.6.1 $ $Date: 2006/11/11 22:47:58 $ 7 | 8 | % If oldmodel is empty then return else delete it 9 | if isempty(getappdata(0,oldmodelName)) 10 | return; 11 | else 12 | rmappdata(0,oldmodelName); 13 | end 14 | 15 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/toRadians.m: -------------------------------------------------------------------------------- 1 | function varargout = toRadians(fromUnits, varargin) 2 | %toRadians Convert angles to radians 3 | % 4 | % [angle1InRadians, angle2InRadians, ...] 5 | % = toRadians(fromUnits, angle1, angle2, ...) 6 | % converts angle1, angle2, ... to radians from the specified input 7 | % ("from") angle units. fromUnits can be either 'degrees' or 'radians' 8 | % and may be abbreviated. The inputs angle1, angle2, ... and their 9 | % corresponding outputs are numeric arrays of various sizes, with 10 | % size(angleNInRadians) matching size(angleN). 11 | % 12 | % See also: deg2rad, fromDegrees, fromRadians, toDegrees. 13 | 14 | % Copyright 2007 The MathWorks, Inc. 15 | % $Revision: 1.1.6.1 $ $Date: 2007/02/11 05:47:43 $ 16 | 17 | varargout = abstractAngleConv( ... 18 | 'radians', 'degrees', @deg2rad, fromUnits, varargin{:}); 19 | -------------------------------------------------------------------------------- /mimiclib/toolboxfiles_map/zero22pi.m: -------------------------------------------------------------------------------- 1 | function lon = zero22pi(lon, angleunits, method) %#ok 2 | %ZERO22PI Wrap longitudes to [0 360] degree interval 3 | % 4 | % ZERO22PI has been replaced by wrapTo360 (for use when working in 5 | % degrees) and wrapTo2Pi (for use when working in radians). 6 | % 7 | % NEWLON = ZERO22PI(LON) wraps angles in degrees into the 0 to 360 8 | % degree range. 9 | % 10 | % NEWLON = ZERO22PI(LON, ANGLEUNITS) works in the units defined by 11 | % the string ANGLEUNITS, which can be either 'degrees' or 'radians'. 12 | % ANGLEUNITS may be abbreviated and is case-insensitive. 13 | % 14 | % Note 15 | % ---- 16 | % ZERO22PI also accepts an optional third argument, but it is unused 17 | % and does not affect the resulting computation in any way. 18 | 19 | % Copyright 1996-2007 The MathWorks, Inc. 20 | % $Revision: 1.9.4.4 $ $Date: 2007/05/10 13:47:40 $ 21 | 22 | % Note: We determined during work on R2007b that use of the third input 23 | % argument, METHOD, is not implemented. Instead, ZERO22PI simply passes 24 | % the hard-code string 'exact' to NPI2PI. However, because this 25 | % function has been replaced, we will not expand its behavior now. 26 | % Instead, we've removed the three-input syntax from the help. METHOD 27 | % remains in the function declaration, however, to ensure backward 28 | % compatibility -- so that call of the form zero22pi(..., 'exact') would 29 | % contiune to work without errors. 30 | 31 | error(nargchk(1, 3, nargin, 'struct')) 32 | if nargin == 1 33 | angleunits = 'degrees'; 34 | end 35 | 36 | % Convert inputs to radians, then wrap to the -pi to pi range 37 | lon = toRadians(angleunits, lon); 38 | lon = npi2pi(lon,'radians','exact'); 39 | 40 | % Allow points near zero to remain there and shift the points in the 41 | % -pi to 0 range to the pi to 2pi range 42 | epsilon = -epsm('radians'); 43 | nearZero = (lon < epsilon); 44 | lon(nearZero) = lon(nearZero) + 2*pi; 45 | 46 | % Reset near-zero points 47 | lon(lon < 0) = 0; 48 | 49 | % Restore original units 50 | lon = fromRadians(angleunits, lon); 51 | -------------------------------------------------------------------------------- /modellib/GetFactorNonLin.m: -------------------------------------------------------------------------------- 1 | function [FactorNonLin,sourceend]=GetFactorNonLin(par,dataset,objfuncopt); 2 | % 3 | % GetFactorNonLin - calculates an vector for multiplication with pred to account for factor differences between datasets 4 | % 5 | % 6 | % Input: dataset 7 | % 8 | % Output: sourceend - index for last source parameter 9 | % 10 | 11 | FactorNonLin=objfuncopt.FactorNonLin ; 12 | 13 | tmp=cell(length(dataset),1); [tmp{:}]=deal(dataset.Ndata); Ndata =cell2mat(tmp); datind=cumsum(Ndata); 14 | tmp=cell(length(dataset),1); [tmp{:}]=deal(dataset.DataSet); DataSet=tmp; 15 | tmp=cell(length(dataset),1); [tmp{:}]=deal(dataset.ind); ind=(tmp); 16 | 17 | ieast =strmatch('GPSeast' ,DataSet); 18 | if isempty(ieast) lastSAR=length(DataSet)-1; else lastSAR=ieast-1; end % lastSAR is actually length(DataSet), however -1 is necessary because there is not GPS data set 19 | 20 | Factor=ones(datind(end),1); 21 | if strcmp('SAR',FactorNonLin) 22 | fac=par(end); 23 | ind=[1:datind(lastSAR)]; Factor(ind)=Factor(ind)*fac ; 24 | %FactorNonLin=[fac*ones(datind(lastSAR),1); ones((datind(end)-datind(lastSAR)),1)] ; 25 | sourceend=length(par)-1; 26 | elseif strcmp('GPS',FactorNonLin) 27 | fac=par(end); 28 | ind=[datind(lastSAR)+1:length(Factor)]; Factor(ind)=Factor(ind)*fac ; 29 | sourceend=length(par)-1; 30 | elseif strcmp('SARmul',FactorNonLin) 31 | fac=par(end-lastSAR+1:end); 32 | i=1; if length(fac)>=i Factor(ind{i})=fac(i)*Factor(ind{i}); end 33 | i=2; if length(fac)>=i Factor(ind{i})=fac(i)*Factor(ind{i}); end 34 | i=3; if length(fac)>=i Factor(ind{i})=fac(i)*Factor(ind{i}); end 35 | i=4; if length(fac)>=i Factor(ind{i})=fac(i)*Factor(ind{i}); end 36 | i=5; if length(fac)>=i Factor(ind{i})=fac(i)*Factor(ind{i}); end 37 | sourceend=length(par)-length(fac); 38 | end 39 | FactorNonLin=Factor; 40 | 41 | -------------------------------------------------------------------------------- /modellib/InitializeDataset.m: -------------------------------------------------------------------------------- 1 | function [dataset]=InitializeDataset(dataset,inverseopt); 2 | %InitializeDataset - initializes the dataset structure by adding the design matrix G_phaseramp for faster inversions 3 | % 4 | %usage: [dataset]=InitializeDataset(dataset,inverseopt) 5 | % 6 | %Note: This can't be done in Qt2dataset because it depends on the inversion options 7 | % 8 | %FA, June 2007 9 | [d.d,d.coord,d.normalization,d.radarlook,d.datind,d.hgt,d.G_phaseramp,d.D_1,d.D_2,d.D_3,d.D_4,d.D_5,d.D_6,d.D_7,d.D_8]=datasetstructure2data(dataset,inverseopt); 10 | dataset(1).fulldata=d; 11 | -------------------------------------------------------------------------------- /modellib/PrepareDataModelResidual_local_AndPlot.m: -------------------------------------------------------------------------------- 1 | function []=PlotDataModelResidual_local(dataset,modelopt,inverseopt) 2 | %PlotDataModelResidual_local - plots data, model and residual in local coordinate system (using PlotModel) 3 | % 4 | %usage: []=PlotDataModelResidual_local(dataset,modelopt,inverseopt) 5 | % 6 | % dataset data structure 7 | % model model structure 8 | % inverseopt only used to generate string containing inversemodelling method (should be removed) 9 | % 10 | % Falk Amelung, May 2007 11 | % Major simplification 7/2008 12 | % 13 | % 14 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15 | % process default options, and set variables to options % 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | global dir_out 18 | defaultopt.plotmodelopt=struct( ... 19 | 'SampleMethod' , 'Grid' , ... 20 | 'Profile' , 'off' , ... 21 | 'modulo' , 'off' , ... 22 | 'modulo_res' , 'off' , ... 23 | 'Plot' , 'on' ) ; 24 | [plotmodelopt] = process_defaultoptions(inverseopt.plotmodelopt,defaultopt.plotmodelopt); 25 | logmessage(sprintf('[]=%s(%s)',mfilename,inputname(1))); 26 | 27 | plotmodelopt.plotdataopt = inverseopt.plotdataopt; 28 | plotmodelopt.RemoveRamps = inverseopt.PhaseRamp ; % FA, Feb 2008: Got an error in PlotModel for ProjectProfile 29 | plotmodelopt.out_name = [dir_out '/DataModelResidual_local']; 30 | 31 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 32 | disp( GenerateSummary(modelopt,dataset,inverseopt) ); 33 | invpar = modelpar2invpar(modelopt.par.xy,inverseopt.objfuncopt,1) ; 34 | PlotModel(invpar,dataset,inverseopt,plotmodelopt) ; % inverseopt used for 35 | -------------------------------------------------------------------------------- /modellib/README: -------------------------------------------------------------------------------- 1 | To add new models the following functions need to be modified: 2 | InitializeModelopt.m 3 | InitializeInverseopt.m 4 | MakeStringForPlot.m 5 | ForwardModel.m 6 | find_coord_index.m 7 | displotmulti.m 8 | plot_model_parameters.m 9 | -------------------------------------------------------------------------------- /modellib/Solution2ModifiedOptions.m: -------------------------------------------------------------------------------- 1 | function [modinverseopt,modmodelopt] = Solution2ModifiedOptions(N_disloc,modelpar,inverseopt,dataset,roughness) 2 | % GenerateSummary - Calculates RMS, Weights, and writes them into a string 3 | % FA 7/2008 4 | % 5 | 6 | 7 | modmodelopt.Unit = inverseopt.objfuncopt.modelopt.Unit; 8 | modmodelopt.N_disloc = N_disloc; 9 | 10 | 11 | modinverseopt.algorithm = 'Distributed Slip'; 12 | modinverseopt.objfunc = inverseopt.objfunc; 13 | modinverseopt.FollowGradient = inverseopt.FollowGradient; 14 | modinverseopt.plotdataopt = inverseopt.plotdataopt; 15 | modinverseopt.objfuncopt = inverseopt.objfuncopt; 16 | modinverseopt.distribopt = inverseopt.distribopt; 17 | modinverseopt.FactorLin = inverseopt.FactorLin; 18 | modinverseopt.PhaseRamp = inverseopt.PhaseRamp; 19 | modinverseopt.FactorNonLin = inverseopt.FactorNonLin; 20 | modinverseopt.FactorNonLinDelta= inverseopt.FactorNonLinDelta; 21 | modinverseopt.plotmodelopt = inverseopt.plotmodelopt; 22 | modinverseopt.disloc_bounds.xy = [modelpar(:) modelpar(:)]; 23 | modmodelopt.par.xy=modelpar(:); 24 | [modmodelopt] = InitializeModelopt(modmodelopt,inverseopt.plotdataopt.basemap); 25 | [qmodinverseopt] = InitializeInverseopt(dataset,modinverseopt,modmodelopt); 26 | 27 | modinverseopt = qmodinverseopt; 28 | 29 | if exist('roughness','var') modmodelopt.roughness = roughness; end 30 | -------------------------------------------------------------------------------- /modellib/datasetstruct2GPSstruct.m: -------------------------------------------------------------------------------- 1 | function [GPSdata,GPSpred]=datasetstruct2GPSstruct(dataset,basemap) 2 | % 3 | % datasetstructure2data - extracts GPS data from dataset structure (uses pred as data if given) 4 | % 5 | % usage: function [GPS]=datasetstructure2data(dataset,pred); 6 | % 7 | % Input: dataset dataset structure 8 | % 9 | % Output: GPS structures 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | 13 | ieast = strmatch('GPSeast' ,{dataset(:).DataSet}); 14 | inorth = strmatch('GPSnorth',{dataset(:).DataSet}); 15 | iup = strmatch('GPSvert' ,{dataset(:).DataSet}); 16 | 17 | if ieast; GPSdata.xy = dataset(ieast).coord; GPSdata.dcov = dataset(ieast).dcov; 18 | elseif inorth; GPSdata.xy = dataset(inorth).coord; GPSdata.dcov = dataset(inorth).dcov; 19 | elseif iup; GPSdata.xy = dataset(iup).coord; GPSdata.dcov = dataset(iup).dcov; 20 | end 21 | 22 | GPSdata.enu = zeros(3,length(GPSdata.xy)); 23 | GPSdata.sig = zeros(3,length(GPSdata.xy)); 24 | 25 | if exist('basemap','var') 26 | GPSdata.lola = lola2xy(GPSdata.xy,basemap,-1); 27 | end 28 | 29 | if ieast; GPSdata.sig(1,:) = dataset(ieast ).normalization; end 30 | if inorth; GPSdata.sig(2,:) = dataset(inorth).normalization; end 31 | if iup; GPSdata.sig(3,:) = dataset(iup ).normalization; end 32 | 33 | if ieast; GPSdata.enu(1,:) = dataset(ieast ).datavec; end 34 | if inorth; GPSdata.enu(2,:) = dataset(inorth).datavec; end 35 | if iup; GPSdata.enu(3,:) = dataset(iup ).datavec; end 36 | 37 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 38 | 39 | GPSpred = GPSdata; 40 | 41 | if ieast; GPSpred.enu(1,:) = dataset(ieast ).predvec; end 42 | if inorth; GPSpred.enu(2,:) = dataset(inorth).predvec; end 43 | if iup; GPSpred.enu(3,:) = dataset(iup ).predvec; end 44 | 45 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 46 | -------------------------------------------------------------------------------- /modellib/datasetstructure2datastructure.m: -------------------------------------------------------------------------------- 1 | function [data,GPS]=datasetstructure2datastructure(dataset,basemap); 2 | % 3 | % datasetstructure2data - converts dataset structure into data format for modelling 4 | % 5 | % usage: function [d,coord,normalization,radarlook,datind,hgt,D_1,D_2,D_3,D_4,D_5]=datasetstructure2data(dataset); 6 | % 7 | % Input: dataset dislocation geometry 8 | % 9 | % Output: d ,coord 10 | % 11 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 12 | [D_1,D_2,D_3,D_4,D_5,D_6,D_7,D_8] = dealfalk(dataset.exist); 13 | [coord_1,coord_2,coord_3,coord_4,coord_5,coord_6,coord_7,coord_8] = dealfalk(dataset.coord); 14 | [Ndata_1,Ndata_2,Ndata_3,Ndata_4,Ndata_5,Ndata_6,Ndata_7,Ndata_8] = dealfalk(dataset.Ndata); 15 | [SAR_1,SAR_2,SAR_3,SAR_4,SAR_5,SAR_6,SAR_7,SAR_8] = dealfalk(dataset.SAR); 16 | [GPS_1,GPS_2,GPS_3,GPS_4,GPS_5,GPS_6,GPS_7,GPS_8] = dealfalk(dataset.GPS); 17 | [ind_1,ind_2,ind_3,ind_4,ind_5,ind_6,ind_7,ind_8] = dealfalk(dataset.ind); 18 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 19 | 20 | N_SAR = sum([dataset(:).SAR]) 21 | N_GPS = sum([dataset(:).GPS]) 22 | 23 | for i=1:N_SAR 24 | data(i)= dataset(i) ; 25 | end 26 | 27 | GPS.enu(1,:) = dataset(N_SAR+1).datavec(:); 28 | GPS.enu(2,:) = dataset(N_SAR+2).datavec(:); 29 | GPS.xy = dataset(N_SAR+1).coord; 30 | GPS.lola = lola2xy(GPS.xy,basemap,-1); 31 | GPS.Unit = dataset(N_SAR+1).Unit; 32 | if N_GPS==3 GPS.enu(3,:) = dataset(N_SAR+3).datavec(:); end % if vertical given 33 | -------------------------------------------------------------------------------- /modellib/displacement2rangechange.m: -------------------------------------------------------------------------------- 1 | function [rangechange]=displacement2rangechange(u,radarlook) 2 | %displacement2rangechange - converts displacement into range change 3 | % 4 | % INPUT: 5 | % u - displacement vector 6 | % radarlook - unit vector in LOS direction 7 | % 8 | % OUTPUT: 9 | % rangechange 10 | % 11 | % 12 | 13 | udim =size(u,2); 14 | 15 | % the following works fine for udim=1 16 | %rangechange = zeros(length(u)/3,udim); 17 | %utmp = u.*radarlook(:); 18 | %utmp3 = reshape(utmp,3,[]); 19 | %rangechange = sum(utmp3)'; 20 | 21 | rangechange = zeros(length(u)/3,udim); 22 | 23 | utmp = u.*repmat(radarlook(:),1,udim); % multiply element-wise (FA 7/2008) 24 | utmp3 = reshape(utmp,3,[]); % reshape into a 3xNdata arrary 25 | rangechangetmp = sum(utmp3)'; % summ over the 3 components (scalar product) 26 | rangechange = reshape(rangechangetmp,[],udim); % reshape rangechange into one colum for each source 27 | -------------------------------------------------------------------------------- /modellib/distlib/BlockDiag.m: -------------------------------------------------------------------------------- 1 | function [block] = BlockDiag(A1,A2,A3,A4,A5,A6,A7,A8) 2 | % BlockDiag - Creates a block diagonal matrix 3 | % 4 | % Input: A1, A2, A3.... up to 8 matrices 5 | % 6 | % Output: block = a block diagona matrix on the form 7 | % 8 | % | A1 0 0 ... | 9 | % block = | 0 A2 0 ... | 10 | % | 0 0 A3 ... | 11 | 12 | block = A1; 13 | 14 | if nargin>1; [lin,col]=size(block); [li2,co2]=size(A2); block = [block zeros(lin,co2); zeros(li2,col) A2]; end 15 | if nargin>2; [lin,col]=size(block); [li2,co2]=size(A3); block = [block zeros(lin,co2); zeros(li2,col) A3]; end 16 | if nargin>3; [lin,col]=size(block); [li2,co2]=size(A4); block = [block zeros(lin,co2); zeros(li2,col) A4]; end 17 | if nargin>4; [lin,col]=size(block); [li2,co2]=size(A5); block = [block zeros(lin,co2); zeros(li2,col) A5]; end 18 | if nargin>5; [lin,col]=size(block); [li2,co2]=size(A6); block = [block zeros(lin,co2); zeros(li2,col) A6]; end 19 | if nargin>6; [lin,col]=size(block); [li2,co2]=size(A7); block = [block zeros(lin,co2); zeros(li2,col) A7]; end 20 | if nargin>7; [lin,col]=size(block); [li2,co2]=size(A8); block = [block zeros(lin,co2); zeros(li2,col) A8]; end 21 | if nargin>8; disp('Too many arguments'); end 22 | 23 | -------------------------------------------------------------------------------- /modellib/distlib/Extend2Surface.m: -------------------------------------------------------------------------------- 1 | function [dis_geom_new,Shift_dist3D] = Extend2Surface(dis_geom,wid_opt) 2 | % Extend2Surface - Extends a dislocation to the surface 3 | % 4 | % Input: 5 | % dis_geom - (10x1) dislocation [len,width,depth,dip,strik,locE,locN,0,0,1]; 6 | % wid_opt - (1x1) Option for the fault width, 7 | % 0 - extends the fault to surface (fault width increased); 8 | % 1 - moves fault to surface (in fault dip direction, DEFAULT); 9 | % 10 | % Output: 11 | % dis_geom_new - (10x1) new dislocation 12 | 13 | 14 | if nargin < 2; wid_opt=1; end 15 | if nargin ==0 | nargin > 2; help SurfProj; end 16 | 17 | % Input variables: 18 | dlg = dis_geom; 19 | if size(dlg,1)~=10; dlg=dlg';end 20 | 21 | len = dlg(1); 22 | wid = dlg(2); 23 | dep = dlg(3); 24 | dip = dlg(4); 25 | str = dlg(5); 26 | dE = dlg(6); 27 | dN = dlg(7); 28 | 29 | % only for negative fault dips 30 | if dip>0 | dip < -180; disp('Use negative fault dip [-180 to 0]'); end 31 | 32 | % Horizontal Shift 33 | Horiz_shift = dep / tan( dip/180*pi ); 34 | Shift_dist3D = abs ( dep / sin( dip/180*pi ) ); 35 | 36 | % Rotate shift 37 | p = [0 Horiz_shift]'; 38 | a = (360-str+90)/180*pi; 39 | R = [cos(a) -sin(a); sin(a) cos(a)]; 40 | shift = R*p; 41 | 42 | %new dislocation 43 | if wid_opt == 0 44 | wid_new = wid + Shift_dist3D; 45 | dis_geom_new = [len wid_new 0 dip str dE+shift(1) dN+shift(2) dlg(8:10)']'; 46 | else 47 | dis_geom_new = [len wid 0 dip str dE+shift(1) dN+shift(2) dlg(8:10)']'; 48 | end 49 | -------------------------------------------------------------------------------- /modellib/distlib/MakeFaultPatches.m: -------------------------------------------------------------------------------- 1 | function [patches,nHorzEl,nVertEl,ExtendSize]=MakeFaultPatches(par,opt,direction) 2 | %MakeFaultPatches - Generates fault patches from dislocation 3 | % 4 | % usage: [modelopt]=MakeFaultPatches(distribopt,modelopt) 5 | % 6 | % FA 7/2008 based on Sjonni Jonsson's code 7 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8 | % all default options are set in InverseDistrib 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | f=fieldnames(opt) ; for i=1:length(f) eval([char(f{i}) '= opt.(f{i}) ;' ]) ; end 11 | logmessage(sprintf('[]=%s(%s)',mfilename,inputname(1))); 12 | 13 | if ~exist('direction','var') direction=1; end 14 | switch direction 15 | case{1} 16 | 17 | if ~PatchSize PatchSize = [par(1) par(2)]; end %set to length,width of original dislocation if 'off' 18 | 19 | tmp_disloc = par; 20 | 21 | if ExtendToSurface tmp_disloc = Extend2Surface(tmp_disloc); end % Extend Input dislocation to surface 22 | if ~ExtendSize ExtendSize = tmp_disloc(1:2); end 23 | tmp_disloc(1:2) = ExtendSize; 24 | 25 | nHorzEl = round( ExtendSize(1)/PatchSize(1) ); 26 | nVertEl = round( ExtendSize(2)/PatchSize(2) ); 27 | nEl = nHorzEl * nVertEl; 28 | 29 | patches = patchfault(tmp_disloc(1:7)',nHorzEl,nVertEl); 30 | 31 | case{-1} 32 | 33 | otherwise 34 | errordlg('direction must be 1 or -1'); error('user error -- exiting'); 35 | end 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /modellib/distlib/MakeKernel.m: -------------------------------------------------------------------------------- 1 | function [G1, G2, G3] = MakeKernel(patch_geom, slip, xy, nu) 2 | 3 | %% [G1, G2, G3] = MakeKernel(patch_geom, slip, xy, nu) 4 | 5 | %Subroutine to make design matrix for slip 6 | 7 | %Input: 8 | % patch_geom - Patch Geometry 9 | % slip - [strike-slip, dip-slip, opening] 10 | % xy - xy coordinates of statinos 11 | % nu - Poisson's ratio 12 | 13 | [nf,nel] = size(patch_geom); 14 | [nsta,nel2] = size(xy); 15 | ndata = 3*nsta; 16 | 17 | G1 = []; G2 = []; G3 = []; 18 | 19 | if slip(1)~=0 20 | G1 = zeros(ndata,nf); 21 | for i=1:nf 22 | u_rel_1 = abs_disp(nu, [patch_geom(i,:),1,0,0], xy); 23 | G1(:,i) = u_rel_1(:); 24 | end 25 | end 26 | 27 | if slip(2)~=0 28 | G2 = zeros(ndata,nf); 29 | for i=1:nf 30 | u_rel_2 = abs_disp(nu, [patch_geom(i,:),0,1,0], xy); 31 | G2(:,i) = u_rel_2(:); 32 | end 33 | end 34 | 35 | if slip(3)~=0 36 | G3 = zeros(ndata,nf); 37 | for i=1:nf 38 | u_rel_3 = abs_disp(nu, [patch_geom(i,:),0,0,1], xy); 39 | G3(:,i) = u_rel_3(:); 40 | end 41 | end 42 | 43 | 44 | -------------------------------------------------------------------------------- /modellib/distlib/MakeRadarKern.m: -------------------------------------------------------------------------------- 1 | function [K1,K2,K3] = MakeRadarKern(pm,slip,coord,nu,nhe,nve,radarlook,Nsites) 2 | 3 | % FA 07/2008: modified so that it works with radarsat given as 4 | % unit vector (1x3) (Sjonni's old version) and as LOSfield (3xN) 5 | % 6 | % Sjonni Jonsson, modfied by FA 7 | 8 | if length(radarlook)==3 9 | LOSfield_flag=false; 10 | else 11 | LOSfield_flag=true; 12 | end 13 | 14 | [G1, G2, G3] = MakeKernel(pm, slip, coord', nu); 15 | 16 | K1=[];K2=[];K3=[]; 17 | 18 | if slip(1)~=0 19 | K1 = zeros(Nsites,nve*nhe); 20 | for i =1:Nsites 21 | if LOSfield_flag 22 | K1(i,:) = radarlook(i,1:3)*G1(3*(i-1)+1:3*(i-1)+3,:); 23 | else 24 | K1(i,:) = radarlook'*G1(3*(i-1)+1:3*(i-1)+3,:); 25 | end 26 | end 27 | end 28 | 29 | if slip(2)~=0 30 | K2 = zeros(Nsites,nve*nhe); 31 | for i =1:Nsites 32 | if LOSfield_flag 33 | K2(i,:) = radarlook(i,1:3)*G2(3*(i-1)+1:3*(i-1)+3,:); 34 | else 35 | K2(i,:) = radarlook'*G2(3*(i-1)+1:3*(i-1)+3,:); 36 | end 37 | end 38 | end 39 | 40 | if slip(3)~=0 41 | K3 = zeros(Nsites,nve*nhe); 42 | for i =1:Nsites 43 | if LOSfield_flag 44 | K3(i,:) = radarlook(i,1:3)*G3(3*(i-1)+1:3*(i-1)+3,:); 45 | else 46 | K3(i,:) = radarlook'*G3(3*(i-1)+1:3*(i-1)+3,:); 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /modellib/distlib/MakeSmoothingMatrix.m: -------------------------------------------------------------------------------- 1 | function [Lap,Lap_inv]=MakeSmoothMatrix(slip, patches, nhorz, nvert, ExtendSize) 2 | %MakeFaultPatches - Generates smoothing matrix (Lapacian) for distributed slip inversion 3 | % 4 | % usage: [modelopt]=MakeFaultPatches(distribopt,modelopt) 5 | % 6 | % FA 7/2008 based on Sjonni Jonsson's code 7 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8 | %logmessage(sprintf('[]=%s(%s)',mfilename,inputname(1))); 9 | 10 | if size(patches,1) ==1 11 | Lap=0 ; Lap_inv=0; % case that only one patch 12 | else 13 | [Lap,Lap_inv]=modelwt2(nvert, nhorz, patches(:,1),ExtendSize(2)/nvert,1); 14 | end 15 | -------------------------------------------------------------------------------- /modellib/distlib/abs_disp.m: -------------------------------------------------------------------------------- 1 | function u = abs_disp(nu, dis_geom, xy) 2 | 3 | % modified in April 2002 by FA: eliminating for loop. Only checked for opening dislocation 4 | 5 | [nsta,m] = size(xy); 6 | 7 | u = zeros(3,nsta); 8 | u = disloc1(dis_geom', xy', nu); 9 | 10 | % for i= 1:nsta 11 | % u(:,i) = disloc(dis_geom', [xy(i,1); xy(i,2)], nu); 12 | % end 13 | 14 | 15 | % u = u'; 16 | -------------------------------------------------------------------------------- /modellib/distlib/flakes.m: -------------------------------------------------------------------------------- 1 | function [fx,fy,fz]=flakes(dis_geom); 2 | % flakes - Produces input for fill3 to see faultslip in 3D 3 | % 4 | % Program to calculate 3D cornerpoints of a rectangular fault so 5 | % it may be plotted and visualized in 3D. This can be particularly 6 | % useful when distributed slip is estimated. Use FILL3 to display 7 | % 8 | % Input: dis_geom - (7xn) or (10xn) matrix with geometries of n faults 9 | % output: [fx,fy,xz] - Input for program FILL3. The three matrices of size 10 | % (4xn) have the cornerpoints of the faultpatches. 11 | % 12 | % e.g. dis_geom = [len,width,depth,dip,strik,locE,locN,0,0,1]'; 13 | % SJ Oct 8 2000 14 | 15 | nf = size(dis_geom,2); 16 | 17 | fx = zeros(4,nf); 18 | fy = zeros(4,nf); 19 | fz = zeros(4,nf); 20 | 21 | for l = 1:nf 22 | len = dis_geom(1,l); 23 | wid = dis_geom(2,l); 24 | dep = dis_geom(3,l); 25 | dip = (dis_geom(4,l))/180*pi; 26 | str = dis_geom(5,l); 27 | dx = dis_geom(6,l); 28 | dy = dis_geom(7,l); 29 | 30 | p = [-len/2 len/2 len/2 -len/2; 31 | 0 0 wid*cos(dip) wid*cos(dip); 32 | dep dep dep-wid*sin(dip) dep-wid*sin(dip)]; 33 | 34 | a = (360-str+90)/180*pi; 35 | 36 | R = [cos(a) -sin(a) 0; sin(a) cos(a) 0; 0 0 1]; 37 | k = R*p; 38 | kk = k + [dx;dy;0]*ones(1,4); 39 | 40 | fx(:,l) = kk(1,:)'; 41 | fy(:,l) = kk(2,:)'; 42 | fz(:,l) = kk(3,:)'; 43 | end 44 | 45 | 46 | -------------------------------------------------------------------------------- /modellib/distlib/flakes2D.m: -------------------------------------------------------------------------------- 1 | function [ffx,ffz]=flakes(dis_geom,nhel,nvel); 2 | % flakes - Produces input for fill3 to see faultslip in 3D 3 | % 4 | % Program to calculate 3D cornerpoints of a rectangular fault so 5 | % it may be plotted and visualized in 3D. This can be particularly 6 | % useful when distributed slip is estimated. Use FILL3 to display 7 | % 8 | % Input: dis_geom - (7xn) or (10xn) matrix with geometries of n faults 9 | % output: [fx,fy,xz] - Input for program FILL3. The three matrices of size 10 | % (4xn) have the cornerpoints of the faultpatches. 11 | % 12 | % e.g. dis_geom = [len,width,depth,dip,strik,locE,locN,0,0,1]'; 13 | % SJ Oct 8 2000 14 | 15 | nf = size(dis_geom,2); 16 | 17 | ffx = zeros(4,nf); 18 | ffz = zeros(4,nf); 19 | cnt = 1; 20 | 21 | xloc = dis_geom(1,1)/2; 22 | 23 | for k=1:nhel 24 | zloc = -10; 25 | for m=1:nvel 26 | len = dis_geom(1,cnt); 27 | wid = dis_geom(2,cnt); 28 | ffx(:,cnt) = [xloc-len/2 xloc+len/2 xloc+len/2 xloc-len/2]'; 29 | ffz(:,cnt) = [zloc-wid/2 zloc-wid/2 zloc+wid/2 zloc+wid/2]'; 30 | zloc = zloc+wid; 31 | cnt=cnt+1; 32 | end 33 | xloc = xloc+len; 34 | end 35 | 36 | ffz = ffz-max(ffz(:)); 37 | 38 | 39 | -------------------------------------------------------------------------------- /modellib/modelpar_lola2xy.m: -------------------------------------------------------------------------------- 1 | function [par_out] = modelpar_lola2xy(par,basemap,modelopt,direc) 2 | %modelpar_lola2xy - converts model parameter from xy (local, disloc) coordinate system into lola and vice-versa 3 | % 4 | % INPUT: 5 | % par - model parameter vector (Nx1) or coordinate vector (2xN) 6 | % basemap - structure with information on x_first, etc 7 | % modelopt - structure with modeloptions 8 | % direc - direction (1: lola->xy; -1: xy->lola) (default: 1) 9 | % 10 | % OUTPUT: 11 | % par_out - model parameter with converted coordinates 12 | % 13 | % FA, June 2007 14 | 15 | ind = find_coord_index(modelopt) ; 16 | 17 | par_out = par; 18 | tmp_in = zeros(2,length(ind)/2); 19 | tmp_in(:) = par(ind); 20 | tmp_lola = lola2xy(tmp_in,basemap,direc); 21 | par_out(ind) = tmp_lola; 22 | -------------------------------------------------------------------------------- /modellib/phaseramp_dummy.m: -------------------------------------------------------------------------------- 1 | function [phaseramp] = phaseramp_dummy(dataset,objfuncopt) 2 | % phaseramp_dummy - generates a dummy phaseramp to remove from the data so that fnnls works in InverseLinDistrib 3 | % 4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 5 | 6 | [SAR_1,SAR_2,SAR_3,SAR_4,SAR_5,SAR_6,SAR_7,SAR_8] = dealfalk(dataset.SAR); 7 | PhaseRamp = objfuncopt.PhaseRamp ; 8 | 9 | % calculate x and y coordinates for plane removal from data_grid 10 | 11 | switch PhaseRamp 12 | case{'Ramp',true} 13 | dummy = [-1 -0.01 -0.01]' ; 14 | case{'Const'} 15 | dummy = -1; 16 | otherwise 17 | dummy =[]; 18 | end 19 | 20 | phaseramp = repmat(dummy,sum([dataset.SAR]), 1); 21 | -------------------------------------------------------------------------------- /modellib/plot_surfaceintersection.m: -------------------------------------------------------------------------------- 1 | function displot_surfaceintersection(disgeom) 2 | % displot - Plots intersection of dislocation with surface . 3 | % Input: Dislocation Geometry in a Global E-N-Up coordinate system 4 | % disgeom(1) = len = fault length in strike direction (km) 5 | % disgeom(2) = wid = fault width in dip direction (km) 6 | % disgeom(3) = dep = fault depth (km) 7 | % disgeom(4) = dip = dip angle (degrees) 8 | % disgeom(5) = strik = strike, clockwise from N (degrees) 9 | % disgeom(6) = delE = East offset of midpoint from origin (km) 10 | % disgeom(7) = delN = North offset of midpoint from origin (km) 11 | % disgeom(8) = ss = strike slip motion (m) 12 | % disgeom(9) = ds = dip slip motion (m) 13 | % disgeom(10) = op = opening motion (m) 14 | %% 15 | 16 | par = Extend2Surface(disgeom); 17 | par(2) = 0; 18 | disgeom = par; 19 | % the following is identical with displot 20 | 21 | 22 | len =disgeom(1); wid = disgeom(2); dep = disgeom(3); delE=disgeom(6); delN=disgeom(7); 23 | i = sqrt(-1); 24 | dipr = disgeom(4)*pi/180; 25 | % 26 | % corners in local coordinates 27 | % 28 | ll = -0.5*len +i*0; lr = 0.5*len + i*0; 29 | ul = -0.5*len +i*wid*cos(dipr); ur = 0.5*len + i*wid*cos(dipr); 30 | % 31 | %transform corners to global coordinates 32 | strkr = (90-disgeom(5))*pi/180; 33 | % 34 | ll = (delE+delN*i) + ll*exp(i*strkr); 35 | lr = (delE+delN*i) + lr*exp(i*strkr); 36 | ul = (delE+delN*i) + ul*exp(i*strkr); 37 | ur = (delE+delN*i) + ur*exp(i*strkr); 38 | % 39 | plot( [real(ll), real(lr)], [imag(ll), imag(lr)],'g' ), axis('equal'); 40 | %plot( [real(ll), real(ul)], [imag(ll), imag(ul)] ), axis(axis); 41 | %plot( [real(ul), real(ur)], [imag(ul), imag(ur)], 'g' ), axis(axis); 42 | %plot( [real(ur), real(lr)], [imag(ur), imag(lr)] ), axis(axis); 43 | -------------------------------------------------------------------------------- /plotlib/viewdirections3d_generate.m: -------------------------------------------------------------------------------- 1 | function [cam_position]=viewdirections3d_generate(modelopt) 2 | % 3 | % viewdirections3d_generate - generates a cell string with view directions for PlotSurface3D 4 | % 5 | 6 | cam_position = {[sind(20+180)*100 cosd(20+180)*100 10]}; %default 7 | 8 | if modelopt.N_disloc || modelopt.N_multidisloc 9 | strike = modelopt.par.xy(5); 10 | cam_position = {[sind(strike+180)*100 cosd(strike+180)*100 -modelopt.par.xy(3)] [sind(strike+90)*100 cosd(strike+90)*100 -modelopt.par.xy(3)] cam_position{:}} ; 11 | end 12 | -------------------------------------------------------------------------------- /preparelib/GenerateLOSVec.m: -------------------------------------------------------------------------------- 1 | function [radarlookvec]=GenerateLOSVec(incanglevec,azimuth) 2 | %GenerateLOSvector - returns LOS field based on corner co-ordinates 3 | % 4 | %usage: 5 | % 6 | %Output: radarlookvec [nx3] LOS vector (ENU) for n co-ordinates 7 | % incanglevec [nx1] incidence angle vector for n co-ordinates 8 | % 9 | % 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11 | 12 | radarlookvec = [-sind(incanglevec(:))*cosd(azimuth) sind(incanglevec(:))*sind(azimuth) cosd(incanglevec(:))]'; 13 | 14 | 15 | -------------------------------------------------------------------------------- /preparelib/MakeFaults.m: -------------------------------------------------------------------------------- 1 | %Script to convert GMT fault files into *mat file as for ML2002-2005.min 2 | % First replace all section delimiters by 3 | % NaN NaN 4 | % then do the following: 5 | 6 | % THIS CODE SHOULD GO INTO PREPARE SO THAT WE CAN READ *txt FILES. THE SEPARATOR COULD BE GIVEN AS AN OPTION 7 | 8 | fid = fopen('/RAID6/insarlab/geophys_data/Haiti/Lines/caribbean_faults.lola.txt'); 9 | C = textscan(fid,'%f %f'); 10 | long = [C{1}']; 11 | lat = [C{2}']; 12 | Lllh = [long' lat']; 13 | save('/RAID6/insarlab/geophys_data/Haiti/Lines/caribbean_faults.mat'); 14 | -------------------------------------------------------------------------------- /preparelib/MakeFocals.m: -------------------------------------------------------------------------------- 1 | function [Focals]=MakeFocals(focalfile,focalfileformat,basemap) 2 | %MakeFocals - reads Focalsfile and saves s structure as matlab file 3 | % 4 | % usage: [Focals]=MakeFocals(focalfile,focalfileformat) 5 | % 6 | % basemap is needed to switch from lola to xy 7 | % 8 | 9 | global dir_out 10 | 11 | if focalfile(1) CheckInOut(focalfile,''); end % check whether quakefile exist 12 | 13 | focals_matfile = fullfile(dir_out,'focals.mat'); 14 | 15 | if CheckInOut('',focals_matfile) load(focals_matfile); return; end 16 | % 17 | % open and read quakefile 18 | % 19 | 20 | fid = fopen(focalfile); 21 | switch focalfileformat 22 | case{'Focal'} 23 | %C = textscan(fid, '%f %f %f %f %f %f %f %f','headerLines',0 ); 24 | C = textscan(fid, '%f %f %f %f %f %f %f %f'); 25 | C=cell2mat(C); 26 | lat = [C(:,1)']; 27 | long = [C(:,2)']; 28 | depth = [C(:,3)']; 29 | mag = [C(:,4)']; 30 | strike= [C(:,5)']; 31 | dip = [C(:,6)']; 32 | rake = [C(:,7)']; 33 | size = [C(:,8)']; 34 | end 35 | 36 | 37 | Focals.lola = [long',lat']; 38 | Focals.depth = depth'; 39 | Focals.mag = mag'; 40 | Focals.strike= strike'; 41 | Focals.dip = dip'; 42 | Focals.rake =rake'; 43 | Focals.size =size'; 44 | Focals.xy = [ lola2xy(Focals.lola',basemap,1) ]'; 45 | ind=find(Focals.mag<0); Focals.lola(ind,:)=[]; Focals.depth(ind)=[]; Focals.mag(ind)=[]; Focals.xy(ind,:)=[]; Focals.strike(ind,:)=[]; Focals.dip(ind,:)=[]; Focals.rake(ind,:)=[]; Focals.size(ind,:)=[] 46 | ind=find(Focals.depth==0); Focals.lola(ind,:)=[]; Focals.depth(ind)=[]; Focals.mag(ind)=[]; Focals.xy(ind,:)=[]; Focals.strike(ind,:)=[]; Focals.dip(ind,:)=[]; Focals.rake(ind,:)=[]; Focals.size(ind,:)=[] 47 | 48 | save(focals_matfile,'Focals') 49 | 50 | -------------------------------------------------------------------------------- /preparelib/RemoveBadIgrams.m: -------------------------------------------------------------------------------- 1 | function [igram,n_igrams]=RemoveBadIgrams(igram,maxthresh) 2 | %RemoveBadIgrams - remove poorly unwrapped interferograms from igram structure 3 | % 4 | % remove interferograms with too much non-unwrapped points 5 | % maxthresh : remove if non-unwrapped percentage >= thresh 6 | % 7 | dim_data=length(igram) ; 8 | 9 | ib=1; ind_badones=zeros(dim_data,1); 10 | 11 | for i=1:dim_data 12 | i_nan=find(isnan(igram(i).data)); 13 | perc=length(i_nan)/prod(size(igram(1).data)) ; 14 | if (perc >= maxthresh) ind_badones(ib)=i; ib=ib+1; end 15 | 16 | str=sprintf('File %d: percentage not-unwrapped: %4.2f',i,perc) ; 17 | if isfield(igram(i),'date1') 18 | str=[ str ': ' igram(i).date1(3:end) '-' igram(i).date2(3:end) ',' ]; 19 | end 20 | logmessage(str) 21 | end 22 | 23 | ind_badones(find(ind_badones==0))=[]; 24 | igram(ind_badones)=[]; 25 | n_igrams=length(igram); 26 | if n_igrams==0 27 | error('user error: no interferograms left after applying coherence threshold -- exiting') ; 28 | end 29 | -------------------------------------------------------------------------------- /preparelib/SUGGESTIONS_FALK: -------------------------------------------------------------------------------- 1 | plotigramopt (prepared by PreparePlot) should contain a field 'BaseMap' which containes the DEM and the shaded relief. This will be used for the 2 | This provides the co-dorfinates in PlotIgram. In a frst stage the igram structure should have the same coordinates as BaseMap but at a later stage it should allow for different coordinates and subsets and the igram data will be resampled on the BaseMap (by filling with zeros or NaNs) 3 | -------------------------------------------------------------------------------- /preparelib/add_mask_to_igram.m: -------------------------------------------------------------------------------- 1 | function [igram]=add_mask_to_igram(igram,mask,lopt,opt) 2 | %add_mask_to_igram - multiplies igram.data with a mask 3 | % usage: [igram]=add_mask_to_igram(igram,mask,lopt) 4 | % 5 | % Part of the TimeSeries suite 6 | % FA, March 2005, 7 | 8 | if isfield(lopt,'subset') 9 | if size(mask)~=size(igram(1).data) %subset mask only if igram and mask have different sizes 10 | mask=mask(lopt.subset(2):lopt.subset(2)+lopt.subset(4)-1,lopt.subset(1):lopt.subset(1)+lopt.subset(3)-1); 11 | end 12 | end 13 | 14 | for i=1:length(igram) 15 | igram(i).data=igram(i).data.*mask; 16 | end 17 | 18 | % Add a phase ambiguity to certain area. Requires a dataset of same size as igram 19 | % which contains values > 0 in are 20 | % can be created using the extractregion.m tool, 21 | if(opt.ambiguityOffset~=0) 22 | S=load(opt.ambiguityOffsetFile); 23 | offsetmask = S.offsetmask; 24 | offsetmask(find(isnan(offsetmask))) = NaN; 25 | offsetmask(find(offsetmask==0)) = 0; 26 | offsetmask(find(offsetmask>0)) = 6.2832 * opt.ambiguityOffset;% 2pi 27 | for i=1:length(igram) 28 | igram(i).data=igram(i).data + offsetmask; 29 | end 30 | 31 | end 32 | %%% Tini 33 | return 34 | -------------------------------------------------------------------------------- /preparelib/add_rating_to_igram.m: -------------------------------------------------------------------------------- 1 | function [igram]=add_rating_to_igram(igram,rfile) 2 | %add_rating_to_igram - add ratings to the igram structure 3 | % usage: add_rating_to_igram(igram,rfile) 4 | % add_rating_to_igram(igram,'/RAID1/amelung_as_apex/HawA6B400More2Yrs/igram_rating.log') 5 | % 6 | % Input: igram: 1xN structure array containing N interferograms with: 7 | % rfile: ASCII file containing the rating for each interferogram 8 | % in the form (produced by select_and_stack.pl) 9 | % 10 | % PO_IFGRAM_HawA6B400More2Yrs_20010526-20040111 2 11 | % 12 | % searches for 'date1-date2' in the dir name 13 | % 14 | % Part of the TimeSeries suite 15 | % FA, March 2005, 16 | 17 | %cc; 18 | 19 | [dirs,ratings] = textread(rfile,'%s%d'); % reads ratingfile 20 | 21 | for j=1:length(igram) 22 | datestr=strcat(igram(j).date1,'-',igram(j).date2); 23 | dirmatch=zeros(length(dirs),1); 24 | for i=1:length(dirs) 25 | dirmatch(i)=length(strfind(char(dirs(i)),datestr)); 26 | end 27 | if length(find(dirmatch==1))==0 error('no match for igram %d : %s',j,datestr) ; end 28 | if length(find(dirmatch==1))> 1 error('more that one match for igram %d %s',j ,datestr) ; end 29 | igram(j).rating=ratings(find(dirmatch==1)) ; 30 | end 31 | 32 | return 33 | -------------------------------------------------------------------------------- /preparelib/add_tforstack_to_igram.m: -------------------------------------------------------------------------------- 1 | function [igram]=add_tforstack_to_igram(igram,date) 2 | %add_tforstack_to_igram - adds tforstack to igram structure 3 | % usage: [igram]=add_tforstack_to_igram(igram,'date') 4 | % [igram]=add_tforstack_to_igram(igram,'20020501') 5 | % Input: igram: 1xN structure array containing N interferograms with: 6 | % 7 | % Output: igram.tforstack time in yrs since 'date' 8 | % 9 | % Part of the TimeSeries suite 10 | % FA, March 2005, 11 | % FA, Sep 2006, fixed for cases where mjdstart= length(chunck)/2 31 | if fittype == 1 & length(chunck_noNaN) >= 3 32 | [m, G, rms] = fit_bilinplane(chunck_noNaN, [c1 c2]'); 33 | else 34 | medvalue = median(chunck_noNaN); 35 | tmp = ones(size(chunck_noNaN)) .* medvalue; 36 | dif = chunck_noNaN - tmp; 37 | rms = sqrt( mean( dif(:).^2 ) ); 38 | m = [medvalue 0 0]'; 39 | end 40 | if rms <= tolerance 41 | oldindmat(k,icol-3:icol) = [ 1 m' ]; 42 | end 43 | elseif length(chunck_noNaN) < 1 44 | oldindmat(k,icol-3:icol) = [ 1 NaN NaN NaN ]; 45 | end 46 | end 47 | end 48 | 49 | newindmat = oldindmat; 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /preparelib/quadtreelib/fit_bilinplane.m: -------------------------------------------------------------------------------- 1 | function [m, G, rootms] = fit_bilinplane(data, coord) 2 | % fit_bilinplane - Fits bi-linear plane to a given image 3 | % 4 | % function [m, G, rootms] = fit_bilinplane(data, coord) 5 | % 6 | % Input: 7 | % data - (nx1) vector of data 8 | % coord - (2xn) matrix of coordinate locations 9 | % 10 | % Output: 11 | % m - (3x1) vector of model parameters 12 | % [a b c]' for plane z(x,y) = a + bx + cy 13 | % G - (tx3) constuction matrix with t <= n lines 14 | % corresponding to no-NaN data 15 | % rootms - (1,1) root mean square error between plane and data 16 | 17 | % Clean data and coordinates of NaNs 18 | NoNanInd=find(isnan(data)==0); 19 | d=data(NoNanInd); 20 | coord=coord(:,NoNanInd); 21 | 22 | N = length(d); 23 | 24 | % If 3 or more data points left after NaN screening, then 25 | if N >= 3 26 | % Make matrix G 27 | G = [ones(N,1) coord(1,:)' coord(2,:)' ]; 28 | gtginv = inv(G'*G); 29 | 30 | m = gtginv*(G'*d); 31 | 32 | % Calculate the rms 33 | rootms = sqrt( mean ( (d-G*m).^2 ) ); 34 | 35 | % Calculate the median value 36 | %valint=median(d); 37 | %corint=mean(coord'); 38 | else 39 | rootms = 0; G=0; m=[0 0 0]'; 40 | end 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /preparelib/quadtreelib/getchunck.m: -------------------------------------------------------------------------------- 1 | function chunck = getchunck(index, data); 2 | % getchunck - Gets a piece of data according to the quadtree index 3 | % 4 | % function chunck = getchunck(index, data); 5 | % 6 | % INPUT 7 | % index = (1xl) quadtree index 8 | % data = (nxn) data matrix 9 | % 10 | % OUPUT 11 | % chunck = (kxk) chunk as indicated by 12 | % the quadtree index 13 | % 14 | 15 | len = length(index) - 4; 16 | [lin,col] = size(data); 17 | blcksz = lin; 18 | lst = 1; cst = 1; 19 | 20 | for k=1:len 21 | blcksz = blcksz/2; 22 | switch index(k) 23 | case 1 24 | lst = lst; cst = cst; 25 | case 2 26 | lst = lst; cst = cst + blcksz; 27 | case 3 28 | lst = lst + blcksz; cst = cst + blcksz; 29 | case 4 30 | lst = lst + blcksz; cst = cst; 31 | end 32 | end 33 | 34 | chunck = data(lst:lst+blcksz-1,cst:cst+blcksz-1); 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /preparelib/quadtreelib/matfill.m: -------------------------------------------------------------------------------- 1 | function newmat = matfill(indmat, matsize); 2 | % matfill - Takes in quadtree index matrix and produces full matrix 3 | % 4 | % function newmat = matfill(indmat, matsize); 5 | % 6 | % This function takes in quadtree index matrix and converts it to 7 | % big matrix of values, to compare with the original image. 8 | % 9 | % INPUT: 10 | % indmat - (k,m) quadtree index matrix with k pts & of level m-2 11 | % matsize - (1,1) size of output matrix (e.g. 1024) 12 | % 13 | % OUTPUT: 14 | % newmat - (matsize x matsize) matrix with values from the 15 | % the last column of the quadtree index matrix at 16 | % locations indicated by the m-2 first column of that 17 | % same matrix 18 | 19 | 20 | % Get location of values, the quadtree level and the # of pts. 21 | val = size(indmat,2); 22 | level = val - 4; 23 | len = size(indmat,1); 24 | 25 | newmat = zeros(matsize)*NaN; 26 | 27 | % loop over every point 28 | for k=1:len 29 | blcksz = matsize; 30 | lst = 1; cst = 1; 31 | 32 | % loop over every quadtree level 33 | for l=1:level 34 | if indmat(k,l) ~= 0 35 | blcksz = blcksz/2; 36 | switch indmat(k,l) 37 | case 1 38 | lst = lst; cst = cst; 39 | case 2 40 | lst = lst; cst = cst + blcksz; 41 | case 3 42 | lst = lst + blcksz; cst = cst + blcksz; 43 | case 4 44 | lst = lst + blcksz; cst = cst; 45 | end 46 | end 47 | end 48 | 49 | % Fill into the new matrix 50 | tmp = ones(blcksz); 51 | [c1,c2]=find(tmp); 52 | d = [ones(blcksz^2,1) c1 c2]*indmat(k,val-2:val)'; 53 | tmp(:) = d; 54 | newmat(lst:lst+blcksz-1,cst:cst+blcksz-1) = tmp; 55 | 56 | end 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /preparelib/quadtreelib/quadtree.m: -------------------------------------------------------------------------------- 1 | function [indexmatrix] = quadtree(oldind) 2 | % quadtree - Add a new quadtree partitioning level 3 | % 4 | % function indexmatrix = quadtree(oldind) 5 | % 6 | % Input: 7 | % oldind - (m x l) old index matrix of level l-2 8 | % 9 | % Output: 10 | % indexmatrix - (t x l+1) new index matrix of level l-1 11 | % where t>m. 12 | 13 | indexmatrix = []; 14 | [lin col] = size(oldind); 15 | nlin = 1; 16 | 17 | % loop over every old quadtree partition 18 | for k = 1:lin 19 | if oldind(k,col-3) == 1 % If deeper part. isn't needed, we add a 0 20 | tmp1 = [oldind(k,1:col-4), 0]; 21 | tmp2 = oldind(k,col-3:col); 22 | 23 | indexmatrix = [indexmatrix ; tmp1 tmp2]; 24 | nlin = nlin+1; 25 | else % Deeper partition needed, we add three new lines to the matrix 26 | tmp1 = [ones(4,1)*oldind(k,1:col-4), [1 2 3 4]']; 27 | tmp2 = [zeros(4,1) ones(4,1)*oldind(k,col-2:col)]; 28 | 29 | indexmatrix = [indexmatrix ; tmp1 tmp2]; 30 | nlin = nlin+4; 31 | end 32 | end 33 | 34 | 35 | -------------------------------------------------------------------------------- /preparelib/remove_mean.m: -------------------------------------------------------------------------------- 1 | function [igram]=remove_mean(igram) 2 | %remove_mean - remove igrams based on given acquisition date 3 | % 4 | % usage: [igram]=remove_mean(igram) 5 | % [igram]=remove_mean(igram) 6 | % 7 | % removes interferograms with matching date from igram structure 8 | % 9 | % Part of the TimeSeries suite 10 | % FA, March 2005, 11 | 12 | for j=1:length(igram) 13 | tmpdata=igram(j).data; 14 | tmean=nanmean(nanmean(tmpdata)); 15 | igram(j).data=igram(j).data-tmean; 16 | end 17 | 18 | return 19 | -------------------------------------------------------------------------------- /tobereplacedlib/PlotFigureTitle.m: -------------------------------------------------------------------------------- 1 | function []=PlotFigureTitle(str) 2 | % PlotFigureTitle - plots title on figure 3 | % function to plot title on figure 4 | % 5 | % FA, Apr 2004 6 | % 7 | axes 8 | th=text(0,0.5,str,'Units','normalized','FontSize',14,'FontName','Courier','HorizontalAlignment','center'); 9 | set(gca,'NextPlot','add','position',[0.5 0.9 0.1 0.10],'vis','off'); 10 | %get(th); 11 | 12 | 13 | --------------------------------------------------------------------------------