consider bias for Mmax estimation

This commit is contained in:
Konstantinos Leptokaropoulos 2020-03-12 13:14:52 +01:00
parent 021b6c8c64
commit 0e48665920
7 changed files with 178 additions and 96 deletions

View File

@ -2,14 +2,24 @@ Welcome to the Seismic HAzard Parameters Evaluation (SHAPE) Toolbox!
Find the two versions in the corresponding directories
SHAPE_ver1.0 - is a Interactive Standalone version
(inputs are set interactively, step by step)
SHAPE_ver2.0 - is a Wrapper version
(inputs are set in the wrapper script and once launched,
the applications runs without any further interruption)
SHAPE_ver1 - is a Interactive Standalone version (inputs are set interactively, step by step)
REQUIREMENTS: Matlab R2017b or later, with installed Toolboxes:
- 'Statistics and Machine Learning'
- 'Image Processing'
please refer to the "READ_ME*******.pdf" file in each directory for further
instructions on the step-by-step implementation of the applications as well
as for data requirements and general tips.
SHAPE_ver2 - is a Wrapper version (inputs are set in the wrapper script and once launched the
application runs without any further interruption)
REQUIREMENTS: Matlab R2017b or later, with installed Toolboxes:
- 'Statistics and Machine Learning'
>> Please refer to the "READ_ME_SHAPE_ver*.pdf" file in each directory for further instructions on
step-by-step implementation of the applications as well as for data requirements & general tips.
>> Your feedback is welcome! contact Dr K. Leptokaropoulos for questions, suggestions or comments:
- kleptoka@igf.edu.pl
>> Please acknowledge any use of SHAPE in your work, by citing:
- Leptokaropoulos & Lasocki (2020), SHAPE: A MATLAB Software Package for Time-dependent Seismic
Hazard Analysis, Seismol. Res. Lett., doi:
ENJOY!

View File

