├── LICENSE ├── README.md ├── demos ├── test_matdrr_drr2d_diffraction.m ├── test_matdrr_drr2d_win.m ├── test_matdrr_drr2d_win_dassafod.m ├── test_matdrr_drr3d.m ├── test_matdrr_drr3d_diffraction.m ├── test_matdrr_drr3d_win.m ├── test_matdrr_drr3d_win_deblending.m ├── test_matdrr_drr3drecon.m ├── test_matdrr_drr3drecon_dealiase.m ├── test_matdrr_drr3drecon_otg_usarray.m ├── test_matdrr_drr3drecon_usarray.m ├── test_matdrr_drr5d.m ├── test_matdrr_drr5drecon.m ├── test_matdrr_odrr3d.m ├── test_matdrr_odrr3drecon.m ├── test_matdrr_odrr5d.m └── test_matdrr_odrr5drecon.m └── matdrr ├── drr3d.m ├── drr3d_auto.m ├── drr3d_win.m ├── drr3d_win_auto.m ├── drr3drecon.m ├── drr3drecon_auto.m ├── drr3drecon_dealiase.m ├── drr3drecon_otg.m ├── drr3drecon_win.m ├── drr3drecon_win_auto.m ├── drr5d.m ├── drr5drecon.m ├── drr_bandpass.m ├── drr_bin3d.m ├── drr_framebox.m ├── drr_genmask.m ├── drr_ifnot.m ├── drr_imagesc.m ├── drr_mf.m ├── drr_optshrink_damp.m ├── drr_plot3d.m ├── drr_ricker.m ├── drr_rperm.m ├── drr_scale.m ├── drr_snr.m ├── drr_transp.m ├── drr_wigbh.m ├── drr_win2d.m ├── drr_win3d.m ├── drr_win3dmask.m ├── localdrr3d.m ├── localdrr3d_auto.m ├── localdrr3drecon.m ├── localdrr3drecon_auto.m ├── odrr3d.m ├── odrr3drecon.m ├── odrr5d.m └── odrr5drecon.m /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 MATdrr 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr2d_diffraction.m: -------------------------------------------------------------------------------- 1 | % Demonstration script for 2 | % 2D diffraction separation via the localized damped rank-reduction method 3 | % (LDRR) 4 | % 5 | % Copyright (C) 2018 Yangkang Chen and Hang Wang 6 | % 7 | % This program is free software: you can redistribute it and/or modify 8 | % it under the terms of the GNU General Public License as published 9 | % by the Free Software Foundation, either version 3 of the License, or 10 | % any later version. 11 | % 12 | % This program is distributed in the hope that it will be useful, 13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 16 | % 17 | % References: 18 | % 19 | % Wang et al., 2020, Separation and imaging of seismic diffractions using a localized rank-reduction method with adaptively selected ranks, 85, V497–V506. 20 | % Chen et al., 2022, 3D seismic diffraction separation and imaging using the local rank-reduction method, IEEE Transactions on Geoscience and Remote Sensing, 60, 4507110. 21 | % Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 22 | % Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 23 | % Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 24 | % Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 25 | % Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 26 | % Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 27 | % Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 28 | % 29 | 30 | clc;clear;close all; 31 | addpath(genpath('../matdrr')); 32 | 33 | 34 | %% Please download data from https://github.com/aaspip/data/blob/main/diffr_syn_2d.mat 35 | % data is observed data 36 | % diffr is the ground-truth diffraction data 37 | load diffr_syn_2d.mat 38 | 39 | [n1,n2]=size(data); 40 | 41 | %% perform diffraction separation 42 | %This example is introduced in Wang et al., 2020. 43 | lf=0;hf=120;dt=0.004;verb=1;N=5;K=4; % N is a scalar (Nmax) or a vector (Nmin,Nmax); 44 | n1win=200;n2win=100;n3win=1;r1=0.5;r2=0.5;r3=0.5;mode=2;%mode=2 means using the singular value ratio criterion 45 | d1=drr3d_win_auto(data,lf,hf,dt,N,K,verb,n1win,n2win,n3win,r1,r2,r3,mode);%reflection from LDRR 46 | diffr1=data-d1; %diffraction from LDRR 47 | 48 | % Quick visualization 49 | % figure;drr_imagesc([data,diffr,diffr1,data-diffr,d1]); 50 | 51 | %% SNR of the separated diffraction 52 | drr_snr(diffr,diffr1) 53 | 54 | 55 | %% plot the results 56 | x=[0:n2-1]*dx; 57 | z=[0:n1-1]*dt; 58 | figure('units','normalized','Position',[0.2 0.4 1, 0.4],'color','w'); 59 | subplot(1,5,1);drr_imagesc(data,0.4,2,x,z);xlabel('Position (km)','Fontsize',15);ylabel('Time (s)','Fontsize',15);title('Data','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-2.5,-0.1,'a)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 60 | subplot(1,5,2);drr_imagesc(diffr,0.4,2,x,z);xlabel('Position (km)','Fontsize',15);title('Ground-truth diffraction','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-2.5,-0.1,'b)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 61 | subplot(1,5,3);drr_imagesc(data-diffr,0.4,2,x,z);xlabel('Position (km)','Fontsize',15);title('Ground-truth reflection','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-2.5,-0.1,'c)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 62 | subplot(1,5,4);drr_imagesc(diffr1,0.4,2,x,z);xlabel('Position (km)','Fontsize',15);title('LDRR diffraction','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-2.5,-0.1,'d)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 63 | subplot(1,5,5);drr_imagesc(data-diffr1,0.4,2,x,z);xlabel('Position (km)','Fontsize',15);title('LDRR reflection','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-2.5,-0.1,'e)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 64 | print(gcf,'-dpng','-r300','test_matdrr_drr2d_diffraction.png'); 65 | print(gcf,'-depsc','-r200','test_matdrr_drr2d_diffraction.eps'); 66 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr2d_win.m: -------------------------------------------------------------------------------- 1 | % Demonstration script for 2 | % 2D denoising via the localized damped rank-reduction method 3 | % (LDRR) 4 | % 5 | % Copyright (C) 2018 Yangkang Chen 6 | % 7 | % This program is free software: you can redistribute it and/or modify 8 | % it under the terms of the GNU General Public License as published 9 | % by the Free Software Foundation, either version 3 of the License, or 10 | % any later version. 11 | % 12 | % This program is distributed in the hope that it will be useful, 13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 16 | % 17 | % References: 18 | % 19 | % Wang et al., 2020, Separation and imaging of seismic diffractions using a localized rank-reduction method with adaptively selected ranks, 85, V497–V506. 20 | % Chen et al., 2022, 3D seismic diffraction separation and imaging using the local rank-reduction method, IEEE Transactions on Geoscience and Remote Sensing, 60, 4507110. 21 | % Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 22 | % Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 23 | % Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 24 | % Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 25 | % Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 26 | % Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 27 | % Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 28 | % 29 | 30 | clc;clear;close all; 31 | addpath(genpath('../matdrr')); 32 | 33 | %% download synthetic data 34 | %please download the data from https://github.com/aaspip/data/blob/main/hevents.mat 35 | load hevents.mat 36 | 37 | d=d/max(max(d)); 38 | randn('state',201314); 39 | dn=d+0.1*randn(size(d)); 40 | 41 | %% parameters 42 | [n1,n2]=size(dn); 43 | param.dt=0.004; 44 | param.flow=0; 45 | param.fhigh=245; 46 | param.N=2; 47 | param.K=4; 48 | param.verb=1; 49 | 50 | %% Global DRR 51 | param.N=6; 52 | d1=drr3d(dn,param.flow,param.fhigh,param.dt,param.N,param.K,param.verb); 53 | 54 | %% Local DRR (Option I, integrated version) 55 | n1win=50;n2win=20;n3win=1; 56 | r1=0.5;r2=0.5;r3=0.5; 57 | param.N=2; 58 | d2=drr3d_win(dn,param.flow,param.fhigh,param.dt,param.N,param.K,param.verb,n1win,n2win,n3win,r1,r2,r3); 59 | 60 | %% Local DRR (Option II, separated version) 61 | d3=drr_win3d(@localdrr3d, param, dn, n1win, n2win, n3win, r1, r2, r3); 62 | 63 | %% SNR comparison 64 | fprintf('SNR of DRR is %g\n',drr_snr(d,d1)); 65 | fprintf('SNR of LDRR is %g\n',drr_snr(d,d2)); 66 | 67 | %% verify correctness of two options (output is zero) 68 | fprintf('Difference between two versions is %g\n',norm(d2-d3)); 69 | 70 | %% plot results 71 | x=1:n2;z=[0:n1-1]*0.004; 72 | figure('units','normalized','Position',[0.2 0.4 0.55, 0.45]); 73 | subplot(1,6,1);drr_imagesc(d,2,0.5,x,z);caxis([-0.5,0.5]);xlabel('Trace','Fontsize',15);ylabel('Time (s)','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('Clean');text(-20,-0.1,'a)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 74 | subplot(1,6,2);drr_imagesc(dn,2,0.5,x,z);caxis([-0.5,0.5]);xlabel('Trace','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('Noisy');text(-20,-0.1,'b)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 75 | subplot(1,6,3);drr_imagesc(d1,2,0.5,x,z);caxis([-0.5,0.5]);xlabel('Trace','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('DRR');text(-20,-0.1,'c)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 76 | subplot(1,6,4);drr_imagesc(d2,2,0.5,x,z);caxis([-0.5,0.5]);xlabel('Trace','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('LDRR');text(-20,-0.1,'d)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 77 | subplot(1,6,5);drr_imagesc(dn-d1,2,0.5,x,z);caxis([-0.5,0.5]);xlabel('Trace','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('DRR');text(-20,-0.1,'e)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 78 | subplot(1,6,6);drr_imagesc(dn-d2,2,0.5,x,z);caxis([-0.5,0.5]);xlabel('Trace','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('LDRR');text(-20,-0.1,'f)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 79 | print(gcf,'-dpng','-r300','test_matdrr_drr2d_win.png'); 80 | print(gcf,'-depsc','-r200','test_matdrr_drr2d_win.eps'); 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr2d_win_dassafod.m: -------------------------------------------------------------------------------- 1 | % DEMO script to generate the DAS example 2 | % BY Yangkang Chen 3 | % Jan, 2023 4 | % This script takes about 10 minutes 5 | % 6 | % Dependency MATdrr 7 | % svn co https://github.com/aaspip/MATdrr/trunk ./MATdrr 8 | % or git clone https://github.com/aaspip/MATdrr ./ 9 | % 10 | % Related pacakge: 11 | % https://github.com/chenyk1990/dasmrrcoh 12 | % https://github.com/chenyk1990/dasmrrcoh-dataonly 13 | 14 | clc;clear;close all; 15 | addpath(genpath('../matdrr')); 16 | 17 | if ~isdir('fig') 18 | mkdir('fig'); 19 | end 20 | 21 | if ~isdir('processed') 22 | mkdir('processed'); 23 | end 24 | 25 | %% Download data first 26 | %% The whole dataset in the folder "raw" can be downloaded from https://github.com/chenyk1990/dasmrrcoh-dataonly 27 | %% A complete processing workflow can be found at https://github.com/chenyk1990/dasmrrcoh-dataonly or https://github.com/chenyk1990/dasmrrcoh 28 | % 29 | % https://github.com/chenyk1990/dasmrrcoh-dataonly/tree/main/raw/2017-06-23T22:03:22.380000Z_mag2.17.mat 30 | 31 | name='2017-06-23T22:03:22.380000Z_mag2.17.mat' 32 | ieq=3; 33 | load(name); 34 | eq=data; 35 | d_bp=drr_bandpass(eq',1/250,0,20)'; 36 | d_bpmf=drr_mf(d_bp,5,1,1); 37 | %% LDRR 38 | n1win=1024;n2win=800;n3win=1; 39 | n1win=512;n2win=200;n3win=1; 40 | r1=0.5;r2=0.5;r3=0.5; 41 | d_bpmfmrr=drr3d_win(d_bpmf',0,50,1/250,2,4,0,n1win,n2win,n3win,r1,r2,r3)'; 42 | save(sprintf('processed/eq%d.mat',ieq),'d_bp','d_bpmf','d_bpmfmrr'); 43 | 44 | [n1,n2]=size(data); 45 | t=[0:n2-1]*(1/250); 46 | x=1:n1; 47 | 48 | figure('units','normalized','Position',[0.2 0.4 0.7, 0.6],'color','w'); 49 | ax1=subplot(2,2,1); 50 | drr_imagesc(eq,95,1,t,x);colormap(ax1,seis); 51 | name(end-3:end)=[]; 52 | title(name,'Interpreter', 'none','Fontsize',14,'fontweight','bold'); 53 | % xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 54 | ylabel('Channel','Fontsize',14,'fontweight','bold'); 55 | set(gca,'Linewidth',2,'Fontsize',14,'Fontweight','bold'); 56 | text(-5,-100,'a)','color','k','Fontsize',18,'fontweight','bold','HorizontalAlignment','center'); 57 | 58 | ax2=subplot(2,2,2); 59 | drr_imagesc(d_bp,95,1,t,x);colormap(ax2,seis); 60 | title('BP','Fontsize',14,'fontweight','bold'); 61 | % xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 62 | % ylabel('Channel','Fontsize',14,'fontweight','bold'); 63 | set(gca,'Linewidth',2,'Fontsize',14,'Fontweight','bold'); 64 | text(-5,-100,'b)','color','k','Fontsize',18,'fontweight','bold','HorizontalAlignment','center'); 65 | 66 | ax3=subplot(2,2,3); 67 | drr_imagesc(d_bpmf,95,1,t,x);colormap(ax3,seis);title('BP+MF'); 68 | title('BP+MF','Fontsize',14,'fontweight','bold'); 69 | % xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 70 | ylabel('Channel','Fontsize',14,'fontweight','bold'); 71 | set(gca,'Linewidth',2,'Fontsize',14,'Fontweight','bold'); 72 | text(-5,-100,'c)','color','k','Fontsize',18,'fontweight','bold','HorizontalAlignment','center'); 73 | xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 74 | 75 | ax4=subplot(2,2,4); 76 | drr_imagesc(d_bpmfmrr,95,1,t,x);colormap(ax4,seis);title('BP+MF+MRR'); 77 | title('BP+MF+MRR','Fontsize',14,'fontweight','bold'); 78 | % xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 79 | % ylabel('Channel','Fontsize',14,'fontweight','bold'); 80 | set(gca,'Linewidth',2,'Fontsize',14,'Fontweight','bold'); 81 | text(-5,-100,'d)','color','k','Fontsize',18,'fontweight','bold','HorizontalAlignment','center'); 82 | xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 83 | print(gcf,'-depsc','-r300','test_matdrr_drr2d_win_dassafod.eps'); 84 | print(gcf,'-dpng','-r300','test_matdrr_drr2d_win_dassafod.png'); 85 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr3d.m: -------------------------------------------------------------------------------- 1 | % Demonstration script for 2 | % 3D seismic denoising via the damped rank-reduction method 3 | % 4 | % Copyright (C) 2015 The University of Texas at Austin 5 | % Copyright (C) 2015 Yangkang Chen 6 | % 7 | % This program is free software: you can redistribute it and/or modify 8 | % it under the terms of the GNU General Public License as published 9 | % by the Free Software Foundation, either version 3 of the License, or 10 | % any later version. 11 | % 12 | % This program is distributed in the hope that it will be useful, 13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 16 | % 17 | % References: 18 | % 19 | % [1] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 20 | % [2] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 21 | % [3] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 22 | % [4] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 23 | % [5] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 24 | 25 | clc;clear;close all; 26 | addpath(genpath('../matdrr')); 27 | %% generate synthetic data 28 | a1=zeros(300,20); 29 | [n,m]=size(a1); 30 | a3=a1; 31 | a4=a1; 32 | 33 | k=0; 34 | a=0.1; 35 | b=1; 36 | for t=-0.055:0.002:0.055 37 | k=k+1; 38 | b1(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 39 | b2(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 40 | b3(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 41 | b4(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 42 | end 43 | for i=1:m 44 | t1(i)=round(140); 45 | t3(i)=round(-6*i+180); 46 | t4(i)=round(6*i+10); 47 | a1(t1(i):t1(i)+k-1,i)=b1; 48 | a3(t3(i):t3(i)+k-1,i)=b1; 49 | a4(t4(i):t4(i)+k-1,i)=b1; 50 | end 51 | 52 | temp=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 53 | for j=1:20 54 | a4=zeros(300,20); 55 | for i=1:m 56 | t4(i)=round(6*i+10+3*j); 57 | a4(t4(i):t4(i)+k-1,i)=b1; 58 | 59 | t1(i)=round(140-2*j); 60 | a1(t1(i):t1(i)+k-1,i)=b1; 61 | end 62 | shot(:,:,j)=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 63 | end 64 | plane3d=shot; 65 | d=plane3d/max(max(max(plane3d))); 66 | 67 | %% adding noise 68 | randn('state',201314); 69 | var=0.2; 70 | dn=d+var*randn(size(d)); 71 | 72 | %% denoise (RR) 73 | flow=0;fhigh=250;dt=0.004;N=3;verb=1; 74 | d1=drr3d(dn(:,:,:),flow,fhigh,dt,N,100,verb); 75 | % figure;drr_imagesc([d(:,:,9),dn(:,:,9),d1(:,:,9),dn(:,:,9)-d1(:,:,9)]);caxis([-0.4,0.4]); 76 | 77 | %% denoise (DRR) 78 | flow=0;fhigh=250;dt=0.004;N=3;verb=1;K=3; 79 | d2=drr3d(dn(:,:,:),flow,fhigh,dt,N,K,verb); 80 | % figure;drr_imagesc([d(:,:,9),dn(:,:,9),d2(:,:,9),dn(:,:,9)-d2(:,:,9)]);caxis([-0.4,0.4]); 81 | 82 | s0=drr_snr(d,dn,2); 83 | s1=drr_snr(d,d1,2); 84 | s2=drr_snr(d,d2,2); 85 | 86 | %% plot the results 87 | [n1,n2,n3]=size(d); 88 | dy=1;dx=1;dt=0.004; 89 | y=[1:n3]*dy; 90 | x=[1:n2]*dx; 91 | z=[1:n1]*dt; 92 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.6],'color','w'); 93 | subplot(2,3,1);drr_plot3d(dn,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('Noisy (SNR=',num2str(s0),' dB )'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'a)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 94 | subplot(2,3,2);drr_plot3d(d1,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('RR (SNR=',num2str(s1),' dB)'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'b)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 95 | subplot(2,3,3);drr_plot3d(d2,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('DRR (SNR=',num2str(s2),' dB)'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'c)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 96 | subplot(2,3,5);drr_plot3d(dn-d1,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('Noise of RR'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'d)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 97 | subplot(2,3,6);drr_plot3d(dn-d2,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('Noise of DRR'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'e)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 98 | 99 | % subplot(3,2,5);drr_plot3d(diffr1,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('LDRR diffraction','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15); 100 | % subplot(3,2,6);drr_plot3d(data-diffr,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('LDRR reflection','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15); 101 | print(gcf,'-dpng','-r300','test_matdrr_drr3d.png'); 102 | print(gcf,'-depsc','-r200','test_matdrr_drr3d.eps'); 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr3d_diffraction.m: -------------------------------------------------------------------------------- 1 | % Demonstration script for 2 | % 3D diffraction separation via the localized damped rank-reduction method 3 | % (LDRR) 4 | % 5 | % Copyright (C) 2020 Yangkang Chen and Wei Chen 6 | % 7 | % This program is free software: you can redistribute it and/or modify 8 | % it under the terms of the GNU General Public License as published 9 | % by the Free Software Foundation, either version 3 of the License, or 10 | % any later version. 11 | % 12 | % This program is distributed in the hope that it will be useful, 13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 16 | % 17 | % References: 18 | % 19 | % Chen et al., 2022, 3D seismic diffraction separation and imaging using the local rank-reduction method, IEEE Transactions on Geoscience and Remote Sensing, 60, 4507110. 20 | % Wang et al., 2020, Separation and imaging of seismic diffractions using a localized rank-reduction method with adaptively selected ranks, 85, V497–V506. 21 | % Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 22 | % Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 23 | % Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 24 | % Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 25 | % Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 26 | % Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 27 | % Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 28 | % 29 | 30 | clc;clear;close all; 31 | addpath(genpath('../matdrr')); 32 | 33 | 34 | %% Please download data from https://github.com/aaspip/data/blob/main/diffr_syn_3d.mat 35 | % data is observed data 36 | % diffr is the ground-truth diffraction data 37 | load diffr_syn_3d.mat 38 | 39 | [n1,n2,n3]=size(data); 40 | 41 | %% perform diffraction separation 42 | %This example is introduced in Chen et al., 2022. 43 | lf=0;hf=100;dt=0.004;verb=1;N=12;N2=50;K=4; % N is a scalar (Nmax) or a vector (Nmin,Nmax); 44 | n1win=200;n2win=40;n3win=40;r1=0.5;r2=0.5;r3=0.5;mode=2;%mode=2 means using the singular value ratio criterion 45 | d1=drr3d_win_auto(data,lf,hf,dt,[N,N2],K,verb,n1win,n2win,n3win,r1,r2,r3,mode);%reflection from LDRR 46 | diffr1=data-d1; %diffraction from LDRR 47 | 48 | % Quick visualization 49 | figure;drr_imagesc([data(:,:,20),diffr(:,:,20),diffr1(:,:,20),data(:,:,20)-diffr(:,:,20),d1(:,:,20)]); 50 | 51 | %% SNR of the separated diffraction 52 | drr_snr(diffr,diffr1,2) 53 | 54 | %% plot the results 55 | y=[0:n3-1]*dy; 56 | x=[0:n2-1]*dx; 57 | z=[0:n1-1]*dt; 58 | figure('units','normalized','Position',[0.2 0.4 0.5, 0.8],'color','w'); 59 | subplot(3,2,1);drr_plot3d(data,[100,20,20],z,x,y);caxis([-0.5,0.5]);xlabel('X (km)','Fontsize',15);ylabel('Y (km)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('Data','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'a)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 60 | subplot(3,2,3);drr_plot3d(diffr,[100,20,20],z,x,y);caxis([-0.5,0.5]);xlabel('X (km)','Fontsize',15);ylabel('Y (km)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('Ground-truth diffraction','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'b)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 61 | subplot(3,2,4);drr_plot3d(data-diffr,[100,20,20],z,x,y);caxis([-0.5,0.5]);xlabel('X (km)','Fontsize',15);ylabel('Y (km)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('Ground-truth reflection','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'c)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 62 | subplot(3,2,5);drr_plot3d(diffr1,[100,20,20],z,x,y);caxis([-0.5,0.5]);xlabel('X (km)','Fontsize',15);ylabel('Y (km)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('LDRR diffraction','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'d)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 63 | subplot(3,2,6);drr_plot3d(data-diffr,[100,20,20],z,x,y);caxis([-0.5,0.5]);xlabel('X (km)','Fontsize',15);ylabel('Y (km)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('LDRR reflection','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'e)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 64 | print(gcf,'-dpng','-r300','test_matdrr_drr3d_diffraction.png'); 65 | print(gcf,'-depsc','-r300','test_matdrr_drr3d_diffraction.eps'); 66 | 67 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr3d_win.m: -------------------------------------------------------------------------------- 1 | % Demonstration script for 2 | % 3D seismic denoising via the localized damped rank-reduction method 3 | % 4 | % Copyright (C) 2015 The University of Texas at Austin 5 | % Copyright (C) 2015 Yangkang Chen 6 | % 7 | % This program is free software: you can redistribute it and/or modify 8 | % it under the terms of the GNU General Public License as published 9 | % by the Free Software Foundation, either version 3 of the License, or 10 | % any later version. 11 | % 12 | % This program is distributed in the hope that it will be useful, 13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 16 | % 17 | % References: 18 | % 19 | % Wang et al., 2020, Separation and imaging of seismic diffractions using a localized rank-reduction method with adaptively selected ranks, 85, V497–V506. 20 | % Chen et al., 2022, 3D seismic diffraction separation and imaging using the local rank-reduction method, IEEE Transactions on Geoscience and Remote Sensing, 60, 4507110. 21 | % Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 22 | % Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 23 | % Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 24 | % Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 25 | % Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 26 | % Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 27 | % Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 28 | % 29 | 30 | clc;clear;close all; 31 | addpath(genpath('../matdrr')); 32 | 33 | %% generate synthetic data 34 | cmp=zeros(50,32,32); 35 | [nz,nx,ny]=size(cmp); 36 | 37 | x=[1:32]; 38 | y=[1:32]; 39 | [x,y]=meshgrid(x,y); 40 | z=10*(sqrt(1+((x-16)./10).^2+((y-16)./10).^2)-1)+20; 41 | % figure;surf(y);set(gca,'ydir','reverse'); 42 | 43 | for ix=1:nx 44 | for iy=1:ny 45 | cmp(round(z(ix,iy))+1,ix,iy)=1; 46 | end 47 | end 48 | 49 | cmp=reshape(cmp,nz,nx*ny); 50 | wav=drr_ricker(30,0.004,0.2); 51 | for ix=1:nx*ny 52 | cmp(:,ix)=conv(cmp(:,ix),wav,'same'); 53 | end 54 | cmp=reshape(cmp,nz,nx,ny); 55 | dc=drr_scale(cmp,3); 56 | 57 | randn('state',201920); 58 | dn=dc+0.1*randn(size(dc)); 59 | 60 | figure;imagesc(dc(:,:,16));colormap(gray); 61 | figure;imagesc(squeeze(dc(:,16,:)));colormap(gray); 62 | figure;imagesc(squeeze(dc(:,:)));colormap(gray); 63 | figure;imagesc(squeeze(dn(:,:)));colormap(gray); 64 | 65 | %% parameters 66 | [n1,n2,n3]=size(dn); 67 | param.dt=0.004; 68 | param.flow=0; 69 | param.fhigh=245; 70 | param.N=2; 71 | param.K=4; 72 | param.verb=1; 73 | 74 | %% Global DRR 75 | param.N=6; 76 | d1=drr3d(dn,param.flow,param.fhigh,param.dt,param.N,param.K,param.verb); 77 | 78 | %% Local DRR (Option I, integrated version) 79 | n1win=50;n2win=16;n3win=16; 80 | r1=0.5;r2=0.5;r3=0.5; 81 | param.N=2; 82 | d2=drr3d_win(dn,param.flow,param.fhigh,param.dt,param.N,param.K,param.verb,n1win,n2win,n3win,r1,r2,r3); 83 | 84 | %% Local DRR (Option II, separated version) 85 | d3=drr_win3d(@localdrr3d, param, dn, n1win, n2win, n3win, r1, r2, r3); 86 | 87 | %% SNR comparison 88 | s0=drr_snr(dc,dn,2); 89 | s1=drr_snr(dc,d1,2); 90 | s2=drr_snr(dc,d2,2) 91 | fprintf('SNR of Noisy is %g\n',drr_snr(dc,dn,2)); 92 | fprintf('SNR of DRR is %g\n',drr_snr(dc,d1,2)); 93 | fprintf('SNR of LDRR is %g\n',drr_snr(dc,d2,2)); 94 | 95 | %% verify correctness of two options (output is zero) 96 | fprintf('Difference between two versions is %g\n',norm(d2(:)-d3(:))); 97 | 98 | 99 | %% plot the results 100 | [n1,n2,n3]=size(dn); 101 | dy=1;dx=1;dt=0.004; 102 | y=[1:n3]*dy; 103 | x=[1:n2]*dx; 104 | z=[1:n1]*dt; 105 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.6],'color','w'); 106 | subplot(2,3,1);drr_plot3d(dn,[25,16,16],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('Noisy (SNR=',num2str(s0),' dB )'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-1.2,-0.2, -0.06,'a)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 107 | subplot(2,3,2);drr_plot3d(d1,[25,16,16],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('DRR (SNR=',num2str(s1),' dB)'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-1.2,-0.2, -0.06,'b)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 108 | subplot(2,3,3);drr_plot3d(d2,[25,16,16],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('LDRR (SNR=',num2str(s2),' dB)'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-1.2,-0.2, -0.06,'c)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 109 | subplot(2,3,5);drr_plot3d(dn-d1,[25,16,16],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('Noise of DRR'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-1.2,-0.2, -0.06,'d)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 110 | subplot(2,3,6);drr_plot3d(dn-d2,[25,16,16],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('Noise of LDRR'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-1.2,-0.2, -0.06,'e)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 111 | print(gcf,'-dpng','-r300','test_matdrr_drr3d_win.png'); 112 | print(gcf,'-depsc','-r200','test_matdrr_drr3d_win.eps'); 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr3d_win_deblending.m: -------------------------------------------------------------------------------- 1 | %% DEMO of the MATdrr package for deblending 2 | 3 | clc;clear;close all; 4 | 5 | %% Please change the directory path 6 | % requiring the DRR package 7 | % https://github.com/chenyk1990/MATdrr 8 | addpath(genpath('~/MATdrr')); 9 | addpath(genpath('~/deblending-time/subroutines')); 10 | 11 | %% please download data from https://drive.google.com/file/d/1ge0Mn_SB4LUsVgOBvATh0iISwGQahKh4/view?usp=sharing 12 | load yc_fieldsr.mat 13 | %% in this dataset 14 | %there are two sources data3d(:,:,1:60) and data3d(:,:,61:120) 15 | %each source contains 120 shots 16 | %there are 60 receivers 17 | % 18 | 19 | d1=data3d(:,:,1); 20 | d2=data3d(:,:,60); 21 | figure; 22 | subplot(1,2,1);dbt_imagesc(d1); 23 | subplot(1,2,2);dbt_imagesc(d2); 24 | 25 | h1=1:120; 26 | h2=1:120; 27 | 28 | dt=0.004; 29 | t=[0:1500-1]*dt; 30 | nt=1500; 31 | nx=120; 32 | %% apply dbt_dithering 33 | randn('state',202122); 34 | shift1=floor(0.1*randn(1,size(d1,2))/dt); % shift of data1 to data2 35 | shift2=-shift1; % shift of data2 to data1 36 | 37 | d1shift=dbt_dither(d1,shift1); 38 | d2shift=dbt_dither(d2,shift2); 39 | 40 | figure; 41 | subplot(1,2,1);imagesc(h1,t,d1shift); 42 | subplot(1,2,2);imagesc(h2,t,d2shift); 43 | 44 | %% blend 45 | d1b=d1+d2shift; 46 | d2b=d2+d1shift; 47 | 48 | %% Correct time 49 | del=shift2; 50 | 51 | %% mask1 52 | dd=[fliplr(d1),d1]; 53 | d1m=dbt_mutter(dd,120,42,505); 54 | % figure;dbt_imagesc([dd,d1m,dd-d1m]); 55 | mask1=ones(size(dd)); 56 | mask1=dbt_mutter(mask1,120,42,505); 57 | mask1=mask1(:,121:end); 58 | %mask2 59 | mask2=ones(size(d2)); 60 | mask2=dbt_mutter(mask2,60,40,310); 61 | 62 | % figure;subplot(1,2,1);imagesc(mask1);subplot(1,2,2);imagesc(mask2); 63 | 64 | 65 | D1=zeros(nt,nx); 66 | D2=zeros(nt,nx); 67 | for iter=1:10 68 | fprintf('\n Iter %d \n',iter); 69 | D1T=dbt_dither(D1,-del); 70 | D2T=dbt_dither(D2,del); 71 | D1u = D1 + 0.5*(d1b-(D1+D2T)); % updated model 72 | D2u = D2 + 0.5*(d2b-(D1T+D2)); % updated model 73 | D1u=D1u.*mask1; 74 | D2u=D2u.*mask2; 75 | D1=drr3d_win(D1u,0,80,0.004,2,4,0,100,20,1,0.5,0.5,0.5); 76 | D2=drr3d_win(D2u,0,80,0.004,2,4,0,100,20,1,0.5,0.5,0.5); 77 | D1=D1.*mask1; 78 | D2=D2.*mask2; 79 | 80 | D1=D1+(d1b-D1).*(1-mask2).*mask1; 81 | D2=D2+(d2b-D2).*(1-mask1).*mask2; 82 | 83 | snr2(iter)=10*log10(sum(sum(d1.*d1))/sum(sum((d1-D1).*(d1-D1)))); 84 | snr22(iter)=10*log10(sum(sum(d2.*d2))/sum(sum((d2-D2).*(d2-D2)))); 85 | fprintf('iter1=%d,SNR=%g,SNR2=%g\n',iter,snr2(iter),snr22(iter)); 86 | end 87 | 88 | D33=D1+(d1b-D1).*(1-mask2).*mask1; 89 | D44=D2+(d2b-D2).*(1-mask1).*mask2; 90 | 91 | 92 | 93 | %% Figure 6 94 | [n1,n2]=size(d1); 95 | ngap=10; 96 | comp1=[d1,zeros(n1,ngap),d1b,zeros(n1,ngap),D33,zeros(n1,ngap),d1b-D33,zeros(n1,ngap),d1-D33]; 97 | comp2=[d2,zeros(n1,ngap),d2b,zeros(n1,ngap),D44,zeros(n1,ngap),d2b-D44,zeros(n1,ngap),d2-D44]; 98 | t=[0:1500-1]*0.004; 99 | x=1:size(comp1,2); 100 | xts1=[30,60,90]; 101 | xts2=xts1+ngap+nx; 102 | xts3=xts1+ngap*2+nx*2; 103 | xts4=xts1+ngap*3+nx*3; 104 | xts5=xts1+ngap*4+nx*4; 105 | xts=[xts1,xts2,xts3,xts4,xts5]; 106 | figure('units','normalized','Position',[0.0 0.0 0.5, 1],'color','w'); 107 | subplot(4,1,1:2);dbt_imagesc(comp1(1:1000,:),98,1,x,t(1:1000)); 108 | text(-50,-0.2,'a)','color','k','Fontsize',16,'fontweight','bold','HorizontalAlignment','left'); 109 | xticks(xts); 110 | set(gca,'xticklabel',{'30','60','90'}); 111 | ylabel('Time (s)','Fontsize',10,'fontweight','bold'); 112 | set(gca,'Linewidth',2,'Fontsize',10,'Fontweight','bold'); 113 | text(nx/2,0.16,'Unblended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 114 | text(nx+ngap+nx/2,0.16,'Blended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 115 | text((nx+ngap)*2+nx/2,0.16,'Deblended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 116 | text((nx+ngap)*3+nx/2,0.16,'Blending noise','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 117 | text((nx+ngap)*4+nx/2,0.16,'Deblending error','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 118 | 119 | text(nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 120 | text(nx+ngap+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 121 | text((nx+ngap)*2+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 122 | text((nx+ngap)*3+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 123 | text((nx+ngap)*4+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 124 | 125 | subplot(4,1,3:4);dbt_imagesc(comp2(1:1000,:),98,1,x,t(1:1000)); 126 | text(-50,-0.2,'b)','color','k','Fontsize',16,'fontweight','bold','HorizontalAlignment','left'); 127 | xticks(xts); 128 | set(gca,'xticklabel',{'30','60','90'}); 129 | ylabel('Time (s)','Fontsize',10,'fontweight','bold'); 130 | set(gca,'Linewidth',2,'Fontsize',10,'Fontweight','bold'); 131 | text(nx/2,0.16,'Unblended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 132 | text(nx+ngap+nx/2,0.16,'Blended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 133 | text((nx+ngap)*2+nx/2,0.16,'Deblended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 134 | text((nx+ngap)*3+nx/2,0.16,'Blending noise','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 135 | text((nx+ngap)*4+nx/2,0.16,'Deblending error','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 136 | text(nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 137 | text(nx+ngap+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 138 | text((nx+ngap)*2+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 139 | text((nx+ngap)*3+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 140 | text((nx+ngap)*4+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 141 | 142 | print(gcf,'-depsc','-r300','test_matdrr_drr3d_win_deblending.eps'); 143 | print(gcf,'-dpng','-r300','test_matdrr_drr3d_win_deblending.png'); 144 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr3drecon.m: -------------------------------------------------------------------------------- 1 | % Demonstration script for 2 | % 3D seismic denoising and reconstruction via the damped rank-reduction method 3 | % 4 | % Copyright (C) 2015 The University of Texas at Austin 5 | % Copyright (C) 2015 Yangkang Chen 6 | % 7 | % This program is free software: you can redistribute it and/or modify 8 | % it under the terms of the GNU General Public License as published 9 | % by the Free Software Foundation, either version 3 of the License, or 10 | % any later version. 11 | % 12 | % This program is distributed in the hope that it will be useful, 13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 16 | % 17 | % References: 18 | % 19 | % [1] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 20 | % [2] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 21 | % [3] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 22 | % [4] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 23 | % [5] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 24 | 25 | clc;clear;close all; 26 | addpath(genpath('../matdrr')); 27 | 28 | %% generate 3D synthetic data 29 | a1=zeros(300,20); 30 | [n,m]=size(a1); 31 | a3=a1; 32 | a4=a1; 33 | 34 | k=0; 35 | a=0.1; 36 | b=1; 37 | for t=-0.055:0.002:0.055 38 | k=k+1; 39 | b1(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 40 | b2(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 41 | b3(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 42 | b4(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 43 | end 44 | for i=1:m 45 | t1(i)=round(140); 46 | t3(i)=round(-6*i+180); 47 | t4(i)=round(6*i+10); 48 | a1(t1(i):t1(i)+k-1,i)=b1; 49 | a3(t3(i):t3(i)+k-1,i)=b1; 50 | a4(t4(i):t4(i)+k-1,i)=b1; 51 | end 52 | 53 | temp=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 54 | for j=1:20 55 | a4=zeros(300,20); 56 | for i=1:m 57 | t4(i)=round(6*i+10+3*j); 58 | a4(t4(i):t4(i)+k-1,i)=b1; 59 | 60 | t1(i)=round(140-2*j); 61 | a1(t1(i):t1(i)+k-1,i)=b1; 62 | end 63 | shot(:,:,j)=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 64 | end 65 | plane3d=shot; 66 | d=plane3d/max(max(max(plane3d))); 67 | 68 | %% without noise 69 | dn=d; 70 | 71 | %% decimate 72 | [nt,nx,ny]=size(d); 73 | ratio=0.5; 74 | mask=drr_genmask(reshape(d,nt,nx*ny),ratio,'c',201415); 75 | mask=reshape(mask,nt,nx,ny); 76 | d0=dn.*mask; 77 | 78 | %% reconstruct (without denoising) 79 | flow=0;fhigh=125;dt=0.004;N=3;Niter=10;mode=0;verb=1; 80 | d1=drr3drecon(d0,mask,flow,fhigh,dt,50,N,Niter,eps,verb,mode); 81 | 82 | % 2D quick comparison (clean,noisy,observed,reconstructed using RR) 83 | % figure;drr_imagesc([d(:,:,9),d0(:,:,9),d1(:,:,9)]);caxis([-0.5,0.5]); 84 | 85 | %% simultaneous denoising and reconstruction 86 | % adding noise 87 | randn('state',201314); 88 | var=0.2; 89 | dn=d+var*randn(size(d)); 90 | d0=dn.*mask; 91 | 92 | %% using RR (when K is suffiently large, see derivations in the references) 93 | flow=0;fhigh=250;dt=0.002;N=3;Niter=10;mode=1;verb=1; 94 | a=(Niter-(1:Niter))/(Niter-1); %linearly decreasing 95 | d1=drr3drecon(d0,mask,flow,fhigh,dt,N,100,Niter,eps,verb,mode,a); 96 | 97 | % 2D quick comparison 98 | % figure;drr_imagesc([d(:,:,9),d0(:,:,9),d1(:,:,9)]);caxis([-0.5,0.5]); 99 | 100 | %% using DRR 101 | flow=0;fhigh=250;dt=0.002;N=3;Niter=10;mode=1;verb=1;K=2; 102 | a=(Niter-(1:Niter))/(Niter-1); %linearly decreasing 103 | d2=drr3drecon(d0,mask,flow,fhigh,dt,N,K,Niter,eps,verb,mode,a); 104 | 105 | % 2D quick comparison 106 | % figure;drr_imagesc([d(:,:,9),d0(:,:,9),d2(:,:,9)]);caxis([-0.5,0.5]); 107 | 108 | %% calculate Signal-to-noise Ratio (SNR) 109 | s0=drr_snr(d,d0,2);%observed data 110 | sn=drr_snr(d,dn,2);%observed data 111 | s1=drr_snr(d,d1,2);%RR method 112 | s2=drr_snr(d,d2,2);%DRR method 113 | 114 | %SNR results (might be slightly different for different PC platforms) 115 | %d0: -5.9853 116 | %d1: 1.4503 117 | %d2: 6.4816 118 | 119 | 120 | [n1,n2,n3]=size(d); 121 | dy=1;dx=1;dt=0.004; 122 | y=[1:n3]*dy; 123 | x=[1:n2]*dx; 124 | z=[1:n1]*dt; 125 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.6],'color','w'); 126 | subplot(2,3,1);drr_plot3d(d,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('Clean'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'a)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 127 | subplot(2,3,2);drr_plot3d(dn,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('Noisy (SNR=',num2str(sn),' dB )'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'b)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 128 | subplot(2,3,3);drr_plot3d(d0,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('Incomplete (SNR=',num2str(s0),' dB )'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'c)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 129 | subplot(2,3,5);drr_plot3d(d1,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('RR (SNR=',num2str(s1),' dB)'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'d)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 130 | subplot(2,3,6);drr_plot3d(d2,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title(strcat('DRR (SNR=',num2str(s2),' dB)'),'Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-0.5,-0.2, -0.3,'e)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 131 | 132 | % subplot(3,2,5);drr_plot3d(diffr1,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('LDRR diffraction','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15); 133 | % subplot(3,2,6);drr_plot3d(data-diffr,[100,10,10],z,x,y);caxis([-0.4,0.4]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('LDRR reflection','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15); 134 | print(gcf,'-dpng','-r300','test_matdrr_drr3drecon.png'); 135 | print(gcf,'-depsc','-r200','test_matdrr_drr3drecon.eps'); 136 | 137 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr3drecon_dealiase.m: -------------------------------------------------------------------------------- 1 | % Demonstration script for 2 | % 3D dealiased reconstruction via the damped rank-reduction method 3 | % 4 | % Copyright (C) 2023 The University of Texas at Austin 5 | % Copyright (C) 2023 Yangkang Chen 6 | % 7 | % This program is free software: you can redistribute it and/or modify 8 | % it under the terms of the GNU General Public License as published 9 | % by the Free Software Foundation, either version 3 of the License, or 10 | % any later version. 11 | % 12 | % This program is distributed in the hope that it will be useful, 13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 16 | % 17 | % References: 18 | % 19 | % [0] Huang, W., D. Feng, and Y. Chen, 2020, De‐aliased and de‐noise Cadzow filtering for seismic data reconstruction, Geophysical Prospecting, 68, 443-571. 20 | % [1] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 21 | % [2] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 22 | % [3] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 23 | % [4] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 24 | % [5] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 25 | 26 | clc;clear;close all; 27 | addpath(genpath('../matdrr')); 28 | 29 | 30 | %% generate 3D synthetic data 31 | a1=zeros(300,20); 32 | [n,m]=size(a1); 33 | a3=a1; 34 | a4=a1; 35 | 36 | k=0; 37 | a=0.1; 38 | b=1; 39 | for t=-0.055:0.002:0.055 40 | k=k+1; 41 | b1(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 42 | b2(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 43 | b3(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 44 | b4(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 45 | end 46 | for i=1:m 47 | t1(i)=round(140); 48 | t3(i)=round(-6*i+180); 49 | t4(i)=round(6*i+10); 50 | a1(t1(i):t1(i)+k-1,i)=b1; 51 | a3(t3(i):t3(i)+k-1,i)=b1; 52 | a4(t4(i):t4(i)+k-1,i)=b1; 53 | end 54 | 55 | temp=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 56 | for j=1:20 57 | a4=zeros(300,20); 58 | for i=1:m 59 | t4(i)=round(6*i+10+3*j); 60 | a4(t4(i):t4(i)+k-1,i)=b1; 61 | 62 | t1(i)=round(140-2*j); 63 | a1(t1(i):t1(i)+k-1,i)=b1; 64 | end 65 | shot(:,:,j)=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 66 | end 67 | plane3d=shot; 68 | d=plane3d/max(max(max(plane3d))); 69 | 70 | 71 | %% add band-limitted noise and decimate data 72 | randn('state',201315); 73 | [nt,nx,ny]=size(d); 74 | noise=randn(nt,nx,ny); 75 | noise=drr_bandpass(noise,0.004,0,60); 76 | dn=0.2*noise+d; 77 | 78 | %% Doing the aliased reconstruction (densification) 79 | d3=drr3drecon_dealiase(dn,1,50,0.004,3,4,10,2,2,1);%takes about 20 minutes 80 | 81 | dy=1;dx=1;dt=0.004; 82 | [n1,n22,n33]=size(dn); 83 | yy=[1:n33]*dy; 84 | xx=[1:n22]*dx; 85 | zz=[1:n1]*dt; 86 | 87 | [n1,n2,n3]=size(d3); 88 | dy=1;dx=1;dt=0.004; 89 | y=[1:n3]*dy; 90 | x=[1:n2]*dx; 91 | z=[1:n1]*dt; 92 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.6],'color','w'); 93 | subplot(1,2,1);drr_plot3d(dn,[100,5,5],zz,xx,yy);caxis([-0.5,0.5]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('Raw','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-2.5,-2.5, -0.3,'a)','color','k','Fontsize',40,'fontweight','bold','HorizontalAlignment','left'); 94 | subplot(1,2,2);drr_plot3d(d3,[100,10,10],z,x,y);caxis([-0.5,0.5]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('Densified','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15);text(-5,-5, -0.3,'b)','color','k','Fontsize',40,'fontweight','bold','HorizontalAlignment','left'); 95 | 96 | % subplot(3,2,5);drr_plot3d(diffr1,[100,10,10],z,x,y);caxis([-0.5,0.5]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('LDRR diffraction','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15); 97 | % subplot(3,2,6);drr_plot3d(data-diffr,[100,10,10],z,x,y);caxis([-0.5,0.5]);xlabel('X (sample)','Fontsize',15);ylabel('Y (sample)','Fontsize',15);zlabel('Time (s)','Fontsize',15);title('LDRR reflection','Fontsize',15,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',15); 98 | print(gcf,'-dpng','-r300','test_matdrr_drr3drecon_dealiase.png'); 99 | print(gcf,'-depsc','-r200','test_matdrr_drr3drecon_dealiase.eps'); 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr3drecon_otg_usarray.m: -------------------------------------------------------------------------------- 1 | % Demo script for OTG teleseismic denoising and reconstruction 2 | % as introduced in Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 3 | % Another version of this example is at 4 | % https://github.com/chenyk1990/reproducible_research/tree/master/nonMada/usarray 5 | % 6 | % This takes about 10 minutes 7 | % 8 | % Written by Yangkang Chen 9 | % Feb, 2018 10 | % Modified on Dec, 2020 11 | % Further polished on July, 2022, Feb, 2023 12 | % 13 | % This program is free software: you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published 15 | % by the Free Software Foundation, either version 3 of the License, or 16 | % any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 22 | % 23 | % REFERENCES 24 | % Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 25 | % Wang et al., 2020, Separation and imaging of seismic diffractions using a localized rank-reduction method with adaptively selected ranks, 85, V497?V506. 26 | % Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 27 | % Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 28 | % Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 29 | % Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 30 | % Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 31 | % Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 32 | 33 | clc;clear;close all; 34 | addpath(genpath('~/MATdrr')); 35 | 36 | %% Please download data from https://github.com/aaspip/data/blob/main/usarray_200901181411_wfm.mat 37 | load('usarray_200901181411_wfm.mat'); 38 | % d, dists(shot receiver distance/offset in degree), stla, stlo, t 39 | 40 | % figure;drr_imagesc([d(:,:)]); 41 | 42 | %% rm bad trace 43 | inds=[18,41,70]; 44 | d(:,inds)=[];d=drr_scale(d); 45 | stlo(inds)=[]; 46 | stla(inds)=[]; 47 | d0=d(:,105:433); 48 | stlo0=stlo(105:433); 49 | stla0=stla(105:433); 50 | 51 | 52 | 53 | d0=d0(1001:3000,:); 54 | 55 | %% 3D processing/reconstruction 56 | mla=[33,49]; 57 | mlo=[-116,-102]; 58 | %binning 59 | [d3d,x1,y1,mask]=drr_bin3d(d0,stlo0,stla0,16,28,mlo(1),mla(1),mlo(2),mla(2)); 60 | [stlo1,stla1]=meshgrid(x1,y1); 61 | 62 | %% global processing 63 | flow=0;fhigh=0.5;dt=1;N=8;Niter=10;mode=1;verb=1;eps=0.00001;K=4; 64 | a=(Niter-(1:Niter))/(Niter-1); %linearly decreasing 65 | d1=drr3drecon(d3d,mask,flow,fhigh,dt,N,K,Niter,eps,verb,mode,a); 66 | 67 | 68 | % figure;drr_imagesc([d3d(:,:),d1(:,:)]); 69 | 70 | d2=drr3drecon_otg(d0,stlo0,stla0,16,28,mlo(1),mla(1),mlo(2),mla(2),flow,fhigh,dt,N,K,Niter,eps,verb,mode); 71 | 72 | % figure;drr_imagesc([d3d(:,:),d1(:,:),d2(:,:)]); 73 | 74 | 75 | %% plot the results 76 | x1=750; 77 | x2=1200; 78 | y1=45; 79 | y2=49.5; 80 | 81 | ilon=12; 82 | dtest=squeeze(d3d(:,ilon,:)); 83 | figure('units','normalized','Position',[0.2 0.4 1.0, 1.2],'color','w'); 84 | subplot(2,3,1); 85 | drr_wigbh(dtest,stla1,t(1001:3000),20); 86 | ylim([31.5,50.2]); 87 | ylabel('Latitude (^o)','Fontsize',20); 88 | xlabel('Time (s)','Fontsize',20); 89 | title('Raw','Fontsize',20); 90 | drr_framebox(x1,x2,y1,y2,'r',2); 91 | text(0,52,'a)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 92 | 93 | subplot(2,3,2); 94 | dtest=squeeze(d1(:,ilon,:)); 95 | drr_wigbh(dtest,stla1,t(1001:3000),20); 96 | ylim([31.5,50.2]); 97 | ylabel('Latitude (^o)','Fontsize',20); 98 | xlabel('Time (s)','Fontsize',20); 99 | title('DRR','Fontsize',20); 100 | drr_framebox(x1,x2,y1,y2,'r',2); 101 | text(0,52,'b)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 102 | 103 | subplot(2,3,3); 104 | dtest=squeeze(d2(:,ilon,:)); 105 | drr_wigbh(dtest,stla1,t(1001:3000),20); 106 | ylim([31.5,50.2]); 107 | ylabel('Latitude (^o)','Fontsize',20); 108 | xlabel('Time (s)','Fontsize',20); 109 | title('OTG','Fontsize',20); 110 | drr_framebox(x1,x2,y1,y2,'r',2); 111 | text(0,52,'c)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 112 | 113 | %% zoomed comparison 114 | subplot(2,3,4); 115 | dtest=squeeze(d3d(:,ilon,:)); 116 | drr_wigbh(dtest,stla1,t(1001:3000),20); 117 | ylim([y1,y2]);xlim([x1,x2]); 118 | ylabel('Latitude (^o)','Fontsize',20); 119 | xlabel('Time (s)','Fontsize',20); 120 | title('Raw','Fontsize',20); 121 | text(660,50,'d)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 122 | 123 | % print(gcf,'-depsc','-r400','us_lon1_z.eps'); 124 | 125 | subplot(2,3,5); 126 | dtest=squeeze(d1(:,ilon,:)); 127 | drr_wigbh(dtest,stla1,t(1001:3000),20); 128 | ylim([y1,y2]);xlim([x1,x2]); 129 | ylabel('Latitude (^o)','Fontsize',20); 130 | xlabel('Time (s)','Fontsize',20); 131 | title('DRR','Fontsize',20); 132 | text(660,50,'e)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 133 | 134 | subplot(2,3,6); 135 | dtest=squeeze(d2(:,ilon,:)); 136 | drr_wigbh(dtest,stla1,t(1001:3000),20); 137 | ylim([y1,y2]);xlim([x1,x2]); 138 | ylabel('Latitude (^o)','Fontsize',20); 139 | xlabel('Time (s)','Fontsize',20); 140 | title('OTG','Fontsize',20); 141 | text(660,50,'f)','color','k','Fontsize',30,'fontweight','bold','HorizontalAlignment','left'); 142 | 143 | 144 | %% following are all annotations 145 | % Create textbox 146 | print(gcf,'-dpng','-r300','test_matdrr_drr3drecon_otg_usarray.png'); 147 | print(gcf,'-depsc','-r300','test_matdrr_drr3drecon_otg_usarray.eps'); 148 | 149 | 150 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr5d.m: -------------------------------------------------------------------------------- 1 | % 5D seismic data denoising via the damped rank-reduction method 2 | % 3 | % Copyright (C) 2022 The University of Texas at Austin 4 | % Copyright (C) 2022 Yangkang Chen 5 | % 6 | % This program is free software: you can redistribute it and/or modify 7 | % it under the terms of the GNU General Public License as published 8 | % by the Free Software Foundation, either version 3 of the License, or 9 | % any later version. 10 | % 11 | % This program is distributed in the hope that it will be useful, 12 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 15 | % 16 | % References: 17 | % 18 | % [1] Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 19 | % [2] Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 20 | % [3] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 21 | % [4] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 22 | % [5] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 23 | % [6] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 24 | % [7] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 25 | % [8] Oboue et al., 2021, Robust damped rank-reduction method for simultaneous denoising and reconstruction of 5-D seismic data, Geophysics, 86, V71–V89. 26 | 27 | clc;clear;close all; 28 | addpath(genpath('../matdrr')); 29 | 30 | %% download and load data 31 | % https://github.com/aaspip/data/blob/main/yc_synth5d.mat 32 | load yc_synth5d.mat 33 | d=data5d;d=d/max(max(max(max(max(d))))); 34 | [nt,nhx,nhy,nx,ny]=size(d); 35 | dt=0.004; 36 | %% exploring the data 37 | %1) ploting CMP gather 38 | % figure;drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 39 | 40 | %2) ploting common offset gather 41 | % figure;drr_imagesc(reshape(d(:,5,5,:,:),100,10*10)); 42 | %% add noise 43 | randn('state',201516); 44 | dn=d+.2*randn(nt,nhx,nhy,nx,ny); 45 | 46 | % figure; 47 | % subplot(2,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 48 | % subplot(2,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 49 | 50 | %% denoise (Traditonal RR) 51 | flow=5;fhigh=100;dt=0.004;N=6; 52 | d1=drr5d(dn,flow,fhigh,dt,N,100,1); 53 | % figure; 54 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 55 | % subplot(3,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 56 | % subplot(3,1,3);drr_imagesc(reshape(d1(:,:,:,1,1),100,10*10)); 57 | 58 | %% denoise (DRR) 59 | flow=5;fhigh=100;dt=0.004;N=6;K=2; 60 | d2=drr5d(dn,flow,fhigh,dt,N,K,1); 61 | 62 | snrnn=drr_snr(d(:,:),dn(:,:)) %-6.6662 63 | snr11=drr_snr(d(:,:),d1(:,:)) %15.6600 64 | snr22=drr_snr(d(:,:),d2(:,:)) %18.8509 65 | 66 | t=[0:100-1]*0.004; 67 | 68 | %% visualization 69 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.7],'color','w'); 70 | subplot(4,2,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Clean'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'a)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 71 | subplot(4,2,3);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Noisy (SNR=',num2str(snrnn),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'c)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 72 | subplot(4,2,5);drr_imagesc(reshape(d1(:,:,:,1,1),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('RR (SNR=',num2str(snr11),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'e)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 73 | subplot(4,2,7);drr_imagesc(reshape(d2(:,:,:,1,1),100,10*10),0.5,2,1:100,t);xlabel('Offset trace','Fontsize',12,'fontweight','normal');ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('DRR (SNR=',num2str(snr22),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'g)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 74 | 75 | subplot(4,2,2);drr_imagesc(reshape(d(:,5,5,:,:),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Clean'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'b)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 76 | subplot(4,2,4);drr_imagesc(reshape(dn(:,5,5,:,:),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Noisy (SNR=',num2str(snrnn),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'d)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 77 | subplot(4,2,6);drr_imagesc(reshape(d1(:,5,5,:,:),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('RR (SNR=',num2str(snr11),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'f)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 78 | subplot(4,2,8);drr_imagesc(reshape(d2(:,5,5,:,:),100,10*10),0.5,2,1:100,t);xlabel('Midpoint trace','Fontsize',12,'fontweight','normal');ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('DRR (SNR=',num2str(snr22),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'h)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 79 | 80 | print(gcf,'-dpng','-r300','test_matdrr_drr5d.png'); 81 | print(gcf,'-depsc','-r200','test_matdrr_drr5d.eps'); 82 | 83 | 84 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr5drecon.m: -------------------------------------------------------------------------------- 1 | % 5D seismic data denoising via the damped rank-reduction method 2 | % 3 | % Copyright (C) 2022 The University of Texas at Austin 4 | % Copyright (C) 2022 Yangkang Chen 5 | % 6 | % This program is free software: you can redistribute it and/or modify 7 | % it under the terms of the GNU General Public License as published 8 | % by the Free Software Foundation, either version 3 of the License, or 9 | % any later version. 10 | % 11 | % This program is distributed in the hope that it will be useful, 12 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 15 | % 16 | % References: 17 | % 18 | % [1] Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 19 | % [2] Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 20 | % [3] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 21 | % [4] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 22 | % [5] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 23 | % [6] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 24 | % [7] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 25 | % [8] Oboue et al., 2021, Robust damped rank-reduction method for simultaneous denoising and reconstruction of 5-D seismic data, Geophysics, 86, V71–V89. 26 | 27 | clc;clear;close all; 28 | addpath(genpath('../matdrr')); 29 | 30 | %% download and load data 31 | % https://github.com/aaspip/data/blob/main/yc_synth5d.mat 32 | load yc_synth5d.mat 33 | 34 | d=data5d;d=d/max(max(max(max(max(d))))); 35 | [nt,nhx,nhy,nx,ny]=size(d); 36 | dt=0.004; 37 | 38 | %% exploring the data 39 | %1) ploting CMP gather 40 | % figure;drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 41 | 42 | %2) ploting common offset gather 43 | % figure;drr_imagesc(reshape(d(:,5,5,:,:),100,10*10)); 44 | 45 | %% simultaneous denoising and reconstruction 46 | randn('state',201314); 47 | var=0.25; 48 | dn=d+var*randn(size(d)); 49 | 50 | %% decimate 51 | [nt,nhx,nhy,nx,ny]=size(d); 52 | ratio=0.3; 53 | mask=drr_genmask(reshape(d,nt,nhx*nhy*nx*ny),ratio,'c',201415); 54 | mask=reshape(mask,nt,nhx,nhy,nx,ny); 55 | d0=dn.*mask; 56 | 57 | %% RR5D 58 | flow=5;fhigh=100;dt=0.004;N=6;Niter=10;mode=1;verb=1; 59 | a=(Niter-(1:Niter))/(Niter-1); %linearly decreasing 60 | d1=drr5drecon(d0,mask,flow,fhigh,dt,N,50,Niter,eps,verb,mode,a); 61 | 62 | % figure; 63 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),nt,10*10)); 64 | % subplot(3,1,2);drr_imagesc(reshape(d0(:,:,:,1,1),nt,10*10)); 65 | % subplot(3,1,3);drr_imagesc(reshape(d1(:,:,:,1,1),nt,10*10)); 66 | % 67 | % figure; 68 | % subplot(3,1,1);drr_imagesc(reshape(d(:,5,5,:,:),nt,10*10)); 69 | % subplot(3,1,2);drr_imagesc(reshape(d0(:,5,5,:,:),nt,10*10)); 70 | % subplot(3,1,3);drr_imagesc(reshape(d1(:,5,5,:,:),nt,10*10)); 71 | 72 | %% DRR5D 73 | flow=5;fhigh=100;dt=0.004;N=6;K=2;Niter=10;mode=1;verb=1; 74 | d2=drr5drecon(d0,mask,flow,fhigh,dt,N,K,Niter,eps,verb,mode,a); 75 | 76 | % figure; 77 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),nt,10*10)); 78 | % subplot(3,1,2);drr_imagesc(reshape(d0(:,:,:,1,1),nt,10*10)); 79 | % subplot(3,1,3);drr_imagesc(reshape(d2(:,:,:,1,1),nt,10*10)); 80 | % 81 | % figure; 82 | % subplot(3,1,1);drr_imagesc(reshape(d(:,5,5,:,:),nt,10*10));caxis([-0.3,0.3]); 83 | % subplot(3,1,2);drr_imagesc(reshape(d0(:,5,5,:,:),nt,10*10));caxis([-0.3,0.3]); 84 | % subplot(3,1,3);drr_imagesc(reshape(d2(:,5,5,:,:),nt,10*10));caxis([-0.3,0.3]); 85 | 86 | %% calculate Signal-to-noise Ratio (SNR) 87 | snrnn=drr_snr(d(:,:),dn(:,:)) %-8.6178 88 | snr00=drr_snr(d(:,:),d0(:,:)) %-4.5929 89 | snr11=drr_snr(d(:,:),d1(:,:)) %7.5638 90 | snr22=drr_snr(d(:,:),d2(:,:)) %11.5626 91 | 92 | t=[0:100-1]*0.004; 93 | %% visualization 94 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.8],'color','w'); 95 | subplot(5,2,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Clean'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'a)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 96 | subplot(5,2,3);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Noisy (SNR=',num2str(snrnn),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'c)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 97 | subplot(5,2,5);drr_imagesc(reshape(d0(:,:,:,1,1),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Incomplete (SNR=',num2str(snr00),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'e)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 98 | subplot(5,2,7);drr_imagesc(reshape(d1(:,:,:,1,1),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('RR (SNR=',num2str(snr11),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'g)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 99 | subplot(5,2,9);drr_imagesc(reshape(d2(:,:,:,1,1),100,10*10),0.5,2,1:100,t);xlabel('Offset trace','Fontsize',12,'fontweight','normal');ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('DRR (SNR=',num2str(snr22),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'i)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 100 | 101 | subplot(5,2,2);drr_imagesc(reshape(d(:,5,5,:,:),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Clean'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'b)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 102 | subplot(5,2,4);drr_imagesc(reshape(dn(:,5,5,:,:),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Noisy (SNR=',num2str(snrnn),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'d)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 103 | subplot(5,2,6);drr_imagesc(reshape(d0(:,5,5,:,:),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Incomplete (SNR=',num2str(snr00),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'f)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 104 | subplot(5,2,8);drr_imagesc(reshape(d1(:,5,5,:,:),100,10*10),0.5,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('RR (SNR=',num2str(snr11),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'h)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 105 | subplot(5,2,10);drr_imagesc(reshape(d2(:,5,5,:,:),100,10*10),0.5,2,1:100,t);xlabel('Midpoint trace','Fontsize',12,'fontweight','normal');ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('DRR (SNR=',num2str(snr22),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'j)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','left'); 106 | 107 | print(gcf,'-dpng','-r300','test_matdrr_drr5drecon.png'); 108 | print(gcf,'-depsc','-r200','test_matdrr_drr5drecon.eps'); 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /demos/test_matdrr_odrr3d.m: -------------------------------------------------------------------------------- 1 | % Demonstration script for 2 | % 3D seismic denoising via the optimally damped rank-reduction method 3 | % 4 | % Copyright (C) 2022 The University of Texas at Austin 5 | % Copyright (C) 2022 Yangkang Chen 6 | % 7 | % This program is free software: you can redistribute it and/or modify 8 | % it under the terms of the GNU General Public License as published 9 | % by the Free Software Foundation, either version 3 of the License, or 10 | % any later version. 11 | % 12 | % This program is distributed in the hope that it will be useful, 13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 16 | % 17 | % References: 18 | % 19 | % [1] Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 20 | % [2] Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 21 | % [3] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 22 | % [4] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 23 | % [5] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 24 | % [6] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 25 | % [7] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 26 | % [8] Oboue et al., 2021, Robust damped rank-reduction method for simultaneous denoising and reconstruction of 5-D seismic data, Geophysics, 86, V71–V89. 27 | 28 | clc;clear;close all; 29 | addpath(genpath('../matdrr')); 30 | %% generate synthetic data 31 | a1=zeros(300,20); 32 | [n,m]=size(a1); 33 | a3=a1; 34 | a4=a1; 35 | 36 | k=0; 37 | a=0.1; 38 | b=1; 39 | for t=-0.055:0.002:0.055 40 | k=k+1; 41 | b1(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 42 | b2(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 43 | b3(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 44 | b4(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 45 | end 46 | for i=1:m 47 | t1(i)=round(140); 48 | t3(i)=round(-6*i+180); 49 | t4(i)=round(6*i+10); 50 | a1(t1(i):t1(i)+k-1,i)=b1; 51 | a3(t3(i):t3(i)+k-1,i)=b1; 52 | a4(t4(i):t4(i)+k-1,i)=b1; 53 | end 54 | 55 | temp=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 56 | for j=1:20 57 | a4=zeros(300,20); 58 | for i=1:m 59 | t4(i)=round(6*i+10+3*j); 60 | a4(t4(i):t4(i)+k-1,i)=b1; 61 | 62 | t1(i)=round(140-2*j); 63 | a1(t1(i):t1(i)+k-1,i)=b1; 64 | end 65 | shot(:,:,j)=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 66 | end 67 | plane3d=shot; 68 | d=plane3d/max(max(max(plane3d))); 69 | 70 | %% adding noise 71 | randn('state',201314); 72 | var=0.2; 73 | dn=d+var*randn(size(d)); 74 | 75 | %% denoise (RR) 76 | flow=0;fhigh=250;dt=0.004;N=6;verb=1; 77 | d1=drr3d(dn(:,:,:),flow,fhigh,dt,N,100,verb); 78 | % figure;drr_imagesc([d(:,:,9),dn(:,:,9),d1(:,:,9),dn(:,:,9)-d1(:,:,9)]);caxis([-0.5,0.5]); 79 | 80 | %% denoise (DRR) 81 | flow=0;fhigh=250;dt=0.004;N=6;verb=1;K=3; 82 | d2=drr3d(dn(:,:,:),flow,fhigh,dt,N,K,verb); 83 | % figure;drr_imagesc([d(:,:,9),dn(:,:,9),d2(:,:,9),dn(:,:,9)-d2(:,:,9)]);caxis([-0.5,0.5]); 84 | 85 | %% denoise (ODRR) 86 | flow=0;fhigh=250;dt=0.004;N=6;verb=1;K=3;O=1; 87 | d3=odrr3d(dn(:,:,:),flow,fhigh,dt,N,K,O,verb); 88 | % figure;drr_imagesc([d(:,:,9),dn(:,:,9),d3(:,:,9),dn(:,:,9)-d3(:,:,9)]);caxis([-0.5,0.5]); 89 | 90 | snrn=drr_snr(d,dn,2) 91 | snr1=drr_snr(d,d1,2) 92 | snr2=drr_snr(d,d2,2) 93 | snr3=drr_snr(d,d3,2) 94 | 95 | 96 | t=[0:300-1]*0.004; 97 | figure('units','normalized','Position',[0.2 0.4 0.4, 0.7],'color','w'); 98 | subplot(4,1,1);drr_imagesc(dn(:,:),0.1,2,1:400,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Noisy (SNR=',num2str(snrn),' dB )'),'Fontsize',15,'fontweight','normal');text(-40,-0.3,'a)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 99 | subplot(4,1,2);drr_imagesc(d1(:,:),0.1,2,1:400,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('RR (SNR=',num2str(snr1),' dB )'),'Fontsize',15,'fontweight','normal');text(-40,-0.3,'b)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 100 | subplot(4,1,3);drr_imagesc(d2(:,:),0.1,2,1:400,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('DRR (SNR=',num2str(snr2),' dB )'),'Fontsize',15,'fontweight','normal');text(-40,-0.3,'c)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 101 | subplot(4,1,4);drr_imagesc(d3(:,:),0.1,2,1:400,t);xlabel('Trace','Fontsize',12,'fontweight','normal');ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('ODRR (SNR=',num2str(snr3),' dB )'),'Fontsize',15,'fontweight','normal');text(-40,-0.3,'d)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 102 | print(gcf,'-dpng','-r300','test_matdrr_odrr3d.png'); 103 | print(gcf,'-depsc','-r200','test_matdrr_odrr3d.eps'); 104 | 105 | 106 | -------------------------------------------------------------------------------- /demos/test_matdrr_odrr3drecon.m: -------------------------------------------------------------------------------- 1 | % Demonstration script for 2 | % 3D seismic denoising and reconstruction via the optimally damped rank-reduction method 3 | % 4 | % Copyright (C) 2022 The University of Texas at Austin 5 | % Copyright (C) 2022 Yangkang Chen 6 | % 7 | % This program is free software: you can redistribute it and/or modify 8 | % it under the terms of the GNU General Public License as published 9 | % by the Free Software Foundation, either version 3 of the License, or 10 | % any later version. 11 | % 12 | % This program is distributed in the hope that it will be useful, 13 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 16 | % 17 | % References: 18 | % 19 | % [1] Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 20 | % [2] Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 21 | % [3] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 22 | % [4] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 23 | % [5] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 24 | % [6] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 25 | % [7] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 26 | % [8] Oboue et al., 2021, Robust damped rank-reduction method for simultaneous denoising and reconstruction of 5-D seismic data, Geophysics, 86, V71–V89. 27 | 28 | clc;clear;close all; 29 | addpath(genpath('../matdrr')); 30 | 31 | %% generate 3D synthetic data 32 | a1=zeros(300,20); 33 | [n,m]=size(a1); 34 | a3=a1; 35 | a4=a1; 36 | 37 | k=0; 38 | a=0.1; 39 | b=1; 40 | for t=-0.055:0.002:0.055 41 | k=k+1; 42 | b1(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 43 | b2(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 44 | b3(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 45 | b4(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 46 | end 47 | for i=1:m 48 | t1(i)=round(140); 49 | t3(i)=round(-6*i+180); 50 | t4(i)=round(6*i+10); 51 | a1(t1(i):t1(i)+k-1,i)=b1; 52 | a3(t3(i):t3(i)+k-1,i)=b1; 53 | a4(t4(i):t4(i)+k-1,i)=b1; 54 | end 55 | 56 | temp=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 57 | for j=1:20 58 | a4=zeros(300,20); 59 | for i=1:m 60 | t4(i)=round(6*i+10+3*j); 61 | a4(t4(i):t4(i)+k-1,i)=b1; 62 | 63 | t1(i)=round(140-2*j); 64 | a1(t1(i):t1(i)+k-1,i)=b1; 65 | end 66 | shot(:,:,j)=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 67 | end 68 | plane3d=shot; 69 | d=plane3d/max(max(max(plane3d))); 70 | 71 | %% without noise 72 | dn=d; 73 | 74 | %% decimate 75 | [nt,nx,ny]=size(d); 76 | ratio=0.5; 77 | mask=drr_genmask(reshape(d,nt,nx*ny),ratio,'c',201415); 78 | mask=reshape(mask,nt,nx,ny); 79 | d0=dn.*mask; 80 | 81 | %% reconstruct (without denoising) 82 | flow=0;fhigh=125;dt=0.004;N=3;Niter=10;mode=0;verb=1; 83 | d1=drr3drecon(d0,mask,flow,fhigh,dt,50,N,Niter,eps,verb,mode); 84 | 85 | % 2D quick comparison (clean,noisy,observed,reconstructed using RR) 86 | figure;drr_imagesc([d(:,:,9),d0(:,:,9),d1(:,:,9)]);caxis([-0.5,0.5]); 87 | 88 | %% simultaneous denoising and reconstruction 89 | % adding noise 90 | randn('state',201314); 91 | var=0.2; 92 | dn=d+var*randn(size(d)); 93 | d0=dn.*mask; 94 | 95 | %% using RR (when K is suffiently large, see derivations in the references) 96 | flow=0;fhigh=250;dt=0.002;N=6;Niter=10;mode=1;verb=1; 97 | a=(Niter-(1:Niter))/(Niter-1); %linearly decreasing 98 | d1=drr3drecon(d0,mask,flow,fhigh,dt,N,100,Niter,eps,verb,mode,a); 99 | 100 | % 2D quick comparison 101 | % figure;drr_imagesc([d(:,:,9),d0(:,:,9),d1(:,:,9)]);caxis([-0.5,0.5]); 102 | 103 | %% using DRR 104 | flow=0;fhigh=250;dt=0.002;N=6;Niter=10;mode=1;verb=1;K=2; 105 | a=(Niter-(1:Niter))/(Niter-1); %linearly decreasing 106 | d2=drr3drecon(d0,mask,flow,fhigh,dt,N,K,Niter,eps,verb,mode,a); 107 | 108 | % 2D quick comparison 109 | % figure;drr_imagesc([d(:,:,9),d0(:,:,9),d2(:,:,9)]);caxis([-0.5,0.5]); 110 | 111 | %% using ODRR 112 | flow=0;fhigh=250;dt=0.002;N=6;Niter=10;mode=1;verb=1;K=2;O=1; 113 | a=(Niter-(1:Niter))/(Niter-1); %linearly decreasing 114 | d3=odrr3drecon(d0,mask,flow,fhigh,dt,N,K,O,Niter,eps,verb,mode,a); 115 | 116 | % 2D quick comparison 117 | % figure;drr_imagesc([d(:,:,9),d0(:,:,9),d3(:,:,9)]);caxis([-0.5,0.5]); 118 | 119 | %% calculate Signal-to-noise Ratio (SNR) 120 | snr0=drr_snr(d,d0,2) %observed data 121 | snrn=drr_snr(d,dn,2) %noisy data 122 | snr1=drr_snr(d,d1,2) %RR method 123 | snr2=drr_snr(d,d2,2) %DRR method 124 | snr3=drr_snr(d,d3,2) %ODRR method 125 | 126 | %SNR results when N=3 (might be slightly different for different PC platforms) 127 | %d0: -5.9853 128 | %d1: 1.4503 129 | %d2: 6.4816 130 | %d3: 7.6997 131 | 132 | %SNR results when N=6 (when rank over-estimated) (might be slightly different for different PC platforms) 133 | %d0: -5.9853 134 | %d1: -0.9812 135 | %d2: 4.9273 136 | %d3: 7.4988 137 | 138 | t=[0:300-1]*0.004; 139 | figure('units','normalized','Position',[0.2 0.4 0.4, 1],'color','w'); 140 | subplot(6,1,1);drr_imagesc(d(:,:),0.1,2,1:400,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Clean'),'Fontsize',15,'fontweight','normal');text(-40,-0.3,'a)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 141 | subplot(6,1,2);drr_imagesc(dn(:,:),0.1,2,1:400,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Noisy (SNR=',num2str(snrn),' dB )'),'Fontsize',15,'fontweight','normal');text(-40,-0.3,'b)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 142 | subplot(6,1,3);drr_imagesc(d0(:,:),0.1,2,1:400,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Incomplete (SNR=',num2str(snr0),' dB )'),'Fontsize',15,'fontweight','normal');text(-40,-0.3,'c)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 143 | subplot(6,1,4);drr_imagesc(d1(:,:),0.1,2,1:400,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('RR (SNR=',num2str(snr1),' dB )'),'Fontsize',15,'fontweight','normal');text(-40,-0.3,'d)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 144 | subplot(6,1,5);drr_imagesc(d2(:,:),0.1,2,1:400,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('DRR (SNR=',num2str(snr2),' dB )'),'Fontsize',15,'fontweight','normal');text(-40,-0.3,'e)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 145 | subplot(6,1,6);drr_imagesc(d3(:,:),0.1,2,1:400,t);xlabel('Trace','Fontsize',12,'fontweight','normal');ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('ODRR (SNR=',num2str(snr3),' dB )'),'Fontsize',15,'fontweight','normal');text(-40,-0.3,'f)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 146 | print(gcf,'-dpng','-r300','test_matdrr_odrr3drecon.png'); 147 | print(gcf,'-depsc','-r200','test_matdrr_odrr3drecon.eps'); 148 | 149 | 150 | -------------------------------------------------------------------------------- /demos/test_matdrr_odrr5d.m: -------------------------------------------------------------------------------- 1 | % 5D seismic data denoising via the damped rank-reduction method 2 | % 3 | % Copyright (C) 2022 The University of Texas at Austin 4 | % Copyright (C) 2022 Yangkang Chen 5 | % 6 | % This program is free software: you can redistribute it and/or modify 7 | % it under the terms of the GNU General Public License as published 8 | % by the Free Software Foundation, either version 3 of the License, or 9 | % any later version. 10 | % 11 | % This program is distributed in the hope that it will be useful, 12 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 15 | % 16 | % References: 17 | % 18 | % [1] Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 19 | % [2] Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 20 | % [3] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 21 | % [4] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 22 | % [5] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 23 | % [6] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 24 | % [7] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 25 | % [8] Oboue et al., 2021, Robust damped rank-reduction method for simultaneous denoising and reconstruction of 5-D seismic data, Geophysics, 86, V71–V89. 26 | 27 | clc;clear;close all; 28 | addpath(genpath('../matdrr')); 29 | 30 | %% download and load data 31 | % https://github.com/aaspip/data/blob/main/yc_synth5d.mat 32 | load yc_synth5d.mat 33 | d=data5d;d=d/max(max(max(max(max(d))))); 34 | [nt,nhx,nhy,nx,ny]=size(d); 35 | dt=0.004; 36 | %% exploring the data 37 | %1) ploting CMP gather 38 | % figure;drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 39 | 40 | %2) ploting common offset gather 41 | % figure;drr_imagesc(reshape(d(:,5,5,:,:),100,10*10)); 42 | %% add noise 43 | randn('state',201516); 44 | dn=d+.2*randn(nt,nhx,nhy,nx,ny); 45 | 46 | % figure; 47 | % subplot(2,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 48 | % subplot(2,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 49 | 50 | %% denoise (Traditonal RR) 51 | flow=1;fhigh=100;dt=0.004;N=20; 52 | d1=drr5d(dn,flow,fhigh,dt,N,100,1); 53 | % figure; 54 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 55 | % subplot(3,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 56 | % subplot(3,1,3);drr_imagesc(reshape(d1(:,:,:,1,1),100,10*10)); 57 | 58 | %% denoise (DRR) 59 | flow=1;fhigh=100;dt=0.004;N=20;K=4; 60 | d2=drr5d(dn,flow,fhigh,dt,N,K,1); 61 | % figure; 62 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 63 | % subplot(3,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 64 | % subplot(3,1,3);drr_imagesc(reshape(d2(:,:,:,1,1),100,10*10)); 65 | 66 | %% denoise (ODRR) 67 | flow=1;fhigh=100;dt=0.004;N=20;K=4;O=1; 68 | d3=odrr5d(dn,flow,fhigh,dt,N,K,O,1); 69 | % figure; 70 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 71 | % subplot(3,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 72 | % subplot(3,1,3);drr_imagesc(reshape(d3(:,:,:,1,1),100,10*10)); 73 | 74 | %% calculate Signal-to-noise Ratio (SNR) 75 | drr_snr(d(:,:),dn(:,:)) 76 | drr_snr(d(:,:),d1(:,:)) 77 | drr_snr(d(:,:),d2(:,:)) 78 | drr_snr(d(:,:),d3(:,:)) 79 | 80 | 81 | % SNR when N=20; (when rank over-estimated) 82 | % sn=-6.6662; 83 | % s1=10.4512; 84 | % s2=18.2299; 85 | % s3=19.0101; 86 | 87 | snrnn=drr_snr(d(:,:),dn(:,:)) % 88 | snr11=drr_snr(d(:,:),d1(:,:)) % 89 | snr22=drr_snr(d(:,:),d2(:,:)) % 90 | snr33=drr_snr(d(:,:),d3(:,:)) % 91 | 92 | t=[0:100-1]*0.004; 93 | 94 | %% visualization 95 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.9],'color','w'); 96 | subplot(5,2,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10),0.1,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Clean'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'a)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 97 | subplot(5,2,3);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10),0.1,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Noisy (SNR=',num2str(snrnn),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'c)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 98 | subplot(5,2,5);drr_imagesc(reshape(d1(:,:,:,1,1),100,10*10),0.1,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('RR (SNR=',num2str(snr11),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'e)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 99 | subplot(5,2,7);drr_imagesc(reshape(d2(:,:,:,1,1),100,10*10),0.1,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('DRR (SNR=',num2str(snr22),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'g)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 100 | subplot(5,2,9);drr_imagesc(reshape(d3(:,:,:,1,1),100,10*10),0.1,2,1:100,t);xlabel('Offset trace','Fontsize',12,'fontweight','normal');ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('ODRR (SNR=',num2str(snr33),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'i)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 101 | 102 | subplot(5,2,2);drr_imagesc(reshape(d(:,5,5,:,:),100,10*10),0.1,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Clean'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'b)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 103 | subplot(5,2,4);drr_imagesc(reshape(dn(:,5,5,:,:),100,10*10),0.1,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('Noisy (SNR=',num2str(snrnn),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'d)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 104 | subplot(5,2,6);drr_imagesc(reshape(d1(:,5,5,:,:),100,10*10),0.1,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('RR (SNR=',num2str(snr11),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'f)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 105 | subplot(5,2,8);drr_imagesc(reshape(d2(:,5,5,:,:),100,10*10),0.1,2,1:100,t);ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('DRR (SNR=',num2str(snr22),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'h)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 106 | subplot(5,2,10);drr_imagesc(reshape(d3(:,5,5,:,:),100,10*10),0.1,2,1:100,t);xlabel('Midpoint trace','Fontsize',12,'fontweight','normal');ylabel('Time (s)','Fontsize',12,'fontweight','normal');set(gca,'Linewidth',2,'Fontsize',12,'Fontweight','normal');title(strcat('ODRR (SNR=',num2str(snr33),' dB )'),'Fontsize',15,'fontweight','normal');text(-9,-0.1,'j)','color','k','Fontsize',25,'fontweight','bold','HorizontalAlignment','left'); 107 | 108 | print(gcf,'-dpng','-r300','test_matdrr_odrr5d.png'); 109 | print(gcf,'-depsc','-r200','test_matdrr_odrr5d.eps'); 110 | -------------------------------------------------------------------------------- /matdrr/drr3d.m: -------------------------------------------------------------------------------- 1 | function [ D1 ] = drr3d(D,flow,fhigh,dt,N,K,verb) 2 | % DRR3D: 3D damped rank-reduction method (or F-XY domain damped multichannel singular spectrum analysis) 3 | % 4 | % IN D: intput 3D data 5 | % flow: processing frequency range (lower) 6 | % fhigh: processing frequency range (higher) 7 | % dt: temporal sampling interval 8 | % N: number of singular value to be preserved 9 | % K: damping factor (default: 4) 10 | % verb: verbosity flag (default: 0) 11 | % 12 | % OUT D1: output data 13 | % 14 | % Copyright (C) 2013 The University of Texas at Austin 15 | % Copyright (C) 2013 Yangkang Chen 16 | % Mofied 2015 by Yangkang Chen 17 | % 18 | % This program is free software: you can redistribute it and/or modify 19 | % it under the terms of the GNU General Public License as published 20 | % by the Free Software Foundation, either version 3 of the License, or 21 | % any later version. 22 | % 23 | % This program is distributed in the hope that it will be useful, 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 27 | % 28 | % References: 29 | % 30 | % [1] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 31 | % [2] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 32 | % [3] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 33 | % [4] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 34 | % [5] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 35 | % [6] Chen, Y., Huang, W., Yang, L., Oboue, Y.A.S.I., Saad, O.M., and Chen Y.F. 2023, DRR: An open-source multi-platform package for the damped rank-reduction method and its applications in seismology. Computers & Geosciences, 180, 105440. 36 | 37 | if nargin==0 38 | error('Input data must be provided!'); 39 | end 40 | 41 | if nargin==1 42 | flow=1; 43 | fhigh=124; 44 | dt=0.004; 45 | N=1; 46 | K=4; 47 | verb=0; 48 | end; 49 | 50 | 51 | [nt,nx,ny]=size(D); 52 | D1=zeros(nt,nx,ny); 53 | 54 | nf=2^nextpow2(nt); 55 | 56 | % Transform into F-X domain 57 | DATA_FX=fft(D,nf,1); 58 | DATA_FX0=zeros(nf,nx,ny); 59 | 60 | % First and last nts of the DFT. 61 | ilow = floor(flow*dt*nf)+1; 62 | 63 | if ilow<1; 64 | ilow=1; 65 | end; 66 | 67 | ihigh = floor(fhigh*dt*nf)+1; 68 | 69 | if ihigh > floor(nf/2)+1; 70 | ihigh=floor(nf/2)+1; 71 | end 72 | 73 | lx=floor(nx/2)+1; 74 | lxx=nx-lx+1; 75 | ly=floor(ny/2)+1; 76 | lyy=ny-ly+1; 77 | M=zeros(lx*ly,lxx*lyy); 78 | 79 | % main loop 80 | for k=ilow:ihigh 81 | 82 | if(ny==1) 83 | M=P_H(DATA_FX(k,:,:).',lx,ly); 84 | else 85 | M=P_H(squeeze(DATA_FX(k,:,:)),lx,ly); 86 | end 87 | 88 | M=P_RD(M,N,K); 89 | DATA_FX0(k,:,:)=P_A(M,nx,ny,lx,ly); 90 | 91 | if(mod(k,5)==0 && verb==1) 92 | fprintf( 'F %d is done!\n\n',k); 93 | end 94 | end 95 | 96 | % Honor symmetries 97 | for k=nf/2+2:nf 98 | DATA_FX0(k,:,:) = conj(DATA_FX0(nf-k+2,:,:)); 99 | end 100 | 101 | % Back to TX (the output) 102 | D1=real(ifft(DATA_FX0,[],1)); 103 | D1=D1(1:nt,:,:); 104 | 105 | return 106 | 107 | 108 | function [dout]=P_H(din,lx,ly) 109 | % forming block Hankel matrix 110 | [nx,ny]=size(din); 111 | lxx=nx-lx+1; 112 | lyy=ny-ly+1; 113 | 114 | for j=1:ny 115 | r=hankel(din(1:lx,j),[din(lx:nx,j)]); 116 | if j floor(nf/2)+1; 90 | ihigh=floor(nf/2)+1; 91 | end 92 | 93 | lx=floor(nx/2)+1; 94 | lxx=nx-lx+1; 95 | ly=floor(ny/2)+1; 96 | lyy=ny-ly+1; 97 | M=zeros(lx*ly,lxx*lyy); 98 | 99 | % main loop 100 | for k=ilow:ihigh 101 | if(ny==1) 102 | M=P_H(DATA_FX(k,:,:).',lx,ly); 103 | else 104 | M=P_H(squeeze(DATA_FX(k,:,:)),lx,ly); 105 | end 106 | 107 | % save data_M M % check if M is Hankel 108 | if k~=ikf 109 | M=P_R(M,Nmin,Nmax,K,mode,eps); 110 | else 111 | [M,H]=P_R(M,Nmin,Nmax,K,mode,eps); 112 | end 113 | 114 | DATA_FX0(k,:,:)=P_A(M,nx,ny,lx,ly); 115 | 116 | if(mod(k,5)==0 && verb==1) 117 | fprintf( 'F %d is done!\n\n',k); 118 | end 119 | end 120 | 121 | % Honor symmetries 122 | for k=nf/2+2:nf 123 | DATA_FX0(k,:,:) = conj(DATA_FX0(nf-k+2,:,:)); 124 | end 125 | 126 | % Back to TX (the output) 127 | D1=real(ifft(DATA_FX0,[],1)); 128 | D1=D1(1:nt,:,:); 129 | 130 | return 131 | 132 | 133 | function [dout]=P_H(din,lx,ly) 134 | % forming block Hankel matrix 135 | [nx,ny]=size(din); 136 | lxx=nx-lx+1; 137 | lyy=ny-ly+1; 138 | 139 | for j=1:ny 140 | r=hankel(din(1:lx,j),[din(lx:nx,j)]); 141 | if j=eps 166 | N=i; 167 | continue 168 | end 169 | end 170 | if N floor(nf/2)+1; 96 | ihigh=floor(nf/2)+1; 97 | end 98 | 99 | lx=floor(nx/2)+1; 100 | lxx=nx-lx+1; 101 | ly=floor(ny/2)+1; 102 | lyy=ny-ly+1; 103 | M=zeros(lx*ly,lxx*lyy); 104 | 105 | % main loop 106 | for k=ilow:ihigh 107 | 108 | % S_obs=squeeze(DATA_FX(k,:,:)); 109 | 110 | if(ny==1) 111 | S_obs=DATA_FX(k,:,:).'; 112 | else 113 | S_obs=squeeze(DATA_FX(k,:,:)); 114 | end 115 | 116 | Sn_1=S_obs; 117 | for iter=1:Niter 118 | M=P_H(Sn_1,lx,ly); 119 | M=P_RD(M,N,K); 120 | Sn=P_A(M,nx,ny,lx,ly); 121 | Sn=a(iter)*S_obs+(1-a(iter))*mask.*Sn+(1-mask).*Sn; 122 | if norm(Sn-Sn_1,'fro') floor(nf/2)+1; 106 | ihigh=floor(nf/2)+1; 107 | end 108 | 109 | lx=floor(nx/2)+1; 110 | lxx=nx-lx+1; 111 | ly=floor(ny/2)+1; 112 | lyy=ny-ly+1; 113 | M=zeros(lx*ly,lxx*lyy); 114 | 115 | if(ny==1) 116 | mask=mask.'; 117 | end 118 | 119 | % main loop 120 | for k=ilow:ihigh 121 | 122 | if(ny==1) 123 | S_obs=DATA_FX(k,:,:).'; 124 | else 125 | S_obs=squeeze(DATA_FX(k,:,:)); 126 | end 127 | Sn_1=S_obs; 128 | for iter=1:Niter 129 | 130 | M=P_H(Sn_1,lx,ly); 131 | % M=P_R(M,N); 132 | M=P_R(M,Nmin,Nmax,K,amode,eps2); 133 | 134 | Sn=P_A(M,nx,ny,lx,ly); 135 | 136 | Sn=a(iter)*S_obs+(1-a(iter))*mask.*Sn+(1-mask).*Sn; 137 | if norm(Sn-Sn_1,'fro')=eps 197 | N=i; 198 | continue 199 | end 200 | end 201 | if N floor(nf/2)+1; 92 | ihigh=floor(nf/2)+1; 93 | end 94 | 95 | lx=floor(nx/2)+1; 96 | lxx=nx-lx+1; 97 | ly=floor(ny/2)+1; 98 | lyy=ny-ly+1; 99 | M=zeros(lx*ly,lxx*lyy); 100 | 101 | % construct par 102 | par.x=x; 103 | par.y=y; 104 | par.nx=nx; 105 | par.ny=ny; 106 | par.ox=ox; 107 | par.oy=oy; 108 | par.mx=mx; 109 | par.my=my; 110 | s=0.5*ones(Niter,1); 111 | % main loop 112 | for k=ilow:ihigh 113 | S_obs=squeeze(DATA_FX(k,:)).'; %1D vector 114 | Sn_1=zeros(nx,ny); 115 | % Sn_1=yc_inter_op(DATA_FX(k,:),par,-1); 116 | for iter=1:Niter 117 | 118 | % size(Sn_1) 119 | % size(S_obs) 120 | % size(inter_op(Sn_1,par,1)) 121 | Sn=Sn_1-s(iter)*inter_op(inter_op(Sn_1,par,-1)-S_obs,par,1); 122 | 123 | 124 | M=P_H(Sn,lx,ly); 125 | M=P_RD(M,N,K); 126 | Sn=P_A(M,nx,ny,lx,ly); 127 | 128 | % Sn=a(iter)*S_obs+(1-a(iter))*mask.*Sn+(1-mask).*Sn; 129 | if norm(Sn-Sn_1,'fro')1 & ib<=Nx & jb>1 & jb<=Ny 266 | t=(rx(k)-xx(ia))/dx; 267 | u=(ry(k)-yy(ja))/dy; 268 | if adj==1 269 | U(ia,ja)=U(ia,ja)+(1-t)*(1-u)*D(k); 270 | U(ib,ja)=U(ib,ja)+t*(1-u)*D(k); 271 | U(ib,jb)=U(ib,jb)+t*u*D(k); 272 | U(ia,jb)=U(ia,jb)+(1-t)*u*D(k); 273 | else 274 | % fprintf('size(D)=(%d,%d)\n',size(D,1),size(D,2)); 275 | U(k)=(1-t)*(1-u)*D(ia,ja)+t*(1-u)*D(ib,ja)+... 276 | t*u*D(ib,jb)+(1-t)*u*D(ia,jb); 277 | end 278 | 279 | end 280 | end 281 | 282 | 283 | 284 | 285 | 286 | return 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | -------------------------------------------------------------------------------- /matdrr/drr3drecon_win.m: -------------------------------------------------------------------------------- 1 | function [ D1 ] = drr3drecon_win(D,mask,flow,fhigh,dt,N,K,Niter,eps,verb,mode,a,n1win,n2win,n3win,r1,r2,r3) 2 | % DRR3D_WIN: DRR3D in windows 3 | % 4 | % IN D: intput 3D data 5 | % MASK: sampling mask (consistent with the POCS based approaches) 6 | % flow: processing frequency range (lower) 7 | % fhigh: processing frequency range (higher) 8 | % dt: temporal sampling interval 9 | % N: number of singular value to be preserved 10 | % K: damping factor 11 | % Niter: number of maximum iteration 12 | % eps: tolerence (||S(n)-S(n-1)||_F floor(nf/2)+1; 71 | ihigh=floor(nf/2)+1; 72 | end 73 | 74 | lx=floor(nx/2)+1; 75 | lxx=nx-lx+1; 76 | ly=floor(ny/2)+1; 77 | lyy=ny-ly+1; 78 | lhx=floor(nhx/2)+1; 79 | lhxx=nhx-lhx+1; 80 | lhy=floor(nhy/2)+1; 81 | lhyy=nhy-lhy+1; 82 | M=zeros(lx*ly*lhx*lhy,lxx*lyy*lhxx,lhyy); 83 | 84 | % main loop 85 | for k=ilow:ihigh 86 | if(ny==1 & nhx==1 & nhy==1) 87 | M=P_H(DATA_FX(k,:,:,:,:).',lx,ly,lhx,lhy); 88 | else 89 | M=P_H(squeeze(DATA_FX(k,:,:,:,:)),lx,ly,lhx,lhy); 90 | end 91 | 92 | M=P_R(M,N,K); 93 | 94 | DATA_FX0(k,:,:,:,:)=P_A(M,nx,ny,nhx,nhy,lx,ly,lhx,lhy); 95 | 96 | if(mod(k,5)==0 && verb==1) 97 | fprintf( 'F %d is done!\n\n',k); 98 | end 99 | end 100 | 101 | % Honor symmetries 102 | for k=nf/2+2:nf 103 | DATA_FX0(k,:,:,:,:) = conj(DATA_FX0(nf-k+2,:,:,:,:)); 104 | end 105 | 106 | % Back to TX (the output) 107 | D1=real(ifft(DATA_FX0,[],1)); 108 | D1=D1(1:nt,:,:,:,:); 109 | 110 | return 111 | 112 | 113 | function [dout]=P_H(din,lx,ly,lhx,lhy) 114 | % forming block Hankel matrix (5D version) 115 | [nx,ny,nhx,nhy]=size(din); 116 | lxx=nx-lx+1; 117 | lyy=ny-ly+1; 118 | lhxx=nhx-lhx+1; 119 | lhyy=nhy-lhy+1; 120 | 121 | for ky=1:nhy 122 | for kx=1:nhx 123 | for j=1:ny 124 | r1=hankel(din(1:lx,j,kx,ky),[din(lx:nx,j,kx,ky)]); 125 | if j1 27 | din=din(:); 28 | end 29 | 30 | [n1,n22,n33,n44,n55]=size(din); 31 | n2=n22*n33*n44*n55; 32 | dout=zeros(n1,n2); 33 | 34 | d1=dt; 35 | eps=0.0001; 36 | 37 | if nargin==1 38 | flo=0; 39 | fhi=0.5; 40 | nphi=6; 41 | nplo=6; 42 | phase=0; 43 | verb=1; 44 | end 45 | 46 | if nargin==4 47 | nphi=6; 48 | nplo=6; 49 | phase=0; 50 | verb=0; 51 | end 52 | 53 | if flo<0 54 | error('Negative flo'); 55 | else 56 | flo=flo*d1; 57 | end 58 | 59 | if fhi<0 60 | error('Negative flo'); 61 | else 62 | fhi=fhi*d1; 63 | if flo>fhi 64 | error('Need flo < fhi\n'); 65 | end 66 | if 0.51 && ~phase 75 | nplo=nplo/2; 76 | end 77 | if nphi<1 78 | nphi=1; 79 | end 80 | if nphi>1 && ~phase 81 | nphi=nphi/2; 82 | end 83 | 84 | if (verb) 85 | fprintf("flo=%g fhi=%g nplo=%d nphi=%d\n",flo,fhi,nplo,nphi); 86 | end 87 | 88 | if flo>eps 89 | blo=butter_init(0,flo,nplo); 90 | else 91 | blo=[]; 92 | end 93 | if fhi<0.5-eps 94 | bhi=butter_init(1,fhi,nphi); 95 | else 96 | bhi=[]; 97 | end 98 | 99 | 100 | for i2=0:n2-1 101 | trace=din(:,i2+1); 102 | 103 | if ~isempty(blo) 104 | trace=butter_apply(blo,n1,trace); 105 | if ~phase 106 | trace=reverse (n1, trace); 107 | trace=butter_apply (blo, n1, trace); 108 | trace=reverse (n1, trace); 109 | end 110 | end 111 | 112 | if ~isempty(bhi) 113 | trace=butter_apply(bhi,n1,trace); 114 | if ~phase 115 | trace=reverse (n1, trace); 116 | trace=butter_apply (bhi, n1, trace); 117 | trace=reverse (n1, trace); 118 | end 119 | end 120 | dout(:,i2+1)=trace(:); 121 | 122 | end 123 | 124 | 125 | dout=reshape(dout,n1,n22,n33,n44,n55); 126 | 127 | return 128 | 129 | 130 | 131 | function [bw]=butter_init(low,cutoff,nn) 132 | % butter_init: initialize 133 | % Aug, 5, 2020 134 | % Yangkang Chen 135 | % 136 | % INPUT 137 | % low: low-pass (or high-pass) 138 | % cutoff: cut off frequency 139 | % nn: number of poles 140 | % 141 | % OUTPUT 142 | % bw: butterworth struct 143 | % 144 | bw=struct; 145 | arg=2*pi*cutoff; 146 | sinw=sin(arg); 147 | cosw=cos(arg); 148 | 149 | bw.nn=nn; 150 | bw.low=low; 151 | bw.den=zeros(2,floor((nn+1)/2)); 152 | 153 | if mod(nn,2)>0 154 | if low 155 | fact=(1+cosw)/sinw; 156 | bw.den(1,floor(nn/2)+1)=1./(1.+fact); 157 | bw.den(2,floor(nn/2)+1)=1.-fact; 158 | else 159 | fact=sinw/(1.+cosw); 160 | bw.den(1,floor(nn/2)+1)=1./(fact+1.0); 161 | bw.den(2,floor(nn/2)+1)=fact-1.0; 162 | end 163 | end 164 | 165 | fact=drr_ifnot(low,sin(0.5*arg),cos(0.5*arg)); 166 | fact=fact*fact; 167 | 168 | for j=0:floor(nn/2)-1 169 | ss=sin(pi*(2*j+1)/(2*nn))*sinw; 170 | bw.den(1,j+1)=fact/(1.+ss); 171 | bw.den(2,j+1)=(1-ss)/fact; 172 | end 173 | bw.mid=-2.*cosw/fact; 174 | return 175 | 176 | 177 | function [x]=butter_apply(bw,nx,x) 178 | % butter_apply: filter the data (in place) 179 | % 180 | %Implementation is inspired by D. Hale and J.F. Claerbout, 1983, Butterworth 181 | %dip filters: Geophysics, 48, 1033-1038. 182 | % 183 | % Aug, 5, 2020 184 | % Yangkang Chen 185 | % 186 | % INPUT 187 | % bw: butterworth struct 188 | % nx: size of x 189 | % x: input data 190 | % 191 | % OUTPUT 192 | % x: output data 193 | d1=bw.mid; 194 | nn=bw.nn; 195 | 196 | if mod(nn,2)>0 197 | d0=bw.den(1,floor(nn/2)+1); 198 | d2=bw.den(2,floor(nn/2)+1); 199 | x0=0; 200 | y1=0; 201 | for ix=0:nx-1 202 | x1=x0;x0=x(ix+1); 203 | y0=drr_ifnot(bw.low,(x0 + x1 - d2 * y1)*d0,(x0 - x1 - d2 * y1)*d0); 204 | x(ix+1)=y0; 205 | y1=y0; 206 | end 207 | end 208 | 209 | for j=0:floor(nn/2)-1 210 | d0=bw.den(1,j+1); 211 | d2=bw.den(2,j+1); 212 | x1=0;x0=0;y1=0;y2=0; 213 | for ix=0:nx-1 214 | x2=x1;x1=x0;x0=x(ix+1); 215 | y0=drr_ifnot(bw.low,(x0 + 2*x1 + x2 - d1 * y1 - d2 * y2)*d0,(x0 - 2*x1 + x2 - d1 * y1 - d2 * y2)*d0); 216 | y2=y1;x(ix+1)=y0;y1=y0; 217 | end 218 | end 219 | 220 | 221 | return 222 | 223 | function [trace]=reverse(n1,trace) 224 | % reverse a trace (in place) 225 | for i1=0:floor(n1/2)-1 226 | t=trace(i1+1); 227 | trace(i1+1)=trace(n1-i1); 228 | trace(n1-i1)=t; 229 | end 230 | 231 | return 232 | 233 | -------------------------------------------------------------------------------- /matdrr/drr_bin3d.m: -------------------------------------------------------------------------------- 1 | function [ dout,xout,yout,mask ] = drr_bin3d(din,x,y,nx,ny,ox,oy,mx,my) 2 | %drr_bin3d (previous cykbin3d or yc_bin3d): 3D seismic data binning (including 1D row vector and 2D seismics) 3 | % IN d: intput 2D data 4 | % x: input x coordinates 5 | % y: input y coordinates 6 | % nx: input number of binned x points 7 | % ny: input number of binned y points 8 | % ox: min of x 9 | % oy: min of y 10 | % mx: max of x 11 | % my: max of y 12 | % 13 | % OUT d1: output data 14 | % xout: output x coordinates 15 | % yout: output x coordinates 16 | % mask: mask operator for interpolation 17 | % 18 | % Copyright (C) 2015 The University of Texas at Austin 19 | % Copyright (C) 2015 Yangkang Chen 20 | % 21 | % This program is free software: you can redistribute it and/or modify 22 | % it under the terms of the GNU General Public License as published 23 | % by the Free Software Foundation, either version 3 of the License, or 24 | % any later version. 25 | % 26 | % This program is distributed in the hope that it will be useful, 27 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 30 | % 31 | % REFERENCES 32 | % Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 33 | % Wang et al., 2020, Separation and imaging of seismic diffractions using a localized rank-reduction method with adaptively selected ranks, 85, V497?V506. 34 | % Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 35 | % Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 36 | % Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 37 | % Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 38 | % Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 39 | % Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 40 | % 41 | % see also: yc_bin2d 42 | % 43 | [n1,n2]=size(din); 44 | 45 | if nargin==5 46 | ox=min(x); 47 | oy=min(y); 48 | mx=max(x); 49 | my=max(y); 50 | dx=(mx-ox)/(nx-1); 51 | dy=(my-oy)/(ny-1); 52 | else 53 | dx=(mx-ox)/(nx-1); 54 | dy=(my-oy)/(ny-1); 55 | end 56 | xout=ox:dx:mx; 57 | yout=oy:dy:my; 58 | 59 | dout=zeros(n1,nx,ny); 60 | mask=ones(nx,ny); 61 | 62 | % dx 63 | % max(x) 64 | % min(x) 65 | 66 | for iy=1:ny 67 | for ix=1:nx 68 | index=find(x>=xout(ix) & x=yout(iy) & y=2 78 | if x(index(1))==xout(ix) & y(index(1))==yout(iy); 79 | dout(:,ix,iy)=din(:,index(1)); 80 | else 81 | t1=sqrt((x(index(1))-xout(ix))^2+(y(index(1))-yout(iy))^2); 82 | t2=sqrt((x(index(2))-xout(ix))^2+(y(index(2))-yout(iy))^2); 83 | dout(:,ix,iy)=(t1*din(:,index(2))+t2*din(:,index(1)))/(t1+t2); 84 | % dout(:,ix)=(t1*din(:,index(2))+t2*din(:,index(1)))/(t1+t2); 85 | end 86 | end 87 | end 88 | end 89 | end 90 | 91 | if nargout==4 92 | mask=ones(n1,1)*reshape(mask,1,nx*ny); 93 | mask=reshape(mask,n1,nx,ny); 94 | end 95 | 96 | return -------------------------------------------------------------------------------- /matdrr/drr_framebox.m: -------------------------------------------------------------------------------- 1 | function [] = drr_framebox(x1,x2,y1,y2,c,lw) 2 | % 3 | % for drawing a frame box 4 | % 5 | % Jan, 5, 2023, By Yangkang Chen 6 | % 7 | % x1,x2,y1,y2: intuitive 8 | % 9 | if nargin==4 10 | c='r'; 11 | lw=2; 12 | end 13 | 14 | hold on; 15 | 16 | 17 | hold on; 18 | plot([x1,x2],[y1,y1],'-','color',c,'linewidth',lw); 19 | plot([x1,x2],[y2,y2],'-','color',c,'linewidth',lw); 20 | plot([x1,x1],[y1,y2],'-','color',c,'linewidth',lw); 21 | plot([x2,x2],[y1,y2],'-','color',c,'linewidth',lw); 22 | 23 | 24 | return -------------------------------------------------------------------------------- /matdrr/drr_genmask.m: -------------------------------------------------------------------------------- 1 | function mask = drr_genmask(u, r, type,seed) 2 | %DRR_GENMASK:Generate Random Sampling Mask 3 | % 4 | % mask = genmask(u,r,type) 5 | % u, image 6 | % r, data KNOWN ratio 7 | % type: data lose type 8 | % 'r': random lose rows 9 | % 'c': random lose columns 10 | % 'p': random lose pixel 11 | % 'seed': seed of random number generator 12 | % 13 | % Copyright (C) 2014 The University of Texas at Austin 14 | % Copyright (C) 2014 Yangkang Chen 15 | % 16 | % This program is free software: you can redistribute it and/or modify 17 | % it under the terms of the GNU General Public License as published 18 | % by the Free Software Foundation, either version 3 of the License, or 19 | % any later version. 20 | % 21 | % This program is distributed in the hope that it will be useful, 22 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 | % GNU General Public License for more details: 25 | % http://www.gnu.org/licenses/ 26 | % 27 | % References: 28 | % 29 | % [1] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 30 | % [2] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 31 | % [3] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 32 | % [4] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 33 | % [5] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 34 | 35 | [m,n] = size(u); 36 | mask = zeros(m,n); 37 | 38 | switch type 39 | case 'r' 40 | row = drr_rperm(m,seed); 41 | k = fix(r*m); 42 | row = row(1:k); 43 | mask(row,:) = 1; 44 | case 'c' 45 | column = drr_rperm(n,seed); 46 | k = fix(r*n); 47 | column = column(1:k); 48 | mask(:, column) = 1; 49 | case 'p' 50 | pix = drr_rperm(m*n,seed); 51 | r = fix(r*m*n); 52 | pix = pix(1:r); 53 | mask(pix) = 1; 54 | end 55 | 56 | -------------------------------------------------------------------------------- /matdrr/drr_ifnot.m: -------------------------------------------------------------------------------- 1 | function v = drr_ifnot(yes, v1, v2) 2 | % drr_ifnot: equivalent to C grammar (v=yes?v1:v2) 3 | % Yangkang Chen 4 | % July, 22, 2020 5 | 6 | if yes 7 | v=v1; 8 | else 9 | v=v2; 10 | end 11 | 12 | return -------------------------------------------------------------------------------- /matdrr/drr_imagesc.m: -------------------------------------------------------------------------------- 1 | function [] = drr_imagesc(data,pclip,mode,x,z) 2 | %drr_imagesc: fast plot data using pclip 3 | % 4 | % by Yangkang Chen 5 | % Jan, 2016 6 | % 7 | % Input: 8 | % data: input data 9 | % pclip: clip value (percential or exact) 10 | % mode=1: pclip; mode=2: clip 11 | % 12 | if nargin==1 13 | pclip=99; 14 | mode=1;%using pclip; 15 | end 16 | 17 | if nargin==2 18 | mode=1; 19 | end 20 | 21 | % mi=min(min(abs(data))); 22 | % ma=max(max(abs(data))); 23 | 24 | if mode==1 25 | t=prctile(abs(data(:)),pclip); 26 | % figure; 27 | if nargin==5 28 | imagesc(x,z,data);caxis([-t,t]);colormap(cseis); 29 | else 30 | imagesc(data);caxis([-t,t]);colormap(cseis); 31 | end 32 | 33 | else 34 | if nargin==5 35 | imagesc(x,z,data);caxis([-pclip,pclip]);colormap(cseis); 36 | else 37 | imagesc(data);caxis([-pclip,pclip]);colormap(cseis); 38 | end 39 | 40 | end 41 | 42 | end 43 | 44 | function [map]=cseis() 45 | 46 | map = [[0.5*ones(1,40),linspace(0.5,1,88),linspace(1,0,88),zeros(1,40)]',[0.25*ones(1,40),linspace(0.25,1,88),linspace(1,0,88),zeros(1,40)]',[zeros(1,40),linspace(0.,1,88),linspace(1,0,88),zeros(1,40)]']; 47 | 48 | end 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /matdrr/drr_mf.m: -------------------------------------------------------------------------------- 1 | function [ D1 ] = das_mf(D,nfw,ifb,axis) 2 | %DRR_MF: median filter along first or second axis for 2D profile 3 | % IN D: intput data 4 | % nfw: window size 5 | % ifb: if use padded boundary (if not, zero will be padded) 6 | % axis: temporal sampling interval 7 | % 8 | % OUT D1: output data 9 | % 10 | % Copyright (C) 2014 The University of Texas at Austin 11 | % Copyright (C) 2014 Yangkang Chen 12 | % 13 | % This program is free software: you can redistribute it and/or modify 14 | % it under the terms of the GNU General Public License as published 15 | % by the Free Software Foundation, either version 3 of the License, or 16 | % any later version. 17 | % 18 | % This program is distributed in the hope that it will be useful, 19 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 22 | % 23 | % 24 | % References 25 | % Huang et al., 2021, Erratic noise suppression using iterative structure-oriented space-varying median filtering with sparsity constraint, Geophysical Prospecting, 69, 101-121. 26 | % Chen et al., 2020, Deblending of simultaneous-source data using a structure-oriented space-varying median filter, Geophysical Journal International, 222, 1805–1823. 27 | % Gan et al., 2016, Separation of simultaneous sources using a structural-oriented median filter in the flattened dimension, Computers & Geosciences, 86, 46-54. 28 | % Chen, Y., 2015, Deblending using a space-varying median filter, Exploration Geophysics, 46, 332-341. 29 | 30 | if nargin==0 31 | error('Input data must be provided!'); 32 | end 33 | 34 | if nargin==1 35 | nfw=7; 36 | ifb=1; 37 | axis=2; 38 | end; 39 | 40 | if nargin==2 41 | ifb=1; 42 | axis=2; 43 | end 44 | 45 | % nfw should be odd 46 | if mod(nfw,2)==0 47 | nfw=nfw+1; 48 | end 49 | 50 | if axis==2 51 | D=D.'; 52 | end 53 | 54 | [n1,n2]=size(D); 55 | nfw2=(nfw-1)/2; 56 | 57 | if ifb==1 58 | D=[flipud(D(1:nfw2,:));D;flipud(D(n1-nfw2+1:n1,:))]; 59 | else 60 | D=[zeros(nfw2,n2);D;zeros(nfw2,n2)]; 61 | end 62 | 63 | % output data 64 | D1=zeros(n1,n2); 65 | for i2=1:n2 66 | for i1=1:n1 67 | D1(i1,i2)=median(D(i1:i1+nfw-1,i2)); 68 | end 69 | end 70 | if axis==2 71 | D1=D1.'; 72 | end 73 | return 74 | -------------------------------------------------------------------------------- /matdrr/drr_optshrink_damp.m: -------------------------------------------------------------------------------- 1 | function [dout] = drr_optshrink_damp(din,N,K) 2 | % DRR_OPTSHRINK_DAMP: Optimally shrink the singular values with damping 3 | % BY Yangkang Chen, Sep, 2017 4 | % Modified by Min Bai, May, 2018 5 | % 6 | % INPUT 7 | % din: input 8 | % N: rank 9 | % K: damping factor 10 | % 11 | % OUTPUT 12 | % dout: output 13 | % 14 | % EXAMPLE 15 | % test_matdrr_odrr3d.m 16 | % 17 | % REFERENCE 18 | % [1] Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783–2807. 19 | % [2] Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 20 | % [3] Nadakuditi, R. R., 2013, Optshrink: An algorithm for improved low-rank signal matrix denoising by optimal, data-driven singular value shrinkage: IEEE Transactions on Information Theory, 60, 3002?3018. 21 | 22 | [n1,n2]=size(din); 23 | [U,S,V]=svd(din); 24 | s=diag(S); 25 | if n1>=n2 26 | St=S(N+1:n2,N+1:n2); %make sure it is a square matrix 27 | else 28 | St=S(N+1:n1,N+1:n1); %make sure it is a square matrix 29 | end 30 | weight=zeros(N,1); 31 | for ir = 1 : N 32 | num=Ds(s(ir),St); 33 | den=DDs(s(ir),St); 34 | weight(ir) = -2*num/den*(1-s(N+1)^K/(s(ir)^K+0.000000000000001)); 35 | end 36 | 37 | dout = U(:,1:N)*diag(weight,0)*V(:,1:N)'; 38 | 39 | end 40 | 41 | function v = Ds(s,X) 42 | % D transform of X 43 | % INPUT 44 | % s: singular value 45 | % X: square singular value matrix 46 | % OUTPUT 47 | % v: output value 48 | % 49 | % Reference 50 | % eq 13 in Bai et al., 2020, GP. 51 | 52 | [n,m] = size(X); 53 | if n~=m 54 | error('X must be a square matrix: n must be equal to m'); 55 | end 56 | I=eye(m); 57 | v=1./(m*m).*trace(s*inv(s^2*I-X.*X)).^2; 58 | 59 | end 60 | 61 | function v = DDs(s,X) 62 | % derivative of D transform of X 63 | % INPUT 64 | % s: singular value 65 | % X: square singular value matrix 66 | % OUTPUT 67 | % v: output value 68 | % 69 | % Reference 70 | % eq 14 in Bai et al., 2020, GP. 71 | [n,m] = size(X); 72 | if n~=m 73 | error('X must be a square matrix: n must be equal to m'); 74 | end 75 | I=eye(m); 76 | v=2./(m*m).*trace(s*inv(s^2*I-X.*X)).*trace(inv(s^2*I-X.*X)-2*s*s*(inv(s*s*I-X.*X).^2)); 77 | 78 | end 79 | -------------------------------------------------------------------------------- /matdrr/drr_plot3d.m: -------------------------------------------------------------------------------- 1 | function [] = drr_plot3d(d3d,frames,z,x,y) 2 | %%drr_plot3d: plot beautiful 3D slices 3 | % 4 | % By Yangkang Chen 5 | % Jan, 2022 6 | % 7 | % INPUT 8 | % d3d: 3D input 9 | % frames: vecotr [3x1], frame1,2,3 10 | % z:axis 11 | % x:axis 12 | % y:axis 13 | % 14 | % OUTPUT 15 | % NO 16 | % 17 | % DEMO 18 | % demos/test_matdrr_drr3d_diffraction.m 19 | % 20 | % REFERENCE 21 | % If you find this plotting function useful, please cite the following 22 | % paper to recognize the authors' credit, where this script was originally created. 23 | % 24 | % Chen, Y., S. Fomel, and R. Abma, 2022, Joint deblending and source time inversion, 88(1), WA27–WA35. 25 | % 26 | 27 | % load data3ddb.mat 28 | data=d3d; 29 | % figure;yc_imagesc(data(:,:,60)); 30 | 31 | % load data3ddb0.mat 32 | [nz,nx,ny]=size(d3d); 33 | % d=d3d; 34 | 35 | if nargin==2 36 | z=[0:nz-1]*0.004; 37 | x=[1:nx]; 38 | y=[1:ny]; 39 | end 40 | 41 | if nargin==1 42 | frames=[round(nz/2),round(nx/2),round(ny/2)]; 43 | z=[0:nz-1]*0.004; 44 | x=[1:nx]; 45 | y=[1:ny]; 46 | end 47 | 48 | f1=frames(1); 49 | f2=frames(2); 50 | f3=frames(3); 51 | 52 | data(1,:,:)=d3d(f1,:,:); 53 | data(:,end,:)=d3d(:,f2,:); 54 | data(:,:,1)=d3d(:,:,f3); 55 | 56 | dd=data; 57 | %% the following ploting is separate 58 | 59 | %% plot isosurface 60 | %% given a input 3D volume of mask (1 for salt, 0 for non-salt): d 61 | %% given a input 3D seismic volume: dd 62 | % randn('state',202020); 63 | % dd=randn(nz,nx,ny); 64 | % %key step 65 | % %shiftdim 66 | % [nz,nx,ny]=size(d); 67 | % z=linspace(-1,1,nz); 68 | % x=linspace(-1,1,nx); 69 | % y=linspace(-1,1,ny); 70 | 71 | %shift data 72 | % d2=shiftdim(d,1);%fix d, the creation and plot are separated 73 | % d2=drr_transp(d2,12); 74 | 75 | dd2=shiftdim(dd,1);%fix d, the creation and plot are separated 76 | dd2=drr_transp(dd2,12); 77 | 78 | 79 | [x2,y2,z2]=meshgrid(x,y,z); 80 | % x2=shiftdim(x1,1); 81 | % y2=shiftdim(y1,1); 82 | % z2=shiftdim(z1,1); 83 | [nx,ny,nz]=size(dd2); 84 | % figure('units','normalized','Position',[0.01 0.01 0.45, 0.5],'color','w'); 85 | % slice(x2,y2,z2,dd2,[nx/2],[ny/2],[nz/2]); caxis([-0.001,0.001]);shading interp; 86 | x0=[min(x2(1,:,1)),max(x2(1,:,1))]; 87 | y0=[min(y2(:,1,1)),max(y2(:,1,1))]; 88 | z0=[min(z2(1,1,:)),max(z2(1,1,:))]; 89 | h=slice(x2,y2,z2,dd2,[x0(2)],[y0(1)],[z0(1)]); caxis([-0.01,0.01]);shading interp; 90 | set(h,'FaceColor','interp','FaceAlpha','interp'); 91 | % set(h,'FaceColor','interp','FaceAlpha',0); 92 | alpha('color');alpha(1); 93 | 94 | xlabel('x'); 95 | ylabel('y'); 96 | zlabel('z'); 97 | % set(gca,'YDir','reverse'); 98 | set(gca,'ZDir','reverse'); 99 | colormap(cseis); 100 | % view(gca,[63 31]); 101 | view(gca,[37 19]); 102 | hold on; 103 | 104 | [nx]=length(x(:)); 105 | [ny]=length(y(:)); 106 | [nz]=length(z(:)); 107 | plot3(x,y0(1)*ones(nx,1),z(f1)*ones(nx,1),'b-','linewidth',2); 108 | plot3(x0(2)*ones(ny,1),y,z(f1)*ones(ny,1),'b-','linewidth',2); 109 | 110 | plot3(x(f2)*ones(nz,1),y0(1)*ones(nz,1),z,'b-','linewidth',2); 111 | plot3(x(f2)*ones(ny,1),y,z0(1)*ones(ny,1),'b-','linewidth',2); 112 | 113 | 114 | plot3(x0(2)*ones(nz,1),y(f3)*ones(nz,1),z,'b-','linewidth',2); 115 | plot3(x,y(f3)*ones(nx,1),z0(1)*ones(nx,1),'b-','linewidth',2); 116 | 117 | 118 | xlim([min(x),max(x)]); 119 | ylim([min(y),max(y)]); 120 | zlim([min(z),max(z)]); 121 | 122 | ylabel('Y','Fontsize',16,'fontweight','bold'); 123 | xlabel('X','Fontsize',16,'fontweight','bold'); 124 | zlabel('Z','Fontsize',16,'fontweight','bold'); 125 | set(gca,'Linewidth',2,'Fontsize',16,'Fontweight','normal'); 126 | 127 | 128 | return 129 | 130 | function [map]=cseis() 131 | 132 | map = [[0.5*ones(1,40),linspace(0.5,1,88),linspace(1,0,88),zeros(1,40)]',[0.25*ones(1,40),linspace(0.25,1,88),linspace(1,0,88),zeros(1,40)]',[zeros(1,40),linspace(0.,1,88),linspace(1,0,88),zeros(1,40)]']; 133 | 134 | return 135 | 136 | function [dout]=drr_transp(din,plane) 137 | % drr_transp: Transpose two axes in a dataset 138 | % by Yangkang Chen, Dec 18, 2019 139 | % Modified on Jan, 2020 140 | % 141 | % INPUT 142 | % din: input dataset 143 | % plane: Two-digit number with axes to transpose. The default is 12 144 | % OUTPUT 145 | % dout: output dataset 146 | % 147 | % DEMO: 148 | % a=magic(3);b=reshape(a,3,1,3);c=drr_transp(b,23);norm(a-c) 149 | 150 | if nargin==1 151 | plane=12; 152 | end 153 | 154 | [n1,n2,n3,n4,n5]=size(din); 155 | 156 | switch plane 157 | 158 | case 12 159 | dout=zeros(n2,n1,n3,n4,n5); 160 | 161 | for i5=1:n5 162 | for i4=1:n4 163 | for i3=1:n3 164 | dout(:,:,i3,i4,i5)=din(:,:,i3,i4,i5).'; 165 | end 166 | end 167 | end 168 | 169 | case 23 170 | dout=zeros(n1,n3,n2,n4,n5); 171 | for i5=1:n5 172 | for i4=1:n4 173 | for i1=1:n1 174 | dout(i1,:,:,i4,i5)=squeeze(din(i1,:,:,i4,i5)).'; 175 | end 176 | end 177 | end 178 | case 13 179 | dout=zeros(n3,n2,n1,n4,n5); 180 | for i5=1:n5 181 | for i4=1:n4 182 | for i2=1:n2 183 | dout(:,i2,:,i4,i5)=squeeze(din(:,i2,:,i4,i5)).'; 184 | end 185 | end 186 | end 187 | 188 | case 14 189 | dout=zeros(n4,n2,n3,n1,n5); 190 | for i5=1:n5 191 | for i3=1:n3 192 | for i2=1:n2 193 | dout(:,i2,i3,:,i5)=squeeze(din(:,i2,i3,:,i5)).'; 194 | end 195 | end 196 | end 197 | 198 | case 15 199 | dout=zeros(n5,n2,n3,n4,n1); 200 | for i4=1:n4 201 | for i3=1:n3 202 | for i2=1:n2 203 | dout(:,i2,i3,i4,:)=squeeze(din(:,i2,i3,i4,:)).'; 204 | end 205 | end 206 | end 207 | 208 | otherwise 209 | error('Invalid argument value.'); 210 | end 211 | 212 | return 213 | -------------------------------------------------------------------------------- /matdrr/drr_ricker.m: -------------------------------------------------------------------------------- 1 | function [w,tw] = drr_ricker(f,dt,tlength) 2 | % drr_ricker: Ricker wavelet of central frequency f0. 3 | % 4 | % INPUT: 5 | % f : central freq. in Hz (f <<1/(2dt) ) 6 | % dt: sampling interval in sec 7 | % tlength : the duration of wavelet in sec 8 | % 9 | % OUTPUT: 10 | % w: the Ricker wavelet 11 | % tw: time axis 12 | % 13 | % Example 14 | % 15 | % [w,tw] = drr_ricker(10,0.004,0.2); 16 | % plot(tw,w); 17 | % 18 | % This program is free software: you can redistribute it and/or modify 19 | % it under the terms of the GNU General Public License as published 20 | % by the Free Software Foundation, either version 3 of the License, or 21 | % any later version. 22 | % 23 | % This program is distributed in the hope that it will be useful, 24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 27 | % 28 | 29 | if nargin==3 30 | nw=floor(tlength/dt)+1; 31 | else 32 | nw=2.2/f/dt; 33 | nw=2*floor(nw/2)+1; 34 | end 35 | nc=floor(nw/2); 36 | w = zeros(nw,1); 37 | 38 | k=[1:1:nw]'; 39 | 40 | alpha = (nc-k+1).*f*dt*pi; 41 | beta=alpha.^2; 42 | w = (1.-beta.*2).*exp(-beta); 43 | 44 | if nargout>1; 45 | tw = -(nc+1-[1:1:nw])*dt; 46 | end 47 | 48 | -------------------------------------------------------------------------------- /matdrr/drr_rperm.m: -------------------------------------------------------------------------------- 1 | function p = drr_rperm(n,seed) 2 | %DRR_RPERM: Random permutation with seeds. 3 | % 4 | % See also RANDPERM 5 | % RANDPERM(n) is a random permutation of the integers from 1 to n. 6 | % For example, RANDPERM(6) might be [2 4 5 6 1 3]. 7 | % 8 | % Copyright (C) 2014 The University of Texas at Austin 9 | % Copyright (C) 2014 Yangkang Chen 10 | % 11 | % This program is free software: you can redistribute it and/or modify 12 | % it under the terms of the GNU General Public License as published 13 | % by the Free Software Foundation, either version 3 of the License, or 14 | % any later version. 15 | % 16 | % This program is distributed in the hope that it will be useful, 17 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | % GNU General Public License for more details: 20 | % http://www.gnu.org/licenses/ 21 | % 22 | % References: 23 | % 24 | % [1] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 25 | % [2] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 26 | % [3] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 27 | % [4] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 28 | % [5] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 29 | 30 | rand('state',seed); 31 | [~,p] = sort(rand(1,n)); 32 | -------------------------------------------------------------------------------- /matdrr/drr_scale.m: -------------------------------------------------------------------------------- 1 | function [ D1 ] = drr_scale(D,N,dscale) 2 | %drr_scale: Scale the data up to the Nth dimension = sfscale axis=N 3 | % IN D: intput data 4 | % N: number of dimension for scaling 5 | % default: N=2 6 | % dscale: Scale by this factor 7 | % (does not include the rscale and pclip functions (not convenient actually)) 8 | % 9 | % OUT D1: output data 10 | % 11 | % Copyright (C) 2015 The University of Texas at Austin 12 | % Copyright (C) 2015 Yangkang Chen 13 | % Modified by Yangkang Chen on Jan, 2020 14 | % 15 | % This program is free software: you can redistribute it and/or modify 16 | % it under the terms of the GNU General Public License as published 17 | % by the Free Software Foundation, either version 3 of the License, or 18 | % any later version. 19 | % 20 | % This program is distributed in the hope that it will be useful, 21 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | % GNU General Public License for more details: http://www.gnu.org/licenses/ 24 | % 25 | 26 | if nargin==0 27 | error('Input data must be provided!'); 28 | end 29 | 30 | if nargin==1 31 | N=2; 32 | dscale=1.0; 33 | end 34 | 35 | if nargin==2 36 | dscale=1.0; 37 | end 38 | 39 | 40 | [n1,n2,n3]=size(D); 41 | D1=D; 42 | switch N 43 | case 1 44 | for i3=1:n3 45 | for i2=1:n2 46 | D1(:,i2,i3)=D1(:,i2,i3)/max(abs(D1(:,i2,i3))); 47 | end 48 | end 49 | case 2 50 | for i3=1:n3 51 | D1(:,:,i3)=D1(:,:,i3)/max(max(abs(D1(:,:,i3)))); 52 | end 53 | case 3 54 | D1=D1/max(max(max(abs(D1)))); 55 | 56 | case 0 57 | 58 | D1=D1*dscale; 59 | 60 | otherwise 61 | error('Invalid argument value N.') 62 | end 63 | 64 | 65 | return 66 | -------------------------------------------------------------------------------- /matdrr/drr_snr.m: -------------------------------------------------------------------------------- 1 | function psnr = drr_snr(g,f,mode) 2 | % DRR_SNR: signal-to-noise ratio (SNR) calculation for 1D, 2D and 3D 3 | % 4 | % Author: Yangkang Chen 5 | % g: ground truth image 6 | % f: noisy/restored image 7 | % mode:1->2D SNR, 2->3D SNR 8 | % 9 | % References (just name a few that uses this metric): 10 | % 11 | % [1] Chen, Y., W. Huang, D. Zhang, W. Chen, 2016, An open-source matlab code package for improved rank-reduction 3D seismic data denoising and reconstruction, Computers & Geosciences, 95, 59-66. 12 | % [2] Chen, Y., D. Zhang, Z. Jin, X. Chen, S. Zu, W. Huang, and S. Gan, 2016, Simultaneous denoising and reconstruction of 5D seismic data via damped rank-reduction method, Geophysical Journal International, 206, 1695-1717. 13 | % [3] Huang, W., R. Wang, Y. Chen, H. Li, and S. Gan, 2016, Damped multichannel singular spectrum analysis for 3D random noise attenuation, Geophysics, 81, V261-V270. 14 | % [4] Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 15 | % [5] Chen et al., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 16 | 17 | if nargin==2 18 | mode=1; 19 | end 20 | 21 | g = double(g); % in case of data format is unit8,12,16 22 | f = double(f); 23 | 24 | if ndims(f) floor(nf/2)+1; 76 | ihigh=floor(nf/2)+1; 77 | end 78 | 79 | lx=floor(nx/2)+1; 80 | lxx=nx-lx+1; 81 | ly=floor(ny/2)+1; 82 | lyy=ny-ly+1; 83 | M=zeros(lx*ly,lxx*lyy); 84 | 85 | % main loop 86 | for k=ilow:ihigh 87 | 88 | if(ny==1) 89 | M=P_H(DATA_FX(k,:,:).',lx,ly); 90 | else 91 | M=P_H(squeeze(DATA_FX(k,:,:)),lx,ly); 92 | end 93 | 94 | if O==0 95 | M=P_RD(M,N,K); 96 | else 97 | M=P_ORD(M,N,K); 98 | end 99 | 100 | DATA_FX0(k,:,:)=P_A(M,nx,ny,lx,ly); 101 | 102 | if(mod(k,5)==0 && verb==1) 103 | fprintf( 'F %d is done!\n\n',k); 104 | end 105 | end 106 | 107 | % Honor symmetries 108 | for k=nf/2+2:nf 109 | DATA_FX0(k,:,:) = conj(DATA_FX0(nf-k+2,:,:)); 110 | end 111 | 112 | % Back to TX (the output) 113 | D1=real(ifft(DATA_FX0,[],1)); 114 | D1=D1(1:nt,:,:); 115 | 116 | return 117 | 118 | 119 | function [dout]=P_H(din,lx,ly) 120 | % forming block Hankel matrix 121 | [nx,ny]=size(din); 122 | lxx=nx-lx+1; 123 | lyy=ny-ly+1; 124 | 125 | for j=1:ny 126 | r=hankel(din(1:lx,j),[din(lx:nx,j)]); 127 | if j floor(nf/2)+1; 93 | ihigh=floor(nf/2)+1; 94 | end 95 | 96 | lx=floor(nx/2)+1; 97 | lxx=nx-lx+1; 98 | ly=floor(ny/2)+1; 99 | lyy=ny-ly+1; 100 | M=zeros(lx*ly,lxx*lyy); 101 | 102 | % main loop 103 | for k=ilow:ihigh 104 | 105 | S_obs=squeeze(DATA_FX(k,:,:)); 106 | Sn_1=S_obs; 107 | for iter=1:Niter 108 | 109 | M=P_H(Sn_1,lx,ly); 110 | if O==0 111 | M=P_RD(M,N,K); 112 | else 113 | M=P_ORD(M,N,K); 114 | end 115 | Sn=P_A(M,nx,ny,lx,ly); 116 | 117 | Sn=a(iter)*S_obs+(1-a(iter))*mask.*Sn+(1-mask).*Sn; 118 | if norm(Sn-Sn_1,'fro')