├── LICENSE ├── README.md ├── SRT_pick ├── functions │ ├── autopickfb.m │ ├── check_depth_array.m │ ├── genmesh.m │ ├── magnify2.m │ ├── makegrid.m │ ├── matpickfb.m │ ├── order.m │ ├── pick_fig.m │ ├── readpicks.m │ ├── readpicks_pg.m │ ├── save_pygimli.m │ ├── shotselec.m │ ├── tt2velinit_new.m │ ├── vel2xzvtomo.m │ └── writepicks_pg.m ├── launcher │ └── SRT_pick.m └── scripts │ ├── SRT_pick_defaultsettings.m │ └── SRT_pick_script.m ├── docs ├── example │ └── yellowstone.tar.gz ├── manual │ ├── SWIP_manual.pdf │ └── latex │ │ ├── SWIP_manual.tex │ │ ├── compile │ │ ├── figures │ │ ├── flowchart_extraction.png │ │ ├── flowchart_inversion.png │ │ ├── logo_UW_brown_2L.png │ │ ├── logo_WyCEHG.png │ │ ├── logo_dept_geol_geophy.png │ │ ├── logo_metis.png │ │ ├── logo_upmc.png │ │ └── stack_wind.png │ │ └── format.tex └── publi │ ├── Pasquet_Bodet_2016_ExAb_NSG.pdf │ ├── Pasquet_Bodet_2016_Poster_NSG.pdf │ ├── Pasquet_Bodet_2017_Geophysics.pdf │ └── Pasquet_etal_2020_Geophysics.pdf ├── functions ├── NanSuite │ ├── nanmax.m │ ├── nanmean.m │ ├── nanmedian.m │ ├── nanmin.m │ ├── nansem.m │ ├── nanstd.m │ ├── nansum.m │ └── nanvar.m ├── bln2xyz.m ├── cat_img.m ├── cbhandle.m ├── cblabel.m ├── cm_saturation.m ├── cmaps │ ├── brewermap.m │ ├── color_2_white.m │ ├── graycm.m │ ├── haxby.m │ ├── haxby_sp.m │ ├── inferno.m │ ├── magma.m │ ├── parula.m │ ├── plasma.m │ ├── pmkmp.m │ ├── polarmap.m │ ├── seismic.m │ └── viridis.m ├── columnlegend.m ├── createcolormap.m ├── dashline.m ├── dat2dsp.m ├── dat2surf.m ├── dat2vol.m ├── dinsave.m ├── dir_create.m ├── dsp2dat.m ├── errorbar_tick.m ├── export_fig │ ├── export_fig.m │ ├── print2array.m │ └── print2eps.m ├── findpeak.m ├── fmin_search.m ├── fmin_search_disp.m ├── gauss_weight.m ├── geopsy_version.m ├── get_acquiparam.m ├── imagescnan.m ├── interp1qr.m ├── ispc_wsl.m ├── lorentzerr.m ├── matdinver.m ├── matgpdc.m ├── matgpdcreport.m ├── matop.m ├── matpickamp.m ├── matpomegal.m ├── matshift.m ├── matspecfx.m ├── matwind.m ├── matzip.m ├── meanvel_find.m ├── median_filt.m ├── median_filt_2D.m ├── mod2param.m ├── mov_aver.m ├── param2mod.m ├── plot_colorbar.m ├── plot_curv.m ├── plot_hist.m ├── plot_img.m ├── plot_img_log.m ├── plot_scat.m ├── plot_scat_log.m ├── plot_stairs.m ├── plot_wiggle.m ├── poisson.m ├── pvc2pvc.m ├── pvc2targ.m ├── readdisp.m ├── readmodel.m ├── readtomo.m ├── readtomo_new.m ├── resampvel.m ├── save_fig.m ├── save_xzv.m ├── secs2hms.m ├── seismo2dat.m ├── selectdata.m ├── shot_stack.m ├── spec2dat.m ├── stack_weight_lam.m ├── stack_weight_lam_new.m ├── stack_weight_lam_old.m ├── stair2plot.m ├── str_split.m ├── swip_version.m ├── targ2pvc.m ├── terrorbar.m ├── unix_cmd.m ├── unix_wsl.m ├── unix_wsl_path.m ├── update_minortick.m ├── velresamp.m └── xyz2plot.m ├── gitpush ├── launchers ├── A_SWIPdisp.m ├── B_SWIPparam.m ├── C_SWIPinv.m ├── D1_SWIPmod1d.m └── D2_SWIPmod2d.m ├── scripts ├── A_SWIPdisp_script.m ├── B_SWIPparam_script.m ├── C_SWIPinv_script.m ├── D1_SWIPmod1d_script.m ├── D2_SWIPmod2d_script.m └── SWIP_defaultsettings.m ├── src ├── configure ├── seg2segy │ └── seg2segy.c └── supomegal │ ├── INSTALL │ ├── makefile │ └── supomegal.c └── tools ├── ascii2su.m ├── batch_rename.m ├── calc_disp.m ├── convert_targ.m ├── convert_xzv.m ├── datablank.m ├── plot_1dmod_multi.m ├── plot_disp.m ├── plot_seismo.m ├── plot_spec.m ├── plot_targ.m ├── plot_targ_multi.m ├── plot_xzv.m ├── quick_invert.m ├── seg2su.m ├── seg2su_clean.m ├── seg2su_simple.m └── sumerge.m /README.md: -------------------------------------------------------------------------------- 1 | # SWIP 2 | Surface-Wave dispersion Inversion and Profiling software 3 | Installation instructions and manual are stored in SWIP/docs/manual 4 | 5 | # What's new 6 | - Works under Windows 10 or higher with the Windows Subsystem for Linux 7 | - Includes a first arrival picking tool for Seismic Refraction Tomography (saves in .sgt format for [pyGIMLi](https://www.pygimli.org/)) 8 | 9 | # Installation 10 | 11 | 1. Install MATLAB 12 | 2. Download SWIP at https://github.com/SWIPdev/SWIP/releases and add the content of the archive 13 | to your MATLAB path 14 | 3. (Windows user only) Install Windows Subsystem for Linux (https://pureinfotech.com/install-wsl-windows-11/) 15 | 4. (Mac OS user only) Install Xcode, Homebrew and gnu-tar 16 | 5. Install Seismic Unix (https://github.com/JohnWStockwellJr/SeisUnix) 17 | 6. Install Geospy (http://www.geopsy.org/download.php) 18 | 7. Install SU extra binaries located in SWIP/src (for Mac users, install seg2segy located in Seismic Unix's third party) 19 | 8. (Optional) Install ImageMagick, PDFjam, and pdfcrop 20 | -------------------------------------------------------------------------------- /SRT_pick/functions/autopickfb.m: -------------------------------------------------------------------------------- 1 | function [seismomat_test, tpick_auto, xpick_auto] = autopickfb(seismomat,xseis,tseis,sx,autopick,plot_fig) 2 | 3 | %% 4 | % close all 5 | amp_lim = 10; 6 | offmin = 5; 7 | 8 | % noise_fac1 = 10; 9 | % noise_fac2 = 250; 10 | % pow1 = 0.2; 11 | % pow2 = 1; 12 | 13 | noise_fac1 = 5; 14 | noise_fac2 = 100; 15 | 16 | pow1 = 0.2; 17 | pow2 = 1; 18 | 19 | xpick_auto = xseis; 20 | 21 | offset = abs(xpick_auto-sx); 22 | noise_fac_law = logspace(log10(noise_fac1),log10(noise_fac2),length(offset))'; 23 | pow_law = logspace(log10(pow1),log10(pow2),length(offset))'; 24 | 25 | if ~isempty(find(tseis<0, 1)) 26 | noise_std = std(abs(seismomat(:,tseis<0)),[],2); 27 | noise_std = median_filt(noise_std',7,1,length(noise_std)); 28 | else 29 | seismomat_tmp = seismomat; 30 | % noise_std = 0.002*offset.*std(abs(seismomat_tmp),[],2); 31 | noise_std = 0.05*mean(abs(seismomat_tmp),2); 32 | noise_std = median_filt(noise_std',7,1,length(noise_std)); 33 | end 34 | 35 | % signal_std = std(abs(seismomat(:,tseis>0)),[],2); 36 | % signal_std = median_filt(signal_std',7,1,length(signal_std)); 37 | 38 | seismomat_temp = seismomat; 39 | seismomat_temp(:,tseis<=2*min(diff(tseis))) = 0; 40 | 41 | noise_law = noise_fac_law.*offset.^-pow_law; 42 | % noise_law(offset>0.5*max(offset)) = noise_fac2*offset(offset>0.5*max(offset)).^-pow2; 43 | noise_law(isinf(noise_law)) = max(noise_fac_law); 44 | 45 | cond = bsxfun(@gt,abs(seismomat_temp),noise_law.*noise_std); 46 | % imagesc(cond') 47 | %% 48 | 49 | if autopick == 1 50 | source_pos = find(offset == min(offset),1); 51 | noise_threshold = min(log10(noise_std))+0.05*abs(median(log10(noise_std))); 52 | noise_threshold_ind_left = find(log10(noise_std)>=noise_threshold & xpick_auto=noise_threshold & xpick_auto>sx,1,'first'); 54 | dist_left = abs(source_pos - noise_threshold_ind_left); 55 | dist_right = abs(source_pos - noise_threshold_ind_right); 56 | offset_min = max([dist_left dist_right]); 57 | if offset_min < offmin/unique(diff(xpick_auto)) 58 | offset_min = offmin/unique(diff(xpick_auto)); 59 | end 60 | % plot_fig = 1; 61 | 62 | cond_filt = despike_2D(cond,7,50,[1 length(xpick_auto)],[1 length(tseis)],source_pos,offset_min,plot_fig); 63 | % cond_filt = despike_2D(cond_filt,7,150,[1 length(xseis)],[1 length(tseis)],source_pos,offset_min,1); 64 | else 65 | cond_filt = cond; 66 | end 67 | 68 | [ok,idx] = max(cond_filt,[],2); 69 | % idx(idx <=4 & xseis~=sx) = 1; 70 | norm_value = ok.*abs(seismomat_temp((1:numel(idx))'+numel(idx)*(idx-1))); 71 | id_ok = find(norm_value~=0); 72 | norm_value = interp1(xseis(id_ok),norm_value(id_ok),xseis); 73 | seismomat_test = bsxfun(@rdivide,seismomat,norm_value); 74 | 75 | % plot_wiggle(2,-1*seismomat_test',xseis,tseis) 76 | % keyboard 77 | 78 | seismomat_test(seismomat_test>amp_lim)=amp_lim; 79 | seismomat_test(seismomat_test<-amp_lim)=-amp_lim; 80 | seismomat_test = seismomat_test./amp_lim; 81 | seismomat_test(isnan(mean(seismomat_test,2)),:) = 0; 82 | 83 | if autopick == 1 84 | TSEIS = repmat(tseis,length(xpick_auto),1); 85 | TSEIS2 = TSEIS(:,idx); 86 | tpick_auto = TSEIS2(1,:); 87 | 88 | % if ismember(sx,xseis) 89 | % if sx~=min(xseis) 90 | % tpick_auto(xseissx) = median_filt(tpick_auto(xseis>sx),3,1,length(tpick_auto(xseis>sx)))'; 94 | % end 95 | % end 96 | 97 | xpick_auto(tpick_auto==0 & xseis'~=sx) = []; 98 | xpick_auto(tpick_auto>max(tseis)) = []; 99 | tpick_auto(tpick_auto==0 & xseis'~=sx) = []; 100 | tpick_auto(tpick_auto>max(tseis)) = []; 101 | 102 | else 103 | xpick_auto = []; 104 | tpick_auto = []; 105 | end -------------------------------------------------------------------------------- /SRT_pick/functions/check_depth_array.m: -------------------------------------------------------------------------------- 1 | function array = check_depth_array(Gx,Gz,Sx,Sz) 2 | 3 | 4 | G_sing = unique([Gx Gz],'rows'); 5 | S_sing = unique([Sx Sz],'rows'); 6 | 7 | try 8 | nG = hist(G_sing(:,1),unique(G_sing(:,1))); 9 | nS = hist(S_sing(:,1),unique(S_sing(:,1))); 10 | catch 11 | keyboard 12 | end 13 | 14 | G_sing_X = unique(G_sing(:,1)); 15 | S_sing_X = unique(S_sing(:,1)); 16 | 17 | if any(nG>1) 18 | ind_nG = find(nG>1); 19 | for i = 1:length(ind_nG) 20 | ind_GX = (G_sing(:,1) == G_sing_X(ind_nG(i))); 21 | ind_GZ_depth = (G_sing(:,2) == min(G_sing(ind_GX,2))); 22 | ind_GZ_surf = (G_sing(:,2) == max(G_sing(ind_GX,2))); 23 | G_sing_depth(i,:) = G_sing(ind_GX & ind_GZ_depth,:); 24 | G_sing_surf(i,:) = G_sing(ind_GX & ind_GZ_surf,:); 25 | end 26 | 27 | ind_nG = find(nG==1); 28 | for i = 1:length(ind_nG) 29 | Gx_tmp = G_sing_X(ind_nG(i)); 30 | Gz_tmp = G_sing(G_sing(:,1) == Gx_tmp,2); 31 | diff_GZ_depth = abs(Gz_tmp - G_sing_depth(:,2)); 32 | diff_GZ_surf = abs(Gz_tmp - G_sing_surf(:,2)); 33 | if min(diff_GZ_depth) < min(diff_GZ_surf) 34 | G_sing_depth = [G_sing_depth; G_sing(G_sing(:,1) == Gx_tmp,:)]; 35 | else 36 | G_sing_surf = [G_sing_surf; G_sing(G_sing(:,1) == Gx_tmp,:)]; 37 | end 38 | end 39 | G_sing_depth = sortrows(G_sing_depth,1); 40 | G_sing_surf = sortrows(G_sing_surf,1); 41 | else 42 | G_sing_depth = []; 43 | % IS_depth = []; 44 | G_sing_surf = G_sing; 45 | % IG_surf = ismember([Gx Gz],G_sing_surf,'rows'); 46 | end 47 | 48 | if any(nS>1) 49 | ind_nS = find(nS>1); 50 | S_sing_depth = []; S_sing_surf = []; 51 | for i = 1:length(ind_nS) 52 | ind_SX = (S_sing(:,1) == S_sing_X(ind_nS(i))); 53 | ind_SZ_depth = (S_sing(:,2) == min(S_sing(ind_SX,2))); 54 | ind_SZ_surf = (S_sing(:,2) == max(S_sing(ind_SX,2))); 55 | S_sing_depth(i,:) = S_sing(ind_SX & ind_SZ_depth,:); 56 | S_sing_surf(i,:) = S_sing(ind_SX & ind_SZ_surf,:); 57 | end 58 | 59 | ind_nS = find(nS==1); 60 | for i = 1:length(ind_nS) 61 | Sx_tmp = S_sing_X(ind_nS(i)); 62 | Sz_tmp = S_sing(S_sing(:,1) == Sx_tmp,2); 63 | diff_SZ_depth = abs(Sz_tmp - G_sing_depth(:,2)); 64 | diff_SZ_surf = abs(Sz_tmp - G_sing_surf(:,2)); 65 | if min(diff_SZ_depth) < min(diff_SZ_surf) 66 | S_sing_depth = [S_sing_depth; S_sing(S_sing(:,1) == Sx_tmp,:)]; 67 | else 68 | S_sing_surf = [S_sing_surf; S_sing(S_sing(:,1) == Sx_tmp,:)]; 69 | end 70 | end 71 | S_sing_depth = sortrows(S_sing_depth,1); 72 | S_sing_surf = sortrows(S_sing_surf,1); 73 | else 74 | S_sing_depth = []; 75 | % IS_depth = []; 76 | S_sing_surf = S_sing; 77 | % IG_surf = ismember([Gx Gz],G_sing_surf,'rows'); 78 | end 79 | 80 | for i = 1:4 81 | if i == 1 82 | if ~isempty(G_sing_surf) && ~isempty(S_sing_surf) 83 | array{i}.G_sing = G_sing_surf; 84 | array{i}.S_sing = S_sing_surf; 85 | else 86 | array{i} = []; 87 | end 88 | elseif i == 2 89 | if ~isempty(G_sing_depth) && ~isempty(S_sing_surf) 90 | array{i}.G_sing = G_sing_depth; 91 | array{i}.S_sing = S_sing_surf; 92 | else 93 | array{i} = []; 94 | end 95 | elseif i == 3 96 | if ~isempty(G_sing_depth) && ~isempty(S_sing_depth) 97 | array{i}.G_sing = G_sing_depth; 98 | array{i}.S_sing = S_sing_depth; 99 | else 100 | array{i} = []; 101 | end 102 | 103 | elseif i == 4 104 | if ~isempty(G_sing_surf) && ~isempty(S_sing_depth) 105 | array{i}.G_sing = G_sing_surf; 106 | array{i}.S_sing = S_sing_depth; 107 | else 108 | array{i} = []; 109 | end 110 | end 111 | end -------------------------------------------------------------------------------- /SRT_pick/functions/magnify2.m: -------------------------------------------------------------------------------- 1 | function a2 = magnify2(f1,zoom_lvl,frame_size) 2 | 3 | if exist('f1','var')==0 || isempty(f1)==1 4 | f1 = gcf; 5 | end 6 | if exist('zoom_lvl','var')==0 || isempty(zoom_lvl)==1 7 | zoom_lvl = 2; 8 | end 9 | if exist('frame_size','var')==0 || isempty(frame_size)==1 10 | frame_size = 0.2; 11 | end 12 | 13 | set(f1,'WindowButtonMotionFcn', @ButtonMotionCallback); 14 | 15 | a1 = get(f1,'CurrentAxes'); 16 | a2 = copyobj(a1,f1); 17 | 18 | set(f1, ... 19 | 'UserData',[f1,a1,a2], ... 20 | 'Pointer','fullcrosshair', ... 21 | 'CurrentAxes',a2); 22 | set(a2, ... 23 | 'UserData',[zoom_lvl,frame_size], ... %magnification, frame size 24 | 'Color',get(a1,'Color'), ... 25 | 'Box','on'); 26 | xlabel(''); ylabel(''); zlabel(''); title(''); 27 | set(get(a2,'Children'), ... 28 | 'LineWidth', 2); 29 | set(a1, ... 30 | 'Color',get(a1,'Color')*0.95); 31 | set(f1, ... 32 | 'CurrentAxes',a1); 33 | ButtonMotionCallback(f1); 34 | 35 | function ButtonMotionCallback(src,eventdata) 36 | H = get(src,'UserData'); 37 | if ~isempty(H) 38 | f1 = H(1); a1 = H(2); a2 = H(3); 39 | a2_param = get(a2,'UserData'); 40 | f_pos = get(f1,'Position'); 41 | a1_pos = get(a1,'Position'); 42 | 43 | [f_cp, a1_cp] = pointer2d(f1,a1); 44 | set(a2,'Position',[(f_cp./f_pos(3:4)) 0 0]+a2_param(2)*a1_pos(3)*[-0.75 -1.5 1.5 2.25]); %% Figure size 45 | a2_pos = get(a2,'Position'); 46 | 47 | set(a2,'XLim',a1_cp(1)+(1/a2_param(1))*(a2_pos(3)/a1_pos(3))*diff(get(a1,'XLim'))*[-0.33 0.33]); % Figure axis 48 | set(a2,'YLim',a1_cp(2)+(1/a2_param(1))*(a2_pos(4)/a1_pos(4))*diff(get(a1,'YLim'))*[-1 1]); 49 | end; 50 | return; 51 | 52 | % Included for completeness (usually in own file) 53 | function [fig_pointer_pos, axes_pointer_val] = pointer2d(fig_hndl,axes_hndl) 54 | % 55 | %pointer2d(fig_hndl,axes_hndl) 56 | % 57 | % Returns the coordinates of the pointer (in pixels) 58 | % in the desired figure (fig_hndl) and the coordinates 59 | % in the desired axis (axes coordinates) 60 | % 61 | % Example: 62 | % figure(1), 63 | % hold on, 64 | % for i = 1:1000, 65 | % [figp,axp]=pointer2d; 66 | % plot(axp(1),axp(2),'.','EraseMode','none'); 67 | % drawnow; 68 | % end; 69 | % hold off 70 | 71 | % Rick Hindman - 4/18/01 72 | 73 | if (nargin == 0), fig_hndl = gcf; axes_hndl = gca; end; 74 | if (nargin == 1), axes_hndl = get(fig_hndl,'CurrentAxes'); end; 75 | 76 | set(fig_hndl,'Units','pixels'); 77 | 78 | pointer_pos = get(0,'PointerLocation'); %pixels {0,0} lower left 79 | fig_pos = get(fig_hndl,'Position'); %pixels {l,b,w,h} 80 | 81 | fig_pointer_pos = pointer_pos - fig_pos([1,2]); 82 | set(fig_hndl,'CurrentPoint',fig_pointer_pos); 83 | 84 | if (isempty(axes_hndl)), 85 | axes_pointer_val = []; 86 | elseif (nargout == 2), 87 | axes_pointer_line = get(axes_hndl,'CurrentPoint'); 88 | axes_pointer_val = sum(axes_pointer_line)/2; 89 | end; 90 | -------------------------------------------------------------------------------- /SRT_pick/functions/makegrid.m: -------------------------------------------------------------------------------- 1 | function c = makegrid(x,z) 2 | 3 | %function to make a grid of x and z points or x and y whichever you prefer. 4 | % returns a two by (x*z) matrix of x,z pairs 5 | 6 | 7 | [mx,nx]=size(x); 8 | [mz,nz]=size(z); 9 | 10 | if mx < nx; 11 | x=x'; 12 | end 13 | 14 | if mz < nz; 15 | z=z'; 16 | end 17 | 18 | tmpx=[]; 19 | tmpz=[]; 20 | 21 | for i=1:length(z); 22 | tmpx=[tmpx; x]; 23 | end 24 | 25 | for i=1:length(z); 26 | tmpz=[tmpz; z(i)*ones(length(x),1)]; 27 | end 28 | 29 | tmpc=[tmpx tmpz]; 30 | 31 | tmpc=sortrows(tmpc,2); 32 | tmpc=sortrows(tmpc,1); 33 | 34 | 35 | c=tmpc; -------------------------------------------------------------------------------- /SRT_pick/functions/order.m: -------------------------------------------------------------------------------- 1 | function n = order( val, base ) 2 | %Order of magnitude of number for specified base. Default base is 10. 3 | %order(0.002) will return -3., order(1.3e6) will return 6. 4 | %Author Ivar Smith 5 | 6 | if nargin < 2 7 | base = 10; 8 | end 9 | n = floor(log(abs(val))./log(base)); -------------------------------------------------------------------------------- /SRT_pick/functions/pick_fig.m: -------------------------------------------------------------------------------- 1 | function [x, y, key] = pick_fig 2 | 3 | %%% S. Pasquet - V17.04.20 4 | % Get X,Y coordinates with mouse pick 5 | 6 | k = waitforbuttonpress; 7 | x=[]; y=[]; key=''; 8 | if k==0 9 | CP = get(gca, 'CurrentPoint'); 10 | CP = CP(1,1:2); 11 | x = CP(1); 12 | y = CP(2); 13 | elseif k==1 14 | key = get(gcf,'CurrentKey'); 15 | end 16 | end -------------------------------------------------------------------------------- /SRT_pick/functions/readpicks.m: -------------------------------------------------------------------------------- 1 | function [Tpick, Sxpick, Szpick, Gxpick, Gzpick, Offpick] = readpicks(input) 2 | 3 | Tpick=[]; Sxpick=[]; Szpick=[]; Offpick=[]; Gxpick=[]; Gzpick=[]; 4 | Sx_sing = input(input(:,1) == 0,2); 5 | nsrc = length(Sx_sing); 6 | 7 | for i=1:nsrc; 8 | ind = find(input(:,1) == i); 9 | nrec = length(ind); 10 | I = input(:,1) == i; 11 | J = find(input(:,4) == i); 12 | Tpick=[Tpick;input(I,4)*1000]; 13 | Sxpick=[Sxpick;repmat(input(J,2),nrec,1)]; 14 | Szpick=[Szpick;repmat(input(J,3),nrec,1)]; 15 | Gxpick=[Gxpick;input(I,2)]; 16 | Gzpick=[Gzpick;input(I,3)]; 17 | Offpick=[Offpick;input(I,2)-repmat(input(J,2),nrec,1)]; 18 | end -------------------------------------------------------------------------------- /SRT_pick/functions/readpicks_pg.m: -------------------------------------------------------------------------------- 1 | function [Tpick, Sxpick, Szpick, Gxpick, Gzpick, Offpick, topo, Errpick] = readpicks_pg(pickfile_GIMLI) 2 | 3 | fidb = fopen(pickfile_GIMLI,'r'); % File opening % 4 | 5 | npos = str2double(fgetl(fidb)); 6 | fgetl(fidb); 7 | 8 | x = zeros(npos,1); 9 | y = x; z = x; 10 | for i = 1:npos 11 | test = str2num(fgetl(fidb)); 12 | x(i) = test(1); 13 | y(i) = test(2); 14 | z(i) = test(3); 15 | end 16 | if ~any(z) && any(y) 17 | z = y; 18 | end 19 | 20 | npicks = str2double(fgetl(fidb)); 21 | Tpick = zeros(npicks,1); 22 | Sxpick = Tpick; Szpick = Tpick; 23 | Gxpick = Tpick; Gzpick = Tpick; 24 | Errpick = Tpick; Offpick = Tpick; 25 | 26 | test = strsplit(fgetl(fidb)); 27 | ind_t = find(strcmp(test,'t')) - 1; 28 | ind_s = find(strcmp(test,'s')) - 1; 29 | ind_g = find(strcmp(test,'g')) - 1; 30 | ind_err = find(strcmp(test,'err')) - 1; 31 | 32 | for i = 1:npicks 33 | data = str2num(fgetl(fidb)); 34 | Tpick(i) = data(ind_t) * 1000; 35 | Sxpick(i) = x(data(ind_s)); 36 | Szpick(i) = z(data(ind_s)); 37 | Gxpick(i) = x(data(ind_g)); 38 | Gzpick(i) = z(data(ind_g)); 39 | if ~isempty(ind_err) 40 | Errpick(i) = data(ind_err); 41 | end 42 | Offpick(i) = Gxpick(i) - Sxpick(i); 43 | end 44 | fclose(fidb); 45 | 46 | ind_topo = find(diff(x) < 0,1); 47 | if ~isempty(ind_topo) 48 | topo = [x(1:ind_topo) z(1:ind_topo)]; 49 | else 50 | topo = [x z]; 51 | end -------------------------------------------------------------------------------- /SRT_pick/functions/save_pygimli.m: -------------------------------------------------------------------------------- 1 | function save_pygimli(pickfile_GIMLI,Gx,Gz,Sx,Sz,Gxpick,Gzpick,Sxpick,Szpick,Tpick,err_pc,err_val,err_val_min,err_val_max) 2 | 3 | if ~exist('err_pc','var') || isempty(err_pc) 4 | err_pc = 0; 5 | end 6 | 7 | if ~exist('err_val','var') || isempty(err_val) 8 | if err_pc == 1 9 | err_val = 0.1; 10 | else 11 | err_val = 1; 12 | end 13 | end 14 | 15 | if ~exist('err_val_min','var') || isempty(err_val_min) 16 | err_val_min = 0; 17 | end 18 | if ~exist('err_val_max','var') || isempty(err_val_max) 19 | err_val_max = 1e6; 20 | end 21 | 22 | % Convert arrays to table 23 | T = table(Sx, Gx, Sz, Gz); 24 | Tpick = table(Sxpick, Gxpick, Szpick, Gzpick, Tpick); 25 | 26 | % Sort by Sx and then by Gx 27 | T = sortrows(T, {'Sx', 'Gx'}); 28 | 29 | % Sort by Sxpick and then by Gxpick 30 | Tpick = sortrows(Tpick, {'Sxpick', 'Gxpick'}); 31 | 32 | % Convert back to arrays 33 | Sx = T.Sx; Gx = T.Gx; Sz = T.Sz; Gz = T.Gz; 34 | Sxpick = Tpick.Sxpick; Gxpick = Tpick.Gxpick; Szpick = Tpick.Szpick; Gzpick = Tpick.Gzpick; Tpick = Tpick.Tpick; 35 | 36 | % Save pick file for pyGIMLI 37 | fidb=fopen(pickfile_GIMLI,'wt'); % File opening % 38 | array = check_depth_array(Gx,Gz,Sx,Sz); 39 | 40 | if ~isempty(array{2}) && ~isempty(array{3}) && ~isempty(array{4}) 41 | all_points_surf = unique([array{1}.G_sing; array{1}.S_sing; array{2}.S_sing; array{4}.G_sing],'rows'); 42 | all_points_depth = unique([array{3}.G_sing; array{3}.S_sing; array{4}.S_sing; array{2}.G_sing],'rows'); 43 | all_points = [all_points_surf; flipud(all_points_depth)]; 44 | else 45 | all_points = unique([[Gx;Sx],[Gz;Sz]],'rows'); 46 | end 47 | 48 | % err_val = 0.125; % strengbach percentage 49 | % err_val = 1; % Error in ms 50 | 51 | npoints = size(all_points,1); 52 | fprintf(fidb,'%d\n',npoints); 53 | fprintf(fidb,'%s\n','# x y z'); 54 | for ii = 1:npoints 55 | fprintf(fidb,'%f\t%f\t%f\n',all_points(ii,1),all_points(ii,2),0); 56 | end 57 | fprintf(fidb,'%d\n',length(Gxpick)); 58 | fprintf(fidb,'%s\n','# g s err t'); 59 | for jj = 1:length(Gxpick) 60 | [~,ind_s] = ismember([Sxpick(jj),Szpick(jj)],all_points,'rows'); 61 | [~,ind_g] = ismember([Gxpick(jj),Gzpick(jj)],all_points,'rows'); 62 | 63 | if err_pc == 1 64 | err_ok = err_val*(Tpick(jj))/1000; 65 | if err_ok > err_val_max/1000 66 | err_ok = err_val_max/1000; 67 | elseif err_ok < err_val_min/1000 68 | err_ok = err_val_min/1000; 69 | end 70 | else 71 | err_ok = err_val/1000; 72 | end 73 | fprintf(fidb,'%d\t%d\t%f\t%f\n',ind_g,ind_s,err_ok,(Tpick(jj))/1000); 74 | end 75 | fclose(fidb); 76 | -------------------------------------------------------------------------------- /SRT_pick/functions/shotselec.m: -------------------------------------------------------------------------------- 1 | function [seismomat,x,z,t,Sx,Sz]=shotselec(sufile,fldr,xsca,loadmat,keepsu,normalize) 2 | % S. Pasquet - V16.3.28 3 | % Select shot with suwind in matlab 4 | 5 | if exist('keepsu','var')==0 || isempty(keepsu)==1 6 | keepsu = 0; 7 | end 8 | 9 | if exist('normalize','var')==0 || isempty(normalize)==1 10 | normalize = 0; 11 | end 12 | 13 | seismofile=strcat(num2str(fldr),'.su'); 14 | % Select shot then window between gmin and gmax 15 | if normalize == 0 16 | com1=sprintf('suwind < %s key=fldr min=%d max=%d | suop op=despike nw=3 > %s',... 17 | sufile,fldr,fldr,seismofile); 18 | else 19 | com1=sprintf('suwind < %s key=fldr min=%d max=%d | suop op=despike nw=5 | suop op=norm > %s',... 20 | sufile,fldr,fldr,seismofile); % 21 | end 22 | unix(com1); 23 | 24 | % Check number of trace 25 | % Geophones positions 26 | [~,Gx]=unix(['sugethw < ',seismofile,' key=gx output=geom']); 27 | Gx=str2num(Gx)/xsca; 28 | % Geophones elevation 29 | [~,Gz]=unix(['sugethw < ',seismofile,' key=gelev output=geom']); 30 | Gz=str2num(Gz)/xsca; 31 | % Source position 32 | [~,Sx]=unix(['sugethw < ',seismofile,' key=sx output=geom | uniq']); 33 | Sx=str2double(Sx)/xsca; 34 | % Source elevation 35 | [~,Sz]=unix(['sugethw < ',seismofile,' key=selev output=geom | uniq']); 36 | Sz=str2double(Sz)/xsca; 37 | 38 | % Save in ASCII .dat file 39 | % Time delay 40 | [~,delay]=unix(['sugethw < ',seismofile,' key=delrt output=geom | uniq']); 41 | delay=str2double(delay)/1000; 42 | % Time sampling 43 | [~,dt]=unix(['sugethw < ',seismofile,' key=dt output=geom | uniq']); 44 | dt=str2double(dt)/1000000; 45 | % Nb of time samples 46 | [~,ns]=unix(['sugethw < ',seismofile,' key=ns output=geom | uniq']); 47 | ns=str2double(ns); 48 | 49 | % X table 50 | x=Gx; 51 | % Z table 52 | z=Gz; 53 | % Time table 54 | t=delay:dt:delay+(ns-1)*dt; 55 | 56 | if loadmat==1 57 | com1=sprintf('sustrip < %s | b2a n1=%d > %s',seismofile,ns,[seismofile,'.dat']); 58 | [~,~]=unix(com1); 59 | % Load image file 60 | seismomat=load([seismofile,'.dat']); 61 | delete([seismofile,'.dat']); 62 | else 63 | seismomat=[]; 64 | end 65 | if keepsu == 0 66 | delete(seismofile); 67 | end 68 | 69 | end -------------------------------------------------------------------------------- /SRT_pick/functions/vel2xzvtomo.m: -------------------------------------------------------------------------------- 1 | function [xzvfinal, xi, zi, vi_filt] = vel2xzvtomo(xx,xzv,F2,min_vel,max_vel,showplot) 2 | 3 | Xfinal=zeros(size(xzv)); 4 | Zfinal=Xfinal; 5 | for ii = 1:length(xzv) 6 | Xfinal(ii) = xzv(ii,1).xz(1); 7 | Zfinal(ii) = xzv(ii,1).xz(2); 8 | end 9 | 10 | [mi,ni] = size(xx); 11 | xi=reshape(Xfinal,mi-1,ni-1); 12 | zi=reshape(Zfinal,mi-1,ni-1); 13 | vi=F2(xi,zi); 14 | 15 | if ~isempty(max_vel) 16 | vi(vi>max_vel) = max_vel; 17 | end 18 | if ~isempty(min_vel) 19 | vi(vi= 1 28 | % vi_filt(i,1:ind_nan_first) = vi_filt(i,ind_nan_first + 1); 29 | % end 30 | % if ind_nan_last <= size(vi_filt,2) 31 | % vi_filt(i,ind_nan_last:end) = vi_filt(i,ind_nan_last - 1); 32 | % end 33 | % end 34 | 35 | if ~isempty(max_vel) && ~isempty(min_vel) 36 | 37 | % vel_mean = mean(vi_filt,2); 38 | % vel_std = std(vi_filt,[],2); 39 | % vel_min = min(vi_filt,[],2); 40 | % vel_max= max(vi_filt,[],2); 41 | % 42 | % a_max = 4; 43 | % a_min = 1/(a_max/2); 44 | % distrand=rand(1)-0.5; 45 | % distrand=(distrand)/0.5; 46 | % a_mean=0.5*(log10(a_min)+log10(a_max)); 47 | % a_diff=0.5*(log10(a_max)-log10(a_min)); 48 | % a_all=a_mean+distrand*a_diff; 49 | % a_all = 10.^a_all; 50 | % 51 | % b_max = std(vi_filt(:)); 52 | % b_min = min_vel; 53 | % distrand=rand(1)-0.5; 54 | % distrand=(distrand)/0.5; 55 | % b_mean=0.5*(b_min+b_max); 56 | % b_diff=0.5*(b_max-b_min); 57 | % b_all=b_mean+distrand*b_diff; 58 | % vi_filt_mean = b_all+a_all*repmat(vel_mean,1,size(vi_filt,2)); 59 | 60 | vi_1D = mov_aver(nanmax(vi_filt,2)',5,1,size(vi_filt,1)); 61 | vi_filt_mean = repmat(vi_1D,1,size(vi_filt,2)); 62 | else 63 | vi_filt_mean = vi_filt; 64 | end 65 | 66 | finalVel=reshape(vi_filt_mean,size(xi,1)*size(xi,2),1); 67 | xzvfinal=xzv; 68 | for ii = 1:length(xzvfinal) 69 | xzvfinal(ii,1).v = finalVel(ii); 70 | xzvfinal(ii,1).u = finalVel(ii)^-1; 71 | end 72 | 73 | if showplot == 1 74 | plot_img([],xi,zi,vi_filt,haxby(32),1,0,1,12,'X (m)',... 75 | 'Altitude (m)','Velocity (m/s)',[],[],[min_vel max_vel],[],[],[],[],[],[],[1 20 24 12],[],1,1); 76 | 77 | plot_img([],xi,zi,vi_filt_mean,haxby(32),1,0,1,12,'X (m)',... 78 | 'Altitude (m)','Velocity (m/s)',[],[],[min_vel max_vel],[],[],[],[],[],[],[24 20 24 12],[],1,1); 79 | end -------------------------------------------------------------------------------- /SRT_pick/functions/writepicks_pg.m: -------------------------------------------------------------------------------- 1 | function writepicks_pg(pickfile_GIMLI,Tpick, Sxpick, Szpick, Gxpick, Gzpick, topo, Errpick) 2 | 3 | % Save pick file for pyGIMLI 4 | fidb=fopen(pickfile_GIMLI,'wt'); % File opening % 5 | all_points = topo; 6 | 7 | npoints = size(all_points,1); 8 | fprintf(fidb,'%d\n',npoints); 9 | fprintf(fidb,'%s\n','# x y z'); 10 | for ii = 1:npoints 11 | fprintf(fidb,'%f\t%f\t%f\n',all_points(ii,1),all_points(ii,2),0); 12 | end 13 | fprintf(fidb,'%d\n',length(Gxpick)); 14 | fprintf(fidb,'%s\n','# g s err t'); 15 | for jj = 1:length(Gxpick) 16 | [~,ind_s] = ismember([Sxpick(jj),Szpick(jj)],all_points,'rows'); 17 | [~,ind_g] = ismember([Gxpick(jj),Gzpick(jj)],all_points,'rows'); 18 | fprintf(fidb,'%d\t%d\t%f\t%f\n',ind_g,ind_s,Errpick(jj)/1000,(Tpick(jj))/1000); 19 | end 20 | fclose(fidb); 21 | -------------------------------------------------------------------------------- /SRT_pick/launcher/SRT_pick.m: -------------------------------------------------------------------------------- 1 | clear all; clc; close all; 2 | 3 | %%% TRAVELTIME TOMOGRAPHY PROCESSING 4 | %%% MODULE A : TOMOpickfb.m 5 | %%% S. Pasquet - V18.04.26 6 | %%% TOMOpickfb.m allows to pick first breaks and plot seismograms 7 | 8 | %%%-------------------------%%% 9 | %%% START OF INITIALIZATION %%% 10 | 11 | Sxselec = [1:5:91]; % Select shots (comment or [] to select all) 12 | 13 | %%% Main settings 14 | pick = 1; % Pick first arrival (=1) or not (=) 15 | save_seis = 1; % Save seismogram image (=1) or not (=) 16 | save_seis_pck = 1; % Save picked seismogram image (=1) or not (=) 17 | save_src_off = 1; % Save source vs offset diagram (=1) or not (=) 18 | save_picks = 1; 19 | showplot = 0; 20 | 21 | %%% Picking settings 22 | % dt_min = 0.25; % Minimum time sample to display seismogram for picking (ms) 23 | offMAX_pick = []; % Max. offset (m) 24 | tMAX_pick = 50; % Max. time (ms) 25 | scal = 2; % Amplitude scaling factor 26 | clip = 1; % Clip (=1) or not (=0) 27 | polarity = -1; % Fill positive (=1) or negative (-1) amplitudes 28 | autogain = 1; % Automatic gain (=1) or not (=0) 29 | 30 | %%% Error settings 31 | err_pc = 1; % Use percentage error (=1) or absolute (=0) 32 | err_val = 0.05; % Error value (in %/100 or ms) 33 | err_val_min = 0.5; % Min absolute error when using percentage error (ms) 34 | err_val_max = 3; % Max absolute error when using percentage error (ms) 35 | 36 | %%% General display settings 37 | imgform = 'png'; % Fig. file format ('pdf', 'png', 'jpeg', 'tiff' or 'fig') 38 | imgres = 150; % Fig. resolution (dpi) when saving as raster 39 | fs = 16; % Fig. font size (reduce by 40% with fs=40 => fs=16 in AI) (max=40) 40 | 41 | %%% Seismogram plot settings 42 | tMIN_seis = 0; % Min. time (ms) 43 | tMAX_seis = 50; % Max. time (ms) 44 | % tseisticks = (tMIN_seis:50:tMAX_seis); 45 | 46 | %%% Source vs offset diagram settings 47 | axetop = 1; % Plot Xaxis on top (=1) or bottom (=0) 48 | horex = 0.25; % Horizontal exageration 49 | plot_pos = 1; % Plot traces positions (=1) or not (=0) 50 | marker = 's'; % Marker type ('s'=square, 'o'=circle) 51 | markersize = 25; % Marker size 52 | map1 = haxby(32); % Colormap for traveltimes 53 | 54 | % xMIN = 0; % Min. X (m) 55 | % xMAX = 270; % Max. X (m) 56 | % xticks = (xMIN:50:xMAX); 57 | offMIN = []; % Min. offset (m) 58 | offMAX = []; % Max. offset (m) 59 | % offticks = (offMIN:25:offMAX); 60 | % tMIN = 0; % Min. traveltime (ms) 61 | % tMAX = 100; % Max. traveltime (ms) 62 | % tticks = (tMIN:25:tMAX); 63 | vMIN = []; % Min. pseudo-velocity (m/s) 64 | vMAX = []; % Max. pseudo-velocity (m/s) 65 | % vticks = (vMIN:250:vMAX); 66 | 67 | %%% END OF INITIALIZATION %%% 68 | %%%-----------------------%%% 69 | 70 | run('SRT_pick_script'); 71 | -------------------------------------------------------------------------------- /docs/example/yellowstone.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/example/yellowstone.tar.gz -------------------------------------------------------------------------------- /docs/manual/SWIP_manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/manual/SWIP_manual.pdf -------------------------------------------------------------------------------- /docs/manual/latex/compile: -------------------------------------------------------------------------------- 1 | rm -f *.{blg,bbl,toc,out,log,maf,nlo,brf} 2 | rm -f *.mtc* 3 | name=SWIP_manual 4 | 5 | pdflatex $name 6 | bibtex $name 7 | pdflatex $name 8 | #pdflatex $name 9 | #pdflatex $name 10 | 11 | rm -f *.{blg,bbl,toc,out,maf,nlo,brf,dvi,lof,lot,log,aux,idx} 12 | rm -f *.mtc* *.spl* 13 | mv $name.pdf .. 14 | -------------------------------------------------------------------------------- /docs/manual/latex/figures/flowchart_extraction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/manual/latex/figures/flowchart_extraction.png -------------------------------------------------------------------------------- /docs/manual/latex/figures/flowchart_inversion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/manual/latex/figures/flowchart_inversion.png -------------------------------------------------------------------------------- /docs/manual/latex/figures/logo_UW_brown_2L.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/manual/latex/figures/logo_UW_brown_2L.png -------------------------------------------------------------------------------- /docs/manual/latex/figures/logo_WyCEHG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/manual/latex/figures/logo_WyCEHG.png -------------------------------------------------------------------------------- /docs/manual/latex/figures/logo_dept_geol_geophy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/manual/latex/figures/logo_dept_geol_geophy.png -------------------------------------------------------------------------------- /docs/manual/latex/figures/logo_metis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/manual/latex/figures/logo_metis.png -------------------------------------------------------------------------------- /docs/manual/latex/figures/logo_upmc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/manual/latex/figures/logo_upmc.png -------------------------------------------------------------------------------- /docs/manual/latex/figures/stack_wind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/manual/latex/figures/stack_wind.png -------------------------------------------------------------------------------- /docs/manual/latex/format.tex: -------------------------------------------------------------------------------- 1 | % Langage et encodage 2 | \usepackage[english]{babel} 3 | \usepackage[utf8]{inputenc} 4 | \usepackage[T1]{fontenc} 5 | \usepackage{lmodern} 6 | 7 | % UPMC recommendations for margin sizes 8 | \usepackage[left=2.5cm,right=2.5cm,top=1.5cm,bottom=2.0cm,includefoot,includehead,headheight=13.6pt]{geometry} 9 | \setlength{\skip\footins}{0.7cm} 10 | \usepackage[bottom]{footmisc} 11 | 12 | % Tableaux 13 | \usepackage{longtable} 14 | \usepackage{tabularx} 15 | \usepackage{multirow} 16 | \usepackage{booktabs} 17 | %\addto\captionsfrench{\def\tablename{Table}} 18 | 19 | % Typo et formules 20 | \usepackage{eurosym} % Symbole euro 21 | \usepackage{latexsym} % Additional symbols 22 | \usepackage{url} % citer des adresses électroniques et des URL 23 | \usepackage{amsmath,amssymb,amsthm} % AMS Math 24 | \usepackage{leftidx} % Better sub and superscripts 25 | \usepackage[mediumspace,mediumqspace,Grey,squaren]{SIunits} % SI units 26 | 27 | % Biblio 28 | \usepackage{natbib} % Package for multiple citation with author-date style 29 | %\setcitestyle{citesep={~;}} % Semicolon separator with french typography 30 | \usepackage{microtype} 31 | \usepackage{breakcites} 32 | \usepackage[hyphenbreaks]{breakurl} 33 | \def\UrlBreaks{\do\/\do-} 34 | 35 | 36 | % Puces numérotées 37 | \usepackage{enumitem} 38 | \setlist{noitemsep} 39 | 40 | % Figures 41 | \usepackage{graphicx} 42 | \usepackage{subfigure} 43 | \usepackage{rotating} % Sideways of figures & tables 44 | \usepackage[singlelinecheck=false]{caption} % Package for caption 45 | 46 | %\DeclareCaptionLabelSeparator{virg}{~: } % New caption label separator 47 | %\captionsetup{labelfont=bf,textfont=it,labelsep=virg} % Set fonts and label separators 48 | %\addto\captionsfrench{% 49 | % \renewcommand{\listfigurename}{Liste des figures}% 50 | %} 51 | 52 | %% Table of contents for each chapter 53 | %\usepackage{tocbibind} 54 | %\usepackage[french]{minitoc} 55 | %\setcounter{minitocdepth}{2} 56 | %\mtcindent=15pt 57 | %\renewcommand{\mtcSfont}{\small\normalfont} % Normal font for minitoc entries 58 | %\newcommand{\miniminitoc}{\minitoc \vspace{12pt}} 59 | %% Use \dominitoc at the beginning of the document 60 | %% Use \minitoc where to put a table of contents 61 | 62 | % Nicer backref links 63 | \usepackage[breaklinks=true,bookmarks=true,pagebackref,hyperindex=true,pdfa]{hyperref} 64 | \backreffrench 65 | \renewcommand*{\backref}[1]{} 66 | \renewcommand*{\backrefalt}[4]{% 67 | \ifcase #1 % 68 | (Non cited)% 69 | \or 70 | (Cited page~#2)% 71 | \else 72 | (Cited pages~#2)% 73 | \fi} 74 | \renewcommand*{\backrefsep}{, } 75 | \renewcommand*{\backreftwosep}{ and~} 76 | \renewcommand*{\backreflastsep}{ and~} 77 | 78 | % Informations included in the pdf file 79 | \hypersetup 80 | { 81 | bookmarksopen=true, 82 | pdftitle="Surface-Wave dispersion Inversion and Profiling", 83 | pdfauthor="Sylvain PASQUET", %auteur du document 84 | pdftoolbar=false, %barre d'outils non visible 85 | pdfmenubar=true, %barre de menu visible 86 | pdfhighlight=/O, %effet d'un clic sur un lien hypertexte 87 | colorlinks=true, %couleurs sur les liens hypertextes 88 | pdfpagemode=UseNone, %aucun mode de page 89 | pdfpagelayout=SinglePage, %ouverture en simple page 90 | pdffitwindow=true, %pages ouvertes entierement dans toute la fenetre 91 | linkcolor=black, %couleur des liens hypertextes internes 92 | citecolor=blue, %couleur des liens pour les citations 93 | urlcolor=black, %couleur des liens pour les url 94 | hyperfootnotes=true 95 | } 96 | -------------------------------------------------------------------------------- /docs/publi/Pasquet_Bodet_2016_ExAb_NSG.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/publi/Pasquet_Bodet_2016_ExAb_NSG.pdf -------------------------------------------------------------------------------- /docs/publi/Pasquet_Bodet_2016_Poster_NSG.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/publi/Pasquet_Bodet_2016_Poster_NSG.pdf -------------------------------------------------------------------------------- /docs/publi/Pasquet_Bodet_2017_Geophysics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/publi/Pasquet_Bodet_2017_Geophysics.pdf -------------------------------------------------------------------------------- /docs/publi/Pasquet_etal_2020_Geophysics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/docs/publi/Pasquet_etal_2020_Geophysics.pdf -------------------------------------------------------------------------------- /functions/NanSuite/nanmax.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/functions/NanSuite/nanmax.m -------------------------------------------------------------------------------- /functions/NanSuite/nanmean.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/functions/NanSuite/nanmean.m -------------------------------------------------------------------------------- /functions/NanSuite/nanmedian.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/functions/NanSuite/nanmedian.m -------------------------------------------------------------------------------- /functions/NanSuite/nanmin.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/functions/NanSuite/nanmin.m -------------------------------------------------------------------------------- /functions/NanSuite/nansem.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/functions/NanSuite/nansem.m -------------------------------------------------------------------------------- /functions/NanSuite/nanstd.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/functions/NanSuite/nanstd.m -------------------------------------------------------------------------------- /functions/NanSuite/nansum.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/functions/NanSuite/nansum.m -------------------------------------------------------------------------------- /functions/NanSuite/nanvar.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/functions/NanSuite/nanvar.m -------------------------------------------------------------------------------- /functions/bln2xyz.m: -------------------------------------------------------------------------------- 1 | function [ZI,XI,YI]=bln2xyz(datafile,blnfile,xsca) 2 | 3 | %%% S. Pasquet - V16.11.18 4 | % Blank X,Y,Z file 5 | % [ZI,XI,YI]=bln2xyz(datafile,blnfile,xsca) 6 | 7 | if nargin<3 8 | xsca=100; 9 | end 10 | 11 | [ZI,XI,YI]=readtomo(datafile,[],[],xsca); % Read data file 12 | if isnumeric(blnfile)==0 13 | blndat=load(blnfile); % Read bln file 14 | if blndat(1,1)==length(blndat)-1 15 | blndat=blndat(2:end,:); 16 | end 17 | Xbln=blndat(:,1); 18 | Ybln=blndat(:,2); 19 | mask=inpolygon(XI,YI,Xbln,Ybln); 20 | else 21 | mask=ZIdownload) 48 | % MATLAB: 8.2.0.701 (R2013b) 49 | % AUTHOR: Carlos Adrian Vargas Aguilera (MEXICO) 50 | % CONTACT: nubeobscura@hotmail.com 51 | 52 | % REVISIONS: 53 | % 1.0 Released. (Aug 21, 2008) 54 | % 2.0 Minor changes. Added CBHANDLE dependency. (Jun 08, 2009) 55 | % 2.1 Changed application data to 'cbfreeze'. (Jun 05, 2014) 56 | % 2.2 Fixed small bug with input reading. (Jul 03, 2014) 57 | 58 | % DISCLAIMER: 59 | % cblabel.m is provided "as is" without warranty of any kind, under the 60 | % revised BSD license. 61 | 62 | % Copyright (c) 2008-2014 Carlos Adrian Vargas Aguilera 63 | 64 | 65 | % INPUTS CHECK-IN 66 | % ------------------------------------------------------------------------- 67 | 68 | % Parameters: 69 | appName = 'cbfreeze'; 70 | 71 | % Sets defaults: 72 | H = get(get(0,'CurrentFigure'),'CurrentAxes'); 73 | LABEL = ''; 74 | TOPT = {}; 75 | 76 | % Number of inputs: 77 | assert(nargout<=1, 'CVARGAS:cblabel:tooManyOutputs',... 78 | 'At most 1 output is allowed.') 79 | 80 | % Looks for H: Version 2.2 81 | if ~isempty(varargin) && ~isempty(varargin{1}) && ... 82 | all(reshape(ishandle(varargin{1}),[],1)) 83 | H = varargin{1}; 84 | varargin(1) = []; 85 | end 86 | 87 | % Looks for CBH: 88 | CBH = cbhandle(H,'force'); 89 | Ncbh = length(CBH); 90 | 91 | % Looks for LABEL: 92 | if ~isempty(varargin) && (ischar(varargin{1}) || iscellstr(varargin{1})) 93 | LABEL = varargin{1}; 94 | varargin(1) = []; 95 | end 96 | 97 | % Forces cell of strings: 98 | if ischar(LABEL) 99 | % Same label to all the colorbars: 100 | LABEL = repmat({LABEL},Ncbh,1); 101 | elseif iscellstr(LABEL) && (length(LABEL)==Ncbh) 102 | % Continue... 103 | else 104 | error('CVARGAS:cblabel:incorrectInputLabel',... 105 | ['LABEL must be a string or cell of strings of equal size as ' ... 106 | 'the color bar handles: %d.'],Ncbh) 107 | end 108 | 109 | % OPTIONAL arguments: 110 | if ~isempty(varargin) 111 | TOPT = varargin; 112 | end 113 | if length(TOPT)==1 114 | TOPT = repmat({TOPT},size(CBH)); 115 | end 116 | 117 | % ------------------------------------------------------------------------- 118 | % MAIN 119 | % ------------------------------------------------------------------------- 120 | 121 | % Applies to each colorbar: 122 | CBLH = NaN(1,Ncbh); 123 | for icb = 1:Ncbh 124 | 125 | % Colorbar handle 126 | cbh = double(CBH(icb)); 127 | 128 | % Searches for label location: 129 | try 130 | % Normal colorbar: 131 | location = get(cbh,'Location'); 132 | catch 133 | % Frozen colorbar: 134 | location = getappdata(cbh,appName); 135 | location = location.cbLocation; 136 | end 137 | switch location(1) 138 | case {'E','e'}, XYstr = 'Y'; 139 | case {'W','w'}, XYstr = 'Y'; 140 | case {'N','n'}, XYstr = 'X'; 141 | case {'S','s'}, XYstr = 'X'; 142 | end 143 | % Gets label handle: 144 | CBLH(icb) = get(cbh,[XYstr 'Label']); 145 | 146 | % Updates label: 147 | set(CBLH(icb),'String',LABEL{icb},TOPT{:}); 148 | 149 | end 150 | 151 | % OUTPUTS CHECK-OUT 152 | % ------------------------------------------------------------------------- 153 | 154 | % Sets output: 155 | if ~nargout 156 | clear CBLH 157 | else 158 | CBLH(~ishandle(CBLH)) = []; 159 | end 160 | 161 | end 162 | 163 | % [EOF] CBLABEL.M by Carlos A. Vargas A. -------------------------------------------------------------------------------- /functions/cm_saturation.m: -------------------------------------------------------------------------------- 1 | function cm_saturation(sat) 2 | %Changes saturation level of current figure use -1:1 3 | ax=gca; 4 | map=colormap(ax); 5 | 6 | newmap=brighten(map,sat); 7 | 8 | 9 | colormap(ax,newmap); -------------------------------------------------------------------------------- /functions/cmaps/color_2_white.m: -------------------------------------------------------------------------------- 1 | function cmap = color_2_white(col,ncol) 2 | 3 | col1 = linspace(col(1),1,ncol); 4 | col2 = linspace(col(2),1,ncol); 5 | col3 = linspace(col(3),1,ncol); 6 | 7 | cmap = [col1' col2' col3']; 8 | -------------------------------------------------------------------------------- /functions/cmaps/graycm.m: -------------------------------------------------------------------------------- 1 | function map=graycm(n) 2 | 3 | %%% S. Pasquet - V16.6.30 4 | % Gray colormap 5 | 6 | map=repmat(linspace(0.2,0.8,n),3,1)'; 7 | map = flipud(map); 8 | end -------------------------------------------------------------------------------- /functions/cmaps/haxby.m: -------------------------------------------------------------------------------- 1 | function map = haxby(m) 2 | %HAXBY Haxby color map 3 | % HAXBY(M) returns an M-by-3 matrix containing a colormap with Haxby's 4 | % colors, commonly used for displaying bathymetry data. 5 | % HAXBY, by itself, is the same length as the current colormap. 6 | % 7 | % For example, to reset the colormap of the current figure: 8 | % 9 | % colormap(haxby) 10 | % 11 | % Use 12 | % colormap(flipud(haxby)) 13 | % 14 | % for bathymetry data (positive downward). 15 | % 16 | % Colormap is based on the colors used by W. F. Haxby's Gravity 17 | % field of World's oceans, 1985, developed for geoid and gravity maps. 18 | % The version used here is formed from a linear interpolation of 19 | % the GMT color table used by MB-System by David W. Caress and Dale N. Chayes. 20 | % 21 | % 22 | % See also HSV, GRAY, PINK, COOL, BONE, COPPER, FLAG, HOT 23 | % COLORMAP, RGBPLOT. 24 | 25 | % Kelsey Jordahl 26 | % Marymount Manhattan College 27 | % Time-stamp: 28 | 29 | if nargin < 1, m = size(get(gcf,'colormap'),1); end 30 | % mbm_grdplot Haxby color pallette 31 | c=[ 10 0 121; 40 0 150; 20 5 175; 0 10 200; 32 | 0 25 212; 0 40 224; 26 102 240; 13 129 248; 33 | 25 175 255; 50 190 255; 68 202 255; 97 225 240; 106 235 225; 34 | 124 235 200; 138 236 174; 172 245 168; 205 255 162; 223 245 141; 35 | 240 236 121; 247 215 104; 255 189 87; 255 160 69; 244 117 75; 238 80 78; 36 | 255 90 90; 255 124 124; 255 158 158 ;245 179 174; 255 196 196; 255 215 215; 37 | 255 230 230]; 38 | ncolors=length(c); 39 | pp=1:(m-1)/(ncolors-1):m; 40 | r=interp1(pp,c(:,1),1:m,'linear'); 41 | g=interp1(pp,c(:,2),1:m,'linear'); 42 | b=interp1(pp,c(:,3),1:m,'linear'); 43 | map=[r' g' b']/255; 44 | 45 | 46 | -------------------------------------------------------------------------------- /functions/cmaps/haxby_sp.m: -------------------------------------------------------------------------------- 1 | function map = haxby_sp(m) 2 | %HAXBY Haxby color map 3 | % HAXBY(M) returns an M-by-3 matrix containing a colormap with Haxby's 4 | % colors, commonly used for displaying bathymetry data. 5 | % HAXBY, by itself, is the same length as the current colormap. 6 | % 7 | % For example, to reset the colormap of the current figure: 8 | % 9 | % colormap(haxby) 10 | % 11 | % Use 12 | % colormap(flipud(haxby)) 13 | % 14 | % for bathymetry data (positive downward). 15 | % 16 | % Colormap is based on the colors used by W. F. Haxby's Gravity 17 | % field of World's oceans, 1985, developed for geoid and gravity maps. 18 | % The version used here is formed from a linear interpolation of 19 | % the GMT color table used by MB-System by David W. Caress and Dale N. Chayes. 20 | % 21 | % 22 | % See also HSV, GRAY, PINK, COOL, BONE, COPPER, FLAG, HOT 23 | % COLORMAP, RGBPLOT. 24 | 25 | % Kelsey Jordahl 26 | % Marymount Manhattan College 27 | % Time-stamp: 28 | 29 | if nargin < 1, m = size(get(gcf,'colormap'),1); end 30 | % mbm_grdplot Haxby color pallette 31 | c=[ 10 0 121; 40 0 150; 20 5 175; 0 10 200; 32 | 0 25 212; 0 40 224; 26 102 240; 13 129 248; 33 | 25 175 255; 50 190 255; 68 202 255; 97 225 240; 106 235 225; 34 | 124 235 200; 138 236 174; 172 245 168; 205 255 162; 223 245 141; 35 | 240 236 121; 247 215 104; 255 189 87; 255 160 69; 244 117 75; 238 80 78; 36 | 255 90 90; 255 124 124; 255 158 158 ;245 179 174];% 255 196 196; 255 215 215; 37 | % 255 230 230]; 38 | ncolors=length(c); 39 | pp=1:(m-1)/(ncolors-1):m; 40 | r=interp1(pp,c(:,1),1:m,'linear'); 41 | g=interp1(pp,c(:,2),1:m,'linear'); 42 | b=interp1(pp,c(:,3),1:m,'linear'); 43 | map=[r' g' b']/255; 44 | 45 | 46 | -------------------------------------------------------------------------------- /functions/cmaps/polarmap.m: -------------------------------------------------------------------------------- 1 | function cmap = polarmap(varargin) 2 | %POLARMAP Polarized color map 3 | % POLARMAP applies a "polarized" blue-white-red colormap to current figure, 4 | % and adjusts the color axis limits to be centered to zero. 5 | % 6 | % POLARMAP(M) fixes the number of colors to M (default is 64). 7 | % 8 | % POLARMAP(MAP) applies linear shading to white to the center of colormap 9 | % MAP which can be any of existing colormaps (an Mx3 matrix of RGB). 10 | % 11 | % POLARMAP(MAP,C) uses exponent C to modify the shading contrast. Default 12 | % is C = 1 for linear shading. Use C = 2 to strengthen the shading, or 13 | % C = 0.5 to attenuate it. 14 | % 15 | % C=POLARMAP(...) returns an M-by-3 matrix containing the colormap, that 16 | % can be used with COLORMAP function like other colormaps. 17 | % 18 | % Examples: 19 | % pcolor(peaks), shading interp 20 | % polarmap, colorbar 21 | % 22 | % then try the following 23 | % polarmap(jet,0.5) 24 | % 25 | % Note the polar shading has no real interest with colormaps that include 26 | % white color as one of the extremes (like GRAY, BONE, HOT, ...). 27 | % 28 | % See also JET, HSV, COPPER, SPRING, SUMMER, WINTER, COOL, COLORMAP, RGBPLOT. 29 | % 30 | % Author: Francois Beauducel, IPGP 31 | % Created: 2011-10-26 32 | % Updated: 2012-06-12 33 | 34 | % Copyright (c) 2012, François Beauducel, covered by BSD License. 35 | % All rights reserved. 36 | % 37 | % Redistribution and use in source and binary forms, with or without 38 | % modification, are permitted provided that the following conditions are 39 | % met: 40 | % 41 | % * Redistributions of source code must retain the above copyright 42 | % notice, this list of conditions and the following disclaimer. 43 | % * Redistributions in binary form must reproduce the above copyright 44 | % notice, this list of conditions and the following disclaimer in 45 | % the documentation and/or other materials provided with the distribution 46 | % 47 | % THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 48 | % AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 49 | % IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 50 | % ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 51 | % LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 | % CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 53 | % SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 54 | % INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 55 | % CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 56 | % ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 57 | % POSSIBILITY OF SUCH DAMAGE. 58 | 59 | % default parameters 60 | m = 64; % number of colors 61 | c = 1; % exponent of shading factor (1 = linear) 62 | 63 | if nargin > 0 64 | if ~isnumeric(varargin{1}) | (size(varargin{1},2) ~= 3 & ~isscalar(varargin{1})) 65 | error('First argument must be numeric: scalar M or Mx3 color matrix'); 66 | end 67 | if isscalar(varargin{1}) 68 | m = varargin{1}; 69 | end 70 | end 71 | if nargin > 0 & size(varargin{1},2) == 3 72 | map = varargin{1}; 73 | m = size(map,1); 74 | else 75 | map = bluered(m); 76 | end 77 | 78 | if nargin > 1 & isscalar(varargin{2}) 79 | c = varargin{2}; 80 | end 81 | 82 | % linear shading from min/max (colormap value) to center (white) 83 | r = repmat(abs(linspace(1,-1,m)).^c,[3,1])'; 84 | map = map.*r + 1 - r; 85 | 86 | if nargout > 0 87 | cmap = map; 88 | else 89 | colormap(map) 90 | caxis([-1,1]*max(abs(caxis))) 91 | % Note: this fixes color axis to manual mode... 92 | end 93 | 94 | 95 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 96 | function map = bluered(m) 97 | 98 | if mod(m,2) 99 | z = [0,0,0]; 100 | m2 = floor(m/2); 101 | else 102 | z = zeros([0,3]); 103 | m2 = m/2; 104 | end 105 | map = [repmat([0,0,1],[m2,1]);z;repmat([1,0,0],[m2,1])]; 106 | 107 | -------------------------------------------------------------------------------- /functions/cmaps/seismic.m: -------------------------------------------------------------------------------- 1 | function rgb = seismic(n) 2 | 3 | % seismic(n) creates a colormap, ranging from dark blue via white to dark 4 | %red. 5 | % 6 | % Nico Sneeuw 7 | % Munich, 31/08/94 8 | 9 | if nargin == 0, n = size(get(gcf,'colormap'),1); end 10 | 11 | m = ceil(n/3); 12 | top = ones(m,1); 13 | bot = zeros(m,1); 14 | up = (0:m-1)'/m; 15 | down = flipud(up); 16 | 17 | r = [bot; up; 1; top; down]; 18 | g = [bot; up; 1; down; bot]; 19 | b = [up; top; 1; down; bot]; 20 | rgb = [r g b]; 21 | 22 | % rgb-map has size 4m+1 now. The central part will be extracted. 23 | 24 | xlarge = 4*m+1-n; 25 | xblue = round(xlarge/2); 26 | xred = xlarge - xblue; 27 | rgb([1:xblue 4*m-xred+2:4*m+1],:) = []; 28 | -------------------------------------------------------------------------------- /functions/createcolormap.m: -------------------------------------------------------------------------------- 1 | function [col,youp,ind]=createcolormap(data,map,colorlogscale,data_min,data_max) 2 | 3 | %%% S. Pasquet - V17.02.17 4 | % Create colormap 5 | % [col,youp,ind]=createcolormap(data,map,colorlogscale) 6 | 7 | if exist('map','var')==0 || isempty(map)==1 8 | map=colormap; 9 | end 10 | if exist('colorlogscale','var')==0 || isempty(colorlogscale)==1 11 | colorlogscale=0; 12 | end 13 | if exist('data_min','var')==0 || isempty(data_min)==1 || exist('data_max','var')==0 || isempty(data_max)==1 14 | diverg = 0; 15 | else 16 | diverg = 1; 17 | end 18 | % Creation of colormaps 19 | if isempty(data)==1 20 | col=[]; 21 | youp=[]; 22 | ind=[]; 23 | elseif length(data)==1 24 | col=map(1,:); 25 | ind=1; 26 | else 27 | if diverg == 0 28 | data_min = min(data); 29 | data_max = max(data); 30 | end 31 | if colorlogscale==0 32 | youp=linspace(data_min,data_max,size(map,1)); 33 | else 34 | youp=logspace(log10(data_min),log10(data_max),size(map,1)); 35 | end 36 | youp(1)=data_min; 37 | youp(end)=data_max; 38 | col=ones(length(data),3); 39 | ind=ones(length(data),1); 40 | for e=1:size(map,1)-1 41 | col(data>=youp(e) & data=youp(e) & data=youp(e) & data %s n1=%d',dspfile_mat,dspfile_tmp,n1); 24 | [~,~]=unix_cmd(com1,wsl); 25 | delete(dspfile_mat); 26 | 27 | com1=sprintf('sustrip < %s > %s head=%s',dspfile_old,dspfile_tmp2,dspfile_head); 28 | [~,~]=unix_cmd(com1,wsl); 29 | delete(dspfile_tmp2); 30 | 31 | com1=sprintf('supaste < %s > %s ns=%d head=%s',dspfile_tmp,dspfile_new,n1,dspfile_head); 32 | [~,~]=unix_cmd(com1,wsl); 33 | delete(dspfile_tmp,dspfile_head); 34 | -------------------------------------------------------------------------------- /functions/dat2surf.m: -------------------------------------------------------------------------------- 1 | function [XX,YY,ZZ,DATA_depth,XX_loc,topo_interp,DEPTH]=dat2surf(filename,dx,dz,utm_start,utm_end,zshift) 2 | 3 | if exist('zshift','var')==0 || isempty(zshift)==1 4 | zshift = 0; 5 | end 6 | 7 | if exist('utm_start','var')==0 || isempty(utm_start)==1 8 | data_type = 1; 9 | % Read file 10 | if isstr(filename) 11 | data = load(filename); 12 | else 13 | data = filename; 14 | end 15 | X = data(:,1); 16 | Y = data(:,2); 17 | Z = data(:,3); 18 | DATA = data(:,4); 19 | utm_start = [X(1) Y(1)]; 20 | utm_end = [X(end) Y(end)]; 21 | 22 | % Calculate local coordinates and new grid 23 | X = utm2local(X,Y,utm_start,utm_end); 24 | if exist('dx','var')==0 || isempty(dx)==1 25 | x = unique(X)'; 26 | else 27 | x = min(unique(X)):dx:max(unique(X)); 28 | end 29 | 30 | % Get topography 31 | uniq_x = unique(X); 32 | topo = zeros(size(uniq_x)); 33 | z_tmp = Z; 34 | 35 | for i=1:length(uniq_x) 36 | topo(i) = max(Z(X==uniq_x(i))); 37 | z_tmp(X==uniq_x(i)) = z_tmp(X==uniq_x(i))-topo(i); 38 | end 39 | if exist('dz','var')==0 || isempty(dx)==1 40 | depth = flipud(unique(z_tmp))'; 41 | elseif length(dz)==1 42 | depth = 0:-dz:-(min(topo)-min(Z(:))); 43 | else 44 | depth = dz; 45 | end 46 | topo_interp = interp1(uniq_x,topo,x); 47 | 48 | [XX,DEPTH] = meshgrid(x,depth); 49 | F2 = scatteredInterpolant(X,z_tmp,DATA,'natural','none'); 50 | DATA_depth=F2(XX,DEPTH); 51 | else 52 | if exist('utm_end','var')==0 || isempty(utm_end)==1 53 | data_type = 2; 54 | else 55 | data_type = 0; 56 | end 57 | % Read file 58 | [DATA,X,Z] = readtomo(filename,1,[],[],100); 59 | 60 | if all(isnan(DATA(1,:))) && length(unique(Z(1,:)))==1 61 | newdata = 0; 62 | else 63 | newdata = 1; 64 | end 65 | 66 | if newdata == 0 67 | % Get topography 68 | [r,c] = find(~isnan(DATA')); 69 | firstIndex = accumarray(r,c,[size(DATA',1),1],@max,max(c)); 70 | topo = Z(firstIndex,1); 71 | z_tmp = Z - repmat(topo',size(Z,1),1); 72 | else 73 | topo = Z(1,:); 74 | for ii = 1:size(DATA,2) 75 | test = find(~isnan(DATA(:,ii)),1); 76 | if ~isempty(test) 77 | topo(ii) = Z(test,ii); 78 | end 79 | end 80 | z_tmp = Z - repmat(topo,size(Z,1),1); 81 | end 82 | 83 | % Flatten and interpolate 84 | if isempty(dx)==1 85 | x = unique(X)'; 86 | else 87 | x = min(unique(X)):dx:max(unique(X)); 88 | end 89 | if isempty(dz)==1 90 | depth = flipud(unique(z_tmp))'; 91 | elseif length(dz)==1 92 | depth = 0:-dz:min(z_tmp(:)); 93 | else 94 | depth = [0 -dz' -max(dz)-mean(diff(dz)):-mean(diff(dz)):min(z_tmp(:))]; 95 | % depth = -dz'; 96 | end 97 | topo_interp = interp1(unique(X),topo,x); 98 | 99 | [XX,DEPTH] = meshgrid(x,depth); 100 | F2 = scatteredInterpolant(X(z_tmp<=0),z_tmp(z_tmp<=0),DATA(z_tmp<=0),'natural','none'); 101 | DATA_depth=F2(XX,DEPTH); 102 | end 103 | XX_loc = XX; 104 | 105 | if data_type==2 106 | aa = load(utm_start); 107 | if size(aa,2)>3 108 | pt = curvspace([aa(:,2),aa(:,3)],length(x)); 109 | else 110 | pt = curvspace([aa(:,1),aa(:,2)],length(x)); 111 | end 112 | X_UTM = pt(:,1); 113 | Y_UTM = pt(:,2); 114 | if zshift == 1 115 | Z_UTM_interp = interp1(aa(:,1),aa(:,4),x); 116 | shift_z = median(Z_UTM_interp - topo_interp);% + 3 117 | end 118 | else 119 | % Calculate UTM coordinates and new grid 120 | [X_UTM, Y_UTM] = local2utm(x,[],utm_start,utm_end); 121 | end 122 | 123 | [XX,~] = meshgrid(X_UTM,depth); 124 | [YY,DEPTH] = meshgrid(Y_UTM,depth); 125 | ZZ = repmat(topo_interp,length(depth),1)+DEPTH; 126 | if zshift == 1 127 | ZZ = ZZ+shift_z; 128 | end 129 | -------------------------------------------------------------------------------- /functions/dat2vol.m: -------------------------------------------------------------------------------- 1 | function [XX,YY,ZZ,DATA_depth]=dat2vol(filename,dx,dy,dz,utm_start,utm_end) 2 | 3 | aa = load(filename); 4 | 5 | X = aa(:,1); 6 | Y = aa(:,2); 7 | Z = aa(:,3); 8 | DATA = aa(:,4); 9 | 10 | % plot_scat_log3(2,X,Y,Z,DATA); drawnow; 11 | 12 | if exist('utm_start','var')==0 || isempty(utm_start)==1 13 | [~, seg_len] = arclength(X,Y); 14 | utm_start = [X(end) Y(end)]; 15 | utm_end = [X(find(seg_len>median(seg_len)*2,1,'last')+1) Y(find(seg_len>median(seg_len)*4,1,'last')+1)]; 16 | % figure; 17 | % plot(X,Y,'x'); 18 | % hold on; 19 | % plot([utm_start(1) utm_end(1)],[utm_start(2) utm_end(2)],'r'); 20 | 21 | % Calculate local coordinates and new grid 22 | [X, Y] = utm2local(X,Y,utm_start,utm_end); 23 | % figure; 24 | % plot(X,Y,'x'); 25 | end 26 | 27 | x = [min(unique(X)):dx/9:min(unique(X))+dx min(unique(X))+2*dx:dx:max(unique(X))-2*dx max(unique(X))-dx:dx/9:max(unique(X))]; 28 | y = [min(unique(Y)):dy/9:min(unique(Y))+dy min(unique(Y))+2*dy:dy:max(unique(Y))-2*dy max(unique(Y))-dy:dy/9:max(unique(Y))]; 29 | 30 | [uni_XY,~,J] = unique([X Y],'rows'); 31 | topo = zeros(size(uni_XY,1),1); 32 | maxdepth = zeros(size(uni_XY,1),1); 33 | for i = 1:length(uni_XY) 34 | topo(i) = max(Z(ismember(J,i))); 35 | maxdepth(i) = topo(i) - min(Z(ismember(J,i))); 36 | end 37 | maxdepth = max(maxdepth); 38 | 39 | [Xt,Yt] = ndgrid(x,y); 40 | F1 = scatteredInterpolant(uni_XY(:,1),uni_XY(:,2),topo,'natural','linear'); 41 | topoI = F1(Xt,Yt); 42 | 43 | if length(dz) == 1; 44 | % z = [min(unique(Z)):dz:max(unique(Z))]; 45 | z = [0:dz:maxdepth]; 46 | else 47 | z = gen_zvec(maxdepth,dz); 48 | z(end) = -maxdepth; 49 | end 50 | topoI = repmat(topoI,1,1,length(z)); 51 | 52 | [XX,YY,ZZ] = ndgrid(x,y,z); 53 | ZZ = ZZ + topoI; 54 | F2 = scatteredInterpolant(X,Y,Z,DATA,'natural','nearest'); 55 | DATA_depth=F2(XX,YY,ZZ); 56 | 57 | if exist('utm_start','var') && ~isempty(utm_start) 58 | % Calculate UTM coordinates and new grid 59 | [X_UTM, Y_UTM] = local2utm(XX(:),YY(:),utm_start,utm_end); 60 | XX = reshape(X_UTM,length(x),length(y),length(z)); 61 | YY = reshape(Y_UTM,length(x),length(y),length(z)); 62 | end 63 | 64 | 65 | -------------------------------------------------------------------------------- /functions/dinsave.m: -------------------------------------------------------------------------------- 1 | function dinsave(filename,thk,vp,vs,rho) 2 | 3 | %%% S. Pasquet - V22.05.04 4 | % Save velocity model in dinver format for forward calculation 5 | % dinsave(filename,thk,vp,vs,rho) 6 | 7 | wsl = ispc_wsl; 8 | 9 | filename_unix = unix_wsl_path(filename,wsl); 10 | 11 | unix_cmd(['rm -rf -- ',filename_unix],wsl); 12 | nl=length(thk); 13 | if length(vp)==1 14 | vp=repmat(vp,size(thk)); 15 | end 16 | if length(vs)==1 17 | vs=repmat(vs,size(thk)); 18 | end 19 | if length(rho)==1 20 | rho=repmat(rho,size(thk)); 21 | end 22 | 23 | fid0=fopen(filename,'w'); % Open file for writing 24 | fprintf(fid0,'%d \n',nl); % Write nb of layers 25 | for i=1:1:nl-1 % Loop over nb of layers - 1 26 | % Write thickness and velocity in dinver format 27 | fprintf(fid0,'%f %f %f %f \n',[thk(i) vp(i) vs(i) rho(i)]); 28 | end 29 | % Write last line 30 | fprintf(fid0,'%f %f %f %f \n',[0 vp(i+1) vs(i+1) rho(i+1)]); 31 | fclose(fid0); % Close file 32 | -------------------------------------------------------------------------------- /functions/dir_create.m: -------------------------------------------------------------------------------- 1 | function [dir_all,dir_inv_img]=dir_create(flag,nWmin,nWmax,dW,dSmin,dSmax,side) 2 | 3 | %%% S. Pasquet - V18.09.06 4 | % Create directories for surface-wave analysis 5 | % [dir_all,dir_inv_img]=dir_create(flag,nWmin,nWmax,dW,dSmin,dSmax,side) 6 | 7 | dir_inv_img=[]; 8 | dir_all.dir_start=pwd; % Current working directory 9 | 10 | if flag~=1 11 | % Select main folder (Wmin_max.dWb.nSmin_max.side) 12 | 13 | files = dir; 14 | dirFlags = [files.isdir]; 15 | files = files(dirFlags); flag2 = 0; 16 | for i = 1:sum(dirFlags) 17 | if ~strcmp(files(i).name,'.') && ~strcmp(files(i).name,'..') && ~strcmp(files(i).name,'file.param') 18 | flag2 = flag2+1; 19 | j = i; 20 | end 21 | end 22 | if flag2 ~= 1 23 | fprintf('\n Select subproject folder (Wmin_max.dWx.dSmin_max.side)'); 24 | dir_all.dir_main=uigetdir('./','Select subproject folder (Wmin_max.dWx.dSmin_max.side)'); 25 | else 26 | fprintf('\n Subproject folder (Wmin_max.dWx.dSmin_max.side)'); 27 | dir_all.dir_main=fullfile(pwd,files(j).name); 28 | end 29 | 30 | if dir_all.dir_main==0 31 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 32 | fprintf('\n Please select a subproject folder'); 33 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 34 | return 35 | end 36 | [~,selected_folder,ext] = fileparts(dir_all.dir_main); 37 | if flag2 ~= 1 38 | fprintf('\n Manual selection: %s\n',strcat(selected_folder,ext)); 39 | else 40 | fprintf('\n Auto selection: %s\n',strcat(selected_folder,ext)); 41 | end 42 | % [~,dir_all.dir_main,ext]=fileparts(dir_all.dir_main); 43 | % dir_all.dir_main=[dir_all.dir_main,ext]; 44 | else 45 | dir_all.dir_main=fullfile(dir_all.dir_start,['W',num2str(nWmin),'_',num2str(nWmax),'.dW'... 46 | ,num2str(dW),'.dS',num2str(dSmin),'_',num2str(dSmax),'.',side]); 47 | if exist(dir_all.dir_main,'dir')~=7 48 | mkdir(dir_all.dir_main); 49 | end 50 | end 51 | 52 | % Path of file.dat folder (contains processing files) 53 | dir_all.dir_dat=fullfile(dir_all.dir_main,'/file.dat/'); 54 | % Path of file.pick folder (contains picked dispersion curves ASCII files) 55 | dir_all.dir_pick=fullfile(dir_all.dir_main,'/file.pick/'); 56 | % Path of file.img folder to store .img files 57 | dir_all.dir_img=fullfile(dir_all.dir_main,'/file.img/'); 58 | % Path of file.xmid folder to store .img files 59 | dir_all.dir_img_xmid=fullfile(dir_all.dir_img,'/1D_data/'); 60 | % Path of file.targ folder to store .targ files 61 | dir_all.dir_targ=fullfile(dir_all.dir_main,'/file.targ/'); 62 | % Path of file.param folder to store global .param files 63 | dir_all.dir_param=fullfile(dir_all.dir_start,'file.param'); 64 | % Path of file.inv folder to store inversion results 65 | dir_all.dir_inv=fullfile(dir_all.dir_main,'/file.inv/'); 66 | % Path of file.xzv folder to store final 2D models 67 | dir_all.dir_xzv=fullfile(dir_all.dir_main,'/file.xzv/'); 68 | 69 | fprintf('\n ---------------------\n'); 70 | 71 | if exist(dir_all.dir_dat,'dir')~=7 72 | if flag==1 73 | mkdir(dir_all.dir_dat); 74 | else 75 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!'); 76 | fprintf('\n Missing file.dat folder'); 77 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 78 | dir_all.dir_main=0; 79 | return 80 | end 81 | end 82 | if exist(dir_all.dir_pick,'dir')~=7 83 | mkdir(dir_all.dir_pick); 84 | end 85 | if exist(dir_all.dir_img,'dir')~=7 86 | mkdir(dir_all.dir_img); 87 | end 88 | if exist(dir_all.dir_img_xmid,'dir')~=7 89 | mkdir(dir_all.dir_img_xmid); 90 | end 91 | if exist(dir_all.dir_targ,'dir')~=7 92 | mkdir(dir_all.dir_targ); 93 | end 94 | if exist(dir_all.dir_param,'dir')~=7 95 | mkdir(dir_all.dir_param); 96 | end 97 | if exist(dir_all.dir_inv,'dir')~=7 98 | mkdir(dir_all.dir_inv); 99 | end 100 | if exist(dir_all.dir_xzv,'dir')~=7 101 | mkdir(dir_all.dir_xzv); 102 | end 103 | 104 | if flag==2 105 | % Select inversion folder containing report folders 106 | 107 | files = dir(dir_all.dir_inv); 108 | dirFlags = [files.isdir]; 109 | files = files(dirFlags); flag2 = 0; 110 | for i = 1:sum(dirFlags) 111 | if ~strcmp(files(i).name,'.') && ~strcmp(files(i).name,'..') 112 | flag2 = flag2+1; 113 | j = i; 114 | end 115 | end 116 | if flag2 ~= 1 117 | fprintf('\n Select inversion folder'); 118 | dir_inv_img.dir_rep_inv=uigetdir([dir_all.dir_main,'/file.inv/'],'Select inversion folder'); 119 | else 120 | fprintf('\n Inversion folder'); 121 | dir_inv_img.dir_rep_inv=fullfile(dir_all.dir_inv,files(j).name); 122 | end 123 | 124 | if dir_inv_img.dir_rep_inv==0 125 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 126 | fprintf('\n Please select an inversion folder'); 127 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 128 | return 129 | end 130 | 131 | [~,selected_folder,ext] = fileparts(dir_inv_img.dir_rep_inv); 132 | if flag2 ~= 1 133 | fprintf('\n Manual selection: %s\n',strcat(selected_folder,ext)); 134 | else 135 | fprintf('\n Auto selection: %s\n',strcat(selected_folder,ext)); 136 | end 137 | 138 | % Get name of inversion folder 139 | if isunix==1 140 | dir_inv_img.dir_inv_name=dir_inv_img.dir_rep_inv... 141 | (strfind(dir_inv_img.dir_rep_inv,'/file.inv/')+10:end); 142 | else 143 | dir_inv_img.dir_inv_name=dir_inv_img.dir_rep_inv... 144 | (strfind(dir_inv_img.dir_rep_inv,'\file.inv\')+10:end); 145 | end 146 | % Folder to store inversion .img files 147 | dir_inv_img.dir_img_inv=[dir_all.dir_img,dir_inv_img.dir_inv_name]; 148 | if exist(dir_inv_img.dir_img_inv,'dir')~=7 149 | mkdir(dir_inv_img.dir_img_inv); 150 | end 151 | % Folder to store inversion .xzv files 152 | dir_inv_img.dir_xzv_inv=[dir_all.dir_xzv,dir_inv_img.dir_inv_name]; 153 | if exist(dir_inv_img.dir_img_inv,'dir')~=7 154 | mkdir(dir_inv_img.dir_img_inv); 155 | end 156 | fprintf('\n ---------------------\n'); 157 | end 158 | 159 | end -------------------------------------------------------------------------------- /functions/dsp2dat.m: -------------------------------------------------------------------------------- 1 | function [dspmat,f,v]=dsp2dat(dspfile,flip,datsave) 2 | 3 | %%% S. Pasquet - V22.05.04 4 | % Convert .dsp su file in ASCII file .dat for matlab 5 | % [dspmat,f,v]=dsp2dat(dspfile,flip,datsave) 6 | 7 | wsl = ispc_wsl; 8 | 9 | dspfile_unix = unix_wsl_path(dspfile,wsl); 10 | 11 | if flip==0 12 | % Frequency minimum 13 | [~,fmin]=unix_cmd(['sugethw < ',dspfile_unix,' key=f1 output=geom | uniq'],wsl); 14 | fmin=str2double(fmin); 15 | % Velocity minimum 16 | [~,vmin]=unix_cmd(['sugethw < ',dspfile_unix,' key=f2 output=geom | uniq'],wsl); 17 | vmin=str2double(vmin); 18 | 19 | % Nb of frequency samples 20 | [~,nf]=unix_cmd(['sugethw < ',dspfile_unix,' key=ns output=geom | uniq'],wsl); 21 | nf=str2double(nf); 22 | % Nb of velocity samples 23 | [~,nv]=unix_cmd(['sugethw < ',dspfile_unix,' key=ntr output=geom | uniq'],wsl); 24 | nv=str2double(nv); 25 | 26 | % Frequency sampling 27 | [~,df]=unix_cmd(['sugethw < ',dspfile_unix,' key=d1 output=geom | uniq'],wsl); 28 | df=str2double(df); 29 | % Velocity sampling 30 | [~,dv]=unix_cmd(['sugethw < ',dspfile_unix,' key=d2 output=geom | uniq'],wsl); 31 | dv=str2double(dv); 32 | 33 | n1=nf; 34 | else 35 | % Frequency minimum 36 | [~,fmin]=unix_cmd(['sugethw < ',dspfile_unix,' key=f2 output=geom | uniq'],wsl); 37 | fmin=str2double(fmin); 38 | % Velocity minimum 39 | [~,vmin]=unix_cmd(['sugethw < ',dspfile_unix,' key=delrt output=geom | uniq'],wsl); 40 | vmin=str2double(vmin); 41 | 42 | % Nb of frequency samples 43 | [~,nf]=unix_cmd(['sugethw < ',dspfile_unix,' key=ntr output=geom | uniq'],wsl); 44 | nf=str2double(nf); 45 | % Nb of velocity samples 46 | [~,nv]=unix_cmd(['sugethw < ',dspfile_unix,' key=ns output=geom | uniq'],wsl); 47 | nv=str2double(nv); 48 | 49 | % Frequency sampling 50 | [~,df]=unix_cmd(['sugethw < ',dspfile_unix,' key=d2 output=geom | uniq'],wsl); 51 | df=str2double(df); 52 | % Velocity sampling 53 | [~,dv]=unix_cmd(['sugethw < ',dspfile_unix,' key=dt output=geom | uniq'],wsl); 54 | dv=str2double(dv)/1000; 55 | 56 | n1=nv; 57 | end 58 | if isunix==1 || ispc_wsl==1 59 | com1=sprintf('sustrip < %s | b2a n1=%d > %s',dspfile_unix,n1,[dspfile_unix,'.dat']); 60 | else 61 | com1=sprintf('sustrip < %s head=head outpar=outpar | b2a n1=%d outpar=outpar > %s',... 62 | dspfile_unix,n1,[dspfile_unix,'.dat']); 63 | end 64 | [~,~]=unix_cmd(com1,wsl); 65 | 66 | % Velocity table 67 | v=vmin:dv:vmin+dv*(nv-1); 68 | % Frequency table 69 | f=fmin:df:fmin+df*(nf-1); 70 | 71 | dspmat=load([dspfile,'.dat']); 72 | if datsave~=1 73 | delete([dspfile,'.dat']); 74 | end 75 | if ~isunix && ~ispc_wsl 76 | delete('head','outpar'); 77 | end 78 | end -------------------------------------------------------------------------------- /functions/errorbar_tick.m: -------------------------------------------------------------------------------- 1 | function errorbar_tick(h,w,xtype) 2 | %ERRORBAR_TICK Adjust the width of errorbars 3 | % ERRORBAR_TICK(H) adjust the width of error bars with handle H. 4 | % Error bars width is given as a ratio of X axis length (1/80). 5 | % ERRORBAR_TICK(H,W) adjust the width of error bars with handle H. 6 | % The input W is given as a ratio of X axis length (1/W). The result 7 | % is independent of the x-axis units. A ratio between 20 and 80 is usually fine. 8 | % ERRORBAR_TICK(H,W,'UNITS') adjust the width of error bars with handle H. 9 | % The input W is given in the units of the current x-axis. 10 | % 11 | % See also ERRORBAR 12 | % 13 | 14 | % Author: Arnaud Laurent 15 | % Creation : Jan 29th 2009 16 | % MATLAB version: R2007a 17 | % 18 | % Notes: This function was created from a post on the french forum : 19 | % http://www.developpez.net/forums/f148/environnements-developpement/matlab/ 20 | % Author : Jerome Briot (Dut) 21 | % http://www.mathworks.com/matlabcentral/newsreader/author/94805 22 | % http://www.developpez.net/forums/u125006/dut/ 23 | % It was further modified by Arnaud Laurent and Jerome Briot. 24 | 25 | % Check numbers of arguments 26 | if nargin<3 27 | return 28 | end 29 | % Check for the use of V6 flag ( even if it is depreciated ;) ) 30 | flagtype = get(h,'type'); 31 | 32 | % Check number of arguments and provide missing values 33 | if nargin==1 34 | w = 80; 35 | end 36 | 37 | if nargin<3 38 | xtype = 'ratio'; 39 | end 40 | 41 | % Calculate width of error bars 42 | if ~strcmpi(xtype,'units') 43 | dx = diff(get(gca,'XLim')); % Retrieve x limits from current axis 44 | w = dx/w; % Errorbar width 45 | end 46 | 47 | % Plot error bars 48 | if strcmpi(flagtype,'hggroup') % ERRORBAR(...) 49 | 50 | hh=get(h,'children'); % Retrieve info from errorbar plot 51 | x = get(hh(2),'xdata'); % Get xdata from errorbar plot 52 | 53 | x(4:9:end) = x(1:9:end)-w/2; % Change xdata with respect to ratio 54 | x(7:9:end) = x(1:9:end)-w/2; 55 | x(5:9:end) = x(1:9:end)+w/2; 56 | x(8:9:end) = x(1:9:end)+w/2; 57 | 58 | set(hh(2),'xdata',x(:)) % Change error bars on the figure 59 | 60 | elseif strcmpi(flagtype,'errorbar') % ERRORBAR(...) 61 | 62 | x = h.Bar.VertexData(:); % Retrieve bar xdata from errorbar 63 | dp = length(x)/3; % 3 data points per error bar 64 | m = 1; % Multiplier for addition/subtraction 65 | for ii = 1:dp 66 | m = -1*m; % Switch between subtraction and addition 67 | x(dp+ii:dp:end) = x(ii)+m*w/2; % Change xdata with respect to the chosen ratio 68 | end 69 | h.Bar.VertexData(1:end) = x; 70 | 71 | else % ERRORBAR('V6',...) 72 | 73 | x = get(h(1),'xdata'); % Get xdata from errorbar plot 74 | 75 | x(4:9:end) = x(1:9:end)-w/2; % Change xdata with respect to the chosen ratio 76 | x(7:9:end) = x(1:9:end)-w/2; 77 | x(5:9:end) = x(1:9:end)+w/2; 78 | x(8:9:end) = x(1:9:end)+w/2; 79 | 80 | set(h(1),'xdata',x(:)) % Change error bars on the figure 81 | end -------------------------------------------------------------------------------- /functions/export_fig/print2eps.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/functions/export_fig/print2eps.m -------------------------------------------------------------------------------- /functions/findpeak.m: -------------------------------------------------------------------------------- 1 | function [vmaxamp,fmaxamp]=findpeak(dspmat,f,v,fpick,vpick,wl) 2 | 3 | % S. Pasquet - V18.05.23 4 | % findpeak.m looks at dispersion image maximum in specified window at the picked frequency 5 | % [vmaxamp,fmaxamp]=findpeak(dspmat,f,v,fpick,vpick,wl) 6 | 7 | nbpick=length(fpick); 8 | fmaxamp=[]; vmaxamp=[]; 9 | for i=1:nbpick 10 | if fpick(i)>max(f) || fpick(i)max(v) 17 | vpick(i)=max(v); 18 | end 19 | if isnan(vpick(i))~=1 20 | if wl(i)>1 21 | vmin=vpick(i)-wl(i); 22 | vmax=vpick(i)+wl(i); 23 | condV=(v>=vmin & v<=vmax); 24 | if isempty(find(condV==1, 1)) 25 | ind_v=find(abs(vpick(i)-v)==min(abs(vpick(i)-v)),1,'first'); 26 | condV(ind_v)=1; 27 | end 28 | ind2=find(dspmat(ind,condV)==max(dspmat(ind,condV))); 29 | nbind2=length(ind2); 30 | if nbind2>1 31 | if mod(nbind2,2)==1 32 | ind2=ind2(1+(nbind2-1)/2); 33 | else 34 | ind2=ind2(nbind2/2); 35 | end 36 | end 37 | vwin=v(condV); 38 | if ~isempty(ind2) 39 | vmaxamp(i)=vwin(ind2); 40 | else 41 | vmaxamp(i)=NaN; 42 | end 43 | else 44 | vmaxamp(i)=vpick(i); 45 | end 46 | else 47 | vmaxamp(i)=NaN; 48 | end 49 | end 50 | 51 | end -------------------------------------------------------------------------------- /functions/fmin_search.m: -------------------------------------------------------------------------------- 1 | function [flim,specfileOK,specmat_all]=fmin_search(av,specstruct,dir_dat_xmid,dt,specampmin,specfmin) 2 | 3 | %%% S. Pasquet - V17.05.23 4 | %%% Look for minimum frequency where spectrogram normalized amplitude reaches specampmin 5 | % [flim,specfileOK]=fmin_search(specstruct,dir_dat_xmid,dt,specampmin,specfmin) 6 | flim=NaN*zeros(length(specstruct),1); 7 | specmat_all = []; 8 | 9 | for ip=1:length(specstruct) 10 | specfile=specstruct(ip).name; 11 | specmat=dsp2dat(fullfile(dir_dat_xmid,[specfile(1:end-4),'spec']),0,0); 12 | fspecmax=1/dt; 13 | nfspec=size(specmat,2); 14 | dfspec=fspecmax/2/(nfspec-1); 15 | fspec=0:dfspec:fspecmax/2; 16 | nx=size(specmat,1); 17 | flimtmp=ones(nx,1)*max(fspec)*NaN; 18 | 19 | specmat_all = [specmat_all; specmat]; 20 | 21 | for jj=1:nx 22 | ind=find(specmat(jj,:)>=specampmin & fspec>specfmin,1,'first'); 23 | if isempty(ind)==0 24 | flimtmp(jj)=fspec(ind); 25 | else 26 | flimtmp(jj)=0; 27 | end 28 | end 29 | flim(ip)=mean(flimtmp(isnan(flimtmp)==0))-std(flimtmp(isnan(flimtmp)==0)); 30 | end 31 | 32 | specamp_mean = mean(specmat_all); 33 | specamp_std = std(specmat_all); 34 | 35 | if av == 1 36 | if isempty(specstruct)==0 37 | specfileOK=specstruct(flim==min(flim)).name; 38 | flim=mean(flim); 39 | else 40 | flim=NaN; 41 | specfileOK=[]; 42 | end 43 | elseif av == 2 || av == 0 44 | % ind = find(specamp_mean>=specampmin & fspec>specfmin,1,'first'); 45 | ind = find(specamp_mean>=specamp_mean(2)+specamp_std(2) & fspec>specfmin,1,'first'); 46 | 47 | if isempty(specstruct)==0 48 | specfileOK=specstruct(flim==min(flim)).name; 49 | flim = fspec(ind-1); 50 | else 51 | flim=NaN; 52 | specfileOK=[]; 53 | end 54 | end 55 | 56 | %% 57 | % plot_curv(1,fspec,specmat_tmp,[],'.-','r',2,0,0,0,16,'Frequency (Hz)','Mean norm. amplitude',[],... 58 | % [0 100],[],[],[],[],[],specampmin,flim,[],[],[],[],[]); 59 | -------------------------------------------------------------------------------- /functions/fmin_search_disp.m: -------------------------------------------------------------------------------- 1 | function [flim,dspmat_all]=fmin_search_disp(dispstruct,dir_dat_xmid,f,specfmin) 2 | 3 | %%% S. Pasquet - V17.05.23 4 | %%% Look for minimum frequency where dispersion image reaches ... 5 | % [flim,specfileOK]=fmin_search(specstruct,dir_dat_xmid,dt,specampmin,specfmin) 6 | 7 | flim=NaN*zeros(length(dispstruct),1); 8 | dspmat_all = []; 9 | 10 | for ip=1:length(dispstruct) 11 | dispfile=dispstruct(ip).name; 12 | dspmat=dsp2dat(fullfile(dir_dat_xmid,[dispfile(1:end-3),'dsp']),0,0); 13 | dspmat_all = [dspmat_all; dspmat]; 14 | end 15 | 16 | dspamp_mean = nanmean(dspmat_all,2); 17 | dspamp_std = nanstd(dspmat_all,2); 18 | try 19 | ind = find(dspamp_mean==max(dspamp_mean) & f>=specfmin,1,'first'); 20 | catch 21 | ind = find(dspamp_mean==max(dspamp_mean) & f'>=specfmin,1,'first'); 22 | end 23 | 24 | flim = f(ind); -------------------------------------------------------------------------------- /functions/gauss_weight.m: -------------------------------------------------------------------------------- 1 | function weight = gauss_weight(misfit) 2 | 3 | % keyboard 4 | nbin = 10; 5 | 6 | t = linspace(min(misfit),max(misfit),nbin); 7 | gauss=(1/(4*std(misfit)*sqrt(2*pi)))*exp(-0.5.*((t-min(misfit))/(4*std(misfit))).^2); 8 | coef=gauss/sum(gauss); 9 | 10 | weight=zeros(size(misfit)); 11 | for gg=1:length(t)-1 12 | flag1=find(misfit>=t(gg) & misfit name of the .SU file 9 | % xsca (optionnal) => scaling factor for spatial coordinates 10 | % 11 | % acquiparam.dt => sampling interval in sec 12 | % acquiparam.dx => mean inter-geophone spacing in m 13 | % acquiparam.Gx => geophones positions in m 14 | % acquiparam.Sx => sources positions in m 15 | % acquiparam.Gz => geophones elevation in m 16 | % acquiparam.Sz => sources elevation in m 17 | % acquiparam.NGx => Nb of geophones positions 18 | % acquiparam.NSx => Nb of sources positions 19 | % acquiparam.Gxsing => Single geophones positions 20 | % acquiparam.Sxsing => Single sources positions 21 | % acquiparam.Gzsing => Single geophones elevations 22 | % acquiparam.Szsing => Single sources elevations 23 | % acquiparam.fldr => Source shot number 24 | % acquiparam.topo => Profile topography (X,Z) 25 | 26 | wsl = ispc_wsl; 27 | 28 | if exist('xsca','var')==0 || isempty(xsca)==1 29 | [~,xsca]=unix_cmd(['sugethw < ',sufile,' scalco output=geom | uniq'],wsl); 30 | xsca=abs(str2double(xsca)); 31 | if xsca==0 32 | answer1=inputdlg({'Scaling factor'},'',1); 33 | if isempty(answer1)==1 34 | xsca=0; 35 | else 36 | xsca=str2double(answer1(1)); 37 | end 38 | end 39 | end 40 | 41 | if nargin<3 42 | istomo=0; 43 | end 44 | 45 | % Sampling interval (in second) 46 | [~,dt]=unix_cmd(['sugethw < ',sufile,' dt output=geom | uniq'],wsl); 47 | dt=str2double(dt)/1000000; 48 | % Mean inter-geophone spacing 49 | [~,dx]=unix_cmd(['sugethw < ',sufile,' gdel output=geom | uniq'],wsl); 50 | dx=str2double(dx)/xsca; 51 | if dx==0 && istomo==0 52 | answer1=inputdlg({'Mean geophone spacing'},'',1); 53 | if isempty(answer1)==1 54 | dx=0; 55 | else 56 | dx=str2double(answer1(1)); 57 | end 58 | end 59 | % Geophones positions 60 | [~,Gx]=unix_cmd(['sugethw < ',sufile,' key=gx output=geom'],wsl); 61 | Gx=str2num(Gx)/xsca; 62 | % Sources positions 63 | [~,Sx]=unix_cmd(['sugethw < ',sufile,' key=sx output=geom'],wsl); 64 | Sx=str2num(Sx)/xsca; 65 | % Geophones elevations 66 | [~,Gz]=unix_cmd(['sugethw < ',sufile,' key=gelev output=geom'],wsl); 67 | Gz=str2num(Gz)/xsca; 68 | % Sources elevations 69 | [~,Sz]=unix_cmd(['sugethw < ',sufile,' key=selev output=geom'],wsl); 70 | Sz=str2num(Sz)/xsca; 71 | % Sources number 72 | [~,fldr]=unix_cmd(['sugethw < ',sufile,' key=fldr output=geom'],wsl); 73 | [fldr,I]=unique(str2num(fldr),'first'); 74 | % Sort source numbers with shot positions 75 | [~,J]=sort(Sx(I)); 76 | fldr=fldr(J); 77 | 78 | [Gxsing,I]=unique(Gx,'first'); % Single geophone positions 79 | Gzsing=Gz(I); % Single geophone altitude 80 | [Sxsing,I]=unique(Sx,'first'); % Single source positions 81 | Szsing=Sz(I); % Single source altitude 82 | NGx=length(Gxsing); % Nb of geophones positions 83 | NSx=length(Sxsing); % Nb of sources positions 84 | [Xsing,I]=unique([Gxsing;Sxsing],'first'); % X single positions 85 | Zsing=[Gzsing;Szsing]; % Z single positions 86 | 87 | array = check_depth_array(Gx,Gz,Sx,Sz); 88 | if ~isempty(array{1}) 89 | topo = unique(sortrows([array{1}.G_sing; array{1}.S_sing],1),'rows'); 90 | else 91 | topo=sortrows([Xsing,Zsing(I)],1); % Topo 92 | end 93 | 94 | acquiparam=struct('dt',dt,'dx',dx,'Gx',Gx,'Gz',Gz,'Sx',Sx,'Sz',Sz,... 95 | 'NGx',NGx,'NSx',NSx,'Gxsing',Gxsing,'Gzsing',Gzsing,... 96 | 'Sxsing',Sxsing,'Szsing',Szsing,'fldr',fldr,'topo',topo,'xsca',xsca); 97 | end -------------------------------------------------------------------------------- /functions/interp1qr.m: -------------------------------------------------------------------------------- 1 | function yi = interp1qr(x,y,xi) 2 | %% Quicker 1D linear interpolation 3 | % Performs 1D linear interpolation of 'xi' points using 'x' and 'y', 4 | % resulting in 'yi', following the formula yi = y1 + (y2-y1)/(x2-x1)*(xi-x1). 5 | % Returns NaN for values of 'xi' out of range of 'x', and when 'xi' is NaN. 6 | % 7 | % 'x' is column vector [m x 1], monotonically increasing. 8 | % 'y' is matrix [m x n], corresponding to 'x'. 9 | % 'xi' is column vector [p x 1], in any order. 10 | % 'yi' is matrix [p x n], corresponding to 'xi'. 11 | % 12 | % Copyright (c) 2013 Jose M. Mier 13 | % 14 | 15 | %% Full function description 16 | % Quicker 1D linear interpolation: 'interp1qr' 17 | % Performs 1D linear interpolation of 'xi' points using 'x' and 'y', 18 | % resulting in 'yi', following the formula yi = y1 + (y2-y1)/(x2-x1)*(xi-x1). 19 | % 20 | % It has same functionality as built-in MATLAB function 'interp1q' (see 21 | % MATLAB help for details). 22 | % 23 | % It runs at least 3x faster than 'interp1q' and 8x faster than 'interp1', 24 | % and more than 10x faster as m=length(x) increases (see attached performance 25 | % graph). 26 | % 27 | % As with 'interp1q', this function does no input checking. To work properly 28 | % user has to be aware of the following: 29 | % - 'x' must be a monotonically increasing column vector. 30 | % - 'y' must be a column vector or matrix with m=length(x) rows. 31 | % - 'xi' must be a column vector. 32 | % 33 | % As with 'interp1q', if 'y' is a matrix, then the interpolation is performed 34 | % for each column of 'y', in which case 'yi' is p=length(xi) by n=size(y,2). 35 | % 36 | % As with 'interp1q', this function returns NaN for any values of 'xi' that 37 | % lie outside the coordinates in 'x', and when 'xi' is NaN. 38 | % 39 | % This function uses the approach given by Loren Shure (The MathWorks) in 40 | % http://blogs.mathworks.com/loren/2008/08/25/piecewise-linear-interpolation/ 41 | % - Uses the function 'histc' to get the 'xi_pos' vector. 42 | % - Also uses a small trick to rearrange the linear operation, such that 43 | % yi = y1 + s*(xi-x1), where s = (y2-y1)/(x2-x1), now becomes 44 | % yi = y1 + t*(y2-y1), where t = (xi-x1)/(x2-x1), which reduces the need 45 | % for replicating a couple of matrices and the right hand division 46 | % operation for 't' is simpler than it was for 's' because it takes place 47 | % only in one dimension (both 'x' and 'xi' are column vectors). 48 | % 49 | % Acknowledgements: Nils Oberg, Blake Landry, Marcelo H. Garcia, 50 | % the University of Illinois (USA), and the University of Cantabria (Spain). 51 | % 52 | % Author: Jose M. Mier 53 | % Contact: jmierlo2@illinois.edu 54 | % Date: August 2013 55 | % Version: 4 56 | % 57 | 58 | %% Function begins 59 | 60 | % Size of 'x' and 'y' 61 | m = size(x,1); 62 | n = size(y,2); 63 | 64 | % For each 'xi', get the position of the 'x' element bounding it on the left [p x 1] 65 | [~,xi_pos] = histc(xi,x); 66 | xi_pos = max(xi_pos,1); % To avoid index=0 when xi < x(1) 67 | xi_pos = min(xi_pos,m-1); % To avoid index=m+1 when xi > x(end). 68 | 69 | % 't' matrix [p x 1] 70 | dxi = xi-x(xi_pos); 71 | dx = x(xi_pos+1)-x(xi_pos); 72 | t = dxi./dx; 73 | 74 | % Get 'yi' 75 | yi = y(xi_pos,:) + t(:,ones(1,n)).*(y(xi_pos+1,:)-y(xi_pos,:)); 76 | 77 | % Give NaN to the values of 'yi' corresponding to 'xi' out of the range of 'x' 78 | yi(xix(end),:) = NaN; 79 | 80 | end 81 | -------------------------------------------------------------------------------- /functions/ispc_wsl.m: -------------------------------------------------------------------------------- 1 | function result = ispc_wsl 2 | 3 | %%% S. Pasquet - V22.05.04 4 | % Test if wsl is installed 5 | % result = ispc_wsl 6 | 7 | if ispc 8 | [s,~] = unix('wsl -l -v'); 9 | if s==0 10 | result = 1; 11 | else 12 | result = 0; 13 | end 14 | else 15 | result = 0; 16 | end -------------------------------------------------------------------------------- /functions/lorentzerr.m: -------------------------------------------------------------------------------- 1 | function deltac=lorentzerr(vel,lam,nW,dx,fac,maxerr,minvelerr,a) 2 | 3 | %%% S. Pasquet - V17.05.23 4 | %%% Compute Lorentzian error according to O'Neill's workflow 5 | % deltac=lorentzerr(vel,lam,nW,dx,fac,maxerr,minvelerr,a) 6 | 7 | if exist('fac','var')==0 || isempty(fac)==1 8 | fac = 10.^(1./sqrt((nW-1)*dx)); % factor to adapt error depending on window size (in A_SWIPdisp_script also) (previously multiplied by 0.8) 9 | end 10 | 11 | if exist('maxerr','var')==0 || isempty(maxerr)==1 12 | maxerr=0.4; % Maximum error ratio (0.4 means that the error won't be higher than 40% of the velocity) 13 | end 14 | 15 | if exist('minvelerr','var')==0 || isempty(minvelerr)==1 16 | minvelerr=5; % Minimum error (in m/s) 17 | end 18 | 19 | if exist('a','var')==0 || isempty(a)==1 20 | a=0.55; % Default a parameter (0.5 recommended by A. O'Neill, 0.75 seems to fit better) increase to tighten errorbars 21 | end 22 | 23 | A=zeros(length(vel),1); 24 | B=A; DELTAc=A; deltac=A; 25 | % Error calculation 26 | A(vel>0)=(1./(vel(vel>0)))-1./((2*vel(vel>0)./lam(vel>0))*((nW-1)*fac)*dx); 27 | B(vel>0)=(1./(vel(vel>0)))+1./((2*vel(vel>0)./lam(vel>0))*((nW-1)*fac)*dx); 28 | DELTAc(vel>0)=abs((1./A(vel>0))-(1./B(vel>0))); 29 | deltac(vel>0)=(10.^(-a)).*DELTAc(vel>0); 30 | 31 | % Error higher limit 32 | deltac(vel'>0 & deltac>(maxerr*vel)')=maxerr*vel(vel'>0 & deltac>(maxerr*vel)')'; 33 | % Error lower limit 34 | deltac(vel'>0 & deltac 2.0) 12 | % ns0 = Nb of starting models 13 | % ns = Nb of models created at each iterations 14 | % nr = Nb of previous models used to build new sub-parameter space for the 15 | % next ns models 16 | % Handles dinver > 2 17 | 18 | version_geopsy = geopsy_version(); 19 | 20 | for j=1:nrun 21 | fprintf(['\n Run ',num2str(j),'\n']); 22 | dlmwrite(fullfile(dir_out,'input.txt'),1); 23 | 24 | if version_geopsy == 2 25 | % com1=['dinver -i DispersionCurve -optimization -target ',targetfile,... 26 | % ' -param ',paramfile,' -itmax ',num2str(itmax),' -ns0 ',... 27 | % num2str(ns0),' -ns ',num2str(ns),' -nr ',num2str(nr),' -f -nobugreport -o ',... 28 | % fullfile(dir_out,['run_0',num2str(j),'.report']),' < ',fullfile(dir_out,'input.txt')]; 29 | 30 | com1=['dinver -i DispersionCurve -optimization -target ',targetfile,... 31 | ' -param ',paramfile,' -itmax ',num2str(itmax),' -ns0 ',... 32 | num2str(ns0),' -ns ',num2str(ns),' -nr ',num2str(nr),' -f -nobugreport -o ',... 33 | fullfile(dir_out,['run_0',num2str(j),'.report'])]; 34 | else 35 | % com1=['dinver -i DispersionCurve -optimization -target ',targetfile,... 36 | % ' -param ',paramfile,' -ns0 ',num2str(ns0),' -ns ',num2str(ns*itmax+ns0),' -nr ',num2str(nr),' -f -nobugreport -o ',... 37 | % fullfile(dir_out,['run_0',num2str(j),'.report']),' < ',fullfile(dir_out,'input.txt')]; 38 | 39 | com1=['dinver -i DispersionCurve -optimization -target ',targetfile,... 40 | ' -param ',paramfile,' -ns0 ',num2str(ns0),' -ns ',num2str(ns*itmax+ns0),' -nr ',num2str(nr),' -f -nobugreport -o ',... 41 | fullfile(dir_out,['run_0',num2str(j),'.report'])]; 42 | end 43 | 44 | if verbose==0 45 | [status,~]=unix(com1); 46 | else 47 | [status]=unix(com1); 48 | end 49 | if status~=0 50 | [status,din_err]=unix(com1); 51 | if isempty(strfind(din_err,'Cannot open file for writing'))==0 52 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 53 | fprintf('\n Invalid working directory name'); 54 | fprintf('\n Remove special characters and spaces'); 55 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 56 | elseif isempty(strfind(din_err,'parameters'))==0 57 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!'); 58 | fprintf('\n Invalid .param file'); 59 | fprintf('\n Go to next Xmid'); 60 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!\n\n'); 61 | elseif isempty(strfind(din_err,'target'))==0 62 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!'); 63 | fprintf('\n Invalid .target file'); 64 | fprintf('\n Go to next Xmid'); 65 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!\n\n'); 66 | end 67 | break 68 | end 69 | delete(fullfile(dir_out,'input.txt')); 70 | end -------------------------------------------------------------------------------- /functions/matgpdc.m: -------------------------------------------------------------------------------- 1 | function status=matgpdc(filevel,nmodemax,wave,nf,fmin,fmax,sampling,filedisp) 2 | 3 | % S. Pasquet - V22.05.04 4 | % Forward dispersion curve calculation using gpdc 5 | % status=matgpdc(filevel,nmodemax,wave,nf,fmin,fmax,sampling,filedisp) 6 | 7 | % Sampling type 8 | % period = regular sampling in period 9 | % frequency = regular sampling in frequency 10 | % log = regular sampling in log (frequency) 11 | if sampling==0 12 | sampling='period'; 13 | elseif sampling==1 14 | sampling='frequency'; 15 | else 16 | sampling='log'; 17 | end 18 | 19 | com1=['gpdc ',filevel,' -' wave ' ' num2str(nmodemax) ... 20 | ' -n ' num2str(nf) ' -min ' num2str(fmin) ' -max ' ... 21 | num2str(fmax) ' -s ' sampling ' > ' filedisp]; 22 | [status,~]=unix(com1); 23 | end -------------------------------------------------------------------------------- /functions/matgpdcreport.m: -------------------------------------------------------------------------------- 1 | function matgpdcreport(dir_in,exportopt,nrun,nmode,nmaxmod,wave,nf,fmin,fmax) 2 | 3 | %%% S. Pasquet - V22.05.04 4 | % Read dinver report files 5 | % matgpdcreport(dir_in,exportopt,nrun,nmode,nmaxmod,wave,nf,fmin,fmax) 6 | 7 | if nargin>6 8 | resamp=1; 9 | else 10 | resamp=0; 11 | end 12 | 13 | for j=1:nrun 14 | 15 | for k=1:nmode 16 | if exportopt==0 || exportopt==2 17 | com1=['gpdcreport ',fullfile(dir_in,['run_0',num2str(j),'.report']),... 18 | ' -p',wave,' ',num2str(k-1),' -best ',num2str(nmaxmod),' > ',... 19 | fullfile(dir_in,['best',num2str(j),'.M',num2str(k-1),'.txt'])]; 20 | unix(com1); 21 | if resamp==1 22 | com1=['mv ',fullfile(dir_in,['best',num2str(j),'.M',num2str(k-1),'.txt']),... 23 | ' ',fullfile(dir_in,'best_old.txt')]; 24 | unix(com1); 25 | com1=['gpcurve ',fullfile(dir_in,'best_old.txt'),' -resample ',... 26 | num2str(nf),' -min ',num2str(fmin),' -max ',num2str(fmax),... 27 | ' > ',fullfile(dir_in,['best',num2str(j),'.M',num2str(k-1),'.txt'])]; 28 | unix(com1); 29 | delete(fullfile(dir_in,'best_old.txt')); 30 | end 31 | end 32 | end 33 | if exportopt==1 || exportopt==2 34 | com1=['gpdcreport ',fullfile(dir_in,['run_0',num2str(j),'.report']),... 35 | ' -vs -best ',num2str(nmaxmod),' > ',... 36 | fullfile(dir_in,['vs',num2str(j),'.txt'])]; 37 | unix(com1); 38 | com1=['gpdcreport ',fullfile(dir_in,['run_0',num2str(j),'.report']),... 39 | ' -vp -best ',num2str(nmaxmod),' > ',... 40 | fullfile(dir_in,['vp',num2str(j),'.txt'])]; 41 | unix(com1); 42 | com1=['gpdcreport ',fullfile(dir_in,['run_0',num2str(j),'.report']),... 43 | ' -rho -best ',num2str(nmaxmod),' > ',... 44 | fullfile(dir_in,['rho',num2str(j),'.txt'])]; 45 | unix(com1); 46 | end 47 | end -------------------------------------------------------------------------------- /functions/matop.m: -------------------------------------------------------------------------------- 1 | function matop(infile,op,flip,outfile) 2 | 3 | %%% S. Pasquet - V22.05.04 4 | % SUOP for matlab 5 | % matop(infile,op,flip,outfile) 6 | 7 | if nargin==3 8 | outfile=infile; 9 | end 10 | 11 | wsl = ispc_wsl; 12 | 13 | infile_unix = unix_wsl_path(infile,wsl); 14 | outfile_unix = unix_wsl_path(outfile,wsl); 15 | 16 | dsppath=fileparts(infile); 17 | dspfile=fullfile(dsppath,'tmp.dsp'); 18 | dspfile_unix = unix_wsl_path(dspfile,wsl); 19 | if flip==0 20 | com1=sprintf('suflip < %s flip=1 > %s',infile_unix,dspfile_unix); 21 | unix_cmd(com1,wsl); 22 | com1=sprintf('suop < %s op=%s > %s',dspfile_unix,op,outfile_unix); 23 | unix_cmd(com1,wsl); 24 | com1=sprintf('suflip < %s flip=-1 > %s',outfile_unix,dspfile_unix); 25 | unix_cmd(com1,wsl); 26 | else 27 | com1=sprintf('suop < %s op=%s > %s',outfile_unix,op,dspfile_unix); 28 | unix_cmd(com1,wsl); 29 | end 30 | movefile(fullfile(dsppath,'tmp.dsp'),outfile); 31 | end -------------------------------------------------------------------------------- /functions/matpomegal.m: -------------------------------------------------------------------------------- 1 | function [dspmat,f,v]=matpomegal(sufile,coord,nray,fmin,fmax,vmin,vmax,flip,xsca,tsca,norm,dspfile,datsave) 2 | 3 | %%% S. Pasquet - V22.05.04 4 | % SUPOMEGAL for matlab 5 | % [dspmat,f,v]=matpomegal(sufile,coord,nray,fmin,fmax,vmin,vmax,flip,xsca,tsca,norm,dspfile,datsave) 6 | 7 | wsl = ispc_wsl; 8 | 9 | sufile_unix = unix_wsl_path(sufile,wsl); 10 | dspfile_unix = unix_wsl_path(dspfile,wsl); 11 | 12 | com1=sprintf(['supomegal < %s coord=%d nray=%d fmin=%d fmax=%d',... 13 | ' vmin=%d vmax=%d flip=%d xsca=%d tsca=%d > %s'],... 14 | sufile_unix,coord,nray,fmin,fmax,vmin,vmax,flip,xsca,tsca,dspfile_unix); 15 | unix_cmd(com1,wsl); 16 | 17 | if norm>0 18 | matop(dspfile_unix,'norm',flip); 19 | end 20 | 21 | % Save in ASCII .dat file 22 | if flip==0 23 | % Nb of frequency samples 24 | [~,nf]=unix_cmd(['sugethw < ',dspfile_unix,' key=ns output=geom | uniq'],wsl); 25 | nf=str2double(nf); 26 | n1=nf; 27 | else 28 | % Nb of frequency samples 29 | [~,nf]=unix_cmd(['sugethw < ',dspfile_unix,' key=ntr output=geom | uniq'],wsl); 30 | nf=str2double(nf); 31 | n1=nray; 32 | end 33 | if isunix==1 || ispc_wsl==1 34 | com1=sprintf('sustrip < %s | b2a n1=%d > %s',dspfile_unix,n1,[dspfile_unix,'.dat']); 35 | else 36 | com1=sprintf('sustrip < %s head=head outpar=outpar | b2a n1=%d outpar=outpar > %s',... 37 | dspfile_unix,n1,[dspfile_unix,'.dat']); 38 | end 39 | [~,~]=unix_cmd(com1,wsl); 40 | 41 | % Velocity step 42 | dv=(vmax-vmin)/(nray-1); 43 | % Velocity table 44 | v=vmin:dv:vmax; 45 | % Frequency step 46 | df=(fmax-fmin)/(nf-1); 47 | % Frequency table 48 | f=fmin:df:fmax; 49 | % Load image file 50 | dspmat=load([dspfile,'.dat']); 51 | 52 | if datsave==0 53 | delete([dspfile,'.dat']); 54 | end 55 | end -------------------------------------------------------------------------------- /functions/matshift.m: -------------------------------------------------------------------------------- 1 | function matshift(infile,tshift,outfile) 2 | 3 | %%% S. Pasquet - V23.02.22 4 | % Shift time in SU files 5 | % matshift(infile,tshift,outfile) 6 | % tshift in ms (ex: -100 to shift upward by 100ms) 7 | 8 | if nargin==2 9 | outfile=infile; 10 | end 11 | supath=fileparts(infile); 12 | com1=sprintf('sushw < %s a=%s,0 key=delrt,tstat | sustatic hdrs=1 sign=1 > %s',infile,num2str(tshift),fullfile(supath,'tmp.su')); 13 | unix(com1); 14 | 15 | movefile(fullfile(supath,'tmp.su'),outfile); 16 | end -------------------------------------------------------------------------------- /functions/matspecfx.m: -------------------------------------------------------------------------------- 1 | function [specmat,f,x]=matspecfx(seismofile,xsca,specfile,datsave,norm) 2 | 3 | %%% S. Pasquet - V22.05.04 4 | % SUSPECFX for matlab 5 | % [specmat,f,x]=matspecfx(seismofile,xsca,specfile,datsave,norm) 6 | 7 | wsl = ispc_wsl; 8 | 9 | seismofile_unix = unix_wsl_path(seismofile,wsl); 10 | specfile_unix = unix_wsl_path(specfile,wsl); 11 | 12 | if exist('norm','var')==0 || isempty(norm)==1 13 | norm=1; 14 | end 15 | 16 | if norm>0 17 | com1=sprintf('suspecfx < %s | suop op=norm > %s',... 18 | seismofile_unix,specfile_unix); 19 | else 20 | com1=sprintf('suspecfx < %s > %s',... 21 | seismofile_unix,specfile_unix); 22 | end 23 | unix_cmd(com1,wsl); 24 | 25 | % Save in ASCII .dat file 26 | % Nb of frequency samples 27 | [~,nf]=unix_cmd(['sugethw < ',specfile_unix,' ns output=geom | uniq'],wsl); 28 | nf=str2double(nf); 29 | % Frequency sampling 30 | [~,df]=unix_cmd(['sugethw < ',specfile_unix,' d1 output=geom | uniq'],wsl); 31 | df=str2double(df); 32 | % Geophones positions 33 | [~,Gx]=unix_cmd(['sugethw < ',specfile_unix,' key=gx output=geom'],wsl); 34 | Gx=str2num(Gx)/xsca; 35 | 36 | if isunix==1 || ispc_wsl==1 37 | com1=sprintf('sustrip < %s | b2a n1=%d > %s',specfile_unix,nf,[specfile_unix,'.dat']); 38 | else 39 | com1=sprintf('sustrip < %s head=head outpar=outpar | b2a n1=%d outpar=outpar > %s',... 40 | specfile_unix,nf,[specfile_unix,'.dat']); 41 | end 42 | [~,~]=unix_cmd(com1,wsl); 43 | 44 | % X table 45 | x=unique(Gx); 46 | % Time table 47 | f=0:df:(nf-1)*df; 48 | % Load image file 49 | specmat=load([specfile,'.dat']); 50 | 51 | if datsave==0 52 | delete([specfile,'.dat']); 53 | end 54 | 55 | end 56 | -------------------------------------------------------------------------------- /functions/matzip.m: -------------------------------------------------------------------------------- 1 | function matzip(compress,files,method,del,output,verbose) 2 | 3 | %%% S. Pasquet - V22.05.04 4 | % GZIP in matlab 5 | % matzip(compress,files,method,del,output,verbose) 6 | wsl = ispc_wsl; 7 | 8 | if nargin<5 9 | output=[]; 10 | end 11 | 12 | if nargin<6 13 | verbose=0; 14 | end 15 | 16 | if verbose==1 17 | tic 18 | end 19 | if compress==1 20 | if method==1 21 | gzip(files); 22 | if del==1 23 | delete(files); 24 | end 25 | elseif method==2 26 | tar(output,files); 27 | if del==1 28 | delete(files); 29 | end 30 | elseif method==3 31 | zip(output,files); 32 | if del==1 33 | delete(files); 34 | end 35 | elseif method==4 36 | [~,~]=unix_cmd(['7z a -aoa ',output,' ',files],wsl); 37 | if del==1 38 | [~,~]=unix_cmd(['rm -rf ',files],wsl); 39 | end 40 | elseif method==5 41 | if del==1 42 | [~,~]=unix_cmd(['gzip -f ',files],wsl); 43 | else 44 | [~,~]=unix_cmd(['gzip -k -f ',files],wsl); 45 | end 46 | elseif method==6 47 | if del==1 48 | [~,~]=unix_cmd(['bzip2 -f ',files],wsl); 49 | else 50 | [~,~]=unix_cmd(['bzip2 -k -f ',files],wsl); 51 | end 52 | end 53 | elseif compress==0 54 | if method==1 55 | gunzip(files); 56 | if del==1 57 | delete(files); 58 | end 59 | elseif method==2 60 | untar(files); 61 | if del==1 62 | delete(files); 63 | end 64 | elseif method==3 65 | unzip(files,output); 66 | if del==1 67 | delete(files); 68 | end 69 | elseif method==4 70 | [~,~]=unix_cmd(['7z e ',files],wsl); 71 | if del==1 72 | [~,~]=unix_cmd(['rm -rf ',files],wsl); 73 | end 74 | elseif method==5 75 | if del==1 76 | [~,~]=unix_cmd(['gunzip -f ',files],wsl); 77 | else 78 | unix_cmd(['gunzip -k -f ',files],wsl); 79 | end 80 | elseif method==6 81 | if del==1 82 | [~,~]=unix_cmd(['bunzip2 -f ',files],wsl); 83 | else 84 | [~,~]=unix_cmd(['bunzip2 -k -f ',files],wsl); 85 | end 86 | end 87 | else 88 | fprintf('\n Wrong command\n'); 89 | end 90 | if verbose==1 91 | toc 92 | end -------------------------------------------------------------------------------- /functions/meanvel_find.m: -------------------------------------------------------------------------------- 1 | function meanvel=meanvel_find(dspmat_weight_win,v) 2 | 3 | meanvel=zeros(size(dspmat_weight_win,3),1); 4 | for i=1:min(size(dspmat_weight_win,3)) 5 | dspmat_temp=dspmat_weight_win(:,:,i); 6 | [~,I]=max(dspmat_temp'); 7 | meanvel(i)=mean(v(I)); 8 | end -------------------------------------------------------------------------------- /functions/median_filt.m: -------------------------------------------------------------------------------- 1 | function velout = median_filt(vel,npts,b1,b2,test) 2 | 3 | %%% S. Pasquet - V16.11.18 4 | % Median filter 5 | % velout = median_filt(vel,npts,b1,b2) 6 | if nargin == 2 7 | b1 = 1; 8 | b2 = length(vel); 9 | end 10 | 11 | if nargin < 5 12 | test = 0; 13 | end 14 | 15 | vel=vel'; 16 | velout=vel; 17 | vel=[repmat(vel(1),fix(npts/2),1);vel;repmat(vel(end),fix(npts/2),1)]; 18 | indstart=find(isnan(vel)~=1,1,'first'); 19 | indend=find(isnan(vel)~=1,1,'last'); 20 | if indstart>1 21 | vel(indstart-fix(npts/2):indstart-1)=vel(indstart); 22 | end 23 | if indendabs(median(vel(i:i+npts-1))-2*std(vel(i:i+npts-1))) 31 | if abs(median(vel(i:i+npts-1))-velout(i))>abs(0.75*std(vel(i:i+npts-1))) 32 | velout(i)=median(vel(i:i+npts-1)); 33 | end 34 | end 35 | end -------------------------------------------------------------------------------- /functions/median_filt_2D.m: -------------------------------------------------------------------------------- 1 | function [data_filt, mean_data_std] = median_filt_2D(data,m,n,test) 2 | 3 | if nargin < 4 4 | test = 0; 5 | end 6 | 7 | [xlength, ylength] = size(data); 8 | X = 1:xlength; 9 | Y = 1:ylength; 10 | 11 | if m > 1 12 | win_size_x = fix(m/2); 13 | else 14 | win_size_x = 1; 15 | end 16 | if n > 1 17 | win_size_y = fix(n/2); 18 | else 19 | win_size_y = 1; 20 | end 21 | 22 | data_filt = data; 23 | data_std = data; 24 | 25 | for i=1:xlength 26 | for j=1:ylength 27 | 28 | if isnan(data(i,j)) 29 | continue 30 | end 31 | dat_select = data(X>i-win_size_x & Xj-win_size_y & Yabs(median(dat_select(:))-std(dat_select(:))) 35 | data_filt(i,j) = nanmedian(dat_select(:)); 36 | end 37 | else 38 | data_filt(i,j) = nanmedian(dat_select(:)); 39 | end 40 | end 41 | end 42 | mean_data_std = nanmean(data_std); -------------------------------------------------------------------------------- /functions/mov_aver.m: -------------------------------------------------------------------------------- 1 | function velout = mov_aver(vel,npts,b1,b2) 2 | 3 | %%% S. Pasquet - V16.11.18 4 | % Moving average filter 5 | % velout = mov_aver(vel,npts,b1,b2) 6 | 7 | if nargin == 2 8 | b1 = 1; 9 | b2 = length(vel); 10 | end 11 | 12 | vel=vel'; 13 | velout=vel; 14 | vel=[repmat(vel(1),fix(npts/2),1);vel;repmat(vel(end),fix(npts/2),1)]; 15 | indstart=find(isnan(vel)~=1,1,'first'); 16 | indend=find(isnan(vel)~=1,1,'last'); 17 | if indstart>1 18 | vel(indstart-fix(npts/2):indstart-1)=vel(indstart); 19 | end 20 | if indendVs'))==1 39 | shortname=fgets(fid0); % Read line 40 | end 41 | for i=1:4 42 | fgets(fid0); % Read line 43 | end 44 | ligne=fgets(fid0); % Read line 45 | while isempty(strfind(ligne,'3 8 | modifpois=1; 9 | if exist('vsin2','var')==0 10 | modifpois=0; 11 | vsout=[]; 12 | end 13 | else 14 | modifpois=0; 15 | verbose=0; 16 | vsout=[]; 17 | plot=0; 18 | end 19 | vpoutstd = []; 20 | nlay=length(zin2)-1; 21 | 22 | if nlay=zin2(ll) & zin<=zin2(ll+1)))==1 && ll>1 29 | vpout(ll)=vpout(ll-1); 30 | vpoutmin(ll)=vpoutmin(ll-1); 31 | vpoutmax(ll)=vpoutmax(ll-1); 32 | vpoutstd(ll)=vpoutstd(ll-1); 33 | else 34 | vpout(ll)=mean(vpin(zin>=zin2(ll) & zin<=zin2(ll+1))); 35 | vpoutmin(ll)=min(vpin(zin>=zin2(ll) & zin<=zin2(ll+1))); 36 | vpoutmax(ll)=max(vpin(zin>=zin2(ll) & zin<=zin2(ll+1))); 37 | vpoutstd(ll)=std(vpin(zin>=zin2(ll) & zin<=zin2(ll+1))); 38 | end 39 | if isnan(vpout(ll))==1 40 | vpout(ll)=vpout(ll-1); 41 | vpoutmin(ll)=vpoutmin(ll-1); 42 | vpoutmax(ll)=vpoutmax(ll-1); 43 | if verbose==1 44 | fprintf(['\n NaN value for layer ',num2str(ll),'\n']); 45 | end 46 | end 47 | if modifpois==1 48 | modifvs(ll)=0; 49 | while poisson(vpout(ll),vsin2(ll))<=poisMIN 50 | vpout(ll)=vpout(ll)+1; 51 | vsin2(ll)=vsin2(ll)-1; 52 | modifvs(ll)=modifvs(ll)+1; 53 | end 54 | if modifvs(ll)>0 && verbose==1 55 | fprintf(['\n Vs corrected of ',num2str(modifvs(ll)),... 56 | 'm/s in layer ',num2str(ll),'\n']); 57 | end 58 | end 59 | end 60 | if plot==1 61 | figure(2); 62 | stairs(zin,vpin(2:end),'g'); 63 | view(90,90) 64 | hold on 65 | stairs(zin2,[vpout';vpout(end)],'r'); 66 | drawnow 67 | hold off 68 | end 69 | 70 | else 71 | ll=1; vpoutmin=[]; vpoutmax=[]; 72 | for ll2=2:length(zin) 73 | while zin(ll2)>zin2(ll) && ll0 && verbose==1 89 | fprintf(['\n Vs corrected of ',num2str(modifvs(ll)),... 90 | 'm/s in layer ',num2str(ll),'\n']); 91 | end 92 | end 93 | ll=ll+1; 94 | end 95 | end 96 | if plot==1 97 | figure(2); 98 | stairs(zin,vpin,'b'); 99 | view(90,90) 100 | hold on 101 | stairs(zin2,[vpout';vpout(end)],'r'); 102 | drawnow 103 | hold off 104 | end 105 | end 106 | vpout=vpout'; 107 | if modifpois==1 108 | vsout=vsin2; 109 | end 110 | end -------------------------------------------------------------------------------- /functions/xyz2plot.m: -------------------------------------------------------------------------------- 1 | function [X,Y,Z] = xyz2plot(X,Y,Z) 2 | 3 | if min(size(X)) == 1 4 | Xnew = X; 5 | Xnew(1:end-1) = Xnew(1:end-1) - diff(Xnew)/2; 6 | Xnew(end) = Xnew(end) - diff(X(end-1:end))/2; 7 | Xnew(end+1) = Xnew(end) + diff(X(end-1:end)); 8 | X = Xnew; 9 | else 10 | ind_x = find(size(X) == length(unique(X))); 11 | if ind_x == 1 12 | Xnew = X'; 13 | else 14 | Xnew = X; 15 | end 16 | Xnew(:,1:end-1) = Xnew(:,1:end-1) - diff(Xnew,1,ind_x)/2; 17 | Xnew(:,end) = Xnew(:,end) - diff(X(:,end-1:end),1,ind_x)/2; 18 | Xnew(:,end+1) = Xnew(:,end) + diff(X(:,end-1:end),1,ind_x); 19 | Xnew(end+1,:) = Xnew(end,:); 20 | if ind_x == 1 21 | X = Xnew'; 22 | else 23 | X = Xnew; 24 | end 25 | end 26 | if min(size(Y)) == 1 27 | Ynew = Y; 28 | Ynew(1:end-1) = Ynew(1:end-1) - diff(Ynew)/2; 29 | Ynew(end) = Ynew(end) - diff(Y(end-1:end))/2; 30 | Ynew(end+1) = Ynew(end) + diff(Y(end-1:end)); 31 | Y = Ynew; 32 | else 33 | if ind_x == 1 34 | Ynew = Y'; 35 | ind_y = 2; 36 | else 37 | Ynew = Y; 38 | ind_y = 1; 39 | end 40 | Ynew(1:end-1,:) = Ynew(1:end-1,:) - diff(Ynew,1,ind_y)/2; 41 | Ynew(end,:) = Ynew(end,:) - diff(Y(end-1:end,:),1,ind_y)/2; 42 | Ynew(end+1,:) = Ynew(end,:) + diff(Y(end-1:end,:),1,ind_y); 43 | Ynew(:,end+1) = Ynew(:,end); 44 | if ind_x == 1 45 | Y = Ynew'; 46 | else 47 | Y = Ynew; 48 | end 49 | end 50 | Z = [Z Z(:,end)]; 51 | Z = [Z;Z(end,:)]; -------------------------------------------------------------------------------- /gitpush: -------------------------------------------------------------------------------- 1 | git add . 2 | git commit -m "SWIP 2.2.1" 3 | git push origin master 4 | -------------------------------------------------------------------------------- /launchers/B_SWIPparam.m: -------------------------------------------------------------------------------- 1 | clear all; clc; close all; 2 | 3 | %%% SURFACE-WAVE dispersion INVERSION & PROFILING (SWIP) 4 | %%% MODULE B : SWIPparam.m 5 | %%% S. Pasquet - V120.02.17 6 | %%% SWIPparam.m creates the parameterization file required to invert with 7 | %%% module C the dispersion curves picked in module A 8 | %%% It can create either a single parameterization file for all the profile 9 | %%% or create automatic parameterization for each Xmid based on a Vp model 10 | 11 | %%% Option paramtype>0 requires to select subproject folder Wmin_max.dWx.dSmin_max.side 12 | %%% and the input of a 3-column ASCII file with X, Z and Vp of the velocity model 13 | 14 | %%% Comment line to use default settings (cf SWIP_defaultsettings.m) 15 | 16 | %%%-------------------------%%% 17 | %%% START OF INITIALIZATION %%% 18 | 19 | %%% Main settings 20 | Xmidselec = []; % Select Xmids (comment or [] to select all) 21 | paramname = []; % Name of parameterization file (empty for autoname) 22 | paramtype = 0; % Type of parameterization 23 | %%% 0 => default inversion (same parameterization for all Xmids) 24 | %%% 1 => Vp and thicknesses vary in reduced range defined from velocity model 25 | %%% 2 => Fixed Vp defined from velocity model - thicknesses vary with Vs 26 | %%% 3 => Fixed thicknesses - Vp vary in reduced range defined from velocity model 27 | %%% 4 => Fixed Vp and thicknesses defined from velocity model 28 | %%% 5 => Vp, Vs and thicknesses vary in reduced range defined from velocity model 29 | 30 | %%% Parameter space settings 31 | nlay = 11; % No. of layers (including half-space) 32 | 33 | %%% The following settings can be either scalars (same parameters for all layers) 34 | %%% or vectors with nlay elements (specific parameters for each layer) 35 | 36 | nsublay = 10; % No. of sublayers per layer (used if shape ~=1) 37 | 38 | thmin = 10.^linspace(log10(0.5),log10(2),nlay-1); % Min. thickness per layer (m) 39 | thmax = 10.^linspace(log10(1.5),log10(6),nlay-1); % Max. thickness per layer (m) 40 | 41 | lvz = 0; % Allow low velocity layer (=1) or not (=0) 42 | shape = 1; % Shape of the velocity variation with depth 43 | %%% (1='Uniform', 2='Linear', 3='LinearIncrease', 4='LinearDecrease', 5='PowerLaw') 44 | 45 | Vsmin = 10; % Min. Vs (m/s) 46 | Vsmax = 2500; % Max. Vs (m/s) 47 | Vpmin = 10; % Min. Vp (m/s) 48 | Vpmax = 5000; % Max. Vp (m/s) 49 | Rhomin = 2000; % Min. Rho (kg/m3) 50 | Rhomax = 2000; % Max. Rho (kg/m3) 51 | Numin = 0.1; % Min. Poisson's ratio 52 | Numax = 0.5; % Max. Poisson's ratio 53 | 54 | Vplink = 1; % Vp linked (=1) or not (=0) to Vs 55 | Rholink = 1; % Rho linked (=1) or not (=0) to Vs 56 | Nulink = 1; % Nu linked (=1) or not (=0) to Vs 57 | 58 | %%% Semi-automatic parameterization settings (used if paramtype~=0) 59 | plot2dVP = 1; % Plot imported Vp models (=1) or not (=0) 60 | dz = 0.2; % Sampling in depth (m) 61 | vfac = 0.25; % Increase Vp range (Vpmin-vfac*Vpmin0 uses a semi-automatic parameterization 22 | %%% Requires to have .param files for each Xmid along with .target files 23 | 24 | %%% Comment line to use default settings (cf SWIP_defaultsettings.m) 25 | 26 | %%%-------------------------%%% 27 | %%% START OF INITIALIZATION %%% 28 | 29 | %%% Main settings 30 | Xmidselec = []; % Select Xmids (comment or [] to select all) 31 | inversion = 1; % Run new inversion (=1) or use existing (=0) 32 | 33 | %%% Inversion settings (used if inversion=1) 34 | paramtype = 0; % Type of parameterization (=0,1,2,3 or 4) (cf Module B) 35 | nrun = 2; % No. of run 36 | itmax = 150; % No. of iteration per run 37 | ns0 = 100; % No. of starting models 38 | ns = 75; % No. of models created at each iterations 39 | nr = 50; % No. of previous models to build new sub-parameter space 40 | verbose = 0; % Display info during inversion (=1) or not (=0) (!! set to 1 to debug !!) 41 | 42 | %%% Average models calculation settings 43 | nbest = 0; % Select best models within error bars (=0) or nbest models (>0) 44 | outpoints = 0; % No. of points allowed out of the error bars 45 | dz = 0.2; % Depth sampling (m) 46 | 47 | %%% Toggle plots 48 | plotinvres = 0; % Save inversion results (=1) or not (=0) (!! time consuming !!) 49 | plotparam = 0; % Save inversion parameters (=1) or not (=0) (!! time consuming !!) 50 | plot2dVS = 1; % Plot raw pseudo-2D Vs section during inversion (=1) or not (=0) 51 | showplot = 0; % Show plots before saving (=1) or not (=0) 52 | 53 | %%% Figure display and output settings 54 | imgform = 'png'; % Fig. file format ('pdf', 'png', 'jpeg', 'tiff' or 'fig') 55 | imgres = 200; % Fig. resolution (dpi) when saving as raster 56 | fs = 20; % Fig. font size 57 | concat = 1; % Save indiv. and merged figures (=2), merged figure (=1) or indiv. figures (=0) 58 | colnb = 3; % No. of columns when merging figures 59 | cbpos = 2; % Colorbar on the right (=1) or at the bottom (=2) 60 | Clogscale = 1; % Log colorscale (=1) or linear (=0) for misfit 61 | map2 = hsv(16); % Colormap for accepted models misfit 62 | map3 = graycm(16); % Colormap for rejected models misfit 63 | 64 | %%% Calculated dispersion curves display settings (used if plotinvres=1) 65 | Flogscale = 0; % Logscale frequency axis (=1) or linear (=0) 66 | fMIN = []; % Min. frequency (Hz) 67 | fMAX = []; % Max. frequency (Hz) 68 | % fticks = (fMIN:15:fMAX); % Frequency ticks (Hz) 69 | VphMIN = []; % Min. phase velocity (m/s) 70 | VphMAX = []; % Max. phase velocity (m/s) 71 | % Vphticks = (VphMIN:500:VphMAX); % Phase velocity ticks (m/s) 72 | 73 | plot1dVS = 1; % Plot final 1D Vs model (=1) or not (=0) 74 | modeltype = 3; % 1D final Vs model to plot 75 | %%% (1=best, 2=averaged layered, 3=average smooth, 4=weighted layered, 5=weighted smooth, 6=ridge) 76 | 77 | dpMIN = []; % Min. depth (m) 78 | dpMAX = []; % Max. depth (m) 79 | % dticks = (dpMIN:10:dpMAX); % Depth ticks (m) 80 | vsMIN = []; % Min. Vs (m/s) 81 | vsMAX = []; % Max. Vs (m/s) 82 | % vsticks = (vsMIN:500:vsMAX); % Vs ticks (m/s) 83 | 84 | %%% Parameter plot settings (used if plotparam=1) 85 | param1 = 'Vs'; % First parameter to plot ('Vs', 'Th', 'Vp', 'Dens') 86 | param2 = 'Th'; % Second parameter to plot ('Vs', 'Th', 'Vp', 'Dens') 87 | np1 = (1:2); % Vector of layer number for first parameter 88 | np2 = (1:2); % Vector of layer number for second parameter 89 | 90 | %%% END OF INITIALIZATION %%% 91 | %%%-----------------------%%% 92 | 93 | run('C_SWIPinv_script'); 94 | -------------------------------------------------------------------------------- /launchers/D1_SWIPmod1d.m: -------------------------------------------------------------------------------- 1 | clear all; clc; close all; 2 | 3 | %%% SURFACE-WAVE dispersion INVERSION & PROFILING (SWIP) 4 | %%% MODULE D1 : SWIPmod1d.m 5 | %%% S. Pasquet - V20.02.17 6 | %%% SWIPmod1d.m plots observed and calculated dispersion for each Xmid 7 | %%% It also plots 1D Vp, Vs, Vp/Vs and Poisson's ratio models 8 | 9 | %%% Option swip=1 plots velocity models and calculates theoretical 10 | %%% dispersion from SWIP inversion results (module C) 11 | %%% Requires to select a subproject folder Wmin_max.dWx.dSmin_max.side 12 | %%% and an inversion folder located in file.inv 13 | %%% If usevptomo=1, dispersion is calculated with VP from refraction tomography 14 | %%% Requires to select a 3-column ASCII file (X, Z, Vp) 15 | %%% Option tomo=1 plots velocity models and calculates theoretical 16 | %%% dispersion from refraction tomography files 17 | %%% Requires to select a subproject folder Wmin_max.dWx.dSmin_max.side 18 | %%% and two 3-column ASCII files (X, Z, Vp) and (X, Z, Vs) 19 | %%% Option user=1 plots velocity models and calculates theoretical 20 | %%% dispersion from user-defined velocity structure 21 | %%% Requires to select a subproject folder Wmin_max.dWx.dSmin_max.side 22 | 23 | %%% Comment line to use default settings (cf SWIP_defaultsettings.m) 24 | 25 | %%%-------------------------%%% 26 | %%% START OF INITIALIZATION %%% 27 | 28 | %%% Main settings 29 | Xmidselec = []; % Select Xmids (comment or [] to select all) 30 | 31 | swip = 1; % Plot vel. models from SWIP (=1) or not (=0) 32 | tomo = 0; % Plot vel. models from P- and SH-wave tomography (=1) or not (=0) 33 | user = 0; % Plot vel. models defined by user below (=1) or with input file (=2) 34 | 35 | %%% SWIP model settings (used if swip=1) 36 | modeltype = 3; % Plotted 1D Vs model 37 | %%% (1=best, 2=averaged layered, 3=average smooth, 4=weighted layered, 5=weighted smooth, 6=ridge) 38 | nbest = 0; % Best models within error bars (=0) or nbest models (>0) 39 | outpoints = 0; % No. of points allowed out of the error bars 40 | usevptomo = 0; % Forward calc. with Vp from tomo. (=1) or from SW inversion (=0) 41 | dz = 0.2; % Sampling in depth (m) 42 | 43 | %%% User defined 1D model parameters (used if user=1) 44 | vpuser = [500,1850,2500,4000]; % Vp (m/s) 45 | vsuser = [200,925,925,1250]; % Vs (m/s) 46 | rhouser = [1800,1800,1800,1800]; % Rho (kg/m3) 47 | thkuser = [0.85,10,25]; % Thickness (m) 48 | 49 | %%% Toggle plots 50 | plot1dcal = 1; % Plot dispersion images with calculated dispersion curves (=1) or not (=0) 51 | plot1dmod = 1; % Plot Vs, Vp, Vp/Vs and Poisson's ratio 1D models (=1) or not (=0) 52 | showplot = 0; % Show plots before saving (=1) or not (=0) 53 | 54 | %%% Figure display and output settings 55 | imgform = 'png'; % Fig. file format ('pdf', 'png', 'jpeg', 'tiff' or 'fig') 56 | imgres = 200; % Fig. resolution (dpi) when saving as raster 57 | fs = 16; % Fig. font size 58 | concat = 1; % Save indiv. and merged figures (=2), merged figure (=1) or indiv. figures (=0) 59 | 60 | %%% Dispersion curves and images settings (used if plot1dcal = 1) 61 | nmodemax = 1; % No. of mode for forward calculation 62 | Dlogscale = 0; % Pseudo-log colorscale for dispersion (=1) or linear (=0) 63 | Flogscale = 1; % Logscale frequency axis (=1) or linear (=0) 64 | axetop = 0; % Plot Xaxis on top (=1) or bottom (=0) 65 | axerev = 0; % Yaxis pointing down (=1) or up (=0) 66 | cb_disp = 0; % Plot dispersion colorbar (=1) or not (=0) 67 | plot1dobs = 1; % Plot picked dispersion curves (=1) or not (=0) 68 | eb = 1; % Plot dispersion curves with errorbars (=1) or not (=0) 69 | pickcol1 = 'w'; % Picks color for even (0, 2,...) modes number (cf ColorSpec) 70 | pickcol2 = 'w'; % Picks color for odd (1, 3,...) modes number (cf ColorSpec) 71 | plotflim = 0; % Plot low cut frequency (=1) or not (=0) 72 | plotlamlim = 1; % Plot max. lambda defined by resampvec (=1) or not (=0) 73 | 74 | map0 = bone(39); % Colormap for dispersion image 75 | fMIN = []; % Min. frequency (Hz) 76 | fMAX = []; % Max. frequency (Hz) 77 | % fticks = (fMIN:20:fMAX); % Frequency ticks (Hz) 78 | VphMIN = []; % Min. phase velocity (m/s) 79 | VphMAX = []; % Max. phase velocity (m/s) 80 | % Vphticks = (VphMIN:250:VphMAX); % Phase velocity ticks (m/s) 81 | 82 | %%% Vs, Vp, Vp/Vs and Poisson's ratio 1D models settings (used if plot1dmod = 1) 83 | plot1dstd = 1; % Plot error enveloppe (=1) or none (=0) 84 | errstd = 0; % Percentage error on velocity models (in %) (0 for STD from SWIP) 85 | plotDOI = 2; % Plot DOI estimated from wavelength (=1), from VsSTD (=2) or not (=0) 86 | doifact = 0.66; % DOI factor (DOI = max_wavelength*doifact) (used if plotDOI=1) 87 | std_mask = 500; % Max. Std Vs (m/s) (used if plotDOI=2) 88 | plot1dvp = 0; % Plot 1D Vp models on same graph with 1D Vs models (=1) or not (=0) 89 | 90 | dpMIN = []; % Min. depth (m) 91 | dpMAX = []; % Max. depth (m) 92 | % dticks = (dpMIN:10:dpMAX); % Depth ticks (m) 93 | vsMIN = []; % Min. Vs (m/s) 94 | vsMAX = []; % Max. Vs (m/s) 95 | % vsticks = (vsMIN:500:vsMAX); % Vs ticks (m/s) 96 | vpMIN = []; % Min. Vp (m/s) 97 | vpMAX = []; % Max. Vp (m/s) 98 | % vpticks = (vpMIN:1000:vpMAX); % Vp ticks (m/s) 99 | vpvsMIN = []; % Min. Vp/Vs 100 | vpvsMAX = []; % Max. Vp/Vs 101 | % vpvsticks = (vpvsMIN:vpvsMAX); % Vp/Vs ticks 102 | poisMIN = []; % Min. Poisson's ratio 103 | poisMAX = []; % Max. Poisson's ratio 104 | % poisticks = (poisMIN:0.1:poisMAX); % Poisson's ratio ticks 105 | 106 | %%% END OF INITIALIZATION %%% 107 | %%%-----------------------%%% 108 | 109 | run('D1_SWIPmod1d_script'); 110 | -------------------------------------------------------------------------------- /src/configure: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | i=$1 4 | 5 | cd supomegal 6 | make remake 7 | 8 | # I tried compiling seg2segy from SU repository (in $CWPROOT/src/Third_Party/seg2segy) 9 | # As it didn't work right away in Ubuntu 24.04, I added the following code to seg2segy.c at line 122, and include the modified code in SWIP 10 | 11 | # /* Forward declaration for swab function */ 12 | # #ifndef __MSDOS__ 13 | # void swab(const void *from, void *to, ssize_t n); 14 | # #endif 15 | 16 | cd ../seg2segy 17 | make remake 18 | 19 | cd .. 20 | -------------------------------------------------------------------------------- /src/supomegal/INSTALL: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spasquet/SWIP/eb6efb12c94d4175e75534583be66128daf90b08/src/supomegal/INSTALL -------------------------------------------------------------------------------- /src/supomegal/makefile: -------------------------------------------------------------------------------- 1 | # Makefile for ...su/main 2 | 3 | include $(CWPROOT)/src/Makefile.config 4 | 5 | D = $L/libcwp.a $L/libpar.a $L/libsu.a 6 | 7 | LFLAGS= $(PRELFLAGS) -L$L -lsu -lpar -lcwp -lm $(POSTLFLAGS) 8 | 9 | 10 | PROGS = \ 11 | $B/supomegal \ 12 | 13 | 14 | 15 | INSTALL : $(PROGS) 16 | @-rm -f INSTALL 17 | @touch $@ 18 | 19 | 20 | $(PROGS): $(CTARGET) $D 21 | -$(CC) $(CFLAGS) $(@F).c $(LFLAGS) -o $@ 22 | @$(MCHMODLINE) 23 | @echo $(@F) installed in $B 24 | 25 | remake : 26 | -rm -f $(PROGS) INSTALL 27 | $(MAKE) 28 | 29 | clean:: 30 | rm -f a.out junk* JUNK* core 31 | -------------------------------------------------------------------------------- /tools/batch_rename.m: -------------------------------------------------------------------------------- 1 | % function batch_rename(dir_dat) 2 | 3 | %%% S. Pasquet - V17.09.05 4 | % Batch rename files for seg2su or ascii2su processing 5 | % batch_rename(dir_dat) 6 | 7 | if exist('dir_dat','var')==0 || isempty(dir_dat)==1 8 | dir_dat=uigetdir('./','Select folder containing files to rename'); 9 | if dir_dat==0 10 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!'); 11 | fprintf('\n Please select a folder'); 12 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 13 | return 14 | end 15 | datstruct=[dir(fullfile(dir_dat,'*txt'));dir(fullfile(dir_dat,'*dat'));dir(fullfile(dir_dat,'*su'));dir(fullfile(dir_dat,'*sgy'))]; 16 | end 17 | 18 | base_file_no=1000; 19 | 20 | for ii=1:length(datstruct) 21 | [folder,nametarg,ext]=fileparts(datstruct(ii).name); 22 | for i=1:length(nametarg) 23 | test=str2double(nametarg(i)); 24 | if isnan(test)==0 && isreal(test)==1 25 | file_no=str2double(nametarg(i:end)); 26 | filename=fullfile(dir_dat,[num2str(base_file_no+file_no),ext]); 27 | movefile(fullfile(dir_dat,datstruct(ii).name),filename); 28 | break 29 | end 30 | end 31 | end -------------------------------------------------------------------------------- /tools/calc_disp.m: -------------------------------------------------------------------------------- 1 | function calc_disp(sufile,nWvec,dSmin,nray,fmin,fmax,vmin,vmax,flip,xsca,tsca,imgform,imgres) 2 | 3 | %%% S. Pasquet - V16.11.22 4 | % Quick extraction of dispersion image from seismogram 5 | % calc_disp(sufile,nWvec,dSmin,nray,fmin,fmax,vmin,vmax,flip,xsca,tsca,imgform,imgres) 6 | 7 | if exist('sufile','var')==0 || isempty(sufile)==1 8 | [sufile,supath]=uigetfile('*.su','Select seismogram file'); 9 | if sufile==0 10 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 11 | fprintf('\n Please select a seismogram file'); 12 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 13 | return 14 | end 15 | else 16 | supath=fileparts(sufile); 17 | end 18 | fprintf('\n Reading %s\n',sufile); 19 | 20 | acquiparam=get_acquiparam(sufile,[]); 21 | 22 | if exist('xsca','var')==0 || isempty(xsca)==1 23 | xsca=acquiparam.xsca; 24 | end 25 | 26 | run('SWIP_defaultsettings'); 27 | 28 | dSmax=dSmin; 29 | dir_dat_xmid=supath; 30 | dx=acquiparam.dx; % Mean inter-geophone spacing (m) 31 | xmidformat=['%12.',num2str(log(xsca)/log(10)),'f']; % Precision 32 | 33 | if dx==0 34 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 35 | fprintf('\n Please provide inter-geophone spacing'); 36 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 37 | return 38 | end 39 | topo=acquiparam.topo; % Get topography (X,Z in m) 40 | Gxsing=acquiparam.Gxsing; % Single geophones positions 41 | Sxsing=acquiparam.Sxsing; % Single sources positions 42 | if length(Sxsing)>1 43 | fprintf('\n Please select single shot SU file\n'); 44 | return 45 | end 46 | 47 | xmin=min(Gxsing); % Get starting X coordinate (m) 48 | xmax=max(Gxsing); % Get ending X coordinate (m) 49 | winsize=nWvec; 50 | maxwinsize=(winsize-1)*dx; 51 | nwin=length(winsize); 52 | 53 | if mod(nWvec,2)==1 54 | XmidT=Gxsing(1+(nWvec-1)/2:dW:end-(nWvec-1)/2); 55 | else 56 | XmidT=mean([Gxsing((nWvec)/2:dW:end-(nWvec)/2),... 57 | Gxsing(1+(nWvec)/2:dW:1+end-(nWvec)/2)],2); 58 | end 59 | XmidT=round(XmidT'*xsca)/xsca; 60 | Xlength=length(XmidT); 61 | 62 | for ix=1:Xlength 63 | j=0; % Stack flag 64 | for jw=1:nwin 65 | % Retrieve first and last geophone position for the current window 66 | if mod(nWvec,2)==1 % Non-even number of traces 67 | Gleft=Gxsing(find(GxsingXmidT(ix),(winsize(jw)-1)/2)); 69 | ntr=length(Gleft)+length(Gright)+1; 70 | if ntr~=winsize(jw) && calc==1 % Check number of extracted traces 71 | fprintf(['\n Not enough traces with nW = ',num2str(winsize(jw)),... 72 | ' - Go to next shot or Xmid\n']); 73 | continue 74 | end 75 | Gmin(ix,jw)=min(Gleft); 76 | Gmax(ix,jw)=max(Gright); 77 | else % Even number of traces 78 | Gleft=Gxsing(find(GxsingXmidT(ix),(winsize(jw))/2)); 80 | ntr=length(Gleft)+length(Gright); 81 | if ntr~=winsize(jw) && calc==1 % Check number of extracted traces 82 | fprintf(['\n Not enough traces with nW = ',num2str(winsize(jw)),... 83 | ' - Go to next shot or Xmid\n']); 84 | continue 85 | end 86 | Gmin(ix,jw)=min(Gleft); 87 | Gmax(ix,jw)=max(Gright); 88 | end 89 | % Retrieve min and max sources position on both sides of the window 90 | Smin=XmidT(ix)-(maxwinsize(jw)/2)-(dx*dSmax+dx); 91 | Smax=XmidT(ix)+(maxwinsize(jw)/2)+(dx*dSmax+dx); 92 | Smed1=XmidT(ix)-(maxwinsize(jw)/2)-(dx*dSmin); 93 | Smed2=XmidT(ix)+(maxwinsize(jw)/2)+(dx*dSmin); 94 | % Select existing sources according to the specified side 95 | if strcmp(side,'L')==1 96 | Sselec=Sxsing(Sxsing>Smin & Sxsing<=Smed1); 97 | elseif strcmp(side,'R')==1 98 | Sselec=Sxsing(Sxsing=Smed2); 99 | else 100 | Sselec=Sxsing((Sxsing>Smin & Sxsing<=Smed1) | ... 101 | (Sxsing=Smed2)); 102 | end 103 | % Get nb of selected shot for the current window 104 | nshot(ix,jw)=length(Sselec); 105 | 106 | if nshot(ix,jw)>0 107 | fprintf(['\n Xmid = ',num2str(XmidT(ix),xmidformat),' m \n']); 108 | fprintf(['\n Shot at ',num2str(Sselec(1)),... 109 | ' m with nW = ',num2str(winsize(jw)),' and dS = ',num2str(dSmin),'\n']); 110 | end 111 | 112 | %%%%%% Loop over all selected shots %%%%%% 113 | 114 | for ks=1:nshot(ix,jw) 115 | % Windowing, muting and saving seismogram in .su file 116 | seismofile=fullfile(dir_dat_xmid,[sufile(1:end-3),'_',num2str(XmidT(ix),xmidformat),'.',... 117 | num2str(winsize(jw)),'.',num2str(Sselec(ks)),'.su']); 118 | [seismomat,xseis,tseis,ntr]=matwind(sufile,Sselec(ks),Gmin(ix,jw),Gmax(ix,jw),xsca,... 119 | winsize(jw),seismofile,0,mute,tmin1,tmin2,tmax1,tmax2); 120 | if ntr~=winsize(jw) % Check number of extracted traces 121 | fprintf('\n Not enough traces - Go to next shot\n'); 122 | nshot(ix,jw)=nshot(ix,jw)-1; 123 | continue 124 | end 125 | j=j+1; % Stack flag 126 | % P-Omega transform on seismogram and saving in .dsp file 127 | dspfile=fullfile(dir_dat_xmid,[sufile(1:end-3),'_',num2str(XmidT(ix),xmidformat),'.',... 128 | num2str(winsize(jw)),'.',num2str(Sselec(ks)),'.dsp']); 129 | [dspmat,f,v]=matpomegal(seismofile,1,nray,fmin,fmax,vmin,vmax,... 130 | flip,xsca,tsca,1,dspfile,0); 131 | unix('rm -f speclud'); 132 | % Spectrogram calculation on seismogram and saving in .spec file 133 | specfile=fullfile(dir_dat_xmid,[sufile(1:end-3),'_',num2str(XmidT(ix),xmidformat),'.',... 134 | num2str(winsize(jw)),'.',num2str(Sselec(ks)),'.spec']); 135 | [specmat,fspec,xspec]=matspecfx(seismofile,xsca,specfile,0,0); 136 | end 137 | end 138 | end 139 | 140 | plot_disp(dspfile,0,Dlogscale,0,max(f(:)),imgform,imgres,flip,eb) 141 | plot_spec(specfile,0,max(f(:)),imgform,imgres) 142 | plot_seismo(seismofile,0,750,imgform,imgres) 143 | 144 | end -------------------------------------------------------------------------------- /tools/convert_targ.m: -------------------------------------------------------------------------------- 1 | function convert_targ(resampvec) 2 | 3 | %%% S. Pasquet - V16.11.22 4 | % Convert target files in pvc files 5 | % convert_targ(resampvec) 6 | 7 | if exist('resampvec','var')==0 || isempty(resampvec)==1 8 | resampvec = 0:0.5:200; 9 | end 10 | 11 | dir_targ=uigetdir('./','Select folder containing target files to convert'); 12 | targstruct=dir(fullfile(dir_targ,'*.target')); 13 | dir_pvc=fullfile(dir_targ,'file.pvc'); 14 | if exist(dir_pvc,'dir')~=7 15 | mkdir(dir_pvc); 16 | end 17 | 18 | for i=1:length(targstruct) 19 | nametarg=targstruct(i).name; 20 | Xmid=str2double(nametarg(1:end-7)); 21 | % pvcfile=[num2str(Xmid),targfile(end-6:end)]; 22 | [freqresamp,vresamp,deltaresamp,modes]=targ2pvc(fullfile(dir_targ,nametarg)); 23 | % Read target file to get picked dispersion curves 24 | npvc=length(modes); 25 | for ip=1:npvc 26 | % Resample in lambda or frequency 27 | if length(freqresamp{modes(ip)+1})>1 28 | plot_curv(modes(ip),freqresamp{modes(ip)+1},vresamp{modes(ip)+1},... 29 | deltaresamp{modes(ip)+1},'.-',[0 0 1],[],0,0,... 30 | 0,16,'Frequency (Hz)','Phase velocity (m/s)',... 31 | [],[],[],[],[],[],[],[],[],[0 0 24 18],[]); 32 | hold on 33 | 34 | [freqresamp{modes(ip)+1},vresamp{modes(ip)+1},deltaresamp{modes(ip)+1}]=... 35 | resampvel(freqresamp{modes(ip)+1},vresamp{modes(ip)+1},deltaresamp{modes(ip)+1},resampvec,0,0); 36 | 37 | namepvc=fullfile(dir_pvc,[num2str(Xmid),'.M',num2str(modes(ip)),'.txt']); 38 | dlmwrite(namepvc,[freqresamp{modes(ip)+1}',vresamp{modes(ip)+1}',deltaresamp{modes(ip)+1}'],'\t'); 39 | 40 | plot_curv(modes(ip),freqresamp{modes(ip)+1},vresamp{modes(ip)+1},... 41 | deltaresamp{modes(ip)+1},'.-',[1 0 0],[],0,0,... 42 | 0,16,'Frequency (Hz)','Phase velocity (m/s)',... 43 | [],[],[],[],[],[],[],[],[],[0 0 24 18],[]); 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /tools/convert_xzv.m: -------------------------------------------------------------------------------- 1 | function [xnew,ynew] = convert_xzv(filevel,utm_start,utm_end) 2 | 3 | %%% S. Pasquet - V17.05.19 4 | % Convert 2D models into UTM coordinate system from X,Z,V ASCII file 5 | 6 | if exist('filevel','var')==0 || isempty(filevel)==1 7 | [filevel,pathvel]=uigetfile({'*.model;*.dat;*.xzv;*.txt'},'Select velocity model'); 8 | else 9 | pathvel=[]; 10 | end 11 | Vfile=fullfile(pathvel,filevel); % File with velocity (3 columns X,Z,Vp) 12 | 13 | aa=load(Vfile); 14 | if size(aa,2)>2 15 | aa(isnan(aa(:,3)),:)=[]; 16 | end 17 | 18 | [xnew,ynew]=local2utm(aa(:,1),utm_start,utm_end); 19 | 20 | [~,newfile] = fileparts(Vfile); 21 | Vfile_new = [pathvel,newfile,'_UTM','.dat']; 22 | if size(aa,2)>2 23 | dlmwrite(Vfile_new,[xnew,ynew,aa(:,2),log10(aa(:,3))],'delimiter','\t','precision','%6.2f'); 24 | else 25 | dlmwrite(Vfile_new,[xnew,ynew,log10(aa(:,2))],'delimiter','\t','precision','%6.2f'); 26 | end 27 | -------------------------------------------------------------------------------- /tools/datablank.m: -------------------------------------------------------------------------------- 1 | function datablank 2 | 3 | %%% S. Pasquet - V16.2.17 4 | % Blank X,Y,Z file and save blanked file 5 | 6 | [filedata,pathdata]=uigetfile({'*.model;*.dat;*.xzv'},'Select XYZ data file'); 7 | [filebln,pathbln]=uigetfile({'*.bln'},'Select XYZ data file'); 8 | 9 | datafile=fullfile(pathdata,filedata); 10 | blnfile=fullfile(pathbln,filebln); 11 | [~,datablnfilename,extension]=fileparts(datafile); 12 | datablnfile=fullfile(pathdata,[datablnfilename,'_bln',extension]); 13 | 14 | [ZI,XI,YI]=bln2xyz(datafile,blnfile); 15 | 16 | X=reshape(XI,1,size(XI,1)*size(XI,2)); 17 | Y=reshape(YI,1,size(XI,1)*size(XI,2)); 18 | Z=reshape(ZI,1,size(XI,1)*size(XI,2)); 19 | 20 | X=X(isnan(Z)==0)'; 21 | Y=Y(isnan(Z)==0)'; 22 | Z=Z(isnan(Z)==0)'; 23 | 24 | dlmwrite(datablnfile,[X,Y,Z],'delimiter',' '); 25 | 26 | -------------------------------------------------------------------------------- /tools/plot_1dmod_multi.m: -------------------------------------------------------------------------------- 1 | function plot_1dmod_multi(dir_mod,mappick,doi,vsMIN,vsMAX,fs,imgform,imgres) 2 | 3 | %%% S. Pasquet - V17.03.29 4 | % Quick plot of multiple 1D velocity models 5 | % plot_1dmod_multi(dir_mod,mappick,doi,vsMIN,vsMAX,fs,imgform,imgres) 6 | 7 | if exist('dir_mod','var')==0 || isempty(dir_mod)==1 8 | dir_mod=uigetdir('./','Select folder containing velocity files'); 9 | if dir_mod==0 10 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 11 | fprintf('\n Please select a velocity folder'); 12 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 13 | return 14 | end 15 | modstruct=[dir(fullfile(dir_mod,'*.smooth')); dir(fullfile(dir_mod,'*.layered'));... 16 | dir(fullfile(dir_mod,'*.ridge')); dir(fullfile(dir_mod,'*.best')) ; dir(fullfile(dir_mod,'*vptomo')); dir(fullfile(dir_mod,'*.txt')); dir(fullfile(dir_mod,'*.dat'))]; 17 | end 18 | 19 | if exist('doi','var')==0 || isempty(doi)==1 20 | doi=[]; 21 | end 22 | 23 | if exist('mappick','var')==0 || isempty(mappick)==1 24 | mappick=jet(length(modstruct)); 25 | end 26 | 27 | run('SWIP_defaultsettings') 28 | 29 | for i=1:length(modstruct) 30 | modfile=modstruct(i).name; 31 | modvel=dlmread(fullfile(dir_mod,modfile),'',1,0); 32 | moddepth=[0;cumsum(modvel(:,1))]; 33 | vssw=modvel(:,3); 34 | [~,str_tmp] = fileparts(modfile); 35 | if i==1 36 | str = {str_tmp}; 37 | [VSplot,Zplot]=stair2plot(vssw,moddepth); 38 | [fig,han(i)]=plot_curv([],VSplot,Zplot,[],'-',mappick(i,:),[],1,1,... 39 | 0,fs,'Vs (m/s)',depthtitle,[],[vsMIN vsMAX],[dpMIN dpMAX],[],... 40 | vsticks,dticks,[],doi,[],[0 0 24 18],[],0); 41 | hold on 42 | else 43 | str = [str ; {str_tmp}]; 44 | [VSplot,Zplot]=stair2plot(vssw,moddepth); 45 | figure(fig); 46 | han(i)=plot(VSplot,Zplot,'-','Color',mappick(i,:),... 47 | 'linewidth',2,'markersize',10); 48 | hold on 49 | end 50 | end 51 | hold off 52 | legend(han,str); 53 | 54 | file1=['mod1d_all.',imgform]; 55 | save_fig(fig,file1,imgform,imgres,1); 56 | 57 | end 58 | -------------------------------------------------------------------------------- /tools/plot_disp.m: -------------------------------------------------------------------------------- 1 | function plot_disp(dspfile,targetfile,Dlogscale,fMIN,fMAX,imgform,imgres,flip,eb) 2 | 3 | %%% S. Pasquet - V16.11.22 4 | % Quick plot of dispersion image and curves 5 | % plot_disp(dspfile,targetfile,Dlogscale,fMIN,fMAX,imgform,imgres,flip,eb) 6 | 7 | if exist('dspfile','var')==0 || isempty(dspfile)==1 8 | [dspfile,dsppath]=uigetfile('*.dsp','Select dispersion file'); 9 | if dspfile==0 10 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 11 | fprintf('\n Please select a dispersion file'); 12 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 13 | return 14 | end 15 | else 16 | dsppath=[]; 17 | end 18 | 19 | if exist('targetfile','var')==0 || isempty(targetfile)==1 20 | [targetfile,targetpath]=uigetfile('*.target','Select dispersion curve or cancel'); 21 | else 22 | targetpath=[]; 23 | end 24 | 25 | run('SWIP_defaultsettings') 26 | 27 | [dspmat,f,v]=dsp2dat(fullfile(dsppath,dspfile),flip,0); 28 | 29 | if Dlogscale==0 30 | fig=plot_img([],f,v,-dspmat',map0,0,axerev,0,fs,... 31 | 'Frequency (Hz)','Phase velocity (m/s)',[],[fMIN fMAX],[],[],... 32 | [],[],[],[],[],[],[1 1 24 18],[]); 33 | else 34 | dspmat=1./(1-dspmat); 35 | dspmat(isinf(dspmat))=max(max(dspmat(isinf(dspmat)==0))); 36 | fig=plot_img_log([],f,v,dspmat',flipud(map0),0,axerev,0,fs,... 37 | 'Frequency (Hz)','Phase velocity (m/s)',[],[fMIN fMAX],[],[1 length(map0)],... 38 | [],[],[],[],[],[],[1 1 24 18],[]); 39 | end 40 | 41 | if targetfile~=0 42 | % Read target file to get picked dispersion curves 43 | [freqresamp,vresamp,deltaresamp,modes]=targ2pvc(fullfile(targetpath,targetfile)); 44 | npvc=length(modes); 45 | for ip=1:npvc 46 | % Resample in lambda or frequency 47 | if length(freqresamp{modes(ip)+1})>1 48 | [freqresamp{modes(ip)+1},vresamp{modes(ip)+1},deltaresamp{modes(ip)+1}]=... 49 | resampvel(freqresamp{modes(ip)+1},vresamp{modes(ip)+1},... 50 | deltaresamp{modes(ip)+1},resampvec,sampling,1); 51 | end 52 | end 53 | 54 | for ip=1:npvc 55 | hold on; 56 | col='w'; 57 | if eb==1 58 | errorbar(freqresamp{modes(ip)+1},vresamp{modes(ip)+1},deltaresamp{modes(ip)+1},'.','Color',col,... 59 | 'linewidth',1.5,'markersize',8); 60 | elseif eb==0 61 | plot(freqresamp{modes(ip)+1},vresamp{modes(ip)+1},'.','Color',col,... 62 | 'linewidth',1.5,'markersize',10); 63 | end 64 | end 65 | end 66 | hold off 67 | 68 | file1=[dspfile(1:end-3),'disp.',imgform]; 69 | save_fig(fig,file1,imgform,imgres,1); 70 | 71 | end -------------------------------------------------------------------------------- /tools/plot_seismo.m: -------------------------------------------------------------------------------- 1 | function plot_seismo(seismofile,tMIN,tMAX,imgform,imgres,fs,fldr,scal,clip,perc,xticks,tticks,xMIN,xMAX,imgsize) 2 | 3 | %%% S. Pasquet - V16.11.22 4 | % Quick plot of seismogram 5 | % plot_seismo(seismofile,tMIN,tMAX,imgform,imgres,fs,fldr,scal,clip,perc,xticks,tticks,xMIN,xMAX,imgsize) 6 | 7 | if exist('seismofile','var')==0 || isempty(seismofile)==1 8 | [seismofile,seismopath]=uigetfile('*.su','Select seismogram file'); 9 | if seismofile==0 10 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 11 | fprintf('\n Please select a seismogram file'); 12 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 13 | return 14 | end 15 | else 16 | seismopath=[]; 17 | end 18 | 19 | run('SWIP_defaultsettings') 20 | 21 | if exist('fldr','var')==0 || isempty(fldr)==1 22 | % Get fldr in case two shots at the same position 23 | com1=sprintf('sugethw < %s key=fldr output=geom | uniq',fullfile(seismopath,seismofile)); 24 | [~,fldr]=unix(com1); 25 | fldr=str2num(fldr); 26 | end 27 | if exist('scal','var')==0 || isempty(scal)==1 28 | scal=1; 29 | end 30 | if exist('clip','var')==0 || isempty(clip)==1 31 | clip=1; 32 | end 33 | if exist('perc','var')==0 || isempty(perc)==1 34 | perc=97; 35 | end 36 | 37 | if exist('imgsize','var')==0 || isempty(imgsize)==1 38 | imgsize=[0 0 25 15]; 39 | end 40 | 41 | [~,xsca]=unix(['sugethw < ',fullfile(seismopath,seismofile),' key=scalco output=geom | uniq']); 42 | xsca=abs(str2double(xsca)); 43 | if xsca == 0 44 | xsca = 1; 45 | end 46 | 47 | % tMIN = -100; 48 | % tMAX = 1000; 49 | 50 | for i=1:length(fldr) 51 | com1=sprintf('suwind < %s key=fldr min=%d max=%d > %s',fullfile(seismopath,seismofile),fldr(i),fldr(i),fullfile(seismopath,'tmp.su')); 52 | unix(com1); 53 | [seismomat,tseis,xseis]=seismo2dat(fullfile(seismopath,'tmp.su'),0); 54 | seismomat_norm = bsxfun(@rdivide,seismomat,max(abs(seismomat),[],2)); 55 | delete(fullfile(seismopath,'tmp.su')); 56 | fig=plot_wiggle(showplot,-seismomat_norm',xseis/xsca,tseis*1000,scal,clip,perc,... 57 | fs,'Gx (m)','Time (ms)',[xMIN xMAX],[tMIN tMAX],xticks,tticks,imgsize,[]); 58 | file1=[num2str(fldr(i)),'.seismo.',imgform]; 59 | % save_fig(fig,file1,imgform,imgres,1); 60 | export_fig(file1); 61 | 62 | end 63 | 64 | end -------------------------------------------------------------------------------- /tools/plot_spec.m: -------------------------------------------------------------------------------- 1 | function plot_spec(specfile,fMIN,fMAX,imgform,imgres) 2 | 3 | %%% S. Pasquet - V16.11.22 4 | % Quick plot of spectrogram 5 | % plot_spec(specfile,fMIN,fMAX,imgform,imgres) 6 | 7 | if exist('specfile','var')==0 || isempty(specfile)==1 8 | [specfile,specpath]=uigetfile('*.spec','Select spectrogram file'); 9 | if specfile==0 10 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 11 | fprintf('\n Please select a spectrogram file'); 12 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 13 | return 14 | end 15 | else 16 | specpath=[]; 17 | end 18 | 19 | run('SWIP_defaultsettings') 20 | 21 | [specmat,fspec,xspec]=spec2dat(fullfile(specpath,specfile),0); 22 | 23 | fig=plot_img([],fspec,xspec,-specmat,map0,0,axerev,1,fs,... 24 | 'Frequency (Hz)','Gx (m)',[],[fMIN fMAX],[],[-10e5 0],... 25 | [],[],[],[],[],[1 1 24 18],[]); 26 | 27 | sizeax=get(gca,'Position'); 28 | set(gca,'ActivePositionProperty','Position'); 29 | set(gca,'position',[sizeax(1),sizeax(2),sizeax(3),sizeax(4)/3]); 30 | % set(gcf,'PaperPosition',[0 0 24 18],'PaperSize',[24 9.5]); 31 | 32 | file1=[specfile,'.',imgform]; 33 | save_fig(fig,file1,imgform,imgres,1); 34 | 35 | end -------------------------------------------------------------------------------- /tools/plot_targ.m: -------------------------------------------------------------------------------- 1 | function plot_targ(targetfile,pickcol1,fMIN,fMAX,fticks,freqtitle_long,axetop,Flogscale,VphMIN,VphMAX,fs,imgform,imgres) 2 | 3 | %%% S. Pasquet - V16.11.30 4 | % Quick plot of dispersion curves 5 | % plot_targ(targetfile,pickcol1,fMIN,fMAX,fticks,freqtitle_long,axetop,Flogscale,VphMIN,VphMAX,fs,imgform,imgres) 6 | 7 | if exist('targetfile','var')==0 || isempty(targetfile)==1 8 | [targetfile,targetpath]=uigetfile('*.target','Select dispersion curve or cancel'); 9 | if targetfile==0 10 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 11 | fprintf('\n Please select a target file'); 12 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 13 | return 14 | end 15 | else 16 | targetpath=[]; 17 | end 18 | 19 | if exist('pickcol1','var')==0 || isempty(pickcol1)==1 20 | pickcol1='k'; 21 | end 22 | 23 | run('SWIP_defaultsettings') 24 | 25 | 26 | % Read target file to get picked dispersion curves 27 | [freqresamp,vresamp,deltaresamp,modes]=targ2pvc(fullfile(targetpath,targetfile)); 28 | npvc=length(modes); 29 | for ip=1:npvc 30 | if ip==1 31 | if eb==1 32 | [fig,han]=plot_curv([],freqresamp{modes(ip)+1},vresamp{modes(ip)+1},... 33 | deltaresamp{modes(ip)+1},'.-',pickcol1,[],axetop,axerev,... 34 | 0,fs,freqtitle_long,'Phase velocity (m/s)',[],[fMIN fMAX],[VphMIN VphMAX],[],... 35 | fticks,Vphticks,[],[],[],[1 1 24 18],[],[],Flogscale); 36 | xlimits=xlim; 37 | tick_length=diff(xlimits)/100; 38 | errorbar_tick(han,tick_length,'units'); 39 | else 40 | fig=plot_curv([],freqresamp{modes(ip)+1},vresamp{modes(ip)+1},[],'.-',pickcol1,[],axetop,axerev,... 41 | 0,fs,freqtitle_long,'Phase velocity (m/s)',[],[fMIN fMAX],[VphMIN VphMAX],[],... 42 | fticks,Vphticks,[],[],[],[1 1 24 18],[],[],Flogscale); 43 | end 44 | hold on 45 | else 46 | figure(fig); 47 | plot(freqresamp{modes(ip)+1},vresamp{modes(ip)+1},'.-','Color',pickcol1,... 48 | 'linewidth',1.5,'markersize',10); 49 | if eb==1 50 | if str2double(matrelease(1:4))>2014 51 | han=terrorbar(freqresamp{modes(ip)+1},vresamp{modes(ip)+1},deltaresamp{modes(ip)+1},1,'units'); 52 | set(han,'LineWidth',1.5,'Color',pickcol1) 53 | else 54 | han=errorbar(freqresamp{modes(ip)+1},vresamp{modes(ip)+1},deltaresamp{modes(ip)+1},... 55 | '.-','Color',pickcol1,'linewidth',1.5,'markersize',10); 56 | xlimits=xlim; 57 | tick_length=diff(xlimits)/100; 58 | errorbar_tick(han,tick_length,'units'); 59 | end 60 | end 61 | end 62 | end 63 | hold off 64 | 65 | file1=[targetfile(1:end-6),'curv.',imgform]; 66 | save_fig(fig,file1,imgform,imgres,1); 67 | 68 | end -------------------------------------------------------------------------------- /tools/plot_targ_multi.m: -------------------------------------------------------------------------------- 1 | function plot_targ_multi(dir_targ,mappick,nmodemax,fMIN,fMAX,fticks,freqtitle_long,axetop,Flogscale,VphMIN,VphMAX,fs,imgform,imgres) 2 | 3 | %%% S. Pasquet - V16.11.30 4 | % Quick plot of multiple dispersion curves 5 | % plot_targ_multi(dir_targ,mappick,nmodemax,fMIN,fMAX,fticks,freqtitle_long,axetop,Flogscale,VphMIN,VphMAX,fs,imgform,imgres) 6 | 7 | if exist('dir_targ','var')==0 || isempty(dir_targ)==1 8 | dir_targ=uigetdir('./','Select folder containing target files'); 9 | if dir_targ==0 10 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 11 | fprintf('\n Please select a target folder'); 12 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 13 | return 14 | end 15 | targstruct=dir(fullfile(dir_targ,'*.target')); 16 | end 17 | 18 | if exist('mappick','var')==0 || isempty(mappick)==1 19 | mappick=jet(length(targstruct)); 20 | end 21 | 22 | if exist('nmodemax','var')==0 || isempty(nmodemax)==1 23 | nmodemax=[]; 24 | end 25 | 26 | run('SWIP_defaultsettings') 27 | 28 | for i=1:length(targstruct) 29 | targetfile=targstruct(i).name; 30 | % Read target file to get picked dispersion curves 31 | [freqresamp,vresamp,deltaresamp,modes]=targ2pvc(fullfile(dir_targ,targetfile)); 32 | npvc=length(modes); 33 | if npvc>nmodemax 34 | npvc=nmodemax; 35 | end 36 | for ip=1:npvc 37 | if mod(ip,2)==1 % non even 38 | symb='+-'; 39 | else 40 | symb='.-'; 41 | end 42 | if i==1 && ip==1 43 | if eb==1 44 | [fig,han]=plot_curv([],freqresamp{modes(ip)+1},vresamp{modes(ip)+1},... 45 | deltaresamp{modes(ip)+1},symb,mappick(i,:),[],axetop,axerev,... 46 | 0,fs,freqtitle_long,'Phase velocity (m/s)',[],[fMIN fMAX],[VphMIN VphMAX],[],... 47 | fticks,Vphticks,[],[],[],[1 1 24 18],[],[],Flogscale); 48 | xlimits=xlim; 49 | tick_length=diff(xlimits)/100; 50 | errorbar_tick(han,tick_length,'units'); 51 | else 52 | fig=plot_curv([],freqresamp{modes(ip)+1},vresamp{modes(ip)+1},[],symb,mappick(i,:),[],axetop,axerev,... 53 | 0,fs,freqtitle_long,'Phase velocity (m/s)',[],[fMIN fMAX],[VphMIN VphMAX],[],... 54 | fticks,Vphticks,[],[],[],[1 1 24 18],[],[],Flogscale); 55 | end 56 | hold on 57 | else 58 | figure(fig); 59 | plot(freqresamp{modes(ip)+1},vresamp{modes(ip)+1},symb,'Color',mappick(i,:),... 60 | 'linewidth',1.5,'markersize',10); 61 | if eb==1 62 | if str2double(matrelease(1:4))>2014 63 | han=terrorbar(freqresamp{modes(ip)+1},vresamp{modes(ip)+1},deltaresamp{modes(ip)+1},1,'units'); 64 | set(han,'LineWidth',1.5,'Color',mappick(i,:)) 65 | else 66 | han=errorbar(freqresamp{modes(ip)+1},vresamp{modes(ip)+1},deltaresamp{modes(ip)+1},... 67 | symb,'Color',mappick(i,:),'linewidth',1.5,'markersize',10); 68 | xlimits=xlim; 69 | tick_length=diff(xlimits)/100; 70 | errorbar_tick(han,tick_length,'units'); 71 | end 72 | end 73 | end 74 | end 75 | end 76 | hold off 77 | 78 | file1=['target.curv.',imgform]; 79 | save_fig(fig,file1,imgform,imgres,1); 80 | 81 | end -------------------------------------------------------------------------------- /tools/plot_xzv.m: -------------------------------------------------------------------------------- 1 | function [Xi,Zi,Vi]=plot_xzv(filevel,logscale,xLIM,xticks,zLIM,zticks,vLIM,... 2 | vsticks,vtitle,isoline,blocky,vertex,imgform,imgres,ISOvel2,filevel2,mask) 3 | 4 | %%% S. Pasquet - V17.01.26 5 | % Quick plot of 2D models from X,Z,V ASCII file 6 | % plot_xzv(filevel,logscale,xLIM,xticks,zLIM,zticks,vLIM,... 7 | % vsticks,vtitle,isoline,blocky,vertex,imgform,imgres,ISOvel2,filevel2,mask) 8 | 9 | 10 | if exist('mask','var')==0 || isempty(mask)==1 11 | mask=0; 12 | end 13 | if exist('logscale','var')==0 || isempty(logscale)==1 14 | logscale=0; 15 | end 16 | if exist('xLIM','var')==1 && isempty(xLIM)==0 17 | xMIN=xLIM(1); xMAX=xLIM(2); 18 | end 19 | if exist('zLIM','var')==1 && isempty(zLIM)==0 20 | zMIN=zLIM(1); zMAX=zLIM(2); 21 | end 22 | if exist('vLIM','var')==1 && isempty(vLIM)==0 23 | vsMIN=vLIM(1); vsMAX=vLIM(2); 24 | end 25 | if exist('vtitle','var')==0 || isempty(vtitle)==1 26 | vtitle='Velocity (m/s)'; 27 | end 28 | if exist('isoline','var')==0 || isempty(isoline)==1 29 | isoline=[]; 30 | end 31 | if exist('filevel','var')==0 || isempty(filevel)==1 32 | [filevel,pathvel]=uigetfile({'*.model;*.dat;*.xzv;*.txt'},'Select velocity model'); 33 | else 34 | pathvel=[]; 35 | end 36 | Vfile=fullfile(pathvel,filevel); % File with velocity (3 columns X,Z,Vp) 37 | if pathvel==0 38 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!'); 39 | fprintf('\n No file selected - Abort'); 40 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!\n'); 41 | return 42 | else 43 | try 44 | [Vi,Xi,Zi]=readtomo(Vfile,mask); % Read Vp tomo file 45 | catch 46 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 47 | fprintf('\n Invalid model file - Abort'); 48 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!\n'); 49 | return 50 | end 51 | end 52 | 53 | if exist('ISOvel2','var')==1 && isempty(ISOvel2)==0 54 | if exist('filevel2','var')==0 || isempty(filevel2)==1 55 | [filevel2,pathvel2]=uigetfile({'*.model;*.dat;*.xzv'},'Select velocity model'); 56 | else 57 | pathvel2=[]; 58 | end 59 | Vfile2=fullfile(pathvel2,filevel2); % File with velocity (3 columns X,Z,Vp) 60 | if pathvel2==0 61 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!'); 62 | fprintf('\n No file selected - Abort'); 63 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!\n'); 64 | return 65 | else 66 | try 67 | [Vi2,Xi2,Zi2]=readtomo(Vfile2,mask); % Read Vp tomo file 68 | catch 69 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!'); 70 | fprintf('\n Invalid model file - Abort'); 71 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!!!!!\n'); 72 | return 73 | end 74 | end 75 | end 76 | 77 | run('SWIP_defaultsettings') 78 | 79 | if exist('xMIN','var')==0 || isempty(xMIN)==1 || exist('xMAX','var')==0 || isempty(xMAX)==1 80 | xMIN=min(min(Xi)); xMAX=max(max(Xi)); 81 | end 82 | 83 | if exist('zMIN','var')==0 || isempty(zMIN)==1 || exist('zMAX','var')==0 || isempty(zMAX)==1 84 | zMIN=min(min(Zi)); zMAX=max(max(Zi)); 85 | end 86 | 87 | if logscale==0 88 | fig=plot_img([],Xi,Zi,Vi,map5,axetop,0,1,fs,'X (m)',... 89 | 'Altitude (m)',vtitle,[xMIN xMAX],[zMIN zMAX],... 90 | [vsMIN vsMAX],xticks,zticks,vsticks,[],[],isoline,[25 16 24 12],[],vertex,blocky); 91 | else 92 | fig=plot_img_log([],Xi,Zi,Vi,map5,axetop,0,1,fs,'X (m)',... 93 | 'Altitude (m)',vtitle,[xMIN xMAX],[zMIN zMAX],... 94 | [vsMIN vsMAX],xticks,zticks,vsticks,[],[],isoline,[25 16 24 12],[],vertex,blocky); 95 | end 96 | 97 | %%% 98 | if exist('ISOvel2','var')==1 && isempty(ISOvel2)~=1 99 | hold on; 100 | if length(ISOvel2)==1 101 | isoline=[ISOvel2 ISOvel2]; 102 | else 103 | isoline=ISOvel2; 104 | end 105 | [cs,hc]=contour(Xi2,Zi2,Vi2,isoline,'color',[0 0 0],'linewidth',1); 106 | clabel(cs, hc,'manual','Color', 'k', 'Rotation', 0,'fontsize',12); 107 | hold off; 108 | end 109 | %%% 110 | 111 | file1=[filevel(1:end-3),imgform]; 112 | save_fig(fig,file1,imgform,imgres,1); -------------------------------------------------------------------------------- /tools/sumerge.m: -------------------------------------------------------------------------------- 1 | function sumerge(dir_su,filename_new,del_file) 2 | 3 | %%% S. Pasquet - V17.05.10 4 | % Merge multiple SU files 5 | % sumerge(dir_su,filename_new,del_file) 6 | 7 | if exist('dir_su','var')==0 || isempty(dir_su)==1 8 | dir_su=uigetdir('./','Select folder containing SU files'); 9 | if dir_su==0 10 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!'); 11 | fprintf('\n Please select a folder'); 12 | fprintf('\n !!!!!!!!!!!!!!!!!!!!!!!!\n\n'); 13 | return 14 | end 15 | sustruct=dir(fullfile(dir_su,'*.su')); 16 | end 17 | 18 | if exist('filename_new','var')==0 || isempty(filename_new)==1 19 | filename_new = 'swip_profile_merged.su'; 20 | end 21 | 22 | if exist('del_file','var')==0 || isempty(del_file)==1 23 | del_file = 0; 24 | end 25 | 26 | com1='cat'; 27 | for i=1:length(sustruct) 28 | com1 = [com1 ' ' sustruct(i).name]; 29 | end 30 | com1=[com1 ' > ' filename_new]; 31 | unix(com1); 32 | 33 | if del_file == 1 34 | delete(sustruct.name); 35 | end --------------------------------------------------------------------------------