@ -1,10 +1,12 @@
% PROGRAM: SHAPE [Seismic HAzard Parameters Evaluation]
% VERSION: V_1.0 [Interactive Standalone Version]
% LAST UPDATED: September 2019
% COMPATIBLE with Matlab version 2017b or later
% REQUIREMENTS: "Statistics and Machine Learning" and "Image Processing" Matlab Toolbox installed
% TOOLBOX: "Hazard Analysis Toolbox" within SERA Project
% DOCUMENT: "READ_ME_SHAPE_ver1.pdf"
% PROGRAM : SHAPE [Seismic HAzard Parameters Evaluation]
% VERSION : V_1.2 [Interactive Standalone Version]
% LAST UPDATED: March 2020
% COMPATIBLE : Matlab version 2017b or later
% REQUIREMENTS: "Statistics and Machine Learning" and "Image Processing" Matlab Toolbox installed
% TOOLBOX : "Hazard Analysis Toolbox" developed within SERA Project
% USER GUIDE : "READ_ME_SHAPE_ver1.pdf"
% CITE AS : Leptokaropoulos K. and S. Lasocki (2020), Seismol. Res. Lett., doi:
% CONTACT : kleptoka@igf.edu.pl (Dr. Kostas Leptokaropoulos)
% --------------------------------------------------------------------------------------------------------------------
% Time-and-Technology Dependent Seismic Hazard Assessment (SHA)
% --------------------------------------------------------------------------------------------------------------------
@ -24,9 +26,9 @@
% --------------------------------------------------------------------------------------------------------------------
% AUTHORS: K. Leptokaropoulos and S. Lasocki
% Based on magnitude distribution and stationary hazard parameters estimation functions originally developed by S. Lasocki
% Last Updated: 01/2020, within SERA PROJECT, EU Horizon 2020 R&I
% Last Updated: 03/2020, within SERA PROJECT, EU Horizon 2020 R&I
% programme under grant agreement No.730900
% CURRENT VERSION: v1.0 **** [INTERACTIVE STANDALONE VERSION!!]
% CURRENT VERSION: v1.2 **** [INTERACTIVE STANDALONE VERSION!!]
%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% PLEASE refer to the accompanying document:
% "READ_ME_SHAPE_ver1.pdf"
@ -101,26 +103,28 @@
% [applies only when "method" is set to 'GRT' or 'NPT']
% - err : Mmax convergence indicator (0-converge, 1-no converge)
% [applies only when "method" is set to 'GRT' or 'NPT']
% - PDF : 2 columns, first representing magnitudes and second the Probability Density Function of those magnitudes
% - PDF : 2 columns, first representing magnitudes and second the Cumulative Distribution Function of those magnitudes
% -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
% REFERENCES:
% Kijko A, Lasocki S, Graham G (2001), Pure Appl. Geophys. 158:16551676
% Kijko A, Sellevoll MA (1989), Bull Seismol. Soc. Am. 79:645654
% Lasocki S (2017), Chapter 11.3 in Rockburst Mechanisms, Oxford, pp 366-380
% Lasocki S, Urban P (2011), Acta Geophys. 59:659673
% Lasocki S, Orlecka-Sikora B (2008), Tectonophysics 456:2837
% Leptokaropoulos K, Staszek M, Cielesta S, Urban P, Olszewska D, Lizurek G (2017), Acta Geophys. 65:493-505
% Leptokaropoulos K, Lasocki S (2020), Seismol. Res. Lett., doi: .
% ---------------------------------------------------------------------------------------------------------------------
% LICENSE
% This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the
% Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty
% of MERCHANTABILITY or FITNESS FOR A PARTICULAR
% PURPOSE. See the GNU General Public License for more details.
% This is free software: you can redistribute it and/or modify it under the terms of the
% GNU General Public License as published by the Free Software Foundation, either version
% 3 of the License, or (at your option) any later version.
% This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
% without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% See the GNU General Public License for more details.
% -------------------------------------------------------------------------------------------------------------------
clear;clc
mkdir Outputs_SHA
set(0, 'DefaultUICOntrolFontSize', 12)
@ -239,7 +243,7 @@ if (length(time_start_vector) ~= length(time_end_vector)); error('time start and
case 'File' %K 27JUN2019
cd TIME_WINDOWS %K 27JUN2019
d=dir;dstr={d.name}; %K 27JUN2019
dlabela='Select Time Windows File:' %K 27JUN2019
dlabela='Select Time Windows File:'; %K 27JUN2019
[s,ok]=listdlg('PromptString',dlabela,... %K 27JUN2019
'SelectionMode','single','ListString',dstr,... %K 27JUN2019
'ListSize',[350 250]); %K 27JUN2019
@ -271,27 +275,53 @@ if indx2==1;prompt = {'\fontsize{12} Magnitude:','\fontsize{12} Period Length, (
elseif indx2==2;prompt = {'\fontsize{12} Magnitude:','\fontsize{12} Period Length, (months):'};
elseif indx2==3;prompt = {'\fontsize{12} Magnitude:','\fontsize{12} Period Length, (years):'};end
if indx1==1;method='GRU';elseif indx1==2;method='GRT';elseif indx1==3;method='NPU';else;method='NPT';end
% SET Mmax for truncated Magnitude distribution
if method=='GRT' | method=='NPT'
prompt2 = ['\fontsize{12} M_M_a_x (>',num2str(max(Cmag)),' or estimated from catalog):'];
dlgtitle2 = 'Set Mmax';
dims2 = [1 59]; opts2.Interpreter='tex';
definput2 = {'estimated'};
answer4 = inputdlg(prompt2,dlgtitle2,dims2,definput2,opts2);
if strcmp(answer4,'estimated');Mmax=[];
%questM='Do you wish to include Mmax Bias?';
%answer=questdlg(questM,'Bias Calculation?','Yes','No',opts);
dlgtitleM='Mmax Bias estimation';
promptM={'\fontsize{12} Enter number of synthetic samples (N>1):'};
dimsM=[1 57];opts.Interpreter='tex';
definputM={num2str(max(1000))};
answer3=inputdlg(promptM,dlgtitleM,dimsM,definputM,opts);
Nsynth=str2double(answer3);
cd SSH/
if strcmp(method,'GRT')==1 & isempty(Mmax)==1;
[p1,p2,p3,p4,p5,pb,Mmax,err,BIAS,SD]=TruncGR_O(Ctime,Cmag,0,Mc,Mmax,Nsynth);
Mmax=Mmax+BIAS;
elseif strcmp(method,'NPT')==1 & isempty(Mmax)==1;
[p1,p2,p3,p4,p5,p6,p7,p8,p9,Mmax,err,BIAS,SD]=Nonpar_tr_O(Ctime,Cmag,0,Mc,Mmax,Nsynth);
Mmax=Mmax+BIAS;
end
cd ../
disp([newline 'Corrected Mmax=',num2str(Mmax)]);
else Mmax=str2double(answer4{1});
end
else Mmax=[];
end
% SHA parameters (Magnitude and Time Period)
dlgtitle = 'Parameters for Hazard Analysis';
dims = [1 55]; opts.Interpreter='tex';
definput = {num2str(max(Cmag)),'1'};
answer3 = inputdlg(prompt,dlgtitle,dims,definput,opts);
if indx1==1;method='GRU';elseif indx1==2;method='GRT';elseif indx1==3;method='NPU';else;method='NPT';end
iop=indx2-1;time_period=str2double(answer3(2));mag=str2double(answer3(1));
% SET Mmax for truncated Magnitude distribution
if method=='GRT' | method=='NPT'
prompt2 = {'\fontsize{12} M_M_a_x (>Maximum Catalog Record):'};
dlgtitle2 = 'Set Mmax';
dims2 = [1 55]; opts2.Interpreter='tex';
definput2 = {'adaptive'};
answer4 = inputdlg(prompt2,dlgtitle2,dims2,definput2,opts2);
if strcmp(answer4,'adaptive');Mmax=[];else Mmax=str2double(answer4{1});end
else Mmax=[];
end
%% ************* STEP_7: GENERATE AND SAVE OUTPUTS **************
@ -476,6 +506,9 @@ end
function [HP] = TDHMagDistWrapper(method, time_win_data, mmin, iop,Mmax)
cd SSH
for j=1:size(time_win_data,2);M1(j)=max(time_win_data(j).M);end
Mmaxcat=max(M1);Mmax=max([Mmaxcat Mmax])
for i=1:size(time_win_data,2)
mags_vec = time_win_data(i).M;
time_vec = time_win_data(i).Time;
@ -486,31 +519,40 @@ cd SSH
case 'GRU'
try
[HP(i).lamb_all, HP(i).lamb, HP(i).lamb_err, HP(i).unit, HP(i).eps, HP(i).b]=UnlimitGR(time_vec, mags_vec, iop, mmin);
HP(i).Mmax=NaN;
HP(i).Mmax=NaN;eps=HP(i).eps;
[m, PDF_GRU, CDF_GRU]=dist_GRU(mmin,Mmax+eps,eps,mmin,eps,HP(i).b); %K29JAN2020 - magnitude PDF/CDF
HP(i).PDF=[m PDF_GRU];HP(i).CDF=[m CDF_GRU]; %K29JAN2020 - magnitude PDF/CDF
catch err
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).b=NaN;HP(i).Mmax=NaN;
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).b=NaN;HP(i).Mmax=NaN;HP(i).PDF=NaN;HP(i).CDF=NaN;
warning('%s: %s', err.identifier, err.message);
end
case 'GRT'
try
[HP(i).lamb_all, HP(i).lamb, HP(i).lamb_err, HP(i).unit, HP(i).eps, HP(i).b, HP(i).Mmax, HP(i).err]=TruncGR_O(time_vec, mags_vec, iop, mmin,Mmax);
eps=HP(i).eps;[m, PDF_GRT, CDF_GRT]=dist_GRT(mmin,Mmax+eps,eps,mmin,eps,HP(i).b,Mmax); %K29JAN2020 - magnitude PDF/CDF
HP(i).PDF=[m PDF_GRT];HP(i).CDF=[m CDF_GRT]; %K29JAN2020 - magnitude PDF/CDF
catch err
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).b=NaN; HP(i).Mmax=NaN; HP(i).err=NaN;
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).b=NaN; HP(i).Mmax=NaN; HP(i).err=NaN;HP(i).PDF=NaN;HP(i).CDF=NaN;
warning('%s: %s', err.identifier, err.message);
end
case 'NPU'
try
[HP(i).lamb_all, HP(i).lamb, HP(i).lamb_err, HP(i).unit, HP(i).eps, HP(i).ierr, HP(i).h, HP(i).xx, HP(i).ambd]=Nonpar_O(time_vec, mags_vec, iop, mmin);
HP(i).Mmax=NaN;
HP(i).Mmax=NaN;eps=HP(i).eps;
[m, PDF_NPU, CDF_NPU]=dist_NPU(mmin,Mmax+eps,eps,mmin,eps,HP(i).h,HP(i).xx,HP(i).ambd); %K29JAN2020 - magnitude PDF/CDF
HP(i).PDF=[m PDF_NPU];HP(i).CDF=[m CDF_NPU]; %K29JAN2020 - magnitude PDF/CDF
catch err
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).ierr=NaN; HP(i).h=NaN; HP(i).xx=[]; HP(i).ambd=[];HP(i).Mmax=NaN;
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).ierr=NaN; HP(i).h=NaN; HP(i).xx=[]; HP(i).ambd=[];HP(i).Mmax=NaN;HP(i).PDF=NaN;HP(i).CDF=NaN;
warning('%s: %s', err.identifier, err.message);
end
case 'NPT'
try
[HP(i).lamb_all, HP(i).lamb, HP(i).lamb_err, HP(i).unit, HP(i).eps, HP(i).ierr, HP(i).h, HP(i).xx, HP(i).ambd, HP(i).Mmax, HP(i).err]=Nonpar_tr_O(time_vec, mags_vec, iop, mmin,Mmax);
eps=HP(i).eps;
[m, PDF_NPT, CDF_NPT]=dist_NPT(mmin,Mmax+eps,eps,mmin,eps,HP(i).h,HP(i).xx,HP(i).ambd,Mmax); %K29JAN2020 - magnitude PDF/CDF
HP(i).PDF=[m PDF_NPT];HP(i).CDF=[m CDF_NPT]; %K29JAN2020 - magnitude PDF/CDF
catch err
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).ierr=NaN; HP(i).h=NaN; HP(i).xx=[]; HP(i).ambd=[]; HP(i).Mmax=NaN; HP(i).err=NaN;
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).ierr=NaN; HP(i).h=NaN; HP(i).xx=[]; HP(i).ambd=[]; HP(i).Mmax=NaN; HP(i).err=NaN;HP(i).PDF=NaN;HP(i).CDF=NaN;
warning('%s: %s', err.identifier, err.message);
end
end

