├── LICENSE ├── README.md ├── demos ├── test_matdrr_drr2d_diffraction.m ├── test_matdrr_drr2d_win.m ├── test_matdrr_drr2d_win_dassafod.m ├── test_matdrr_drr2drecon_dealiase.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_syn.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_fk2d.m ├── drr_framebox.m ├── drr_genmask.m ├── drr_ifnot.m ├── drr_imagesc.m ├── drr_inter_op.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 | % Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 29 | 30 | 31 | clc;clear;close all; 32 | addpath(genpath('../matdrr')); 33 | 34 | 35 | %% Please download data from https://github.com/aaspip/data/blob/main/diffr_syn_2d.mat 36 | % data is observed data 37 | % diffr is the ground-truth diffraction data 38 | load diffr_syn_2d.mat 39 | 40 | [n1,n2]=size(data); 41 | 42 | %% perform diffraction separation 43 | %This example is introduced in Wang et al., 2020. 44 | lf=0;hf=120;dt=0.004;verb=1;N=5;K=4; % N is a scalar (Nmax) or a vector (Nmin,Nmax); 45 | 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 46 | d1=drr3d_win_auto(data,lf,hf,dt,N,K,verb,n1win,n2win,n3win,r1,r2,r3,mode);%reflection from LDRR 47 | diffr1=data-d1; %diffraction from LDRR 48 | 49 | % Quick visualization 50 | % figure;drr_imagesc([data,diffr,diffr1,data-diffr,d1]); 51 | 52 | %% SNR of the separated diffraction 53 | drr_snr(diffr,diffr1) 54 | 55 | 56 | %% plot the results 57 | x=[0:n2-1]*dx; 58 | z=[0:n1-1]*dt; 59 | figure('units','normalized','Position',[0.2 0.4 1, 0.4],'color','w'); 60 | 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'); 61 | 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'); 62 | 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'); 63 | 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'); 64 | 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'); 65 | print(gcf,'-dpng','-r300','test_matdrr_drr2d_diffraction.png'); 66 | print(gcf,'-depsc','-r200','test_matdrr_drr2d_diffraction.eps'); 67 | -------------------------------------------------------------------------------- /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 | % Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 29 | 30 | 31 | clc;clear;close all; 32 | addpath(genpath('../matdrr')); 33 | 34 | %% download synthetic data 35 | %please download the data from https://github.com/aaspip/data/blob/main/hevents.mat 36 | load hevents.mat 37 | 38 | d=d/max(max(d)); 39 | randn('state',201314); 40 | dn=d+0.1*randn(size(d)); 41 | 42 | %% parameters 43 | [n1,n2]=size(dn); 44 | param.dt=0.004; 45 | param.flow=0; 46 | param.fhigh=245; 47 | param.N=2; 48 | param.K=4; 49 | param.verb=1; 50 | 51 | %% Global DRR 52 | param.N=6; 53 | d1=drr3d(dn,param.flow,param.fhigh,param.dt,param.N,param.K,param.verb); 54 | 55 | %% Local DRR (Option I, integrated version) 56 | n1win=50;n2win=20;n3win=1; 57 | r1=0.5;r2=0.5;r3=0.5; 58 | param.N=2; 59 | d2=drr3d_win(dn,param.flow,param.fhigh,param.dt,param.N,param.K,param.verb,n1win,n2win,n3win,r1,r2,r3); 60 | 61 | %% Local DRR (Option II, separated version) 62 | d3=drr_win3d(@localdrr3d, param, dn, n1win, n2win, n3win, r1, r2, r3); 63 | 64 | %% SNR comparison 65 | fprintf('SNR of DRR is %g\n',drr_snr(d,d1)); 66 | fprintf('SNR of LDRR is %g\n',drr_snr(d,d2)); 67 | 68 | %% verify correctness of two options (output is zero) 69 | fprintf('Difference between two versions is %g\n',norm(d2-d3)); 70 | 71 | %% plot results 72 | x=1:n2;z=[0:n1-1]*0.004; 73 | figure('units','normalized','Position',[0.2 0.4 0.55, 0.45]); 74 | 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'); 75 | 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'); 76 | 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'); 77 | 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'); 78 | 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'); 79 | 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'); 80 | print(gcf,'-dpng','-r300','test_matdrr_drr2d_win.png'); 81 | print(gcf,'-depsc','-r200','test_matdrr_drr2d_win.eps'); 82 | 83 | 84 | %% plot FK spectra 85 | dt=0.004;dx=1; 86 | [D,f,k]=drr_fk2d(d,dt,dx); 87 | [Dn,f,k]=drr_fk2d(dn,dt,dx); 88 | [D1,f,k]=drr_fk2d(d1,dt,dx); 89 | [D2,f,k]=drr_fk2d(d2,dt,dx); 90 | [DN1,f,k]=drr_fk2d(dn-d1,dt,dx); 91 | [DN2,f,k]=drr_fk2d(dn-d2,dt,dx); 92 | 93 | fmin=0;fmax=30; 94 | figure('units','normalized','Position',[0.2 0.4 0.55, 0.45]); 95 | subplot(1,6,1);drr_imagesc(abs(D),10,2,k,f);colormap(jet);ylim([fmin,fmax]);caxis([0,50]);xlabel('K','Fontsize',15);ylabel('Frequency (Hz)','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('Clean');text(-0.85,-2,'a)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 96 | subplot(1,6,2);drr_imagesc(abs(Dn),10,2,k,f);colormap(jet);ylim([fmin,fmax]);caxis([0,50]);xlabel('K','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('Noisy');text(-0.85,-2,'b)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 97 | subplot(1,6,3);drr_imagesc(abs(D1),10,2,k,f);colormap(jet);ylim([fmin,fmax]);caxis([0,50]);xlabel('K','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('DRR');text(-0.85,-2,'c)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 98 | subplot(1,6,4);drr_imagesc(abs(D2),10,2,k,f);colormap(jet);ylim([fmin,fmax]);caxis([0,50]);xlabel('K','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('LDRR');text(-0.85,-2,'d)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 99 | subplot(1,6,5);drr_imagesc(abs(DN1),10,2,k,f);colormap(jet);ylim([fmin,fmax]);caxis([0,50]);xlabel('K','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('DRR');text(-0.85,-2,'e)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 100 | subplot(1,6,6);drr_imagesc(abs(DN2),10,2,k,f);colormap(jet);ylim([fmin,fmax]);caxis([0,50]);xlabel('K','Fontsize',15);set(gca,'Linewidth',2,'Fontsize',12);axis on;title('LDRR');text(-0.85,-2,'f)','color','k','Fontsize',20,'fontweight','bold','HorizontalAlignment','left'); 101 | print(gcf,'-dpng','-r300','test_matdrr_drr2d_win_fk.png'); 102 | 103 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr2d_win_dassafod.m: -------------------------------------------------------------------------------- 1 | % Demonstration script for 2 | % State-of-the-art DAS denoising via the localized damped rank-reduction method (LDRR) 3 | % This script takes about 10 minutes 4 | % 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 | % 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 | % Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 29 | % 30 | % Dependency MATdrr 31 | % svn co https://github.com/aaspip/MATdrr/trunk ./MATdrr 32 | % or git clone https://github.com/aaspip/MATdrr ./ 33 | % 34 | % Related pacakge: 35 | % https://github.com/chenyk1990/dasmrrcoh 36 | % https://github.com/chenyk1990/dasmrrcoh-dataonly 37 | 38 | clc;clear;close all; 39 | addpath(genpath('../matdrr')); 40 | 41 | if ~isdir('fig') 42 | mkdir('fig'); 43 | end 44 | 45 | if ~isdir('processed') 46 | mkdir('processed'); 47 | end 48 | 49 | %% Download data first 50 | %% The whole dataset in the folder "raw" can be downloaded from https://github.com/chenyk1990/dasmrrcoh-dataonly 51 | %% A complete processing workflow can be found at https://github.com/chenyk1990/dasmrrcoh-dataonly or https://github.com/chenyk1990/dasmrrcoh 52 | % 53 | % https://github.com/chenyk1990/dasmrrcoh-dataonly/tree/main/raw/2017-06-23T22:03:22.380000Z_mag2.17.mat 54 | 55 | name='2017-06-23T22:03:22.380000Z_mag2.17.mat' 56 | ieq=3; 57 | load(name); 58 | eq=data; 59 | d_bp=drr_bandpass(eq',1/250,0,20)'; 60 | d_bpmf=drr_mf(d_bp,5,1,1); 61 | %% LDRR 62 | n1win=1024;n2win=800;n3win=1; 63 | n1win=512;n2win=200;n3win=1; 64 | r1=0.5;r2=0.5;r3=0.5; 65 | d_bpmfmrr=drr3d_win(d_bpmf',0,50,1/250,2,4,0,n1win,n2win,n3win,r1,r2,r3)'; 66 | save(sprintf('processed/eq%d.mat',ieq),'d_bp','d_bpmf','d_bpmfmrr'); 67 | 68 | [n1,n2]=size(data); 69 | t=[0:n2-1]*(1/250); 70 | x=1:n1; 71 | 72 | figure('units','normalized','Position',[0.2 0.4 0.7, 0.6],'color','w'); 73 | ax1=subplot(2,2,1); 74 | drr_imagesc(eq,95,1,t,x);colormap(ax1,seis); 75 | name(end-3:end)=[]; 76 | title(name,'Interpreter', 'none','Fontsize',14,'fontweight','bold'); 77 | % xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 78 | ylabel('Channel','Fontsize',14,'fontweight','bold'); 79 | set(gca,'Linewidth',2,'Fontsize',14,'Fontweight','bold'); 80 | text(-5,-100,'a)','color','k','Fontsize',18,'fontweight','bold','HorizontalAlignment','center'); 81 | 82 | ax2=subplot(2,2,2); 83 | drr_imagesc(d_bp,95,1,t,x);colormap(ax2,seis); 84 | title('BP','Fontsize',14,'fontweight','bold'); 85 | % xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 86 | % ylabel('Channel','Fontsize',14,'fontweight','bold'); 87 | set(gca,'Linewidth',2,'Fontsize',14,'Fontweight','bold'); 88 | text(-5,-100,'b)','color','k','Fontsize',18,'fontweight','bold','HorizontalAlignment','center'); 89 | 90 | ax3=subplot(2,2,3); 91 | drr_imagesc(d_bpmf,95,1,t,x);colormap(ax3,seis);title('BP+MF'); 92 | title('BP+MF','Fontsize',14,'fontweight','bold'); 93 | % xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 94 | ylabel('Channel','Fontsize',14,'fontweight','bold'); 95 | set(gca,'Linewidth',2,'Fontsize',14,'Fontweight','bold'); 96 | text(-5,-100,'c)','color','k','Fontsize',18,'fontweight','bold','HorizontalAlignment','center'); 97 | xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 98 | 99 | ax4=subplot(2,2,4); 100 | drr_imagesc(d_bpmfmrr,95,1,t,x);colormap(ax4,seis);title('BP+MF+MRR'); 101 | title('BP+MF+MRR','Fontsize',14,'fontweight','bold'); 102 | % xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 103 | % ylabel('Channel','Fontsize',14,'fontweight','bold'); 104 | set(gca,'Linewidth',2,'Fontsize',14,'Fontweight','bold'); 105 | text(-5,-100,'d)','color','k','Fontsize',18,'fontweight','bold','HorizontalAlignment','center'); 106 | xlabel('Time (s)','Fontsize',14,'fontweight','bold'); 107 | print(gcf,'-depsc','-r300','test_matdrr_drr2d_win_dassafod.eps'); 108 | print(gcf,'-dpng','-r300','test_matdrr_drr2d_win_dassafod.png'); 109 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr2drecon_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 | % [6] Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 26 | 27 | clc;clear;close all; 28 | addpath(genpath('../matdrr')); 29 | 30 | 31 | %% generate 3D synthetic data 32 | a1=zeros(300,40); 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(-3*i+180); 50 | t4(i)=round(3*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 | d=a1+a3+a4; 57 | 58 | %% add band-limitted noise and decimate data 59 | randn('state',201315); 60 | [nt,nx,ny]=size(d); 61 | noise=randn(nt,nx,ny); 62 | noise=drr_bandpass(noise,0.004,0,60); 63 | dn=0.1*noise+d; 64 | 65 | %% Doing the aliased reconstruction (2D densification) 66 | d1=dn(:,1:2:end); 67 | [n1,n2,n3]=size(d1); 68 | d3=drr3drecon_dealiase(d1,0,50,0.004,3,4,20,2,2,1);%takes about ? minutes 69 | d3=d3(:,:,1); 70 | 71 | 72 | %% professional plot 73 | dt=0.004;dx=1; 74 | figure('units','normalized','Position',[0.2 0.4 0.5, 0.8]); 75 | subplot(2,2,1) 76 | t=[0:n1-1]*dt; 77 | x=[1:n2]*dx; 78 | drr_imagesc(d1,1,2,x,t); 79 | ylabel('Time (s)','Fontsize',16,'fontweight','bold'); 80 | xlabel('Trace','Fontsize',16,'fontweight','bold'); 81 | set(gca,'Linewidth',2,'Fontsize',16,'Fontweight','bold'); 82 | title('Under-sampled','Fontsize',16,'fontweight','bold'); 83 | text(-2.5,-0.1,'a)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','center'); 84 | 85 | subplot(2,2,2) 86 | t=[0:n1-1]*dt; 87 | x=[1:n2]*dx; 88 | drr_imagesc(d3,1,2,[1:n2*2]*dx,t); 89 | ylabel('Time (s)','Fontsize',16,'fontweight','bold'); 90 | set(gca,'Linewidth',2,'Fontsize',16,'Fontweight','bold'); 91 | xlabel('Trace','Fontsize',16,'fontweight','bold'); 92 | title('Densified','Fontsize',16,'fontweight','bold'); 93 | text(-5,-0.1,'b)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','center'); 94 | 95 | subplot(2,1,2); 96 | dcomp=[d,dn,d3,dn-d3]; 97 | drr_imagesc(dcomp,1,2,[1:n2*4]*dx,t); 98 | % imagesc(1:n2,[0:n1-1]*dt,dcomp);colormap(seis); 99 | ylabel('Time (s)','Fontsize',16,'fontweight','bold'); 100 | xlabel('Trace','Fontsize',16,'fontweight','bold'); 101 | title(sprintf('2D densification performance (Clean|Noisy|Recon|Error; SNR=%g dB)',drr_snr(d,d3)),'Fontsize',16,'fontweight','bold'); 102 | set(gca,'Linewidth',2,'Fontsize',16,'Fontweight','bold'); 103 | text(-5,-0.1,'c)','color','k','Fontsize',24,'fontweight','bold','HorizontalAlignment','center'); 104 | 105 | print(gcf,'-dpng','-r300','test_matdrr_drr2drecon_dealiase.png'); 106 | print(gcf,'-depsc','-r200','test_matdrr_drr2drecon_dealiase.eps'); 107 | -------------------------------------------------------------------------------- /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 | % [6] Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 25 | 26 | 27 | clc;clear;close all; 28 | addpath(genpath('../matdrr')); 29 | %% generate synthetic data 30 | a1=zeros(300,20); 31 | [n,m]=size(a1); 32 | a3=a1; 33 | a4=a1; 34 | 35 | k=0; 36 | a=0.1; 37 | b=1; 38 | for t=-0.055:0.002:0.055 39 | k=k+1; 40 | b1(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 41 | b2(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 42 | b3(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 43 | b4(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 44 | end 45 | for i=1:m 46 | t1(i)=round(140); 47 | t3(i)=round(-6*i+180); 48 | t4(i)=round(6*i+10); 49 | a1(t1(i):t1(i)+k-1,i)=b1; 50 | a3(t3(i):t3(i)+k-1,i)=b1; 51 | a4(t4(i):t4(i)+k-1,i)=b1; 52 | end 53 | 54 | temp=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 55 | for j=1:20 56 | a4=zeros(300,20); 57 | for i=1:m 58 | t4(i)=round(6*i+10+3*j); 59 | a4(t4(i):t4(i)+k-1,i)=b1; 60 | 61 | t1(i)=round(140-2*j); 62 | a1(t1(i):t1(i)+k-1,i)=b1; 63 | end 64 | shot(:,:,j)=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 65 | end 66 | plane3d=shot; 67 | d=plane3d/max(max(max(plane3d))); 68 | 69 | %% adding noise 70 | randn('state',201314); 71 | var=0.2; 72 | dn=d+var*randn(size(d)); 73 | 74 | %% denoise (RR) 75 | flow=0;fhigh=250;dt=0.004;N=3;verb=1; 76 | d1=drr3d(dn(:,:,:),flow,fhigh,dt,N,100,verb); 77 | % figure;drr_imagesc([d(:,:,9),dn(:,:,9),d1(:,:,9),dn(:,:,9)-d1(:,:,9)]);caxis([-0.4,0.4]); 78 | 79 | %% denoise (DRR) 80 | flow=0;fhigh=250;dt=0.004;N=3;verb=1;K=3; 81 | d2=drr3d(dn(:,:,:),flow,fhigh,dt,N,K,verb); 82 | % figure;drr_imagesc([d(:,:,9),dn(:,:,9),d2(:,:,9),dn(:,:,9)-d2(:,:,9)]);caxis([-0.4,0.4]); 83 | 84 | s0=drr_snr(d,dn,2); 85 | s1=drr_snr(d,d1,2); 86 | s2=drr_snr(d,d2,2); 87 | 88 | %% plot the results 89 | [n1,n2,n3]=size(d); 90 | dy=1;dx=1;dt=0.004; 91 | y=[1:n3]*dy; 92 | x=[1:n2]*dx; 93 | z=[1:n1]*dt; 94 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.6],'color','w'); 95 | 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'); 96 | 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'); 97 | 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'); 98 | 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'); 99 | 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'); 100 | 101 | % 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); 102 | % 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); 103 | print(gcf,'-dpng','-r300','test_matdrr_drr3d.png'); 104 | print(gcf,'-depsc','-r200','test_matdrr_drr3d.eps'); 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /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 | % Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 29 | 30 | 31 | clc;clear;close all; 32 | addpath(genpath('../matdrr')); 33 | 34 | 35 | %% Please download data from https://github.com/aaspip/data/blob/main/diffr_syn_3d.mat 36 | % data is observed data 37 | % diffr is the ground-truth diffraction data 38 | load diffr_syn_3d.mat 39 | 40 | [n1,n2,n3]=size(data); 41 | 42 | %% perform diffraction separation 43 | %This example is introduced in Chen et al., 2022. 44 | 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); 45 | 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 46 | d1=drr3d_win_auto(data,lf,hf,dt,[N,N2],K,verb,n1win,n2win,n3win,r1,r2,r3,mode);%reflection from LDRR 47 | diffr1=data-d1; %diffraction from LDRR 48 | 49 | % Quick visualization 50 | figure;drr_imagesc([data(:,:,20),diffr(:,:,20),diffr1(:,:,20),data(:,:,20)-diffr(:,:,20),d1(:,:,20)]); 51 | 52 | %% SNR of the separated diffraction 53 | drr_snr(diffr,diffr1,2) 54 | 55 | %% plot the results 56 | y=[0:n3-1]*dy; 57 | x=[0:n2-1]*dx; 58 | z=[0:n1-1]*dt; 59 | figure('units','normalized','Position',[0.2 0.4 0.5, 0.8],'color','w'); 60 | 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'); 61 | 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'); 62 | 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'); 63 | 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'); 64 | 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'); 65 | print(gcf,'-dpng','-r300','test_matdrr_drr3d_diffraction.png'); 66 | print(gcf,'-depsc','-r300','test_matdrr_drr3d_diffraction.eps'); 67 | 68 | -------------------------------------------------------------------------------- /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 | % Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 29 | 30 | 31 | clc;clear;close all; 32 | addpath(genpath('../matdrr')); 33 | 34 | %% generate synthetic data 35 | cmp=zeros(50,32,32); 36 | [nz,nx,ny]=size(cmp); 37 | 38 | x=[1:32]; 39 | y=[1:32]; 40 | [x,y]=meshgrid(x,y); 41 | z=10*(sqrt(1+((x-16)./10).^2+((y-16)./10).^2)-1)+20; 42 | % figure;surf(y);set(gca,'ydir','reverse'); 43 | 44 | for ix=1:nx 45 | for iy=1:ny 46 | cmp(round(z(ix,iy))+1,ix,iy)=1; 47 | end 48 | end 49 | 50 | cmp=reshape(cmp,nz,nx*ny); 51 | wav=drr_ricker(30,0.004,0.2); 52 | for ix=1:nx*ny 53 | cmp(:,ix)=conv(cmp(:,ix),wav,'same'); 54 | end 55 | cmp=reshape(cmp,nz,nx,ny); 56 | dc=drr_scale(cmp,3); 57 | 58 | randn('state',201920); 59 | dn=dc+0.1*randn(size(dc)); 60 | 61 | figure;imagesc(dc(:,:,16));colormap(gray); 62 | figure;imagesc(squeeze(dc(:,16,:)));colormap(gray); 63 | figure;imagesc(squeeze(dc(:,:)));colormap(gray); 64 | figure;imagesc(squeeze(dn(:,:)));colormap(gray); 65 | 66 | %% parameters 67 | [n1,n2,n3]=size(dn); 68 | param.dt=0.004; 69 | param.flow=0; 70 | param.fhigh=245; 71 | param.N=2; 72 | param.K=4; 73 | param.verb=1; 74 | 75 | %% Global DRR 76 | param.N=6; 77 | d1=drr3d(dn,param.flow,param.fhigh,param.dt,param.N,param.K,param.verb); 78 | 79 | %% Local DRR (Option I, integrated version) 80 | n1win=50;n2win=16;n3win=16; 81 | r1=0.5;r2=0.5;r3=0.5; 82 | param.N=2; 83 | d2=drr3d_win(dn,param.flow,param.fhigh,param.dt,param.N,param.K,param.verb,n1win,n2win,n3win,r1,r2,r3); 84 | 85 | %% Local DRR (Option II, separated version) 86 | d3=drr_win3d(@localdrr3d, param, dn, n1win, n2win, n3win, r1, r2, r3); 87 | 88 | %% SNR comparison 89 | s0=drr_snr(dc,dn,2); 90 | s1=drr_snr(dc,d1,2); 91 | s2=drr_snr(dc,d2,2) 92 | fprintf('SNR of Noisy is %g\n',drr_snr(dc,dn,2)); 93 | fprintf('SNR of DRR is %g\n',drr_snr(dc,d1,2)); 94 | fprintf('SNR of LDRR is %g\n',drr_snr(dc,d2,2)); 95 | 96 | %% verify correctness of two options (output is zero) 97 | fprintf('Difference between two versions is %g\n',norm(d2(:)-d3(:))); 98 | 99 | 100 | %% plot the results 101 | [n1,n2,n3]=size(dn); 102 | dy=1;dx=1;dt=0.004; 103 | y=[1:n3]*dy; 104 | x=[1:n2]*dx; 105 | z=[1:n1]*dt; 106 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.6],'color','w'); 107 | 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'); 108 | 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'); 109 | 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'); 110 | 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'); 111 | 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'); 112 | print(gcf,'-dpng','-r300','test_matdrr_drr3d_win.png'); 113 | print(gcf,'-depsc','-r200','test_matdrr_drr3d_win.eps'); 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /demos/test_matdrr_drr3d_win_deblending.m: -------------------------------------------------------------------------------- 1 | % Demonstration script for 2 | % State-of-the-art deblending via the localized damped rank-reduction method (LDRR) 3 | % 4 | % Copyright (C) 2023 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 | % 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. 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., 2019, Obtaining free USArray data by multi-dimensional seismic reconstruction, Nature Communications, 10:4434. 21 | % Bai et al., 2020, Seismic signal enhancement based on the lowrank methods, Geophysical Prospecting, 68, 2783-2807. 22 | % Chen et al., 2020, Five-dimensional seismic data reconstruction using the optimally damped rank-reduction method, Geophysical Journal International, 222, 1824-1845. 23 | % 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. 24 | % 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. 25 | % 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. 26 | % Chen et al., 2017, Preserving the discontinuities in least-squares reverse time migration of simultaneous-source data, Geophysics, 82, S185-S196. 27 | % Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 28 | 29 | 30 | clc;clear;close all; 31 | 32 | %% Please change the directory path 33 | % requiring the DRR package 34 | % https://github.com/chenyk1990/MATdrr 35 | addpath(genpath('~/MATdrr')); 36 | addpath(genpath('~/deblending-time/subroutines')); 37 | 38 | %% please download data from https://drive.google.com/file/d/1ge0Mn_SB4LUsVgOBvATh0iISwGQahKh4/view?usp=sharing 39 | load yc_fieldsr.mat 40 | %% in this dataset 41 | %there are two sources data3d(:,:,1:60) and data3d(:,:,61:120) 42 | %each source contains 120 shots 43 | %there are 60 receivers 44 | % 45 | 46 | d1=data3d(:,:,1); 47 | d2=data3d(:,:,60); 48 | figure; 49 | subplot(1,2,1);dbt_imagesc(d1); 50 | subplot(1,2,2);dbt_imagesc(d2); 51 | 52 | h1=1:120; 53 | h2=1:120; 54 | 55 | dt=0.004; 56 | t=[0:1500-1]*dt; 57 | nt=1500; 58 | nx=120; 59 | %% apply dbt_dithering 60 | randn('state',202122); 61 | shift1=floor(0.1*randn(1,size(d1,2))/dt); % shift of data1 to data2 62 | shift2=-shift1; % shift of data2 to data1 63 | 64 | d1shift=dbt_dither(d1,shift1); 65 | d2shift=dbt_dither(d2,shift2); 66 | 67 | figure; 68 | subplot(1,2,1);imagesc(h1,t,d1shift); 69 | subplot(1,2,2);imagesc(h2,t,d2shift); 70 | 71 | %% blend 72 | d1b=d1+d2shift; 73 | d2b=d2+d1shift; 74 | 75 | %% Correct time 76 | del=shift2; 77 | 78 | %% mask1 79 | dd=[fliplr(d1),d1]; 80 | d1m=dbt_mutter(dd,120,42,505); 81 | % figure;dbt_imagesc([dd,d1m,dd-d1m]); 82 | mask1=ones(size(dd)); 83 | mask1=dbt_mutter(mask1,120,42,505); 84 | mask1=mask1(:,121:end); 85 | %mask2 86 | mask2=ones(size(d2)); 87 | mask2=dbt_mutter(mask2,60,40,310); 88 | 89 | % figure;subplot(1,2,1);imagesc(mask1);subplot(1,2,2);imagesc(mask2); 90 | 91 | 92 | D1=zeros(nt,nx); 93 | D2=zeros(nt,nx); 94 | for iter=1:10 95 | fprintf('\n Iter %d \n',iter); 96 | D1T=dbt_dither(D1,-del); 97 | D2T=dbt_dither(D2,del); 98 | D1u = D1 + 0.5*(d1b-(D1+D2T)); % updated model 99 | D2u = D2 + 0.5*(d2b-(D1T+D2)); % updated model 100 | D1u=D1u.*mask1; 101 | D2u=D2u.*mask2; 102 | D1=drr3d_win(D1u,0,80,0.004,2,4,0,100,20,1,0.5,0.5,0.5); 103 | D2=drr3d_win(D2u,0,80,0.004,2,4,0,100,20,1,0.5,0.5,0.5); 104 | D1=D1.*mask1; 105 | D2=D2.*mask2; 106 | 107 | D1=D1+(d1b-D1).*(1-mask2).*mask1; 108 | D2=D2+(d2b-D2).*(1-mask1).*mask2; 109 | 110 | snr2(iter)=10*log10(sum(sum(d1.*d1))/sum(sum((d1-D1).*(d1-D1)))); 111 | snr22(iter)=10*log10(sum(sum(d2.*d2))/sum(sum((d2-D2).*(d2-D2)))); 112 | fprintf('iter1=%d,SNR=%g,SNR2=%g\n',iter,snr2(iter),snr22(iter)); 113 | end 114 | 115 | D33=D1+(d1b-D1).*(1-mask2).*mask1; 116 | D44=D2+(d2b-D2).*(1-mask1).*mask2; 117 | 118 | 119 | 120 | %% Figure 6 121 | [n1,n2]=size(d1); 122 | ngap=10; 123 | comp1=[d1,zeros(n1,ngap),d1b,zeros(n1,ngap),D33,zeros(n1,ngap),d1b-D33,zeros(n1,ngap),d1-D33]; 124 | comp2=[d2,zeros(n1,ngap),d2b,zeros(n1,ngap),D44,zeros(n1,ngap),d2b-D44,zeros(n1,ngap),d2-D44]; 125 | t=[0:1500-1]*0.004; 126 | x=1:size(comp1,2); 127 | xts1=[30,60,90]; 128 | xts2=xts1+ngap+nx; 129 | xts3=xts1+ngap*2+nx*2; 130 | xts4=xts1+ngap*3+nx*3; 131 | xts5=xts1+ngap*4+nx*4; 132 | xts=[xts1,xts2,xts3,xts4,xts5]; 133 | figure('units','normalized','Position',[0.0 0.0 0.5, 1],'color','w'); 134 | subplot(4,1,1:2);dbt_imagesc(comp1(1:1000,:),98,1,x,t(1:1000)); 135 | text(-50,-0.2,'a)','color','k','Fontsize',16,'fontweight','bold','HorizontalAlignment','left'); 136 | xticks(xts); 137 | set(gca,'xticklabel',{'30','60','90'}); 138 | ylabel('Time (s)','Fontsize',10,'fontweight','bold'); 139 | set(gca,'Linewidth',2,'Fontsize',10,'Fontweight','bold'); 140 | text(nx/2,0.16,'Unblended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 141 | text(nx+ngap+nx/2,0.16,'Blended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 142 | text((nx+ngap)*2+nx/2,0.16,'Deblended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 143 | text((nx+ngap)*3+nx/2,0.16,'Blending noise','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 144 | text((nx+ngap)*4+nx/2,0.16,'Deblending error','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 145 | 146 | text(nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 147 | text(nx+ngap+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 148 | text((nx+ngap)*2+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 149 | text((nx+ngap)*3+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 150 | text((nx+ngap)*4+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 151 | 152 | subplot(4,1,3:4);dbt_imagesc(comp2(1:1000,:),98,1,x,t(1:1000)); 153 | text(-50,-0.2,'b)','color','k','Fontsize',16,'fontweight','bold','HorizontalAlignment','left'); 154 | xticks(xts); 155 | set(gca,'xticklabel',{'30','60','90'}); 156 | ylabel('Time (s)','Fontsize',10,'fontweight','bold'); 157 | set(gca,'Linewidth',2,'Fontsize',10,'Fontweight','bold'); 158 | text(nx/2,0.16,'Unblended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 159 | text(nx+ngap+nx/2,0.16,'Blended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 160 | text((nx+ngap)*2+nx/2,0.16,'Deblended','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 161 | text((nx+ngap)*3+nx/2,0.16,'Blending noise','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 162 | text((nx+ngap)*4+nx/2,0.16,'Deblending error','color','b','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 163 | text(nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 164 | text(nx+ngap+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 165 | text((nx+ngap)*2+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 166 | text((nx+ngap)*3+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 167 | text((nx+ngap)*4+nx/2,4.35,'Shot NO #','color','k','Fontsize',10,'fontweight','bold','HorizontalAlignment','center'); 168 | 169 | print(gcf,'-depsc','-r300','test_matdrr_drr3d_win_deblending.eps'); 170 | print(gcf,'-dpng','-r300','test_matdrr_drr3d_win_deblending.png'); 171 | -------------------------------------------------------------------------------- /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 | % [6] Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 26 | 27 | clc;clear;close all; 28 | addpath(genpath('../matdrr')); 29 | 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 | 72 | %% add band-limitted noise and decimate data 73 | randn('state',201315); 74 | [nt,nx,ny]=size(d); 75 | noise=randn(nt,nx,ny); 76 | noise=drr_bandpass(noise,0.004,0,60); 77 | dn=0.2*noise+d; 78 | 79 | %% Doing the aliased reconstruction (densification) 80 | d3=drr3drecon_dealiase(dn,1,50,0.004,3,4,10,2,2,1); 81 | 82 | dy=1;dx=1;dt=0.004; 83 | [n1,n22,n33]=size(dn); 84 | yy=[1:n33]*dy; 85 | xx=[1:n22]*dx; 86 | zz=[1:n1]*dt; 87 | 88 | [n1,n2,n3]=size(d3); 89 | dy=1;dx=1;dt=0.004; 90 | y=[1:n3]*dy; 91 | x=[1:n2]*dx; 92 | z=[1:n1]*dt; 93 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.6],'color','w'); 94 | 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'); 95 | 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'); 96 | 97 | % 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); 98 | % 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); 99 | print(gcf,'-dpng','-r300','test_matdrr_drr3drecon_dealiase.png'); 100 | print(gcf,'-depsc','-r200','test_matdrr_drr3drecon_dealiase.eps'); 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /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 | % [9] Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 27 | 28 | clc;clear;close all; 29 | addpath(genpath('../matdrr')); 30 | 31 | %% download and load data 32 | % https://github.com/aaspip/data/blob/main/yc_synth5d.mat 33 | load yc_synth5d.mat 34 | d=data5d;d=d/max(max(max(max(max(d))))); 35 | [nt,nhx,nhy,nx,ny]=size(d); 36 | dt=0.004; 37 | %% exploring the data 38 | %1) ploting CMP gather 39 | % figure;drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 40 | 41 | %2) ploting common offset gather 42 | % figure;drr_imagesc(reshape(d(:,5,5,:,:),100,10*10)); 43 | %% add noise 44 | randn('state',201516); 45 | dn=d+.2*randn(nt,nhx,nhy,nx,ny); 46 | 47 | % figure; 48 | % subplot(2,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 49 | % subplot(2,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 50 | 51 | %% denoise (Traditonal RR) 52 | flow=5;fhigh=100;dt=0.004;N=6; 53 | d1=drr5d(dn,flow,fhigh,dt,N,100,1); 54 | % figure; 55 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 56 | % subplot(3,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 57 | % subplot(3,1,3);drr_imagesc(reshape(d1(:,:,:,1,1),100,10*10)); 58 | 59 | %% denoise (DRR) 60 | flow=5;fhigh=100;dt=0.004;N=6;K=2; 61 | d2=drr5d(dn,flow,fhigh,dt,N,K,1); 62 | 63 | snrnn=drr_snr(d(:,:),dn(:,:)) %-6.6662 64 | snr11=drr_snr(d(:,:),d1(:,:)) %15.6600 65 | snr22=drr_snr(d(:,:),d2(:,:)) %18.8509 66 | 67 | t=[0:100-1]*0.004; 68 | 69 | %% visualization 70 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.7],'color','w'); 71 | 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'); 72 | 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'); 73 | 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'); 74 | 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'); 75 | 76 | 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'); 77 | 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'); 78 | 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'); 79 | 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'); 80 | 81 | print(gcf,'-dpng','-r300','test_matdrr_drr5d.png'); 82 | print(gcf,'-depsc','-r200','test_matdrr_drr5d.eps'); 83 | 84 | 85 | -------------------------------------------------------------------------------- /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 | % [9] Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 27 | 28 | clc;clear;close all; 29 | addpath(genpath('../matdrr')); 30 | 31 | %% download and load data 32 | % https://github.com/aaspip/data/blob/main/yc_synth5d.mat 33 | load yc_synth5d.mat 34 | 35 | d=data5d;d=d/max(max(max(max(max(d))))); 36 | [nt,nhx,nhy,nx,ny]=size(d); 37 | dt=0.004; 38 | 39 | %% exploring the data 40 | %1) ploting CMP gather 41 | % figure;drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 42 | 43 | %2) ploting common offset gather 44 | % figure;drr_imagesc(reshape(d(:,5,5,:,:),100,10*10)); 45 | 46 | %% simultaneous denoising and reconstruction 47 | randn('state',201314); 48 | var=0.25; 49 | dn=d+var*randn(size(d)); 50 | 51 | %% decimate 52 | [nt,nhx,nhy,nx,ny]=size(d); 53 | ratio=0.3; 54 | mask=drr_genmask(reshape(d,nt,nhx*nhy*nx*ny),ratio,'c',201415); 55 | mask=reshape(mask,nt,nhx,nhy,nx,ny); 56 | d0=dn.*mask; 57 | 58 | %% RR5D 59 | flow=5;fhigh=100;dt=0.004;N=6;Niter=10;mode=1;verb=1; 60 | a=(Niter-(1:Niter))/(Niter-1); %linearly decreasing 61 | d1=drr5drecon(d0,mask,flow,fhigh,dt,N,50,Niter,eps,verb,mode,a); 62 | 63 | % figure; 64 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),nt,10*10)); 65 | % subplot(3,1,2);drr_imagesc(reshape(d0(:,:,:,1,1),nt,10*10)); 66 | % subplot(3,1,3);drr_imagesc(reshape(d1(:,:,:,1,1),nt,10*10)); 67 | % 68 | % figure; 69 | % subplot(3,1,1);drr_imagesc(reshape(d(:,5,5,:,:),nt,10*10)); 70 | % subplot(3,1,2);drr_imagesc(reshape(d0(:,5,5,:,:),nt,10*10)); 71 | % subplot(3,1,3);drr_imagesc(reshape(d1(:,5,5,:,:),nt,10*10)); 72 | 73 | %% DRR5D 74 | flow=5;fhigh=100;dt=0.004;N=6;K=2;Niter=10;mode=1;verb=1; 75 | d2=drr5drecon(d0,mask,flow,fhigh,dt,N,K,Niter,eps,verb,mode,a); 76 | 77 | % figure; 78 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),nt,10*10)); 79 | % subplot(3,1,2);drr_imagesc(reshape(d0(:,:,:,1,1),nt,10*10)); 80 | % subplot(3,1,3);drr_imagesc(reshape(d2(:,:,:,1,1),nt,10*10)); 81 | % 82 | % figure; 83 | % subplot(3,1,1);drr_imagesc(reshape(d(:,5,5,:,:),nt,10*10));caxis([-0.3,0.3]); 84 | % subplot(3,1,2);drr_imagesc(reshape(d0(:,5,5,:,:),nt,10*10));caxis([-0.3,0.3]); 85 | % subplot(3,1,3);drr_imagesc(reshape(d2(:,5,5,:,:),nt,10*10));caxis([-0.3,0.3]); 86 | 87 | %% calculate Signal-to-noise Ratio (SNR) 88 | snrnn=drr_snr(d(:,:),dn(:,:)) %-8.6178 89 | snr00=drr_snr(d(:,:),d0(:,:)) %-4.5929 90 | snr11=drr_snr(d(:,:),d1(:,:)) %7.5638 91 | snr22=drr_snr(d(:,:),d2(:,:)) %11.5626 92 | 93 | t=[0:100-1]*0.004; 94 | %% visualization 95 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.8],'color','w'); 96 | 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'); 97 | 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'); 98 | 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'); 99 | 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'); 100 | 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'); 101 | 102 | 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'); 103 | 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'); 104 | 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'); 105 | 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'); 106 | 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'); 107 | 108 | print(gcf,'-dpng','-r300','test_matdrr_drr5drecon.png'); 109 | print(gcf,'-depsc','-r200','test_matdrr_drr5drecon.eps'); 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /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 | % [9] Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 28 | 29 | clc;clear;close all; 30 | addpath(genpath('../matdrr')); 31 | %% generate 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 | %% adding noise 72 | randn('state',201314); 73 | var=0.2; 74 | dn=d+var*randn(size(d)); 75 | 76 | %% denoise (RR) 77 | flow=0;fhigh=250;dt=0.004;N=6;verb=1; 78 | d1=drr3d(dn(:,:,:),flow,fhigh,dt,N,100,verb); 79 | % figure;drr_imagesc([d(:,:,9),dn(:,:,9),d1(:,:,9),dn(:,:,9)-d1(:,:,9)]);caxis([-0.5,0.5]); 80 | 81 | %% denoise (DRR) 82 | flow=0;fhigh=250;dt=0.004;N=6;verb=1;K=3; 83 | d2=drr3d(dn(:,:,:),flow,fhigh,dt,N,K,verb); 84 | % figure;drr_imagesc([d(:,:,9),dn(:,:,9),d2(:,:,9),dn(:,:,9)-d2(:,:,9)]);caxis([-0.5,0.5]); 85 | 86 | %% denoise (ODRR) 87 | flow=0;fhigh=250;dt=0.004;N=6;verb=1;K=3;O=1; 88 | d3=odrr3d(dn(:,:,:),flow,fhigh,dt,N,K,O,verb); 89 | % figure;drr_imagesc([d(:,:,9),dn(:,:,9),d3(:,:,9),dn(:,:,9)-d3(:,:,9)]);caxis([-0.5,0.5]); 90 | 91 | snrn=drr_snr(d,dn,2) 92 | snr1=drr_snr(d,d1,2) 93 | snr2=drr_snr(d,d2,2) 94 | snr3=drr_snr(d,d3,2) 95 | 96 | 97 | t=[0:300-1]*0.004; 98 | figure('units','normalized','Position',[0.2 0.4 0.4, 0.7],'color','w'); 99 | 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'); 100 | 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'); 101 | 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'); 102 | 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'); 103 | print(gcf,'-dpng','-r300','test_matdrr_odrr3d.png'); 104 | print(gcf,'-depsc','-r200','test_matdrr_odrr3d.eps'); 105 | 106 | 107 | -------------------------------------------------------------------------------- /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 | % [9] Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 28 | 29 | clc;clear;close all; 30 | addpath(genpath('../matdrr')); 31 | 32 | %% generate 3D synthetic data 33 | a1=zeros(300,20); 34 | [n,m]=size(a1); 35 | a3=a1; 36 | a4=a1; 37 | 38 | k=0; 39 | a=0.1; 40 | b=1; 41 | for t=-0.055:0.002:0.055 42 | k=k+1; 43 | b1(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 44 | b2(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 45 | b3(k)=(1-2*(pi*40*t).^2).*exp(-(pi*40*t).^2); 46 | b4(k)=(1-2*(pi*30*t).^2).*exp(-(pi*30*t).^2); 47 | end 48 | for i=1:m 49 | t1(i)=round(140); 50 | t3(i)=round(-6*i+180); 51 | t4(i)=round(6*i+10); 52 | a1(t1(i):t1(i)+k-1,i)=b1; 53 | a3(t3(i):t3(i)+k-1,i)=b1; 54 | a4(t4(i):t4(i)+k-1,i)=b1; 55 | end 56 | 57 | temp=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 58 | for j=1:20 59 | a4=zeros(300,20); 60 | for i=1:m 61 | t4(i)=round(6*i+10+3*j); 62 | a4(t4(i):t4(i)+k-1,i)=b1; 63 | 64 | t1(i)=round(140-2*j); 65 | a1(t1(i):t1(i)+k-1,i)=b1; 66 | end 67 | shot(:,:,j)=a1(1:300,:)+a3(1:300,:)+a4(1:300,:); 68 | end 69 | plane3d=shot; 70 | d=plane3d/max(max(max(plane3d))); 71 | 72 | %% without noise 73 | dn=d; 74 | 75 | %% decimate 76 | [nt,nx,ny]=size(d); 77 | ratio=0.5; 78 | mask=drr_genmask(reshape(d,nt,nx*ny),ratio,'c',201415); 79 | mask=reshape(mask,nt,nx,ny); 80 | d0=dn.*mask; 81 | 82 | %% reconstruct (without denoising) 83 | flow=0;fhigh=125;dt=0.004;N=3;Niter=10;mode=0;verb=1; 84 | d1=drr3drecon(d0,mask,flow,fhigh,dt,50,N,Niter,eps,verb,mode); 85 | 86 | % 2D quick comparison (clean,noisy,observed,reconstructed using RR) 87 | figure;drr_imagesc([d(:,:,9),d0(:,:,9),d1(:,:,9)]);caxis([-0.5,0.5]); 88 | 89 | %% simultaneous denoising and reconstruction 90 | % adding noise 91 | randn('state',201314); 92 | var=0.2; 93 | dn=d+var*randn(size(d)); 94 | d0=dn.*mask; 95 | 96 | %% using RR (when K is suffiently large, see derivations in the references) 97 | flow=0;fhigh=250;dt=0.002;N=6;Niter=10;mode=1;verb=1; 98 | a=(Niter-(1:Niter))/(Niter-1); %linearly decreasing 99 | d1=drr3drecon(d0,mask,flow,fhigh,dt,N,100,Niter,eps,verb,mode,a); 100 | 101 | % 2D quick comparison 102 | % figure;drr_imagesc([d(:,:,9),d0(:,:,9),d1(:,:,9)]);caxis([-0.5,0.5]); 103 | 104 | %% using DRR 105 | flow=0;fhigh=250;dt=0.002;N=6;Niter=10;mode=1;verb=1;K=2; 106 | a=(Niter-(1:Niter))/(Niter-1); %linearly decreasing 107 | d2=drr3drecon(d0,mask,flow,fhigh,dt,N,K,Niter,eps,verb,mode,a); 108 | 109 | % 2D quick comparison 110 | % figure;drr_imagesc([d(:,:,9),d0(:,:,9),d2(:,:,9)]);caxis([-0.5,0.5]); 111 | 112 | %% using ODRR 113 | flow=0;fhigh=250;dt=0.002;N=6;Niter=10;mode=1;verb=1;K=2;O=1; 114 | a=(Niter-(1:Niter))/(Niter-1); %linearly decreasing 115 | d3=odrr3drecon(d0,mask,flow,fhigh,dt,N,K,O,Niter,eps,verb,mode,a); 116 | 117 | % 2D quick comparison 118 | % figure;drr_imagesc([d(:,:,9),d0(:,:,9),d3(:,:,9)]);caxis([-0.5,0.5]); 119 | 120 | %% calculate Signal-to-noise Ratio (SNR) 121 | snr0=drr_snr(d,d0,2) %observed data 122 | snrn=drr_snr(d,dn,2) %noisy data 123 | snr1=drr_snr(d,d1,2) %RR method 124 | snr2=drr_snr(d,d2,2) %DRR method 125 | snr3=drr_snr(d,d3,2) %ODRR method 126 | 127 | %SNR results when N=3 (might be slightly different for different PC platforms) 128 | %d0: -5.9853 129 | %d1: 1.4503 130 | %d2: 6.4816 131 | %d3: 7.6997 132 | 133 | %SNR results when N=6 (when rank over-estimated) (might be slightly different for different PC platforms) 134 | %d0: -5.9853 135 | %d1: -0.9812 136 | %d2: 4.9273 137 | %d3: 7.4988 138 | 139 | t=[0:300-1]*0.004; 140 | figure('units','normalized','Position',[0.2 0.4 0.4, 1],'color','w'); 141 | 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'); 142 | 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'); 143 | 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'); 144 | 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'); 145 | 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'); 146 | 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'); 147 | print(gcf,'-dpng','-r300','test_matdrr_odrr3drecon.png'); 148 | print(gcf,'-depsc','-r200','test_matdrr_odrr3drecon.eps'); 149 | 150 | 151 | -------------------------------------------------------------------------------- /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 | % [9] Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 27 | 28 | clc;clear;close all; 29 | addpath(genpath('../matdrr')); 30 | 31 | %% download and load data 32 | % https://github.com/aaspip/data/blob/main/yc_synth5d.mat 33 | load yc_synth5d.mat 34 | d=data5d;d=d/max(max(max(max(max(d))))); 35 | [nt,nhx,nhy,nx,ny]=size(d); 36 | dt=0.004; 37 | %% exploring the data 38 | %1) ploting CMP gather 39 | % figure;drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 40 | 41 | %2) ploting common offset gather 42 | % figure;drr_imagesc(reshape(d(:,5,5,:,:),100,10*10)); 43 | %% add noise 44 | randn('state',201516); 45 | dn=d+.2*randn(nt,nhx,nhy,nx,ny); 46 | 47 | % figure; 48 | % subplot(2,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 49 | % subplot(2,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 50 | 51 | %% denoise (Traditonal RR) 52 | flow=1;fhigh=100;dt=0.004;N=20; 53 | d1=drr5d(dn,flow,fhigh,dt,N,100,1); 54 | % figure; 55 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 56 | % subplot(3,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 57 | % subplot(3,1,3);drr_imagesc(reshape(d1(:,:,:,1,1),100,10*10)); 58 | 59 | %% denoise (DRR) 60 | flow=1;fhigh=100;dt=0.004;N=20;K=4; 61 | d2=drr5d(dn,flow,fhigh,dt,N,K,1); 62 | % figure; 63 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 64 | % subplot(3,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 65 | % subplot(3,1,3);drr_imagesc(reshape(d2(:,:,:,1,1),100,10*10)); 66 | 67 | %% denoise (ODRR) 68 | flow=1;fhigh=100;dt=0.004;N=20;K=4;O=1; 69 | d3=odrr5d(dn,flow,fhigh,dt,N,K,O,1); 70 | % figure; 71 | % subplot(3,1,1);drr_imagesc(reshape(d(:,:,:,1,1),100,10*10)); 72 | % subplot(3,1,2);drr_imagesc(reshape(dn(:,:,:,1,1),100,10*10)); 73 | % subplot(3,1,3);drr_imagesc(reshape(d3(:,:,:,1,1),100,10*10)); 74 | 75 | %% calculate Signal-to-noise Ratio (SNR) 76 | drr_snr(d(:,:),dn(:,:)) 77 | drr_snr(d(:,:),d1(:,:)) 78 | drr_snr(d(:,:),d2(:,:)) 79 | drr_snr(d(:,:),d3(:,:)) 80 | 81 | 82 | % SNR when N=20; (when rank over-estimated) 83 | % sn=-6.6662; 84 | % s1=10.4512; 85 | % s2=18.2299; 86 | % s3=19.0101; 87 | 88 | snrnn=drr_snr(d(:,:),dn(:,:)) % 89 | snr11=drr_snr(d(:,:),d1(:,:)) % 90 | snr22=drr_snr(d(:,:),d2(:,:)) % 91 | snr33=drr_snr(d(:,:),d3(:,:)) % 92 | 93 | t=[0:100-1]*0.004; 94 | 95 | %% visualization 96 | figure('units','normalized','Position',[0.2 0.4 0.8, 0.9],'color','w'); 97 | 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'); 98 | 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'); 99 | 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'); 100 | 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'); 101 | 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'); 102 | 103 | 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'); 104 | 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'); 105 | 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'); 106 | 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'); 107 | 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'); 108 | 109 | print(gcf,'-dpng','-r300','test_matdrr_odrr5d.png'); 110 | print(gcf,'-depsc','-r200','test_matdrr_odrr5d.eps'); 111 | -------------------------------------------------------------------------------- /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 et al., 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; 107 | ihigh=floor(nf/2)+1; 108 | end 109 | 110 | lx=floor(nx/2)+1; 111 | lxx=nx-lx+1; 112 | ly=floor(ny/2)+1; 113 | lyy=ny-ly+1; 114 | M=zeros(lx*ly,lxx*lyy); 115 | 116 | if(ny==1) 117 | mask=mask.'; 118 | end 119 | 120 | % main loop 121 | for k=ilow:ihigh 122 | 123 | if(ny==1) 124 | S_obs=DATA_FX(k,:,:).'; 125 | else 126 | S_obs=squeeze(DATA_FX(k,:,:)); 127 | end 128 | Sn_1=S_obs; 129 | for iter=1:Niter 130 | 131 | M=P_H(Sn_1,lx,ly); 132 | % M=P_R(M,N); 133 | M=P_R(M,Nmin,Nmax,K,amode,eps2); 134 | 135 | Sn=P_A(M,nx,ny,lx,ly); 136 | 137 | Sn=a(iter)*S_obs+(1-a(iter))*mask.*Sn+(1-mask).*Sn; 138 | if norm(Sn-Sn_1,'fro')=eps 198 | N=i; 199 | continue 200 | end 201 | end 202 | if N 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 | % construct par 103 | par.x=x; 104 | par.y=y; 105 | par.nx=nx; 106 | par.ny=ny; 107 | par.ox=ox; 108 | par.oy=oy; 109 | par.mx=mx; 110 | par.my=my; 111 | s=0.5*ones(Niter,1); 112 | % main loop 113 | for k=ilow:ihigh 114 | S_obs=squeeze(DATA_FX(k,:)).'; %1D vector 115 | Sn_1=zeros(nx,ny); 116 | % Sn_1=drr_inter_op(DATA_FX(k,:),par,-1); 117 | for iter=1:Niter 118 | 119 | % size(Sn_1) 120 | % size(S_obs) 121 | % size(inter_op(Sn_1,par,1)) 122 | Sn=Sn_1-s(iter)*drr_inter_op(drr_inter_op(Sn_1,par,-1)-S_obs,par,1); 123 | 124 | 125 | M=P_H(Sn,lx,ly); 126 | M=P_RD(M,N,K); 127 | Sn=P_A(M,nx,ny,lx,ly); 128 | 129 | % Sn=a(iter)*S_obs+(1-a(iter))*mask.*Sn+(1-mask).*Sn; 130 | if norm(Sn-Sn_1,'fro')1 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 | % Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 41 | % 42 | % see also: yc_bin2d 43 | % 44 | [n1,n2]=size(din); 45 | 46 | if nargin==5 47 | ox=min(x); 48 | oy=min(y); 49 | mx=max(x); 50 | my=max(y); 51 | dx=(mx-ox)/(nx-1); 52 | dy=(my-oy)/(ny-1); 53 | else 54 | dx=(mx-ox)/(nx-1); 55 | dy=(my-oy)/(ny-1); 56 | end 57 | xout=ox:dx:mx; 58 | yout=oy:dy:my; 59 | 60 | dout=zeros(n1,nx,ny); 61 | mask=ones(nx,ny); 62 | 63 | % dx 64 | % max(x) 65 | % min(x) 66 | 67 | for iy=1:ny 68 | for ix=1:nx 69 | index=find(x>=xout(ix) & x=yout(iy) & y=2 79 | if x(index(1))==xout(ix) & y(index(1))==yout(iy); 80 | dout(:,ix,iy)=din(:,index(1)); 81 | else 82 | t1=sqrt((x(index(1))-xout(ix))^2+(y(index(1))-yout(iy))^2); 83 | t2=sqrt((x(index(2))-xout(ix))^2+(y(index(2))-yout(iy))^2); 84 | dout(:,ix,iy)=(t1*din(:,index(2))+t2*din(:,index(1)))/(t1+t2); 85 | % dout(:,ix)=(t1*din(:,index(2))+t2*din(:,index(1)))/(t1+t2); 86 | end 87 | end 88 | end 89 | end 90 | end 91 | 92 | if nargout==4 93 | mask=ones(n1,1)*reshape(mask,1,nx*ny); 94 | mask=reshape(mask,n1,nx,ny); 95 | end 96 | 97 | return -------------------------------------------------------------------------------- /matdrr/drr_fk2d.m: -------------------------------------------------------------------------------- 1 | function [D,f,k]=drr_fk2d(d,dt,dx) 2 | % drr_fk2d: FK spectrum (2D) for spectrum comparison 3 | % 4 | % INPUT 5 | % d: intput data 6 | % dt: time sampling 7 | % dx: space sampling 8 | % 9 | % OUTPUT 10 | % D: output spectrum 11 | % 12 | % DEMO 13 | % demos/test_matdrr_drr2d_win.m 14 | % 15 | % By Yangkang Chen 16 | % Jan, 26, 2020 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==1 30 | dt=0.004; 31 | dx=1; 32 | end 33 | 34 | [n1,n2]=size(d); 35 | nf = 2^nextpow2(n1);nf2=nf/2; 36 | nk = 2^nextpow2(n2); 37 | 38 | D=fftshift(fft(fft(d,nf,1),nk,2)); 39 | D=D(nf/2+1:end,:); 40 | 41 | f_nq=1/dt/2; 42 | k_nq=1/dx/2; 43 | f=linspace(0,f_nq,nf2); 44 | k=linspace(-k_nq,k_nq,nk); 45 | 46 | 47 | return 48 | 49 | 50 | -------------------------------------------------------------------------------- /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 | % [6] Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 35 | 36 | [m,n] = size(u); 37 | mask = zeros(m,n); 38 | 39 | switch type 40 | case 'r' 41 | row = drr_rperm(m,seed); 42 | k = fix(r*m); 43 | row = row(1:k); 44 | mask(row,:) = 1; 45 | case 'c' 46 | column = drr_rperm(n,seed); 47 | k = fix(r*n); 48 | column = column(1:k); 49 | mask(:, column) = 1; 50 | case 'p' 51 | pix = drr_rperm(m*n,seed); 52 | r = fix(r*m*n); 53 | pix = pix(1:r); 54 | mask(pix) = 1; 55 | end 56 | 57 | -------------------------------------------------------------------------------- /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_inter_op.m: -------------------------------------------------------------------------------- 1 | function [U] = drr_inter_op(D,par,adj) 2 | %%drr_inter_op: Forward bi-linear interpolation operator 3 | % 4 | % By Yangkang Chen 5 | % Jan, 2022 6 | % Revised in April, 2024 7 | % 8 | % INPUT 9 | % 10 | % if adj = true, D: 1D data, U: 2D data 11 | % if adj = false, D: 2D data, U: 1D data 12 | % 13 | % par.x=x; 14 | % par.y=y; 15 | % par.nx=nx; 16 | % par.ny=ny; 17 | % par.ox=ox; 18 | % par.oy=oy; 19 | % par.mx=mx; 20 | % par.my=my; 21 | 22 | rx=par.x; 23 | ry=par.y; 24 | 25 | dx=(par.mx-par.ox)/(par.nx-1); 26 | dy=(par.my-par.oy)/(par.ny-1); 27 | xx=par.ox+[0:par.nx-1]*dx; 28 | yy=par.oy+[0:par.ny-1]*dy; 29 | 30 | 31 | Nu=length(rx); 32 | Nx=length(xx); 33 | Ny=length(yy); 34 | if adj==1 35 | U=zeros(Nx,Ny); 36 | else 37 | U=zeros(Nu,1); 38 | end 39 | for k=1:Nu 40 | ia=floor((rx(k)-xx(1))/dx)+1;ib=ia+1; 41 | ja=floor((ry(k)-yy(1))/dy)+1;jb=ja+1; 42 | if ib>1 & ib<=Nx & jb>1 & jb<=Ny 43 | t=(rx(k)-xx(ia))/dx; 44 | u=(ry(k)-yy(ja))/dy; 45 | if adj==1 46 | U(ia,ja)=U(ia,ja)+(1-t)*(1-u)*D(k); 47 | U(ib,ja)=U(ib,ja)+t*(1-u)*D(k); 48 | U(ib,jb)=U(ib,jb)+t*u*D(k); 49 | U(ia,jb)=U(ia,jb)+(1-t)*u*D(k); 50 | else 51 | % fprintf('size(D)=(%d,%d)\n',size(D,1),size(D,2)); 52 | U(k)=(1-t)*(1-u)*D(ia,ja)+t*(1-u)*D(ib,ja)+... 53 | t*u*D(ib,jb)+(1-t)*u*D(ia,jb); 54 | end 55 | 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /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 | % [6] Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 30 | 31 | rand('state',seed); 32 | [~,p] = sort(rand(1,n)); 33 | -------------------------------------------------------------------------------- /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 | % [6] Chen et al., 2023, DRR: an open-source multi-platform package for the damped rank-reduction method and its applications in seismology, Computers & Geosciences, 180, 105440. 17 | 18 | if nargin==2 19 | mode=1; 20 | end 21 | 22 | g = double(g); % in case of data format is unit8,12,16 23 | f = double(f); 24 | 25 | if ndims(f) floor(nf/2)+1; 77 | ihigh=floor(nf/2)+1; 78 | end 79 | 80 | lx=floor(nx/2)+1; 81 | lxx=nx-lx+1; 82 | ly=floor(ny/2)+1; 83 | lyy=ny-ly+1; 84 | M=zeros(lx*ly,lxx*lyy); 85 | 86 | % main loop 87 | for k=ilow:ihigh 88 | 89 | if(ny==1) 90 | M=P_H(DATA_FX(k,:,:).',lx,ly); 91 | else 92 | M=P_H(squeeze(DATA_FX(k,:,:)),lx,ly); 93 | end 94 | 95 | if O==0 96 | M=P_RD(M,N,K); 97 | else 98 | M=P_ORD(M,N,K); 99 | end 100 | 101 | DATA_FX0(k,:,:)=P_A(M,nx,ny,lx,ly); 102 | 103 | if(mod(k,5)==0 && verb==1) 104 | fprintf( 'F %d is done!\n\n',k); 105 | end 106 | end 107 | 108 | % Honor symmetries 109 | for k=nf/2+2:nf 110 | DATA_FX0(k,:,:) = conj(DATA_FX0(nf-k+2,:,:)); 111 | end 112 | 113 | % Back to TX (the output) 114 | D1=real(ifft(DATA_FX0,[],1)); 115 | D1=D1(1:nt,:,:); 116 | 117 | return 118 | 119 | 120 | function [dout]=P_H(din,lx,ly) 121 | % forming block Hankel matrix 122 | [nx,ny]=size(din); 123 | lxx=nx-lx+1; 124 | lyy=ny-ly+1; 125 | 126 | for j=1:ny 127 | r=hankel(din(1:lx,j),[din(lx:nx,j)]); 128 | if j floor(nf/2)+1; 94 | ihigh=floor(nf/2)+1; 95 | end 96 | 97 | lx=floor(nx/2)+1; 98 | lxx=nx-lx+1; 99 | ly=floor(ny/2)+1; 100 | lyy=ny-ly+1; 101 | M=zeros(lx*ly,lxx*lyy); 102 | 103 | % main loop 104 | for k=ilow:ihigh 105 | 106 | S_obs=squeeze(DATA_FX(k,:,:)); 107 | Sn_1=S_obs; 108 | for iter=1:Niter 109 | 110 | M=P_H(Sn_1,lx,ly); 111 | if O==0 112 | M=P_RD(M,N,K); 113 | else 114 | M=P_ORD(M,N,K); 115 | end 116 | Sn=P_A(M,nx,ny,lx,ly); 117 | 118 | Sn=a(iter)*S_obs+(1-a(iter))*mask.*Sn+(1-mask).*Sn; 119 | if norm(Sn-Sn_1,'fro')