View File

@ -2,7 +2,7 @@
cd Outputs_SHA
fid=fopen('REPORT_Hazard_Analysis.txt','w');
fprintf(fid,['Parameters Report & Results for HAZARD ANALYSIS (created on ', datestr(now),')\n']);
fprintf(fid,['Parameters Estimated: Mean Return Period (MRP) and Exceedance Probability (EPR) \n']);
fprintf(fid,['Parameters Estimated: Mean Return Period (MRP) and Exceedance Probability (EP) \n']);
fprintf(fid,'------------------------------------------------------------------------------------\n');
fprintf(fid,['<Magnitude Scale Selected >: ', Mtype,'\n']);
fprintf(fid,['<Time Unit >: ', list2{indx2},'\n']);
@ -29,13 +29,13 @@ SN(j)=j;Nevents(j)=numel(time_windows(j).M);TS(j)=time_windows(j).Tstart;TE(j)=t
end
fprintf(fid,[' Set N Starting Date/Time Ending Date/Time events MRP EPR b-value Mmax \n']);
fprintf(fid,[' Set N Starting Date/Time Ending Date/Time events MRP EP b-value Mmax \n']);
fprintf(fid,[' per ',HP(1).unit, ' ',HP(1).unit,'s' '\n']);
for i=1:numel(HP)
if strcmp(method,'GRU')==1 || strcmp(method,'GRT')==1;
fprintf(fid,['%4d %5d %s %s %9.3f %13.3f %13.11f %5.3f %4.2f \n'],SN(i),Nevents(i),datestr(TS(i)),datestr(TE(i)),lambda(i),MRPer(i),ExPr(i),bval(i),HP(i).Mmax);
fprintf(fid,['%4d %5d %s %s %9.3f %13.3f %13.11f %5.3f %4.2f \n'],SN(i),Nevents(i),datestr(TS(i),0),datestr(TE(i),0),lambda(i),MRPer(i),ExPr(i),bval(i),HP(i).Mmax);
else
fprintf(fid,['%4d %5d %s %s %9.3f %13.3f %13.11f %s %4.2f \n'],SN(i),Nevents(i),datestr(TS(i)),datestr(TE(i)),lambda(i),MRPer(i),ExPr(i),'NaN',HP(i).Mmax);
fprintf(fid,['%4d %5d %s %s %9.3f %13.3f %13.11f %s %4.2f \n'],SN(i),Nevents(i),datestr(TS(i),0),datestr(TE(i),0),lambda(i),MRPer(i),ExPr(i),'NaN',HP(i).Mmax);
end
end
@ -64,6 +64,8 @@ for i=1:length(HP)
SHA(i).err=HP(i).err;
else
end
SHA(i).PDF=HP(i).PDF; %K29JAN2020
SHA(i).CDF=HP(i).CDF; %K29JAN2020
end
prompt={'\fontsize{12} Please enter output file name:'};

View File

@ -1,10 +1,12 @@
% PROGRAM: SHAPE [Seismic HAzard Parameters Evaluation]
% VERSION: V_2.0 [Wrapper (fast) Standalone Version]
% LAST UPDATED: September 2019
% COMPATIBLE with Matlab version 2017b or later
% REQUIREMENTS: "Statistics and Machine Learning" Matlab Toolbox installed
% TOOLBOX: "Hazard Analysis Toolbox" within SERA Project
% DOCUMENT: "READ_ME_SHAPE_ver2.docx"
% PROGRAM : SHAPE [Seismic HAzard Parameters Evaluation]
% VERSION : V_2.2 [Wrapper (fast) Standalone Version]
% LAST UPDATED: March 2020
% COMPATIBLE : Matlab version 2017b or later
% REQUIREMENTS: "Statistics and Machine Learning" Matlab Toolbox installed
% TOOLBOX : "Hazard Analysis Toolbox" developed within SERA Project
% USER GUIDE : "READ_ME_SHAPE_ver2.docx"
% CITE AS : Leptokaropoulos K. and S. Lasocki (2020), Seismol. Res. Lett., doi:
% CONTACT : kleptoka@igf.edu.pl (Dr. Kostas Leptokaropoulos)
% --------------------------------------------------------------------------------------------------------------------
% Time-and-Technology Dependent Seismic Hazard Assessment (SHA)
% --------------------------------------------------------------------------------------------------------------------
@ -23,9 +25,9 @@
% --------------------------------------------------------------------------------------------------------------------
% AUTHORS: K. Leptokaropoulos and S. Lasocki
% Based on magnitude distribution and stationary hazard parameters estimation functions originally developed by S. Lasocki
% Last Updated: 01/2020, within SERA PROJECT, EU Horizon 2020 R&I
% Last Updated: 03/2020, within SERA PROJECT, EU Horizon 2020 R&I
% programme under grant agreement No.730900
% CURRENT VERSION: v2.0 **** [WRAPPER (fast) STANDALONE VERSION!!]
% CURRENT VERSION: v2.2 **** [WRAPPER (fast) STANDALONE VERSION!!]
%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% PLEASE refer to the accompanying document:
% "READ_ME_SHAPE_ver2.pdf"
@ -53,12 +55,10 @@
% STEP_6. Plotting (optional)
% STEP_7. save OUTPUTS
% ---------------------------------------------------------------------------------------------------------------------
%% INPUT: All input data are sufficiently explained in the script as well as
% while running the code (interaction with the user). NOTE that
% all input files (seismic catalog, production data, time windows)
% must be in ASCII format (i.e. *.txt).
% Please refer to the APPLICATION DOCUMENTATION for further
% instructions and input data requirement specifications: "READ_ME_SHAPE_ver2.pdf"
%% INPUT: All input data are sufficiently explained in the script as well as while running the code
% (interaction with the user). NOTE that all input files (seismic catalog, production data,
% time windows) must be in ASCII format (i.e. *.txt). Please refer to the APPLICATION DOCUMENTATION
% for further instructions and input data requirement specifications: "READ_ME_SHAPE_ver2.pdf"
% ----------------------------------------------------------------------------------------------------------------------
%% OUTPUT:
% <> Output Report with summary of the Results as well as data and parameters used
@ -88,29 +88,31 @@
% [applies only when "method" is set to 'GRT' or 'NPT']
% - err : Mmax convergence indicator (0-converge, 1-no converge)
% [applies only when "method" is set to 'GRT' or 'NPT']
% - PDF : 2 columns, first representing magnitudes and second the Probability Density Function of those magnitudes
% - PDF : 2 columns, first representing magnitudes and second the Cumulative Distribution Function of those magnitudes
% -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
% REFERENCES:
% Kijko A, Lasocki S, Graham G (2001), Pure Appl. Geophys. 158:16551676
% Kijko A, Sellevoll MA (1989), Bull Seismol. Soc. Am. 79:645654
% Lasocki S (2017), Chapter 11.3 in Rockburst Mechanisms, Oxford, pp 366-380
% Lasocki S, Urban P (2011), Acta Geophys. 59:659673
% Lasocki S, Orlecka-Sikora B (2008), Tectonophysics 456:2837
% Leptokaropoulos K, Staszek M, Cielesta S, Urban P, Olszewska D, Lizurek G (2017), Acta Geophys. 65:493-505
% Leptokaropoulos K, Lasocki S (2020), Seismol. Res. Lett., doi: .
% ---------------------------------------------------------------------------------------------------------------------
% LICENSE
% This is free software: you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the
% Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty
% of MERCHANTABILITY or FITNESS FOR A PARTICULAR
% PURPOSE. See the GNU General Public License for more details.
% This is free software: you can redistribute it and/or modify it under the terms of the
% GNU General Public License as published by the Free Software Foundation, either version
% 3 of the License, or (at your option) any later version.
% This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
% without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% See the GNU General Public License for more details.
% -------------------------------------------------------------------------------------------------------------------
clc;clear;
close all;
close all;mkdir Outputs_SHA
% PLEASE SET INPUT ARGUMENTS [LINES 115-131]
% PLEASE SET INPUT ARGUMENTS [LINES 117-134]
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SEIS_DATA='ST2_SEIS_Data.txt'; % Seismic Data File - NOTE: SEIS_DATA=[] is valid as well
SEIS_FIELDS='ST2_SEIS_Fields.txt'; % Seismic Data Fields File
@ -119,13 +121,14 @@ PROD_FIELDS='ST2_PROD_Fields.txt'; % Production Data (non-seismic) Fie
PROD_FIELD=2; % field (column) corresponding to a selected Production Parameter
MScale='ML'; % Magnitude Scale (e.g. 'ML', 'Mw' etc). NOTE: MScale=[] is also valid
Mc=1.0; % Select Mc
Mmax=3.5; % Valid for GRT and NPT/ if Mmax=[], it is calculated internally
winmode='File'; % Select MODE for windows creation: 'Time' or 'Events' or 'File'
Mmax=[]; % Valid for GRT and NPT/ if Mmax=[], it is calculated internally
Nsynth=1000; % number of trials to estimated Mmax bias/ if Nsynth=[], no bias is estimated
winmode='Time'; % Select MODE for windows creation: 'Time' or 'Events' or 'File'
file_n='ST2_test_timewindows.txt'; % Select file name with starting and ending time of time windows, applicable only for winmode='File'
window_size=30; % time window span (days or events, depending on "winmode")
dt=30; % time step (days)
method='NPU'; % Select M distribution model among 'GRU','GRT','NPU','NPT'
Tunit='month'; % Select time unit among 'day', 'month', 'year'
window_size=50; % time window span (days or events, depending on "winmode")
dt=50; % time step (days)
method='GRT'; % Select M distribution model among 'GRU','GRT','NPU','NPT'
Tunit='day'; % Select time unit among 'day', 'month', 'year'
MaG=3.0; % set target Magnitude for EPR and MRP calculation
Plength=1; % set target time Period (days) for EPR calculation
Plotopt='ON'; % To enable ('ON') or disable ('OFF') plotting
@ -145,6 +148,17 @@ end
%% STEP 3: Filter data for Mc
[Ctime,Cmag,Catalog]=FiltMc_ver2(Ctime,Cmag,Catalog,s1,Mc);
%% STEP 3b: Estimate Mmax for Truncated Distributions (GRT and NPT)
cd SSH/
if strcmp(method,'GRT')==1 & isempty(Mmax)==1;
[p1,p2,p3,p4,p5,pb,Mmax,err,BIAS,SD]=TruncGR_O(Ctime,Cmag,0,Mc,Mmax,Nsynth);
Mmax=Mmax+BIAS;
elseif strcmp(method,'NPT')==1 & isempty(Mmax)==1;
[p1,p2,p3,p4,p5,p6,p7,p8,p9,Mmax,err,BIAS,SD]=Nonpar_tr_O(Ctime,Cmag,0,Mc,Mmax,Nsynth);
Mmax=Mmax+BIAS;
end
cd ../
%% STEP 4: Create Time Windows
time_windows=struct;time_windows.Time=[];
@ -230,7 +244,7 @@ else
%% ------------------------------------------------------------------------------------------------------------------------------------
% BOTH -SEISMIC and PRODUCTION DATA
cd CATALOGS %Seismic Data
cd CATALOGS %Seismic Data
SData=load(SEIS_DATA);
SFields=fileread(SEIS_FIELDS);
cd ../
@ -384,10 +398,13 @@ Cmag=Catalog(id).val;Ctime=Catalog(id_time).val;
end
%% -----------!!!!!!!!!!! HAZARD PARAM<ETERS ESTIMATE FUNCTIONS !!!!!!!!!!!-----------
%% -----------!!!!!!!!!!! HAZARD PARAMETERS ESTIMATE FUNCTIONS !!!!!!!!!!!-----------
function [HP] = TDHMagDistWrapper(method, time_win_data, mmin, iop,Mmax)
cd SSH
for j=1:size(time_win_data,2);M1(j)=max(time_win_data(j).M);end
Mmaxcat=max(M1);Mmax=max([Mmaxcat Mmax])
for i=1:size(time_win_data,2)
mags_vec = time_win_data(i).M;
time_vec = time_win_data(i).Time;
@ -398,31 +415,40 @@ cd SSH
case 'GRU'
try
[HP(i).lamb_all, HP(i).lamb, HP(i).lamb_err, HP(i).unit, HP(i).eps, HP(i).b]=UnlimitGR(time_vec, mags_vec, iop, mmin);
HP(i).Mmax=NaN;
HP(i).Mmax=NaN;eps=HP(i).eps;
[m, PDF_GRU, CDF_GRU]=dist_GRU(mmin,Mmax+eps,eps,mmin,eps,HP(i).b); %K29JAN2020 - magnitude PDF/CDF
HP(i).PDF=[m PDF_GRU];HP(i).CDF=[m CDF_GRU]; %K29JAN2020 - magnitude PDF/CDF
catch err
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).b=NaN;HP(i).Mmax=NaN;
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).b=NaN;HP(i).Mmax=NaN;HP(i).PDF=NaN;HP(i).CDF=NaN;
warning('%s: %s', err.identifier, err.message);
end
case 'GRT'
try
[HP(i).lamb_all, HP(i).lamb, HP(i).lamb_err, HP(i).unit, HP(i).eps, HP(i).b, HP(i).Mmax, HP(i).err]=TruncGR_O(time_vec, mags_vec, iop, mmin,Mmax);
eps=HP(i).eps;[m, PDF_GRT, CDF_GRT]=dist_GRT(mmin,Mmax+eps,eps,mmin,eps,HP(i).b,Mmax); %K29JAN2020 - magnitude PDF/CDF
HP(i).PDF=[m PDF_GRT];HP(i).CDF=[m CDF_GRT]; %K29JAN2020 - magnitude PDF/CDF
catch err
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).b=NaN; HP(i).Mmax=NaN; HP(i).err=NaN;
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).b=NaN; HP(i).Mmax=NaN; HP(i).err=NaN;HP(i).PDF=NaN;HP(i).CDF=NaN;
warning('%s: %s', err.identifier, err.message);
end
case 'NPU'
try
[HP(i).lamb_all, HP(i).lamb, HP(i).lamb_err, HP(i).unit, HP(i).eps, HP(i).ierr, HP(i).h, HP(i).xx, HP(i).ambd]=Nonpar_O(time_vec, mags_vec, iop, mmin);
HP(i).Mmax=NaN;
HP(i).Mmax=NaN;eps=HP(i).eps;
[m, PDF_NPU, CDF_NPU]=dist_NPU(mmin,Mmax+eps,eps,mmin,eps,HP(i).h,HP(i).xx,HP(i).ambd); %K29JAN2020 - magnitude PDF/CDF
HP(i).PDF=[m PDF_NPU];HP(i).CDF=[m CDF_NPU]; %K29JAN2020 - magnitude PDF/CDF
catch err
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).ierr=NaN; HP(i).h=NaN; HP(i).xx=[]; HP(i).ambd=[];HP(i).Mmax=NaN;
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).ierr=NaN; HP(i).h=NaN; HP(i).xx=[]; HP(i).ambd=[];HP(i).Mmax=NaN;HP(i).PDF=NaN;HP(i).CDF=NaN;
warning('%s: %s', err.identifier, err.message);
end
case 'NPT'
try
[HP(i).lamb_all, HP(i).lamb, HP(i).lamb_err, HP(i).unit, HP(i).eps, HP(i).ierr, HP(i).h, HP(i).xx, HP(i).ambd, HP(i).Mmax, HP(i).err]=Nonpar_tr_O(time_vec, mags_vec, iop, mmin,Mmax);
eps=HP(i).eps;
[m, PDF_NPT, CDF_NPT]=dist_NPT(mmin,Mmax+eps,eps,mmin,eps,HP(i).h,HP(i).xx,HP(i).ambd,Mmax); %K29JAN2020 - magnitude PDF/CDF
HP(i).PDF=[m PDF_NPT];HP(i).CDF=[m CDF_NPT]; %K29JAN2020 - magnitude PDF/CDF
catch err
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).ierr=NaN; HP(i).h=NaN; HP(i).xx=[]; HP(i).ambd=[]; HP(i).Mmax=NaN; HP(i).err=NaN;
HP(i).lamb_all=NaN; HP(i).lamb=NaN; HP(i).lamb_err=2; HP(i).unit=''; HP(i).eps=NaN; HP(i).ierr=NaN; HP(i).h=NaN; HP(i).xx=[]; HP(i).ambd=[]; HP(i).Mmax=NaN; HP(i).err=NaN;HP(i).PDF=NaN;HP(i).CDF=NaN;
warning('%s: %s', err.identifier, err.message);
end
end

View File

@ -2,7 +2,7 @@
cd Outputs_SHA
fid=fopen('REPORT_Hazard_Analysis.txt','w');
fprintf(fid,['Parameters Report & Results for HAZARD ANALYSIS (created on ', datestr(now),')\n']);
fprintf(fid,['Parameters Estimated: Mean Return Period (MRP) and Exceedance Probability (EPR) \n']);
fprintf(fid,['Parameters Estimated: Mean Return Period (MRP) and Exceedance Probability (EP) \n']);
fprintf(fid,'------------------------------------------------------------------------------------\n');
fprintf(fid,['<Magnitude Scale Selected >: ', MScale,'\n']);
fprintf(fid,['<Time Unit >: ', Tunit,'\n']);
@ -29,13 +29,13 @@ SN(j)=j;Nevents(j)=numel(time_windows(j).M);TS(j)=time_windows(j).Tstart;TE(j)=t
end
fprintf(fid,[' Set N Starting Date/Time Ending Date/Time events MRP EPR b-value Mmax \n']);
fprintf(fid,[' Set N Starting Date/Time Ending Date/Time events MRP EP b-value Mmax \n']);
fprintf(fid,[' per ',Tunit, ' ',Tunit,'s' '\n']);
for i=1:numel(HP)
if strcmp(method,'GRU')==1 || strcmp(method,'GRT')==1;
fprintf(fid,['%4d %5d %s %s %9.3f %13.3f %13.11f %5.3f %4.2f \n'],SN(i),Nevents(i),datestr(TS(i)),datestr(TE(i)),lambda(i),MRPer(i),ExPr(i),bval(i),HP(i).Mmax);
fprintf(fid,['%4d %5d %s %s %9.3f %13.3f %13.11f %5.3f %4.2f \n'],SN(i),Nevents(i),datestr(TS(i),0),datestr(TE(i),0),lambda(i),MRPer(i),ExPr(i),bval(i),HP(i).Mmax);
else
fprintf(fid,['%4d %5d %s %s %9.3f %13.3f %13.11f %s %4.2f \n'],SN(i),Nevents(i),datestr(TS(i)),datestr(TE(i)),lambda(i),MRPer(i),ExPr(i),'NaN',HP(i).Mmax);
fprintf(fid,['%4d %5d %s %s %9.3f %13.3f %13.11f %s %4.2f \n'],SN(i),Nevents(i),datestr(TS(i),0),datestr(TE(i),0),lambda(i),MRPer(i),ExPr(i),'NaN',HP(i).Mmax);
end
end
@ -64,6 +64,8 @@ for i=1:length(HP)
SHA(i).err=HP(i).err;
else
end
SHA(i).PDF=HP(i).PDF; %K29JAN2020
SHA(i).CDF=HP(i).CDF; %K29JAN2020
end