SHAPE_ver1.0 package for seismic hazard analysis

This commit is contained in:
Konstantinos Leptokaropoulos 2019-09-11 09:52:14 +02:00
parent cc698d85ad
commit 575512fdba
79 changed files with 21470 additions and 0 deletions

View File

@ -0,0 +1,15 @@
Welcome to the Seismic HAzard Parameters Eveluation (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)
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.
ENJOY!

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
Time ML Long Lat Depth

View File

@ -0,0 +1,56 @@
function [Ctime,Cmag,Data,Mc]=FiltDep(Ctime,Cmag,Catalog,s1)
clc
cou=1;
for i=1:length(Catalog)
if strcmp(Catalog(i).field,'Depth')==1
C(cou).field=Catalog(i).field;cou=cou+1;
end
end
if cou==1;error('MyComponent:incorrectType',...
'No Depth column detected!! Please check: Depth field must be noted as "Depth"');end
id=findfield(Catalog,C(cou-1).field);
Cdep=Catalog(id).val;
save('Cdep.mat','Cdep')
out2=ZDepth1;
prompt = {'Enter MIN Depth:','Enter MAX Depth:'};
dlgtitle = 'Depth Range';
dims = [1 35];
definput = {num2str(min(Cdep)),num2str(max(Cdep))};
answer = inputdlg(prompt,dlgtitle,dims,definput);
a1=str2double(answer(1)); a2=str2double(answer(2));
cou=1;
for i=1:length(s1)
x=Catalog(s1(i)).val;x=x(Cdep>=a1 & Cdep<=a2);
index=isnan(x)==0;
x=x(isnan(x)==0);
Data(cou).field=Catalog(s1(i)).field;
Data(cou).fieldType=Catalog(s1(i)).fieldType;
Data(cou).val=nan(size(index)); Data(cou).val(index)=x;
cou=cou+1;
end
Ctime=Ctime(Cdep>=a1 & Cdep<=a2);
Cmag=Cmag(Cdep>=a1 & Cdep<=a2);Mc=min(Cmag);
Cdep=Cdep(Cdep>=a1 & Cdep<=a2);
n=length(Ctime);
disp(['number of events: ',num2str(n)])
end

View File

@ -0,0 +1,63 @@
function [Ctime,Cmag,Data,Mc]=FiltMc(Ctime,Cmag,Catalog,s1)
clc
id_time=findfield(Catalog,'Occurrence_Time');
%opts.Interpreter='tex';opts.Default='Yes';
%quest='Do you wish to filter Data for Mc?';
%answer=questdlg(quest,'Data Completenes','Yes','No',opts);
%if strcmp(answer,'Yes')
%% THIS HAS MOVED TO A SEPARATE FUNCTION IN THE BEGINNING OF THE APPLICATION
% cou=1;
% for i=1:length(Catalog)
% if strcmp(Catalog(i).fieldType,'Magnitude')==1
% C(cou).field=Catalog(i).field;cou=cou+1;
% end
% end
%
% % Check for no magnitude
% if cou==1;error('MyComponent:incorrectType',...
% 'No magnitude column detected!! Please check: Magnitude fields must be noted as one of the following:\nM , Mw , ML , Ms , mb , Md\n or select the entire sample for analysis');end
%
% %Select Parameters from Seismic Catalog -
% [ss1,ok]=listdlg('PromptString','Please Select M scale:',...
% 'ListString',{C.field}, 'SelectionMode','single');
%
% id=findfield(Catalog,C(ss1).field);
% Mtype=Catalog(id).field;
% Ctime=Catalog(id_time).val;
% id_M=findfield(Catalog,Mtype);
% Cmag=Catalog(id_M).val;
%%
ar=min(Cmag):0.1:max(Cmag);
fig_Mc=figure;histogram(Cmag,length(ar));set(gca,'YScale','log')
title('Please Select M_C','FontSize',14);xlabel('M','FontSize',14),ylabel('Log_1_0N','FontSize',14)
% Select events above Mc
[Mc,N]=ginput(1);Mc=floor(10*Mc)/10;close(fig_Mc);
disp(['Mc: ',num2str(Mc)])
% elseif strcmp(answer,'No')
% Ctime=Catalog(id_time).val;Cmag=Ctime;Mc=-20;
% end
cou=1;
for i=1:length(s1)
x=Catalog(s1(i)).val;x=x(Cmag>=Mc);
index=isnan(x)==0;
x=x(isnan(x)==0);
Data(cou).field=Catalog(s1(i)).field;
Data(cou).fieldType=Catalog(s1(i)).fieldType;
Data(cou).val=nan(size(index)); Data(cou).val(index)=x;
cou=cou+1;
end
Ctime=Ctime(Cmag>=Mc);Cmag=Cmag(Cmag>=Mc);
n=length(Ctime);
disp(['number of events: ',num2str(n)])
end

View File

@ -0,0 +1,83 @@
function [Ctime,Cmag,Catalog,Mc]=FiltSpace(Ctime,Cmag,Catalog,s1)
clc
id_time=findfield(Catalog,'Occurrence_Time');
id_X=findfield(Catalog,'X');id_Y=findfield(Catalog,'Y');
id_Lat=findfield(Catalog,'Lat');id_Long=findfield(Catalog,'Long');
% SELECT COORDINATES SYSTEM
if id_X==0;
disp('Only Geopraphical Coordinates are Available')
XCO=Catalog(id_Long).val;YCO=Catalog(id_Lat).val;
elseif id_Lat==0
disp('Only Cartesian Coordinates are Available')
XCO=Catalog(id_X).val;YCO=Catalog(id_Y).val;
else
opts.Interpreter='tex';opts.Default='Geographical';
quest='Please Select Coordinate System:';
answer=questdlg(quest,'Coordinate System','Geographical','Cartesian',opts);
if strcmp(answer,'Geographical')
XCO=Catalog(id_Long).val;YCO=Catalog(id_Lat).val;
else
XCO=Catalog(id_X).val;YCO=Catalog(id_Y).val;
end
end
% AREA SELECTION MODE
opts.Interpreter='tex';opts.Default='Polygon';
quest='Please Choose an Area Selection Mode:';
answer1=questdlg(quest,'Data Selection','Polygon','Circular',opts);
plot(XCO,YCO,'o')
switch answer1
case 'Polygon'
h=drawpolygon;clc
display('Use mouse to define the area, then press any key to continue')
pause
in=inpolygon(XCO,YCO,h.Position(:,1),h.Position(:,2));
Catalog=newCat(Catalog,in,s1);
hold on;plot(XCO(in),YCO(in),'rx')
case 'Circular'
h=drawcircle;clc
display('Use mouse to define the area, then press any key to continue')
pause
in=inpolygon(XCO,YCO,h.Vertices(:,1),h.Vertices(:,2));
Catalog=newCat(Catalog,in,s1);
hold on;plot(XCO(in),YCO(in),'rx')
end
Cmag=Cmag(in);
Ctime=Ctime(in);
Mc=min(Cmag);
pause(1)
close,clc
n=length(Ctime);
disp(['number of events: ',num2str(n)])
end
%Functions
function Data=newCat(Catalog,in,s1)
cou=1;
for i=1:length(s1)
x=Catalog(s1(i)).val(in);
index=isnan(x)==0;
x=x(isnan(x)==0);
Data(cou).field=Catalog(s1(i)).field;
Data(cou).fieldType=Catalog(s1(i)).fieldType;
Data(cou).val=nan(size(index)); Data(cou).val(index)=x;
cou=cou+1;
end
end

View File

@ -0,0 +1,34 @@
function [Ctime,Cmag,Data,Mc]=FiltTime(Ctime,Cmag,Catalog,PROD_Data,s1)
clc
title('Select time period for analysis','FontSize',14,'FontWeight','bold');hold on
plot(Ctime,1:length(Ctime),'-','LineWidth',2);ylabel('Events','FontSize',14);hold on
if isempty(PROD_Data)==0;
yyaxis right; plot(PROD_Data(1).val,PROD_Data(2).val,'-','LineWidth',2);ylabel(PROD_Data(2).field,'FontSize',14,'Interpreter','none');
end
datetick('x',20);xlabel('Date','FontSize',14);xlim([min(Ctime)-1,max(Ctime)+1])
[T,N]=ginput(2);
cou=1;
for i=1:length(s1)
x=Catalog(s1(i)).val;x=x(Ctime>=T(1) & Ctime<=T(2));
index=isnan(x)==0;
x=x(isnan(x)==0);
Data(cou).field=Catalog(s1(i)).field;
Data(cou).fieldType=Catalog(s1(i)).fieldType;
Data(cou).val=nan(size(index));Data(cou).val(index)=x;
cou=cou+1;
end
Cmag=Cmag(Ctime>=T(1) & Ctime<=T(2));Mc=min(Cmag);
Ctime=Ctime(Ctime>=T(1) & Ctime<=T(2));
n=length(Ctime);
disp(['number of events: ',num2str(n)])
close
end

View File

@ -0,0 +1,156 @@
function varargout = Toolbox_SHA_TEST_2(varargin)
%TOOLBOX_SHA_TEST_2 MATLAB code file for Toolbox_SHA_TEST_2.fig
% TOOLBOX_SHA_TEST_2, by itself, creates a new TOOLBOX_SHA_TEST_2 or raises the existing
% singleton*.
%
% H = TOOLBOX_SHA_TEST_2 returns the handle to a new TOOLBOX_SHA_TEST_2 or the handle to
% the existing singleton*.
%
% TOOLBOX_SHA_TEST_2('Property','Value',...) creates a new TOOLBOX_SHA_TEST_2 using the
% given property value pairs. Unrecognized properties are passed via
% varargin to Toolbox_SHA_TEST_2_OpeningFcn. This calling syntax produces a
% warning when there is an existing singleton*.
%
% TOOLBOX_SHA_TEST_2('CALLBACK') and TOOLBOX_SHA_TEST_2('CALLBACK',hObject,...) call the
% local function named CALLBACK in TOOLBOX_SHA_TEST_2.M with the given input
% arguments.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Toolbox_SHA_TEST_2
% Last Modified by GUIDE v2.5 23-May-2019 14:48:12
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Toolbox_SHA_TEST_2_OpeningFcn, ...
'gui_OutputFcn', @Toolbox_SHA_TEST_2_OutputFcn, ...
'gui_LayoutFcn', [], ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Toolbox_SHA_TEST_2 is made visible.
function Toolbox_SHA_TEST_2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin unrecognized PropertyName/PropertyValue pairs from the command line (see VARARGIN)
% Choose default command line output for Toolbox_SHA_TEST_2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Toolbox_SHA_TEST_2 wait for user response (see UIRESUME)
uiwait(handles.figure1);
set(hObject,'toolbar','figure'); % Toolbar appear in the window
set(hObject,'menubar','figure'); % Menubar appear in the window
% --- Outputs from this function are returned to the command line.
function varargout = Toolbox_SHA_TEST_2_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% The figure can be deleted now
delete(handles.figure1);
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = 1;
% Update handles structure
guidata(hObject, handles);
% Use UIRESUME instead of delete because the OutputFcn needs
% to get the updated handles structure.
uiresume(handles.figure1);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = 2;
% Update handles structure
guidata(hObject, handles);
% Use UIRESUME instead of delete because the OutputFcn needs
% to get the updated handles structure.
uiresume(handles.figure1);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = 3;
% Update handles structure
guidata(hObject, handles);
% Use UIRESUME instead of delete because the OutputFcn needs
% to get the updated handles structure.
uiresume(handles.figure1);
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = 4;
% Update handles structure
guidata(hObject, handles);
% Use UIRESUME instead of delete because the OutputFcn needs
% to get the updated handles structure.
uiresume(handles.figure1);
% --- Executes when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isequal(get(hObject, 'waitstatus'), 'waiting')
% The GUI is still in UIWAIT, us UIRESUME
uiresume(hObject);
else
% The GUI is no longer waiting, just close it
delete(hObject);
end

Binary file not shown.

View File

@ -0,0 +1,208 @@
function varargout = ZDepth1(varargin)
%ZDEPTH1 MATLAB code file for ZDepth1.fig
% ZDEPTH1, by itself, creates a new ZDEPTH1 or raises the existing
% singleton*.
%
% H = ZDEPTH1 returns the handle to a new ZDEPTH1 or the handle to
% the existing singleton*.
%
% ZDEPTH1('Property','Value',...) creates a new ZDEPTH1 using the
% given property value pairs. Unrecognized properties are passed via
% varargin to ZDepth1_OpeningFcn. This calling syntax produces a
% warning when there is an existing singleton*.
%
% ZDEPTH1('CALLBACK') and ZDEPTH1('CALLBACK',hObject,...) call the
% local function named CALLBACK in ZDEPTH1.M with the given input
% arguments.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help ZDepth1
% Last Modified by GUIDE v2.5 30-Apr-2019 09:43:33
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @ZDepth1_OpeningFcn, ...
'gui_OutputFcn', @ZDepth1_OutputFcn, ...
'gui_LayoutFcn', [], ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before ZDepth1 is made visible.
function ZDepth1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% Choose default command line output for ZDepth1
load Cdep.mat
ar=min(Cdep):0.1:max(Cdep);
subplot(1,2,2);plot(-Cdep,'o');axis square;xlabel('Events','FontSize',14);
ylabel('Depth','FontSize',14);title('Depth Distribution','FontSize',14)
subplot(1,2,1);histogram(Cdep,10);set(gca,'YScale','linear');axis square
title('Depth Histogram','FontSize',14);xlabel('Depth','FontSize',14),ylabel('Events Count','FontSize',14)
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes ZDepth1 wait for user response (see UIRESUME)
uiwait(handles.output);
set(hObject,'toolbar','figure'); % Toolbar appear in the window
set(hObject,'menubar','figure'); % Menubar appear in the window
% --- Outputs from this function are returned to the command line.
function varargout = ZDepth1_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
delete(handles.output)
% --- Executes during object creation, after setting all properties.
function Histo_CreateFcn(hObject, eventdata, handles)
% hObject handle to Histo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate Histo
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Nb=str2double(get(handles.edit3,'string'));
h=findobj(gca,'Type','histogram');
hold off;histogram(h.Data,Nb);axis square;title('Depth Histogram','FontSize',14);
xlabel('Depth','FontSize',14),ylabel('Events Count','FontSize',14)
guidata(hObject, handles);
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
uiresume(handles.output);
delete Cdep.mat
% --- Executes when user attempts to close CloseF.
function CloseF_CloseRequestFcn(hObject, eventdata, handles)
% hObject handle to CloseF (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: delete(hObject) closes the figure
if isequal(get(hObject, 'waitstatus'), 'waiting')
% The GUI is still in UIWAIT, us UIRESUME
uiresume(hObject);
else
% The GUI is no longer waiting, just close it
delete(hObject);
end

View File

@ -0,0 +1,11 @@
% finds a field defined by a certain (string) name
function [id] = findfield( catalog,field )
id=0;
j=1;
while j <= size(catalog,2) && id==0
if (strcmp(catalog(j).field,field)==1)
id=j;
end
j=j+1;
end
end

View File

@ -0,0 +1,833 @@
2013 08 23 00 00 00 139.89
2013 08 24 00 00 00 140.04
2013 08 25 00 00 00 140.32
2013 08 26 00 00 00 140.44
2013 08 27 00 00 00 140.34
2013 08 28 00 00 00 140.29
2013 08 29 00 00 00 140.42
2013 08 30 00 00 00 140.34
2013 08 31 00 00 00 140.21
2013 09 01 00 00 00 140.2
2013 09 02 00 00 00 140.3
2013 09 03 00 00 00 140.22
2013 09 04 00 00 00 140.16
2013 09 05 00 00 00 140.18
2013 09 06 00 00 00 140.19
2013 09 07 00 00 00 140.33
2013 09 08 00 00 00 140.32
2013 09 09 00 00 00 140.33
2013 09 10 00 00 00 140.38
2013 09 11 00 00 00 140.38
2013 09 12 00 00 00 140.92
2013 09 13 00 00 00 141.03
2013 09 14 00 00 00 140.95
2013 09 15 00 00 00 141.65
2013 09 16 00 00 00 141.27
2013 09 17 00 00 00 141.01
2013 09 18 00 00 00 142.7
2013 09 19 00 00 00 144.12
2013 09 20 00 00 00 144.04
2013 09 21 00 00 00 143.65
2013 09 22 00 00 00 143.16
2013 09 23 00 00 00 142.71
2013 09 24 00 00 00 142.21
2013 09 25 00 00 00 141.48
2013 09 26 00 00 00 141.46
2013 09 27 00 00 00 141.5
2013 09 28 00 00 00 141.29
2013 09 29 00 00 00 141.03
2013 09 30 00 00 00 140.56
2013 10 01 00 00 00 140.2
2013 10 02 00 00 00 145.84
2013 10 03 00 00 00 151.98
2013 10 04 00 00 00 155.71
2013 10 05 00 00 00 157.51
2013 10 06 00 00 00 158.13
2013 10 07 00 00 00 158.26
2013 10 08 00 00 00 158.1
2013 10 09 00 00 00 157.78
2013 10 10 00 00 00 157.36
2013 10 11 00 00 00 156.84
2013 10 12 00 00 00 156.28
2013 10 13 00 00 00 155.69
2013 10 14 00 00 00 154.99
2013 10 15 00 00 00 157.77
2013 10 16 00 00 00 158.99
2013 10 17 00 00 00 158.86
2013 10 18 00 00 00 158.67
2013 10 19 00 00 00 158.33
2013 10 20 00 00 00 158.13
2013 10 21 00 00 00 158.12
2013 10 22 00 00 00 157.84
2013 10 23 00 00 00 157.43
2013 10 24 00 00 00 156.91
2013 10 25 00 00 00 156.32
2013 10 26 00 00 00 155.68
2013 10 27 00 00 00 155.03
2013 10 28 00 00 00 154.33
2013 10 29 00 00 00 153.55
2013 10 30 00 00 00 152.81
2013 10 31 00 00 00 152.03
2013 11 01 00 00 00 151.16
2013 11 02 00 00 00 151.23
2013 11 03 00 00 00 149.37
2013 11 04 00 00 00 148.41
2013 11 05 00 00 00 147.61
2013 11 06 00 00 00 149.06
2013 11 07 00 00 00 154.63
2013 11 08 00 00 00 157.7
2013 11 09 00 00 00 158.46
2013 11 10 00 00 00 159.1
2013 11 11 00 00 00 159.46
2013 11 12 00 00 00 159.39
2013 11 13 00 00 00 159.14
2013 11 14 00 00 00 158.91
2013 11 15 00 00 00 163.76
2013 11 16 00 00 00 164.31
2013 11 17 00 00 00 164.34
2013 11 18 00 00 00 163.4
2013 11 19 00 00 00 162.6
2013 11 20 00 00 00 162.52
2013 11 21 00 00 00 162.12
2013 11 22 00 00 00 161.8
2013 11 23 00 00 00 161.6
2013 11 24 00 00 00 161.41
2013 11 25 00 00 00 161.21
2013 11 26 00 00 00 161.05
2013 11 27 00 00 00 160.83
2013 11 28 00 00 00 160.6
2013 11 29 00 00 00 160.97
2013 11 30 00 00 00 161.24
2013 12 01 00 00 00 161.25
2013 12 02 00 00 00 161.13
2013 12 03 00 00 00 160.96
2013 12 04 00 00 00 160.69
2013 12 05 00 00 00 160.33
2013 12 06 00 00 00 159.89
2013 12 07 00 00 00 159.37
2013 12 08 00 00 00 158.79
2013 12 09 00 00 00 158.28
2013 12 10 00 00 00 157.97
2013 12 11 00 00 00 157.95
2013 12 12 00 00 00 158.13
2013 12 13 00 00 00 158.58
2013 12 14 00 00 00 158.71
2013 12 15 00 00 00 158.99
2013 12 16 00 00 00 158.37
2013 12 17 00 00 00 159.5
2013 12 18 00 00 00 159.72
2013 12 19 00 00 00 159.95
2013 12 20 00 00 00 160.39
2013 12 21 00 00 00 160.82
2013 12 22 00 00 00 161.25
2013 12 23 00 00 00 161.54
2013 12 24 00 00 00 161.99
2013 12 25 00 00 00 162.37
2013 12 27 00 00 00 163.07
2013 12 28 00 00 00 163.41
2013 12 29 00 00 00 163.73
2013 12 30 00 00 00 164.04
2014 01 01 00 00 00 164.42
2014 01 02 00 00 00 163.74
2014 01 03 00 00 00 164.7
2014 01 04 00 00 00 164.74
2014 01 05 00 00 00 164.78
2014 01 06 00 00 00 164.9
2014 01 07 00 00 00 164.98
2014 01 08 00 00 00 164.96
2014 01 09 00 00 00 164.89
2014 01 10 00 00 00 164.88
2014 01 11 00 00 00 164.94
2014 01 13 00 00 00 165.34
2014 01 14 00 00 00 165.69
2014 01 15 00 00 00 165.82
2014 01 16 00 00 00 165.85
2014 01 17 00 00 00 165.74
2014 01 18 00 00 00 165.66
2014 01 19 00 00 00 165.58
2014 01 20 00 00 00 165.59
2014 01 21 00 00 00 165.62
2014 01 22 00 00 00 165.66
2014 01 23 00 00 00 165.73
2014 01 24 00 00 00 165.63
2014 01 25 00 00 00 165.53
2014 01 26 00 00 00 165.45
2014 01 27 00 00 00 165.38
2014 01 28 00 00 00 165.4
2014 01 29 00 00 00 165.55
2014 01 30 00 00 00 165.62
2014 01 31 00 00 00 165.58
2014 02 01 00 00 00 165.54
2014 02 02 00 00 00 165.49
2014 02 03 00 00 00 165.51
2014 02 04 00 00 00 165.43
2014 02 05 00 00 00 165.35
2014 02 06 00 00 00 165.3
2014 02 07 00 00 00 165.23
2014 02 08 00 00 00 165.07
2014 02 09 00 00 00 164.99
2014 02 10 00 00 00 164.97
2014 02 11 00 00 00 164.94
2014 02 12 00 00 00 164.95
2014 02 13 00 00 00 164.91
2014 02 14 00 00 00 164.93
2014 02 15 00 00 00 164.91
2014 02 16 00 00 00 164.7
2014 02 17 00 00 00 164.62
2014 02 18 00 00 00 164.49
2014 02 19 00 00 00 164.39
2014 02 20 00 00 00 164.38
2014 02 21 00 00 00 164.38
2014 02 22 00 00 00 164.3
2014 02 23 00 00 00 164.25
2014 02 24 00 00 00 164.24
2014 02 25 00 00 00 164.19
2014 02 26 00 00 00 164.16
2014 02 27 00 00 00 164.14
2014 02 28 00 00 00 164.05
2014 03 01 00 00 00 163.96
2014 03 02 00 00 00 163.99
2014 03 03 00 00 00 163.96
2014 03 04 00 00 00 163.93
2014 03 05 00 00 00 163.99
2014 03 06 00 00 00 164.04
2014 03 07 00 00 00 164
2014 03 08 00 00 00 163.85
2014 03 09 00 00 00 163.75
2014 03 10 00 00 00 163.66
2014 03 11 00 00 00 163.54
2014 03 12 00 00 00 163.37
2014 03 13 00 00 00 163.16
2014 03 14 00 00 00 162.94
2014 03 15 00 00 00 162.73
2014 03 16 00 00 00 162.75
2014 03 17 00 00 00 162.72
2014 03 18 00 00 00 162.26
2014 03 19 00 00 00 161.68
2014 03 20 00 00 00 161.27
2014 03 21 00 00 00 160.99
2014 03 22 00 00 00 160.67
2014 03 23 00 00 00 160.59
2014 03 24 00 00 00 160.76
2014 03 25 00 00 00 160.9
2014 03 26 00 00 00 161.01
2014 03 27 00 00 00 161.13
2014 03 28 00 00 00 161.11
2014 03 29 00 00 00 160.87
2014 03 30 00 00 00 160.62
2014 03 31 00 00 00 160.37
2014 04 01 00 00 00 160.12
2014 04 02 00 00 00 160.03
2014 04 03 00 00 00 160.15
2014 04 04 00 00 00 160.29
2014 04 05 00 00 00 160.5
2014 04 06 00 00 00 160.78
2014 04 07 00 00 00 160.86
2014 04 08 00 00 00 160.78
2014 04 09 00 00 00 160.69
2014 04 10 00 00 00 160.62
2014 04 11 00 00 00 160.36
2014 04 12 00 00 00 160.38
2014 04 13 00 00 00 160.51
2014 04 14 00 00 00 160.63
2014 04 15 00 00 00 160.73
2014 04 16 00 00 00 160.83
2014 04 17 00 00 00 160.8
2014 04 18 00 00 00 160.64
2014 04 19 00 00 00 160.44
2014 04 20 00 00 00 160.34
2014 04 21 00 00 00 160.22
2014 04 22 00 00 00 159.49
2014 04 23 00 00 00 158.81
2014 04 24 00 00 00 158.2
2014 04 25 00 00 00 158.25
2014 04 26 00 00 00 158.34
2014 04 27 00 00 00 158.45
2014 04 28 00 00 00 158.45
2014 04 29 00 00 00 158.59
2014 04 30 00 00 00 158.64
2014 05 01 00 00 00 158.74
2014 05 02 00 00 00 159.12
2014 05 03 00 00 00 159.52
2014 05 04 00 00 00 159.91
2014 05 05 00 00 00 160.2
2014 05 06 00 00 00 160.5
2014 05 07 00 00 00 160.82
2014 05 08 00 00 00 161.04
2014 05 09 00 00 00 161.27
2014 05 10 00 00 00 161.36
2014 05 11 00 00 00 161.5
2014 05 12 00 00 00 161.63
2014 05 13 00 00 00 161.83
2014 05 14 00 00 00 161.96
2014 05 15 00 00 00 161.89
2014 05 16 00 00 00 161.62
2014 05 17 00 00 00 161.59
2014 05 18 00 00 00 161.41
2014 05 19 00 00 00 161.2
2014 05 20 00 00 00 161.02
2014 05 21 00 00 00 160.81
2014 05 22 00 00 00 160.4
2014 05 23 00 00 00 159.66
2014 05 24 00 00 00 159.09
2014 05 25 00 00 00 158.79
2014 05 26 00 00 00 158.38
2014 05 27 00 00 00 157.86
2014 05 28 00 00 00 157.05
2014 05 29 00 00 00 156.29
2014 05 30 00 00 00 155.67
2014 05 31 00 00 00 155.03
2014 06 01 00 00 00 154.47
2014 06 02 00 00 00 154.21
2014 06 03 00 00 00 153.67
2014 06 04 00 00 00 153.02
2014 06 05 00 00 00 152.59
2014 06 06 00 00 00 152.23
2014 06 07 00 00 00 151.8
2014 06 08 00 00 00 151.61
2014 06 09 00 00 00 151.67
2014 06 10 00 00 00 151.38
2014 06 11 00 00 00 150.87
2014 06 12 00 00 00 150.24
2014 06 13 00 00 00 149.65
2014 06 14 00 00 00 149.27
2014 06 15 00 00 00 148.86
2014 06 16 00 00 00 148.54
2014 06 17 00 00 00 148.33
2014 06 18 00 00 00 148.48
2014 06 19 00 00 00 148.58
2014 06 20 00 00 00 148.56
2014 06 21 00 00 00 148.34
2014 06 22 00 00 00 147.96
2014 06 23 00 00 00 147.51
2014 06 24 00 00 00 147.04
2014 06 25 00 00 00 146.6
2014 06 26 00 00 00 146.17
2014 06 27 00 00 00 145.89
2014 06 28 00 00 00 145.96
2014 06 29 00 00 00 146.13
2014 06 30 00 00 00 146.39
2014 07 01 00 00 00 146.39
2014 07 02 00 00 00 146.4
2014 07 03 00 00 00 145.64
2014 07 04 00 00 00 145.25
2014 07 05 00 00 00 145.09
2014 07 06 00 00 00 145.28
2014 07 07 00 00 00 144.68
2014 07 08 00 00 00 144.73
2014 07 09 00 00 00 144.84
2014 07 10 00 00 00 145
2014 07 11 00 00 00 144.97
2014 07 12 00 00 00 144.6
2014 07 13 00 00 00 144.3
2014 07 14 00 00 00 144
2014 07 15 00 00 00 143.66
2014 07 16 00 00 00 143.24
2014 07 17 00 00 00 143.02
2014 07 18 00 00 00 143.22
2014 07 19 00 00 00 143.38
2014 07 20 00 00 00 143.47
2014 07 21 00 00 00 143.43
2014 07 22 00 00 00 143.01
2014 07 23 00 00 00 142.84
2014 07 24 00 00 00 143.36
2014 07 25 00 00 00 142.12
2014 07 26 00 00 00 141.72
2014 07 27 00 00 00 141.6
2014 07 28 00 00 00 141.95
2014 07 29 00 00 00 142.23
2014 07 30 00 00 00 142.76
2014 07 31 00 00 00 142.96
2014 08 01 00 00 00 143.06
2014 08 02 00 00 00 142.86
2014 08 03 00 00 00 142.63
2014 08 04 00 00 00 142.37
2014 08 05 00 00 00 142.08
2014 08 06 00 00 00 141.96
2014 08 07 00 00 00 142.19
2014 08 08 00 00 00 142.4
2014 08 09 00 00 00 142.58
2014 08 10 00 00 00 142.57
2014 08 11 00 00 00 142.17
2014 08 12 00 00 00 141.79
2014 08 13 00 00 00 141.43
2014 08 14 00 00 00 141.05
2014 08 15 00 00 00 140.7
2014 08 16 00 00 00 140.68
2014 08 17 00 00 00 140.93
2014 08 18 00 00 00 141.13
2014 08 19 00 00 00 141.1
2014 08 20 00 00 00 140.75
2014 08 21 00 00 00 140.69
2014 08 22 00 00 00 141.01
2014 08 23 00 00 00 141.33
2014 08 24 00 00 00 141.6
2014 08 25 00 00 00 141.8
2014 08 26 00 00 00 142.06
2014 08 27 00 00 00 142.39
2014 08 28 00 00 00 142.75
2014 08 29 00 00 00 143.02
2014 08 30 00 00 00 143.44
2014 08 31 00 00 00 143.87
2014 09 01 00 00 00 145.92
2014 09 02 00 00 00 146.24
2014 09 03 00 00 00 146.81
2014 09 04 00 00 00 147.26
2014 09 05 00 00 00 147.58
2014 09 06 00 00 00 147.71
2014 09 07 00 00 00 147.87
2014 09 08 00 00 00 148.08
2014 09 09 00 00 00 148.46
2014 09 10 00 00 00 148.58
2014 09 11 00 00 00 148.15
2014 09 12 00 00 00 147.39
2014 09 13 00 00 00 146.9
2014 09 14 00 00 00 146.85
2014 09 15 00 00 00 146.66
2014 09 16 00 00 00 145.9
2014 09 17 00 00 00 145.4
2014 09 18 00 00 00 145.19
2014 09 19 00 00 00 145.01
2014 09 20 00 00 00 145.11
2014 09 21 00 00 00 145.44
2014 09 22 00 00 00 145.72
2014 09 23 00 00 00 145.87
2014 09 24 00 00 00 146.57
2014 09 25 00 00 00 146.94
2014 09 26 00 00 00 147.25
2014 09 27 00 00 00 147.61
2014 09 28 00 00 00 147.92
2014 09 29 00 00 00 148.23
2014 09 30 00 00 00 148.53
2014 10 01 00 00 00 148.68
2014 10 02 00 00 00 148.67
2014 10 03 00 00 00 148.35
2014 10 04 00 00 00 147.9
2014 10 05 00 00 00 147.96
2014 10 06 00 00 00 148.34
2014 10 07 00 00 00 148.53
2014 10 08 00 00 00 149.56
2014 10 09 00 00 00 149.92
2014 10 10 00 00 00 149.94
2014 10 11 00 00 00 149.82
2014 10 12 00 00 00 149.55
2014 10 13 00 00 00 149.43
2014 10 14 00 00 00 148.95
2014 10 15 00 00 00 148.6
2014 10 16 00 00 00 148.33
2014 10 17 00 00 00 148.31
2014 10 18 00 00 00 148.4
2014 10 19 00 00 00 149.27
2014 10 20 00 00 00 149.57
2014 10 21 00 00 00 149.02
2014 10 22 00 00 00 148.84
2014 10 23 00 00 00 149.12
2014 10 24 00 00 00 149.12
2014 10 25 00 00 00 149.37
2014 10 26 00 00 00 150.5
2014 10 27 00 00 00 151.23
2014 10 28 00 00 00 151.17
2014 10 29 00 00 00 150.73
2014 10 30 00 00 00 150.42
2014 10 31 00 00 00 150.19
2014 11 01 00 00 00 150.07
2014 11 02 00 00 00 149.75
2014 11 03 00 00 00 149.66
2014 11 04 00 00 00 149.23
2014 11 05 00 00 00 148.96
2014 11 06 00 00 00 149.09
2014 11 07 00 00 00 149.34
2014 11 08 00 00 00 149.84
2014 11 09 00 00 00 150.31
2014 11 10 00 00 00 150.63
2014 11 11 00 00 00 150.76
2014 11 12 00 00 00 150.89
2014 11 13 00 00 00 151.55
2014 11 14 00 00 00 153.94
2014 11 15 00 00 00 156.7
2014 11 16 00 00 00 158.48
2014 11 17 00 00 00 159.22
2014 11 18 00 00 00 159.51
2014 11 19 00 00 00 159.47
2014 11 20 00 00 00 159.62
2014 11 21 00 00 00 159.73
2014 11 22 00 00 00 159.78
2014 11 23 00 00 00 160.01
2014 11 24 00 00 00 160.38
2014 11 25 00 00 00 160.44
2014 11 26 00 00 00 160.52
2014 11 27 00 00 00 160.65
2014 11 28 00 00 00 160.78
2014 11 29 00 00 00 160.98
2014 11 30 00 00 00 161.45
2014 12 01 00 00 00 162.55
2014 12 02 00 00 00 162.91
2014 12 03 00 00 00 163.15
2014 12 04 00 00 00 163.01
2014 12 05 00 00 00 163.36
2014 12 06 00 00 00 163.98
2014 12 07 00 00 00 164.71
2014 12 08 00 00 00 164.92
2014 12 09 00 00 00 165.15
2014 12 10 00 00 00 165.02
2014 12 11 00 00 00 164.78
2014 12 12 00 00 00 165.08
2014 12 13 00 00 00 165.33
2014 12 14 00 00 00 165.39
2014 12 15 00 00 00 165.25
2014 12 16 00 00 00 165.36
2014 12 17 00 00 00 165.8
2014 12 18 00 00 00 165.82
2014 12 19 00 00 00 165.67
2014 12 20 00 00 00 165.41
2014 12 21 00 00 00 165.2
2014 12 22 00 00 00 165.32
2014 12 23 00 00 00 165.57
2014 12 24 00 00 00 165.36
2014 12 25 00 00 00 165.31
2014 12 26 00 00 00 165.42
2014 12 27 00 00 00 165.75
2014 12 28 00 00 00 165.99
2014 12 29 00 00 00 166
2014 12 30 00 00 00 166.06
2014 12 31 00 00 00 166.79
2015 01 01 00 00 00 167.54
2015 01 02 00 00 00 168.16
2015 01 03 00 00 00 168.72
2015 01 04 00 00 00 169.3
2015 01 05 00 00 00 169.77
2015 01 06 00 00 00 170.17
2015 01 07 00 00 00 170.74
2015 01 08 00 00 00 171.51
2015 01 09 00 00 00 171.91
2015 01 10 00 00 00 172
2015 01 11 00 00 00 172
2015 01 12 00 00 00 171.97
2015 01 13 00 00 00 171.77
2015 01 14 00 00 00 171.53
2015 01 15 00 00 00 171.22
2015 01 16 00 00 00 170.97
2015 01 17 00 00 00 170.68
2015 01 18 00 00 00 170.65
2015 01 19 00 00 00 170.78
2015 01 20 00 00 00 170.93
2015 01 21 00 00 00 171.05
2015 01 22 00 00 00 171.07
2015 01 23 00 00 00 171.04
2015 01 24 00 00 00 170.99
2015 01 25 00 00 00 170.94
2015 01 26 00 00 00 170.91
2015 01 27 00 00 00 170.95
2015 01 28 00 00 00 170.93
2015 01 29 00 00 00 171.02
2015 01 30 00 00 00 171.05
2015 01 31 00 00 00 171.1
2015 02 01 00 00 00 171.28
2015 02 02 00 00 00 171.57
2015 02 03 00 00 00 171.29
2015 02 04 00 00 00 170.9
2015 02 05 00 00 00 170.82
2015 02 06 00 00 00 170.77
2015 02 07 00 00 00 170.73
2015 02 08 00 00 00 170.66
2015 02 09 00 00 00 170.6
2015 02 10 00 00 00 170.53
2015 02 11 00 00 00 170.4
2015 02 12 00 00 00 170.37
2015 02 13 00 00 00 170.34
2015 02 14 00 00 00 170.4
2015 02 15 00 00 00 170.58
2015 02 16 00 00 00 170.63
2015 02 17 00 00 00 170.64
2015 02 18 00 00 00 170.8
2015 02 19 00 00 00 170.88
2015 02 20 00 00 00 171.11
2015 02 21 00 00 00 171.33
2015 02 22 00 00 00 171.59
2015 02 23 00 00 00 171.72
2015 02 24 00 00 00 171.69
2015 02 25 00 00 00 171.53
2015 02 26 00 00 00 171.47
2015 02 27 00 00 00 171.46
2015 02 28 00 00 00 171.38
2015 03 01 00 00 00 171.37
2015 03 02 00 00 00 171.35
2015 03 03 00 00 00 171.27
2015 03 04 00 00 00 171.15
2015 03 05 00 00 00 171.04
2015 03 06 00 00 00 170.9
2015 03 07 00 00 00 170.82
2015 03 08 00 00 00 170.7
2015 03 09 00 00 00 170.57
2015 03 10 00 00 00 170.55
2015 03 11 00 00 00 170.69
2015 03 12 00 00 00 170.86
2015 03 13 00 00 00 170.95
2015 03 14 00 00 00 170.88
2015 03 15 00 00 00 170.76
2015 03 16 00 00 00 170.5
2015 03 17 00 00 00 170.29
2015 03 18 00 00 00 170.17
2015 03 19 00 00 00 169.91
2015 03 20 00 00 00 169.5
2015 03 21 00 00 00 169.28
2015 04 01 00 00 00 170.68
2015 04 02 00 00 00 170.36
2015 04 03 00 00 00 170.02
2015 04 04 00 00 00 169.7
2015 04 05 00 00 00 169.55
2015 04 06 00 00 00 169.41
2015 04 07 00 00 00 169.04
2015 04 08 00 00 00 168.37
2015 04 09 00 00 00 167.64
2015 04 10 00 00 00 167.32
2015 04 11 00 00 00 167.49
2015 04 12 00 00 00 167.63
2015 04 13 00 00 00 167.87
2015 04 14 00 00 00 168.05
2015 04 15 00 00 00 168.21
2015 04 16 00 00 00 168.34
2015 04 17 00 00 00 168.48
2015 04 18 00 00 00 168.61
2015 04 19 00 00 00 168.75
2015 04 20 00 00 00 168.89
2015 04 21 00 00 00 169.01
2015 04 22 00 00 00 169.18
2015 04 23 00 00 00 169.09
2015 04 24 00 00 00 168.78
2015 04 25 00 00 00 168.29
2015 04 26 00 00 00 167.85
2015 04 27 00 00 00 167.34
2015 04 28 00 00 00 167.01
2015 04 29 00 00 00 166.79
2015 04 30 00 00 00 166.7
2015 05 01 00 00 00 166.83
2015 05 02 00 00 00 166.65
2015 05 03 00 00 00 166.01
2015 05 04 00 00 00 165.45
2015 05 05 00 00 00 164.61
2015 05 06 00 00 00 163.86
2015 05 07 00 00 00 163.36
2015 05 08 00 00 00 163.02
2015 05 09 00 00 00 162.73
2015 05 10 00 00 00 162.81
2015 05 11 00 00 00 162.93
2015 05 12 00 00 00 162.76
2015 05 13 00 00 00 162.54
2015 05 14 00 00 00 162.36
2015 05 15 00 00 00 162.19
2015 05 16 00 00 00 162.03
2015 05 17 00 00 00 161.93
2015 05 18 00 00 00 161.79
2015 05 19 00 00 00 161.38
2015 05 20 00 00 00 160.79
2015 05 21 00 00 00 160.15
2015 05 22 00 00 00 159.43
2015 05 23 00 00 00 158.84
2015 05 24 00 00 00 158.38
2015 05 25 00 00 00 158
2015 05 26 00 00 00 157.48
2015 05 27 00 00 00 157.09
2015 05 28 00 00 00 156.77
2015 05 29 00 00 00 156.41
2015 05 30 00 00 00 156.06
2015 05 31 00 00 00 155.75
2015 06 01 00 00 00 155.45
2015 06 02 00 00 00 155.02
2015 06 03 00 00 00 154.79
2015 06 04 00 00 00 154.45
2015 06 05 00 00 00 154.18
2015 06 06 00 00 00 153.97
2015 06 07 00 00 00 153.78
2015 06 08 00 00 00 153.53
2015 06 09 00 00 00 153.28
2015 06 10 00 00 00 153.1
2015 06 11 00 00 00 152.48
2015 06 12 00 00 00 152.02
2015 06 13 00 00 00 152.06
2015 06 14 00 00 00 151.98
2015 06 15 00 00 00 152.06
2015 06 16 00 00 00 151.69
2015 06 17 00 00 00 151.11
2015 06 18 00 00 00 150.89
2015 06 19 00 00 00 150.73
2015 06 20 00 00 00 150.5
2015 06 21 00 00 00 150.41
2015 06 22 00 00 00 150.56
2015 06 23 00 00 00 150.56
2015 06 24 00 00 00 150.44
2015 06 25 00 00 00 150.18
2015 06 26 00 00 00 149.74
2015 06 28 00 00 00 149.24
2015 06 29 00 00 00 148.92
2015 06 30 00 00 00 148.5
2015 07 01 00 00 00 148.19
2015 07 02 00 00 00 148.16
2015 07 03 00 00 00 147.92
2015 07 04 00 00 00 147.4
2015 07 05 00 00 00 147.07
2015 07 06 00 00 00 146.79
2015 07 07 00 00 00 146.46
2015 07 08 00 00 00 146.11
2015 07 09 00 00 00 145.9
2015 07 10 00 00 00 146.13
2015 07 11 00 00 00 146.38
2015 07 12 00 00 00 146.58
2015 07 13 00 00 00 146.57
2015 07 14 00 00 00 146.36
2015 07 15 00 00 00 146.08
2015 07 16 00 00 00 145.89
2015 07 17 00 00 00 146.06
2015 07 18 00 00 00 146.2
2015 07 19 00 00 00 146.45
2015 07 21 00 00 00 146.53
2015 07 22 00 00 00 146.16
2015 07 23 00 00 00 145.81
2015 07 24 00 00 00 145.4
2015 07 25 00 00 00 145.02
2015 07 26 00 00 00 144.61
2015 07 27 00 00 00 144.41
2015 07 28 00 00 00 144.51
2015 07 29 00 00 00 144.65
2015 07 30 00 00 00 144.82
2015 07 31 00 00 00 144.75
2015 08 01 00 00 00 144.38
2015 08 02 00 00 00 144.01
2015 08 03 00 00 00 143.67
2015 08 04 00 00 00 143.49
2015 08 05 00 00 00 143.19
2015 08 06 00 00 00 143.28
2015 08 07 00 00 00 144.03
2015 08 08 00 00 00 144.44
2015 08 09 00 00 00 144.81
2015 08 10 00 00 00 145.19
2015 08 11 00 00 00 145.23
2015 08 12 00 00 00 145.14
2015 08 13 00 00 00 144.96
2015 08 14 00 00 00 144.69
2015 08 15 00 00 00 144.43
2015 08 16 00 00 00 144.29
2015 08 17 00 00 00 144.5
2015 08 18 00 00 00 144.68
2015 08 19 00 00 00 144.82
2015 08 20 00 00 00 144.8
2015 08 21 00 00 00 144.59
2015 08 22 00 00 00 144.34
2015 08 23 00 00 00 144.07
2015 08 24 00 00 00 143.76
2015 08 25 00 00 00 143.56
2015 08 26 00 00 00 143.36
2015 08 27 00 00 00 143.1
2015 08 28 00 00 00 143.02
2015 08 29 00 00 00 143.23
2015 08 30 00 00 00 143.44
2015 08 31 00 00 00 143.66
2015 09 01 00 00 00 143.65
2015 09 02 00 00 00 143.54
2015 09 03 00 00 00 143.49
2015 09 04 00 00 00 143.07
2015 09 05 00 00 00 142.88
2015 09 06 00 00 00 142.52
2015 09 07 00 00 00 142.25
2015 09 08 00 00 00 142.1
2015 09 09 00 00 00 141.67
2015 09 10 00 00 00 141.23
2015 09 11 00 00 00 141.09
2015 09 12 00 00 00 141.34
2015 09 13 00 00 00 141.58
2015 09 14 00 00 00 143.4
2015 09 15 00 00 00 145.38
2015 09 16 00 00 00 145.63
2015 09 17 00 00 00 145.5
2015 09 18 00 00 00 145.83
2015 09 19 00 00 00 145.83
2015 09 20 00 00 00 146.99
2015 09 21 00 00 00 147.36
2015 09 22 00 00 00 147.87
2015 09 23 00 00 00 148.38
2015 09 24 00 00 00 148.9
2015 09 25 00 00 00 148.9
2015 09 26 00 00 00 148.95
2015 09 27 00 00 00 149.1
2015 09 28 00 00 00 149.23
2015 09 29 00 00 00 149.2
2015 09 30 00 00 00 149.51
2015 10 01 00 00 00 149.74
2015 10 02 00 00 00 149.86
2015 10 03 00 00 00 150.14
2015 10 04 00 00 00 150.71
2015 10 05 00 00 00 151.05
2015 10 06 00 00 00 151.22
2015 10 07 00 00 00 151.62
2015 10 08 00 00 00 151.85
2015 10 09 00 00 00 152.43
2015 10 10 00 00 00 153.08
2015 10 11 00 00 00 153.95
2015 10 12 00 00 00 154.78
2015 10 13 00 00 00 155.47
2015 10 14 00 00 00 155.95
2015 10 15 00 00 00 157.32
2015 10 16 00 00 00 158.11
2015 10 17 00 00 00 158.41
2015 10 18 00 00 00 158.8
2015 10 19 00 00 00 159
2015 10 20 00 00 00 158.73
2015 10 21 00 00 00 158.59
2015 10 22 00 00 00 158.56
2015 10 23 00 00 00 158.61
2015 10 24 00 00 00 158.78
2015 10 25 00 00 00 158.99
2015 10 28 00 00 00 158.99
2015 11 01 00 00 00 159.93
2015 11 02 00 00 00 162.8
2015 11 03 00 00 00 165.42
2015 11 04 00 00 00 168.01
2015 11 05 00 00 00 170.61
2015 11 06 00 00 00 171.94
2015 11 07 00 00 00 171.96
2015 11 08 00 00 00 171.97
2015 11 09 00 00 00 171.97
2015 11 10 00 00 00 171.93
2015 11 11 00 00 00 171.7
2015 11 12 00 00 00 171.39
2015 11 13 00 00 00 171.02
2015 11 14 00 00 00 170.61
2015 11 15 00 00 00 170.2
2015 11 16 00 00 00 170.01
2015 11 17 00 00 00 169.62
2015 11 18 00 00 00 169.18
2015 11 19 00 00 00 168.85
2015 11 20 00 00 00 168.42
2015 11 21 00 00 00 168.12
2015 11 22 00 00 00 168.09
2015 11 23 00 00 00 168.32
2015 11 24 00 00 00 168.52
2015 11 25 00 00 00 168.84
2015 11 26 00 00 00 168.9
2015 11 27 00 00 00 169.46
2015 11 28 00 00 00 169.79
2015 11 29 00 00 00 169.86
2015 11 30 00 00 00 169.85
2015 12 01 00 00 00 169.76
2015 12 02 00 00 00 169.73
2015 12 03 00 00 00 169.58
2015 12 04 00 00 00 169.48
2015 12 05 00 00 00 169.56
2015 12 06 00 00 00 169.75
2015 12 07 00 00 00 170.14
2015 12 08 00 00 00 170.17
2015 12 09 00 00 00 170.34
2015 12 10 00 00 00 170.3
2015 12 11 00 00 00 170.17
2015 12 12 00 00 00 170.21
2015 12 13 00 00 00 170.34
2015 12 14 00 00 00 170.38
2015 12 15 00 00 00 170.24
2015 12 16 00 00 00 170.66
2015 12 17 00 00 00 171.38
2015 12 18 00 00 00 171.82
2015 12 19 00 00 00 172.3
2015 12 20 00 00 00 172.82
2015 12 21 00 00 00 173.42
2015 12 22 00 00 00 173.88
2015 12 23 00 00 00 174.19

View File

@ -0,0 +1 @@
Date Water_Level

Binary file not shown.

View File

@ -0,0 +1,608 @@
% PROGRAM: SHAPE [Seismic HAzard Parameters Evaluation]
% VERSION: V_1.0 [Interactive Standalone Version]
% LAST UPDATED: September 2019
% COMPATIBLE with Matlab version 2017b or later
% TOOLBOX: "Hazard Analysis Toolbox" within SERA Project
% DOCUMENT: "READ_ME_SHAPE_ver1.pdf"
% --------------------------------------------------------------------------------------------------------------------
% Time-and-Technology Dependent Seismic Hazard Assessment (SHA)
% --------------------------------------------------------------------------------------------------------------------
% INPUT:
% !!! ---------------------------- INPUT DATA REQUIREMENTS ----------------------------- !!!
% the program works with ASCII input data files (e.g. *.txt). The files needed are:
% > File with the parameters of seismic data [mandatory]
% > File with the parameters of production data [optional]
% > File specifying time windows for SHA analysis [optional]
% > Files(s) with the fields description of the corresponding parameters in the seismic data file
% > Files(s) with the fields description of the corresponding parameters in the production data files
% FOR DETAILS on data requirements please refer to the document:
% "READ_ME_SHAPE_ver1.pdf"
% --------------------------------------------------------------------------------------------------------------------
% OVERVIEW:THE PROGRAM takes as input a Seismic and optionally, a Production data parameters files to provides Seismic
% Hazard Assessment for specified time-windows after filtering appropriately the data following User's specifications.
% --------------------------------------------------------------------------------------------------------------------
% AUTHORS: K. Leptokaropoulos,
% Last Updated: 09/2019, within SERA PROJECT, EU Horizon 2020 R&I
% programme under grant agreement No.730900
% CURRENT VERSION: v1.0 **** [INTERACTIVE STANDALONE VERSION!!]
%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% PLEASE refer to the accompanying document:
% "READ_ME_SHAPE_ver1.pdf"
% for description of the Application and its requirements.
%% -----------------------------------------------------------------------------------------------------------------------
% DESCRIPTION: The Application performs time-dependent Seismic Hazard Analysis (SHA),
% taking into account the activity rate and the magnitude distribution of seismicity
% for selected time windows. The hazard parameters estimated are:
% 1) The Mean Return Period (MRP) of a given magnitude, M, which is defined as the
% average elapsed time between the occurrence of consecutive events of M and
% 2) The Exceedance Probability (EPR) of a given magnitude, M, within a given time
% period of length, T, which is defined as the probability of an earthquake of
% M to occur during T.
% These hazard parameters are estimated for different time windows which are constructed
% upon Users particular specifications. 4 different magnitude distribution models can
% be chosen. The input files must be in ASCII format (e.g. *.txt). A brief description
% of the preparation process is given here:
% (please see in the script for more comments and details for each STEP)
% STEP_1. MODE SELECTION: Select '1' for Seismic Data, '2' for both Seismic & Production Data
% STEP_2. DATA SELECTION: Depending on the MODE selection (STEP 1), the user is requested
% here to select data and data field files
% STEP_3. MAGNITUDE SCALE SELECTION
% STEP_4. DATA FILTERING: Before proceeding to Seismic Hazard Analysis the User is given
% the option to filter the data according to
% - Time
% - Epicentral Location
% - Events Depths
% - Magnitude
% STEP_5. TIME WINDOWS GENERATION: The data in here divided according to time windows
% defined by the User, by means of 4 different modes
% - Time
% - Events
% - Graphical
% - Read from File
% STEP_6. SHA PARAMETERS SELECTION: Selection of Magnitude Distribution Model, Time Unit,
% Magnitude(for exceedance probability and mean return period estimate) and Time
% Period (for exceedance probability estimate)
% STEP_7. OUTPUTS: Generate and save output files, and figures
% ---------------------------------------------------------------------------------------------------------------------
%% 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_ver1.pdf"
% ----------------------------------------------------------------------------------------------------------------------
%% OUTPUT:
% <> Output Report with summary of the Results as well as data and parameters used
% <> Output Figure with the results in *.mat and *.jpeg formats
% <> Output Matlab Structure with input parameter values and output results, having
% as many cells as the number of time windows generated.
% Structure fields are:
% - Time : vector with origin times of the events included in each time window
% - M : vector with events magnitudes
% - Mmin : Completeness magnitude
% - eps : Magnitude round-off interval
% - lambd : mean activity rate
% - lambd_err : events number sufficiency (0-all parametes estiamated, 1-all parameters set as NaNs)
% - unit : Time Unit
% - method : Magnitude Distribution Model
% - b : b-value of GR law
% [applies only when "method" is set to 'GRU' or 'GRT']
% - h : Kernel smoothing factor
% [applies only when "method" is set to 'NPU' or 'NPT']
% - xx : Background sample for kernel magnitude estimate
% [applies only when "method" is set to 'NPU' or 'NPT']
% - ambd : weigthing factors for the adaptive kernel
% [applies only when "method" is set to 'NPU' or 'NPT']
% - ierr : h convergence indicator (0-converges,1-multiple zeros, 2-no zeros)
% [applies only when "method" is set to 'NPU' or 'NPT']
% - Mmax : Upper limit of magnitude distribution (truncated)
% [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']
% -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
% 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, 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
% ---------------------------------------------------------------------------------------------------------------------
% 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.
% -------------------------------------------------------------------------------------------------------------------
clear;clc
mkdir Outputs_SHA
set(0, 'DefaultUICOntrolFontSize', 12)
% Browse Directury with Functions
%% *********** STEP_1 and STEP_2: MODE and DATA SELECTION **************
[Catalog,PROD_Data,Mode1,dstr1,dstr2,s,s1,ss,s2]=Data_Hand_A2M;
%% *********** STEP_3: SELECT MAGNITUDE SCALE **************
[Ctime,Cmag,Mtype]=Select_Magnitude_Scale(Catalog);
Mc=min(Cmag);
%% *********** STEP_4: DATA FILTERING **************
% Ask for additional filtering
opts.Interpreter='tex';opts.Default='Yes';
quest='Do you wish to filter Data?';
answer=questdlg(quest,'Data Filtering','Yes','No',opts);
while strcmp(answer,'Yes')
cd Filtering
% FILTERING FOR MC, Depth, Time and Epicentral coordinates
[out]=Toolbox_SHA_TEST_2
if out==4
[Ctime,Cmag,Catalog,Mc]=FiltMc(Ctime,Cmag,Catalog,s1);
elseif out==3
[Ctime,Cmag,Catalog,Mc]=FiltDep(Ctime,Cmag,Catalog,s1);
elseif out==1
[Ctime,Cmag,Catalog,Mc]=FiltTime(Ctime,Cmag,Catalog,PROD_Data,s1);
elseif out==2
[Ctime,Cmag,Catalog,Mc]=FiltSpace(Ctime,Cmag,Catalog,s1);
end
quest='Do you wish to filter Data?';
answer=questdlg(quest,'Data Filtering','Yes','No',opts);
cd ../
end
disp('Proceed to Parameters Setting')
%% % ************* STEP_5: CREATE TIME WINDOWS **************
time_windows=struct;time_windows.Time=[];
to=Ctime-Ctime(1);tmin=min(to);tmax=max(to);
lista = {'Time','Events','Graphical','File'}; % select one of the windows creation mode
answer1 = listdlg('PromptString','Please Select a Window Creation Mode: ', ...
'SelectionMode','single','ListString',lista,'ListSize',[350 250],'InitialValue',3);
answer1=char(lista(answer1));
switch answer1
%% TIME
case 'Time'
prompt = {'\fontsize{12} Enter window size (DAYS):','\fontsize{12} Enter window step (DAYS):'};
dlgtitle = 'Configure Time Windows';
dims = [1 50]; opts.Interpreter='tex';
definput = {'30','1'};
answer = inputdlg(prompt,dlgtitle,dims,definput,opts);
window_size=str2double(answer(1));dt=str2double(answer(2));
if window_size>tmax;n=1;warning('time window is set larger than data time span');end
n=ceil((tmax-window_size)/dt);
for i=1:n
time_windows(i).Time=Ctime(to>=(i-1)*dt & to<(i-1)*dt+window_size);
time_windows(i).M=Cmag(to>=(i-1)*dt & to<(i-1)*dt+window_size);
time_windows(i).Tstart=Ctime(1)+(i-1)*dt;
time_windows(i).Tend=Ctime(1)+(i-1)*dt+window_size;
end
%% EVENTS
case 'Events'
prompt = {'\fontsize{12} Enter window size (EVENTS):','\fontsize{12} Enter window step (DAYS):'};
dlgtitle = 'Configure Time Windows';
dims = [1 50]; opts.Interpreter='tex';
definput = {'100','1'};
answer = inputdlg(prompt,dlgtitle,dims,definput,opts);
window_size=str2double(answer(1));dt=str2double(answer(2));
if window_size>numel(to);window_size=numel(to);warning('events window is set larger than given data');end
n=ceil(tmax/dt);
for i=1:n
To=find(to>=(i-1)*dt);To=To(1);
if To<=length(Ctime)-window_size+1;
time_windows(i).Time=Ctime(To:To+window_size-1);
time_windows(i).M=Cmag(To:To+window_size-1);
time_windows(i).Tstart=Ctime(1)+(i-1)*dt;
time_windows(i).Tend=max(time_windows(i).Time);
end
end
%% GRAPHICAL
case 'Graphical'
fig1=figure('Position',[300 100 1600 500]);
plot(Ctime,1:numel(Ctime));xlabel(['Time'],'FontSize',16);ylabel(['Events'],'FontSize',16);hold on;
if isempty(PROD_Data)==0;
yyaxis right;plot(PROD_Data(1).val,PROD_Data(s2).val);ylabel(PROD_Data(s2).field,'FontSize',16,'interpreter','none');
end
datetick('x',20);
title(['Please select starting/ending points for time periods (press enter to submit)'],'FontSize',16)
[x,y]=ginput;close(fig1)
if length(x)>1
time_start_vector=x(1:length(x)-1);time_end_vector=x(2:length(x));
else; time_start_vector=Ctime(1)-1;time_end_vector=Ctime(length(Ctime))+1;
end
if (length(time_start_vector) ~= length(time_end_vector)); error('time start and end vectors must have the same size'); end
time_windows=struct;
time_windows.Time=[];
time_windows.M=[];
for i = 1:length(time_start_vector)
startTime = time_start_vector(i);
endTime = time_end_vector(i);
time_windows(i).Time=Ctime(Ctime > startTime & Ctime <= endTime);
time_windows(i).M=Cmag(Ctime > startTime & Ctime <= endTime);
time_windows(i).Tstart = startTime;
time_windows(i).Tend = endTime;
end
%% Read from FILE
case 'File' %K 27JUN2019
cd TIME_WINDOWS %K 27JUN2019
d=dir;dstr={d.name}; %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
if ok; Twindows=dlmread(dstr{s});end %K 27JUN2019
T1=Twindows(:,1);T2=Twindows(:,2);n=numel(T1); %K 27JUN2019
for i=1:n %K 27JUN2019
time_windows(i).Time=Ctime(Ctime>=T1(i) & Ctime<T2(i)); %K 27JUN2019
time_windows(i).M=Cmag(Ctime>=T1(i) & Ctime<T2(i)); %K 27JUN2019
time_windows(i).Tstart=T1(i); %K 27JUN2019
time_windows(i).Tend=T2(i); %K 27JUN2019
end %K 27JUN2019
cd ../ %K 27JUN2019
end
%% % ************* STEP_6: SELECT PARAMETERS for SHA **************
% Magnitude Distribution Mode
list1 = {'Unbounded Gutenberg-Richter','Upper-bounded Gutenberg-Richter',...
'Unbounded non-parametric Kernel','Upper-bounded non-parametric Kernel'};
% Time Unit
list2 = {'Day','Month','Year'};
[indx1] = listdlg('PromptString','Select a Method:',...
'SelectionMode','single','ListString',list1,'ListSize',[350 250]);
[indx2] = listdlg('PromptString','Select time unit:',...
'SelectionMode','single','ListString',list2,'ListSize',[150 250]);
if indx2==1;prompt = {'\fontsize{12} Magnitude:','\fontsize{12} Period Length, (days):'};
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
% 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 **************
%% RUN MAGDIST
[HP] = TDHMagDistWrapper(method, time_windows, Mc, iop,Mmax)
%% Harzard Parameters Estimate
[MRPer,ExPr]=TDHRetPeriodExcProbWrapper(method,mag,time_period,Mc,HP)
% Return from Directory with Functions
%% PLOT and Save Results
Zplo
Zsave_output
%% -*-*-*-*-*-*-*-*-*-*-*-*- F U N C T I O N S -*-*-*-*-*-*-*-*-*-*-*-*-
%% ------------------------- DATA HANDLING FUNCTION --------------------------
function [Catalog,PROD_data,Mode1,dstr1,dstr2,s,ss1,ss,ss2]=Data_Hand_A2M
clc
disp('please select mode:');
disp(' "1" - For Seismic Data');
disp(' "2" - For both Seismic and Production Data');
Mode1=input('mode: ');
switch Mode1
case 1
%% SEISMIC DATA
cd CATALOGS\
d=dir;dstr1={d.name};
[SData,SFields,s,s1]=DatLoad(dstr1,1);
cd ../
Na=length(SFields);if SFields(Na)~=' ';SFields(Na+1)=' ';end
[cou,c,Datime,Catalog]=Fields_dat(SData,SFields,1);
ss1=1:length(Catalog);% ss1=SetParams(Catalog);%Catalog=Catalog(ss1);
PROD_data=[];ss=[];s2=[];ss2=[];dstr2=[];
case 2
%% ------------------------------------------------------------------------------------------------------------------------------------
% BOTH -SEISMIC and PRODUCTION DATA
cd CATALOGS\ %Seismic Data
d=dir;dstr1={d.name};
[SData,SFields,s,s1]=DatLoad(dstr1,1);
cd ../
Na=length(SFields);if SFields(Na)~=' ';SFields(Na+1)=' ';end
[cou,c,Datime,Catalog]=Fields_dat(SData,SFields,1);
ss1=1:length(Catalog);
% ss1=SetParams(Catalog);%Catalog=Catalog(ss1);
cd PRODUCTION_DATA\ % Production (non-Seismic) Data
d=dir;dstr2={d.name};
[OData,OFields,ss,s2]=DatLoad(dstr2,2);
cd ../
Na1=length(OFields);if OFields(Na1)~=' ';OFields(Na1+1)=' ';end
[cou1,c1,Datime1,PROD_data]=Fields_dat(OData,OFields,2);
ss2=SetParams(PROD_data);%PROD_data=PROD_data(ss2);
end
% save('Catalog_ST2_Test','Catalog')
% save('Catalog_ST2_Test','Catalog')
%% ----------------------------------------- F U N C T I O N S -----------------------------------------
function [cou,c,Datime,OUT]=Fields_dat(indata,infields,iop)
Datime=datenum(indata(:,1),indata(:,2),indata(:,3),indata(:,4),indata(:,5),indata(:,6)); % Convert time to matlab format
% Define Fields
c=1;
for i=1:length(infields)-1
if strcmp(infields(i),' ')==1;cou(i)=0;
else cou(i)=c;end
if strcmp(infields(i),' ')==0 & strcmp(infields(i+1),' ')==1;c=c+1;end
end
if iop==1
OUT(1).field='Occurrence_Time';OUT(1).val=Datime;
elseif iop==2
OUT(1).field='Production_Time';OUT(1).val=Datime;
end
for i=2:c-1
OUT(i).field=infields(cou==i);
OUT(i).val=indata(:,i+5);
end
%Set Field Type for Magnitude Recognition
for i=1:size(OUT,2)
if strcmp(OUT(i).field,'ML') || strcmp(OUT(i).field,'Mw') || strcmp(OUT(i).field,'M') ...
|| strcmp(OUT(i).field,'Ms') || strcmp(OUT(i).field,'mb') || strcmp(OUT(i).field,'Md')
OUT(i).fieldType='Magnitude';
else
OUT(i).fieldType=[];
end
end
end
%% -----------------------------------------------------------------------------------------------------------
function [Data,Fields,s,f]=DatLoad(dstr,da)
% Select Seismic Catalog
if da==1;dlabel1='Select Seismic Catalog:';dlabel2='Select Catalog FIELDS file:';
elseif da==2;dlabel1='Select Production Data file:';dlabel2='Select Production FIELDS file:';end
[s,ok]=listdlg('PromptString',dlabel1,...
'SelectionMode','single',...
'ListString',dstr,'ListSize',[350 250]);
if ok; Data=load(dstr{s});end
[f,ok]=listdlg('PromptString',dlabel2,...
'SelectionMode','single',...
'ListString',dstr,'ListSize',[350 250]);
if ok; Fields=fileread(dstr{f});end
end
%%---------------------------------------------------------------------------------------------------------------
function ss1=SetParams(Data)
%Select Parameters from Seismic Catalog
[s1,ok]=listdlg('PromptString','Select field:',...
'ListString',{Data.field},'SelectionMode','single','ListSize',[350 250]);
for i=1:length(s1)
ss1=s1(isnan(s1)==0);
end
end
% ----------------------------------------------------------------------------------------------------------------
end
%%----------------------------------------------------------------------------------------------------------------
function [Ctime,Cmag,Mtype]=Select_Magnitude_Scale(Catalog)
cou=1;
for i=1:length(Catalog)
if strcmp(Catalog(i).fieldType,'Magnitude')==1
C(cou).field=Catalog(i).field;cou=cou+1;
end
end
% Check for no magnitude
if cou==1;error('MyComponent:incorrectType',...
'No magnitude column detected!! Please check: Magnitude fields must be noted as one of the following:\nM , Mw , ML , Ms , mb , Md\n or select the entire sample for analysis');end
%Select Parameters from Seismic Catalog -
[ss1,ok]=listdlg('PromptString','Please Select M scale:',...
'ListString',{C.field}, 'SelectionMode','single');
id=findfield(Catalog,C(ss1).field);
id_time=findfield(Catalog,'Occurrence_Time');
Mtype=Catalog(id).field;
Cmag=Catalog(id).val;Ctime=Catalog(id_time).val;
end
%% --------------------------------------------------------------------------------------
% finds a field defined by a certain (string) name
function [id] = findfield( catalog,field )
id=0;
j=1;
while j <= size(catalog,2) && id==0
if (strcmp(catalog(j).field,field)==1)
id=j;
end
j=j+1;
end
end
%% -----------!!!!!!!!!!! HAZARD PARAM<ETERS ESTIMATE FUNCTIONS !!!!!!!!!!!-----------
function [HP] = TDHMagDistWrapper(method, time_win_data, mmin, iop,Mmax)
cd SSH
for i=1:size(time_win_data,2)
mags_vec = time_win_data(i).M;
time_vec = time_win_data(i).Time;
HP(i).mmin = mmin;
HP(i).iop = iop;
HP(i).method = method;
switch method
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;
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;
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);
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;
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;
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;
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);
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;
warning('%s: %s', err.identifier, err.message);
end
end
% K12NOV2015
% Calculate lamb and lamb_all in case of 0, 1, or 2 events.
% It may be generalized in all cases. Rate is now calculated
% by division of the event number by the duration of the set
% - not the time difference between the first and last events.
if numel(mags_vec(mags_vec>=mmin))<3
HP(i).lamb_all= numel(mags_vec)/(time_win_data(i).Tend-time_win_data(i).Tstart);
HP(i).lamb= numel(mags_vec(mags_vec>=mmin))/(time_win_data(i).Tend-time_win_data(i).Tstart);
switch iop
case 0
%OK
case 1
HP(i).lamb_all=HP(i).lamb_all*30;
HP(i).lamb=HP(i).lamb*30;
case 2
HP(i).lamb_all=HP(i).lamb_all*365;
HP(i).lamb=HP(i).lamb*365;
end
end
% K12NOV2015
end
cd ../
end
%%
function [MRPer,ExPr]=TDHRetPeriodExcProbWrapper(meth,mag,time_period,Mmin,HP)
nn=size(HP,2);
if nn==0; 'All datasets are empty'
MRPer=[]; ExPr=[];
else
for i=1:nn
Mmax=HP(i).Mmax;
if HP(i).lamb_err==0;
try
[MRPer(i),ExPr(i)]=SingleRetPeriodExcProbWrapper(meth,mag,time_period,Mmin,HP(i),Mmax);
catch err
MRPer(i)=NaN; ExPr(i)=NaN;
warning('%s: %s', err.identifier, err.message);cd ../
end
else
MRPer(i)=NaN; ExPr(i)=NaN;
if MRPer(i)==inf;MRPer(i)=NaN;end %K 21OCT2016
end
end
end
end
%% Function - SingleRetPeriodExcProbWrapper
function [MRPer,ExPr]=SingleRetPeriodExcProbWrapper(meth,mag,time_period,Mmin,HP,Mmax)
cd SSH
%Md=3;Mu=3;dM=3;Mmin=0.6;
Md = mag;
Mu = mag;
dM = mag;
if isnan(Mmax) && isfield(HP,'Mmax')
Mmax = HP.Mmax;
end
m = []; rper = []; prob = [];
switch meth
case 'GRU'
[m,rper]=Ret_periodGRU(Md,Mu,dM,Mmin,HP.lamb,HP.eps,HP.b);
[m,prob]=ExcProbGRU(0,Md,Mu,dM,time_period,Mmin,HP.lamb,HP.eps,HP.b);
case 'GRT'
[m,rper]=Ret_periodGRT(Md,Mu,dM,Mmin,HP.lamb,HP.eps,HP.b,Mmax);
[m,prob]=ExcProbGRT(0,Md,Mu,dM,time_period,Mmin,HP.lamb,HP.eps,HP.b,Mmax);
case 'NPU'
[m,rper]=Ret_periodNPU(Md,Mu,dM,Mmin,HP.lamb,HP.eps,HP.h,HP.xx,HP.ambd);
[m,prob]=ExcProbNPU(0,Md,Mu,dM,time_period,Mmin,HP.lamb,HP.eps,HP.h,HP.xx,HP.ambd);
case 'NPT'
[m,rper]=Ret_periodNPT(Md,Mu,dM,Mmin,HP.lamb,HP.eps,HP.h,HP.xx,HP.ambd,Mmax);
[m,prob]=ExcProbNPT(0,Md,Mu,dM,time_period,Mmin,HP.lamb,HP.eps,HP.h,HP.xx,HP.ambd,Mmax);
end
if isempty(rper)
MRPer = NaN;
ExPr = NaN;
else
MRPer = rper(1);
ExPr = prob(1);
end
cd ../
end

View File

@ -0,0 +1,99 @@
% [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax)
%
%EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UPPER-BOUNDED G-R
% LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode.
%
% The exceedance probability of magnitude M' in the time period of
% length T' is the probability of an earthquake of magnitude M' or greater
% to occur in T'. Depending on the value of the parameter opt the
% exceedance probability values are calculated for a fixed time period T'
% and different magnitude values or for a fixed magnitude M' and different
% time period length values. In either case the independent variable vector
% starts from xd, up to xu with step dx. In either case the result is
% returned in the vector z.
%
%INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
%OUTPUT:
% x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1,
% x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end
%----------------------------------------------------------
beta=b*log(10);
if opt==0
if xd<Mmin; xd=Mmin;end
if xu>Mmax; xu=Mmax;end
end
x=(xd:dx:xu)';
if opt==0
z=1-exp(-lamb*y.*(1-Cdfgr(x,beta,Mmin-eps/2,Mmax)));
else
z=1-exp(-lamb*(1-Cdfgr(y,beta,Mmin-eps/2,Mmax)).*x);
end
end
function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
% beta - the distribution parameter
% t - vector of magnitudes (independent variable)
% y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1);
y(idx)=ones(size(idx));
end

View File

@ -0,0 +1,78 @@
% [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b)
%
%EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UNLIMITED G-R
% LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode.
%
% The exceedance probability of magnitude M' in the time period of
% length T' is the probability of an earthquake of magnitude M' or greater
% to occur in T'. Depending on the value of the parameter opt the
% exceedance probability values are calculated for a fixed time period T'
% and different magnitude values or for a fixed magnitude M' and different
% time period length values. In either case the independent variable vector
% starts from xd, up to xu with step dx. In either case the result is
% returned in the vector z.
%
%INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
%OUTPUT
% x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1,
% x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end
%----------------------------------------------------------
beta=b*log(10);
if opt==0
if xd<Mmin; xd=Mmin;end
end
x=(xd:dx:xu)';
if opt==0
z=1-exp(-lamb*y.*exp(-beta*(x-Mmin+eps/2)));
else
z=1-exp(-lamb*exp(-beta*(y-Mmin+eps/2)).*x);
end
end

View File

@ -0,0 +1,116 @@
% [x,z]=ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE
% EXCEEDANCE PROBABILITY VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2.
%
% The exceedance probability of magnitude M' in the time
% period of length T' is the probability of an earthquake of magnitude M'
% or greater to occur in T'.
%
% Depending on the value of the parameter opt the exceedance probability
% values are calculated for a fixed time period T' and different magnitude
% values or for a fixed magnitude M' and different time period length
% values. In either case the independent variable vector starts from
% xd, up to xu with step dx. In either case the result is returned in the
% vector z.
%
% REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% x - vector of changeable independent variable x=(xd:dx:xu)
% z - vector of exceedance probability values
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [x,z]=...
ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end
%----------------------------------------------------------
if opt==0
if xd<Mmin; xd=Mmin;end
if xu>Mmax; xu=Mmax;end
end
x=(xd:dx:xu)';
n=length(x);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
if opt==0
for i=1:n
CDF_NPT=2*(Dystr_npr(x(i),xx,ambd,h)...
-Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian;
z(i)=1-exp(-lamb*y.*(1-CDF_NPT));
end
else
CDF_NPT=2*(Dystr_npr(y,xx,ambd,h)...
-Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian;
z=1-exp(-lamb*(1-CDF_NPT).*x);
if y>Mmax;z=zeros(size(x));end %K15DEC2015
end
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,105 @@
% [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE
% EXCEEDANCE PROBABILITY VALUES FOR THE UNBOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2.
% The exceedance probability of magnitude M' in the time period of length
% T' is the probability of an earthquake of magnitude M' or greater to
% occur in T'.
% Depending on the value of the parameter opt the exceedance probability
% values are calculated for a fixed time period T' and different magnitude
% values or for a fixed magnitude M' and different time period length
% values. In either case the independent variable vector starts from
% xd, up to xu with step dx. In either case the result is returned in the
% vector z.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
%
% OUTPUT:
% x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1,
% x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end
%----------------------------------------------------------
x=(xd:dx:xu)';
n=length(x);
if opt==0
for i=1:n
CDF_NPU=2*(Dystr_npr(x(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
z(i)=1-exp(-lamb*y.*(1-CDF_NPU));
end
else
CDF_NPU=2*(Dystr_npr(y,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
z=1-exp(-lamb*(1-CDF_NPU).*x);
end
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,59 @@
% [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax)
%EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UPPER-BOUNDED
% G-R LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode.
%
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
% INPUT:
% Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
beta=b*log(10);
mian=(1-exp(-beta*(Mmax-Mmin+eps/2)));
m=Mmin-eps/2-1/beta*log((1-(1-1./(lamb*T))*mian));
end

View File

@ -0,0 +1,63 @@
% [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b)
%
%EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UNLIMITED
% G-R LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode.
%
% The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T.
%
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
%INPUT:
% Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
%
%OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
beta=b*log(10);
m=Mmin-eps/2+1/beta.*log(lamb*T);
end

View File

@ -0,0 +1,98 @@
% [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM
% CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2.
%
% The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
% REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
n=length(T);
interval=[Mmin-eps/2 Mmax-0.001];
for i=1:n
m(i)=fzero(@F_maxmagn,interval,[],xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i));
end
m=m';
end
function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D)
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian;
y=CDF_NPT-1+1/(lamb*D);
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,98 @@
% [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) ---- (Octave Compatible Version)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM
% CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2.
%
% The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
% REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
n=length(T);
interval=[Mmin-eps/2 Mmax-0.001];
for i=1:n
m(i)=fzero(@(t) F_maxmagn(t,xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i)),interval);
end
m=m';
end
function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D)
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian;
y=CDF_NPT-1+1/(lamb*D);
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,98 @@
% [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2.
%
% The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
%INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
%
%OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
n=length(T);
interval=[Mmin-eps/2 10.0];
for i=1:n
m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i));
end
m=m';
end
function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D)
CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
y=CDF_NPU-1+1/(lamb*D);
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,99 @@
% [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) ---- (Octave Comlatible Version)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2.
%
% The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
%INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
%
%OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
n=length(T);
interval=[Mmin-eps/2 10.0];
for i=1:n
% m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i));
m(i)=fzero(@(t) F_maxmagn_NPU(t,xx,h,ambd,Mmin-eps/2,lamb,T(i)),interval);
end
m=m';
end
function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D)
CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
y=CDF_NPU-1+1/(lamb*D);
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,259 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin)
%
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd
% FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE
% DISTRIBUTION.
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx.
% See: the references below for a more comprehensive description.
%
% This is a beta version of the program. Further developments are foreseen.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level
%
% OUTPUT
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (the zero of the h functional
% has been found, ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken.
% h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude
% distribution
% ambd - the weigthing factors for the adaptive kernel
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=...
Nonpar(t,M,iop,Mmin)
lamb_err=0;
n=length(M);
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
if iop==0
lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1);
unit='day';
elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014
unit='month';
else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014
unit='year';
end
if nn<50
eps=0;ierr=0;h=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
n=0;
for i=1:length(M)
if M(i)>=Mmin;
n=n+1;
x(n)=M(i);
end
end
x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx);
clear x;
xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx);
[ambd]=scaling(xx,h);
end
function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
%
% m - input vector of magnitudes
% Mmin - catalog completeness level
% eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution
%
% m_corr - vector of randomized magnitudes
%
F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m));
w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta;
end
function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending
% order
x2=[-x+2*x0
x];
x2=sort(x2);
end
function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares
%method
% x - column data vector
% The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search
% MODIFIED JUNE 2014
ierr=0;
n=length(x);
x=sort(x);
interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
[hh(1),fval,exitflag]=fzero(@funct,interval,[],x);
% Extra zeros search
jj=1;
for kk=2:7
interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
jj=jj+1;
[hh(jj),fval,exitflag]=fzero(@funct,interval,[],x);
end
end
if jj>1;ierr=1;end
h=max(hh);
if exitflag==1;return;end
end
h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2;
end
function [fct]=funct(t,x)
p2=1.41421356;
n=length(x);
yy=zeros(size(x));
for i=1:n,
xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y);
end;
fct=sum(yy)-2*n;
clear xij y yy;
end
function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending
% order
% h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors
n=length(x);
c=sqrt(2*pi);
gau=zeros(1,n);
for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end
g=exp(mean(log(gau)));
ambd=sqrt(g./gau);
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end

View File

@ -0,0 +1,310 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin)
%
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd
% FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE
% DISTRIBUTION.
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx.
% See: the references below for a more comprehensive description.
%
% This is a beta version of the program. Further developments are foreseen.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level
%
% OUTPUT
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (the zero of the h functional
% has been found, ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken.
% h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude
% distribution
% ambd - the weigthing factors for the adaptive kernel
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=...
Nonpar_O(t,M,iop,Mmin)
if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP
lamb_err=0;
%%% %%%%%%%%%%%%%MICHAL
xx=NaN;
ambd=NaN;
%%% %%%%%%%%%%%%%MICHAL
n=length(M);
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
% SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM;
% SL 03MAR2015 ----------------------------------
if nn<50
eps=0;ierr=0;h=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
n=0;
for i=1:length(M)
if M(i)>=Mmin;
n=n+1;
x(n)=M(i);
end
end
x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx);
clear x;
xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx);
[ambd]=scaling(xx,h);
% enai=dlmread('para.txt'); %for fixed xx,ambd to test in different platforms
% [ambd]=enai(:,1);
% xx=enai(:,2)';
% [h,ierr]=hopt(xx);
end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
%
% t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
%
% NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0
NM=(t2-t1);
unit='day';
elseif iop==1
V1=datevec(t1);
V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12;
unit='month';
else
V1=datevec(t1);
V2=datevec(t2);
NM2=V2(3);
if V2(2)>1
for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k);
end
end
day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2;
NM1=V1(3);
if V1(2)>1
for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k);
end
end
day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year';
end
end
function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
%
% m - input vector of magnitudes
% Mmin - catalog completeness level
% eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution
%
% m_corr - vector of randomized magnitudes
%
F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m));
w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta;
end
function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending
% order
x2=[-x+2*x0
x];
x2=sort(x2);
end
function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares
%method
% x - column data vector
% The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search
% MODIFIED JUNE 2014
ierr=0;
n=length(x);
x=sort(x);
interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
fun = @(t) funct(t,x); % FOR OCTAVE
x0 =interval; % FOR OCTAVE
[hh(1),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE
% Extra zeros search
jj=1;
for kk=2:7
interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
jj=jj+1;
fun = @(t) funct(t,x); % FOR OCTAVE
x0 =interval; % FOR OCTAVE
[hh(jj),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE
end
end
if jj>1;ierr=1;end
h=max(hh);
if exitflag==1;return;end
end
h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2;
end
function [fct]=funct(t,x)
p2=1.41421356;
n=length(x);
yy=zeros(size(x));
for i=1:n,
xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y);
end;
fct=sum(yy)-2*n;
clear xij y yy;
end
function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending
% order
% h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors
n=length(x);
c=sqrt(2*pi);
gau=zeros(1,n);
for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end
g=exp(mean(log(gau)));
ambd=sqrt(g./gau);
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end

View File

@ -0,0 +1,373 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=
% Nonpar(t,M,iop,Mmin)
%
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND
% THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC
% ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE
% ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION.
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx.
% The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred.
% The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)).
%
% See: the references below for a more comprehensive description.
%
% This is a beta version of the program. Further developments are foreseen.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level
%
% OUTPUT
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (a zero of the h functional
% has been found), ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken.
% h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude
% distribution
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used.
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=...
Nonpar_tr(t,M,iop,Mmin)
lamb_err=0;
n=length(M);
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
if iop==0
lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1);
unit='day';
elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014
unit='month';
else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014
unit='year';
end
if nn<50
eps=0;ierr=0;h=0;Mmax=0;err=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
n=0;
for i=1:length(M)
if M(i)>=Mmin;
n=n+1;
x(n)=M(i);
end
end
x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx);
clear x;
xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx);
[ambd]=scaling(xx,h);
[Mmax,err]=Mmaxest(xx,h,Mmin-eps/2);
end
function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
%
% m - input vector of magnitudes
% Mmin - catalog completeness level
% eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution
%
% m_corr - vector of randomized magnitudes
%
F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m));
w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta;
end
function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending
% order
x2=[-x+2*x0
x];
x2=sort(x2);
end
function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares
%method
% x - column data vector
% The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search
% MODIFIED JUNE 2014
ierr=0;
n=length(x);
x=sort(x);
interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
[hh(1),fval,exitflag]=fzero(@funct,interval,[],x);
% Extra zeros search
jj=1;
for kk=2:7
interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
jj=jj+1;
[hh(jj),fval,exitflag]=fzero(@funct,interval,[],x);
end
end
if jj>1;ierr=1;end
h=max(hh);
if exitflag==1;return;end
end
h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2;
end
function [fct]=funct(t,x)
p2=1.41421356;
n=length(x);
yy=zeros(size(x));
for i=1:n,
xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y);
end;
fct=sum(yy)-2*n;
clear xij y yy;
end
function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending
% order
% h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors
n=length(x);
c=sqrt(2*pi);
gau=zeros(1,n);
for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end
g=exp(mean(log(gau)));
ambd=sqrt(g./gau);
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end
function [Mmax,ierr]=Mmaxest(x,h,Mmin)
% ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS
% x - row vector of magnitudes (basic sample).
% h - optimal smoothing factor
% Mmax - upper bound
% ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas
% estimation
% Uses function 'dystryb'
n=length(x);
ierr=1;
x=sort(x);
Mmax1=x(n);
for i=1:50,
d=normcdf((Mmin-x)./h);
mian=sum(normcdf((Mmax1-x)./h)-d);
Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d);
if abs(Mmax-Mmax1)<0.01
ierr=0;break;
end
Mmax1=Mmax;
end
if (ierr==1 || Mmax>9)
Mmax=2*x(n)-x(n-1);
ierr=1;
end
end
function [y]=dystryb(z,h,mian,x,d)
n=length(x);
m=length(z);
for i=1:m,
t=(z(i)-x)./h;
t=normcdf(t);
yy=sum(t-d);
y(i)=(yy/mian)^n;
end
end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated
% a,b - integration limits
% eps - accurracy
% varargin - other parameters of function to be integrated
% calka - integral
% ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12;
delta=CONST*abs(a-b);
calka=0.;
aa=a;
y=b-aa;
ier=0;
while abs(y)>delta,
bb=aa+y;
c1=0.5*(aa+bb);
c2=c1-aa;
s8=0.;
s16=0.;
for i=1:4,
u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
for i=5:12,
u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
s8=s8*c2;
s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y;
calka=0.;
ier=1;
else
calka=calka+s16;
aa=bb;
y=b-aa;
ier=0;
end
end
end

View File

@ -0,0 +1,431 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=
% Nonpar_tr(t,M,iop,Mmin)
%
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND
% THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC
% ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE
% ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION.
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx.
% The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred.
% The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)).
%
% See: the references below for a more comprehensive description.
%
% This is a beta version of the program. Further developments are foreseen.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level
%
% OUTPUT
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (a zero of the h functional
% has been found), ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken.
% h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude
% distribution
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used.
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=...
Nonpar_tr_O(t,M,iop,Mmin,Mmax)
if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP
lamb_err=0;
n=length(M);
t1=t(1);
%%% %%%%%%%%%%%%%MICHAL
xx=NaN;
ambd=NaN;
%%% %%%%%%%%%%%%%MICHAL
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
% SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM;
% SL 03MAR2015 ----------------------------------
if nn<50
eps=0;ierr=0;h=0;Mmax=0;err=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
n=0;
for i=1:length(M)
if M(i)>=Mmin;
n=n+1;
x(n)=M(i);
end
end
x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx);
clear x;
xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx);
[ambd]=scaling(xx,h);
if isempty(Mmax) %K30AUG2019 - Allow for manually set Mmax
[Mmax,err]=Mmaxest(xx,h,Mmin-eps/2);
else
err=0; %K30AUG2019
end
% enai=dlmread('paraT.txt'); %for fixed xx,ambd to test in different platforms
% [ambd]=enai(:,1);
% xx=enai(:,2)';
% [h,ierr]=hopt(xx);
% [Mmax,err]=Mmaxest(xx,h,Mmin-eps/2);
end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 ----------------------------------
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
%
% t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
%
% NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0
NM=(t2-t1);
unit='day';
elseif iop==1
V1=datevec(t1);
V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12;
unit='month';
else
V1=datevec(t1);
V2=datevec(t2);
NM2=V2(3);
if V2(2)>1
for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k);
end
end
day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2;
NM1=V1(3);
if V1(2)>1
for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k);
end
end
day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year';
end
end
function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
%
% m - input vector of magnitudes
% Mmin - catalog completeness level
% eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution
%
% m_corr - vector of randomized magnitudes
%
F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m));
w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta;
end
function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending
% order
x2=[-x+2*x0
x];
x2=sort(x2);
end
function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares
%method
% x - column data vector
% The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search
% MODIFIED JUNE 2014
ierr=0;
n=length(x);
x=sort(x);
interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
fun = @(t) funct(t,x); % for octave
x0 =interval; % for octave
[hh(1),fval,exitflag] = fzero(fun,x0); % for octave
% Extra zeros search
jj=1;
for kk=2:7
interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
jj=jj+1;
fun = @(t) funct(t,x); % for octave
x0 =interval; % for octave
[hh(jj),fval,exitflag] = fzero(fun,x0); % for octave
end
end
if jj>1;ierr=1;end
h=max(hh);
if exitflag==1;return;end
end
h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2;
end
function [fct]=funct(t,x)
p2=1.41421356;
n=length(x);
yy=zeros(size(x));
for i=1:n,
xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y);
end;
fct=sum(yy)-2*n;
clear xij y yy;
end
function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending
% order
% h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors
n=length(x);
c=sqrt(2*pi);
gau=zeros(1,n);
for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end
g=exp(mean(log(gau)));
ambd=sqrt(g./gau);
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end
function [Mmax,ierr]=Mmaxest(x,h,Mmin)
% ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS
% x - row vector of magnitudes (basic sample).
% h - optimal smoothing factor
% Mmax - upper bound
% ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas
% estimation
% Uses function 'dystryb'
n=length(x);
ierr=1;
x=sort(x);
Mmax1=x(n);
for i=1:50,
d=normcdf((Mmin-x)./h);
mian=sum(normcdf((Mmax1-x)./h)-d);
Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d);
if abs(Mmax-Mmax1)<0.01
ierr=0;break;
end
Mmax1=Mmax;
end
if (ierr==1 || Mmax>9)
Mmax=2*x(n)-x(n-1);
ierr=1;
end
end
function [y]=dystryb(z,h,mian,x,d)
n=length(x);
m=length(z);
for i=1:m,
t=(z(i)-x)./h;
t=normcdf(t);
yy=sum(t-d);
y(i)=(yy/mian)^n;
end
end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated
% a,b - integration limits
% eps - accurracy
% varargin - other parameters of function to be integrated
% calka - integral
% ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12;
delta=CONST*abs(a-b);
calka=0.;
aa=a;
y=b-aa;
ier=0;
while abs(y)>delta,
bb=aa+y;
c1=0.5*(aa+bb);
c2=c1-aa;
s8=0.;
s16=0.;
for i=1:4,
u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
for i=5:12,
u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
s8=s8*c2;
s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y;
calka=0.;
ier=1;
else
calka=calka+s16;
aa=bb;
y=b-aa;
ier=0;
end
end
end

View File

@ -0,0 +1,83 @@
% [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax)
%
% EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UPPER-BOUNDED G-R LED
% MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode.
%
% The mean return period of magnitude M is the average elapsed time between
% the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM.
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes
% Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
% OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
if Md<Mmin; Md=Mmin;end
if Mu>Mmax; Mu=Mmax;end
m=(Md:dM:Mu)';
beta=b*log(10);
T=1/lamb./(1-Cdfgr(m,beta,Mmin-eps/2,Mmax));
end
function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
% beta - the distribution parameter
% t - vector of magnitudes (independent variable)
% y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1);
y(idx)=ones(size(idx));
end

View File

@ -0,0 +1,59 @@
% [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b)
%
% EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UNLIMITED G-R LED
% MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode.
%
% The mean return period of magnitude M is the average elapsed time between
% the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM.
%
%INPUT:
% Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
%
%OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
if Md<Mmin; Md=Mmin;end
m=(Md:dM:Mu)';
beta=b*log(10);
T=1/lamb./exp(-beta*(m-Mmin+eps/2));
end

View File

@ -0,0 +1,94 @@
% [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax)
%
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MEAN
% RETURN PERIOD VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2.
%
% The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM.
%
% REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
if Md<Mmin; Md=Mmin;end
if Mu>Mmax; Mu=Mmax;end
m=(Md:dM:Mu)';
n=length(m);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
for i=1:n
CDF_NPT=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian;
T(i)=1/lamb./(1-CDF_NPT);
end
T=T';
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,91 @@
% [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MEAN RETURN PERIOD VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2.
%
% The mean return period of magnitude M is the average
% elapsed time between the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
%
%OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
if Md<Mmin; Md=Mmin;end
m=(Md:dM:Mu)';
n=length(m);
for i=1:n
CDF_NPU=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
T(i)=1/lamb./(1-CDF_NPU);
end
T=T';
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,250 @@
%
% [lamb_all,lamb,lmab_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin)
%
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE,
% THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE
% DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution and consequently the G-R
% b-value is estimated by maximum likelihood method (Aki-Utsu procedure).
% The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)).
% The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps is the least non-zero difference
% between sample data or 0.1 if the least difference is greater than 0.1.
%
% REFERENCES:
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally.
% Can take any value from [min(M), max(M)].
%
% OUTPUT:
%
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 15 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used.
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin)
n=length(M);
lamb_err=0;
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
if iop==0
lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1);
unit='day';
elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014
unit='month';
else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014
unit='year';
end
if nn<15
eps=0;b=0;Mmax=0;err=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014
% x=sort(M,'descend');
% for i=1:n
% if x(i)<Mmin; break; end
% xx(i)=x(i); %
% end
clear x;
nn=length(xx);
Max_obs=max(xx);
beta0=0;
Mmax1=Max_obs;
for i=1:50,
beta=fzero(@bet_est,[0.05,4.0],[],mean(xx),Mmin-eps/2,Mmax1);
Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1);
if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001))
err=0;
break;
end
Mmax1=Mmax;
beta0=beta;
end
if i==50;
err=1.0;
Mmax=2*xx(1)-xx(2);
beta=fzero(@bet_est,1.0,[],mean(xx),Mmin-eps/2,Mmax);
end
b=beta/log(10);
clear xx
end
function [zero]=bet_est(b,ms,Mmin,Mmax)
%First derivative of the log likelihood function of the upper-bounded
% exponential distribution (truncated GR model)
% b - parameter of the distribution 'beta'
% ms - mean of the observed magnitudes
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
M_max_min=Mmax-Mmin;
e_m=exp(-b*M_max_min);
zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m);
end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated
% a,b - integration limits
% eps - accurracy
% varargin - other parameters of function to be integrated
% calka - integral
% ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12;
delta=CONST*abs(a-b);
calka=0.;
aa=a;
y=b-aa;
ier=0;
while abs(y)>delta,
bb=aa+y;
c1=0.5*(aa+bb);
c2=c1-aa;
s8=0.;
s16=0.;
for i=1:4,
u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
for i=5:12,
u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
s8=s8*c2;
s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y;
calka=0.;
ier=1;
else
calka=calka+s16;
aa=bb;
y=b-aa;
ier=0;
end
end
end
function [y]=f_podc(z,n,beta,Mmin,Mmax)
% Integrated function for Mmax estimation. Truncated GR model
% z - column vector of independent variable
% n - the size of 'z'
% beta - the distribution parameter
% Mmin - the catalog completeness level
% Mmax - the upper limit of the distribution
y=Cdfgr(z,beta,Mmin,Mmax).^n;
end
function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
% beta - the distribution parameter
% t - vector of magnitudes (independent variable)
% y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1);
y(idx)=ones(size(idx));
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end

View File

@ -0,0 +1,305 @@
%
% [lamb_all,lamb,lmab_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin)
%
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE,
% THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE
% DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution and consequently the G-R
% b-value is estimated by maximum likelihood method (Aki-Utsu procedure).
% The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)).
% The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps is the least non-zero difference
% between sample data or 0.1 if the least difference is greater than 0.1.
%
% REFERENCES:
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally.
% Can take any value from [min(M), max(M)].
%
% OUTPUT:
%
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 15 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used.
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err]=TruncGR_O(t,M,iop,Mmin,Mmax)
if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP
n=length(M);
lamb_err=0;
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
% SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM;
% SL 03MAR2015 ----------------------------------
if nn<15
eps=0;b=0;Mmax=0;err=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014
% x=sort(M,'descend');
% for i=1:n
% if x(i)<Mmin; break; end
% xx(i)=x(i); %
% end
clear x;
nn=length(xx);
Max_obs=max(xx);
beta0=0;
Mmax1=Max_obs;
if isempty(Mmax)==0 %%% K 28JUL2015
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax); %%% K 28JUL2015
x0 = 1; %[0.05,4.0]; %%% K 28JUL2015 - See exception line 153
beta = fzero(fun,x0); %%% K 28JUL2015
err=0; %%% K 28JUL2015
else %%% K 28JUL2015 - line 148
for i=1:50,
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax1);
x0 =1; %[0.05,4.0]; %%% K29JUL2015 - See exception line 153
beta = fzero(fun,x0);
Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1);
if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001))
err=0;
break;
end
Mmax1=Mmax;
beta0=beta;
end
if i==50;
err=1.0;
Mmax=2*xx(1)-xx(2);
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax);
x0 =1;
beta = fzero(fun,x0);
end
end %%% K 28JUL2015
b=beta/log(10);
clear xx
% Exception for v-value
if b<0.05 || b>6.0; error('Unacceptable b-value, abort and select different dataset');end
beta;
end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
%
% t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
%
% NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0
NM=(t2-t1);
unit='day';
elseif iop==1
V1=datevec(t1);
V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12;
unit='month';
else
V1=datevec(t1);
V2=datevec(t2);
NM2=V2(3);
if V2(2)>1
for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k);
end
end
day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2;
NM1=V1(3);
if V1(2)>1
for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k);
end
end
day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year';
end
end
function [zero]=bet_est(b,ms,Mmin,Mmax)
%First derivative of the log likelihood function of the upper-bounded
% exponential distribution (truncated GR model)
% b - parameter of the distribution 'beta'
% ms - mean of the observed magnitudes
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
M_max_min=Mmax-Mmin;
e_m=exp(-b*M_max_min);
zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m);
end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated
% a,b - integration limits
% eps - accurracy
% varargin - other parameters of function to be integrated
% calka - integral
% ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12;
delta=CONST*abs(a-b);
calka=0.;
aa=a;
y=b-aa;
ier=0;
while abs(y)>delta,
bb=aa+y;
c1=0.5*(aa+bb);
c2=c1-aa;
s8=0.;
s16=0.;
for i=1:4,
u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
for i=5:12,
u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
s8=s8*c2;
s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y;
calka=0.;
ier=1;
else
calka=calka+s16;
aa=bb;
y=b-aa;
ier=0;
end
end
end
function [y]=f_podc(z,n,beta,Mmin,Mmax)
% Integrated function for Mmax estimation. Truncated GR model
% z - column vector of independent variable
% n - the size of 'z'
% beta - the distribution parameter
% Mmin - the catalog completeness level
% Mmax - the upper limit of the distribution
y=Cdfgr(z,beta,Mmin,Mmax).^n;
end
function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
% beta - the distribution parameter
% t - vector of magnitudes (independent variable)
% y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1);
y(idx)=ones(size(idx));
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end

View File

@ -0,0 +1,162 @@
% [lamb_all,lamb,lmab_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin)
%
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE AND THE
% GUTENBERG-RICHTER B-VALUE USING THE UNLIMITED G-R LED MAGNITUDE
% DISTRIBUTION MODEL
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value is estimated by
% maximum likelihood method (Aki-Utsu procedure).
% The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps if the least non-zero difference
% between sample data or 0.1 is the least difference is greater than 0.1.
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally.
% can take any value from [min(M), max(M)].
%
% OUTPUT:
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 7 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
function [lamb_all,lamb,lamb_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin)
if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP
lamb_err=0;
n=length(M);
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
% SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM;
% SL 03MAR2015 ----------------------------------
if nn<7
eps=0;b=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014
% x=sort(M,'descend');
% for i=1:n
% if x(i)<Mmin; break; end
% xx(i)=x(i); %
% end
clear x;
beta=1/(mean(xx)-Mmin+eps/2);
b=beta/log(10);
clear xx
end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
%
% t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
%
% NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0
NM=(t2-t1);
unit='day';
elseif iop==1
V1=datevec(t1);
V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12;
unit='month';
else
V1=datevec(t1);
V2=datevec(t2);
NM2=V2(3);
if V2(2)>1
for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k);
end
end
day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2;
NM1=V1(3);
if V1(2)>1
for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k);
end
end
day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year';
end
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end

View File

@ -0,0 +1,64 @@
% [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax)
%
% EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE
% UNDER THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distribution Mmax are calculated at
% start-up of the stationary hazard assessment services in the
% upper-bounded Gutenberg-Richter estimation mode.
%
% The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM.
%
%INPUT:
% Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
%
%OUTPUT:
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_GRT - PDF vector of the same length as m
% CDF_GRT - CDF vector of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
m=(Md:dM:Mu)';
beta=b*log(10);
mian=(1-exp(-beta*(Mmax-Mmin+eps/2)));
PDF_GRT=beta*exp(-beta*(m-Mmin+eps/2))/mian;
CDF_GRT=(1-exp(-beta*(m-Mmin+eps/2)))/mian;
idx=find(CDF_GRT<0);
PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=zeros(size(idx));
idx=find(CDF_GRT>1);
PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=ones(size(idx));
end

View File

@ -0,0 +1,61 @@
% [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b)
%
% EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE
% UNDER THE UNLIMITED G-R LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode.
%
% The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM.
%
%INPUT:
% Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
%
%OUTPUT:
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_GRT - PDF vector of the same length as m
% CDF_GRT - CDF vector of the same length as m
%
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
m=(Md:dM:Mu)';
beta=b*log(10);
PDF_GRU=beta*exp(-beta*(m-Mmin+eps/2));
CDF_GRU=1-exp(-beta*(m-Mmin+eps/2));
idx=find(CDF_GRU<0);
PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=zeros(size(idx));
idx=find(CDF_GRU>1);
PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=ones(size(idx));
end

View File

@ -0,0 +1,116 @@
% [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax)
%
% USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY
% AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UPPER-BOUNDED MAGNITUDE
% DISTRIBUTION.
%
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2.
%
% REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
%INPUT:
% Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% m - vector of the independent variable (magnitude)
% PDF_NPT - PDF vector
% CDF_NPT - CDF vector
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
m=(Md:dM:Mu)';
nn=length(m);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
for i=1:nn
if m(i)<Mmin-eps/2
PDF_NPT(i)=0;CDF_NPT(i)=0;
elseif m(i)>Mmax
PDF_NPT(i)=0;CDF_NPT(i)=1;
else
PDF_NPT(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2)/mian;
CDF_NPT(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian;
end
end
PDF_NPT=PDF_NPT';CDF_NPT=CDF_NPT';
end
function [gau]=dens_npr1(y,x,ambd,h,x1)
%Nonparametric adaptive density for a variable from the interval [x1,inf)
% x - the sample data doubled and sorted in the ascending order. Use
% "podwajanie.m" first to accmoplish that.
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
c=sqrt(2*pi);
if y<x1
gau=0;
else
gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h;
end
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,114 @@
% [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd)
%
% USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY
% AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UNLIMITED MAGNITUDE
% DISTRIBUTION.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2
%
% The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
%INPUT:
% Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
%
%
%OUTPUT
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_NPU - PDF vector of the same length as m
% CDF_NPU - CDF vector of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
m=(Md:dM:Mu)';
nn=length(m);
for i=1:nn
if m(i)>=Mmin-eps/2
PDF_NPU(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2);
CDF_NPU(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
else
PDF_NPU(i)=0;
CDF_NPU(i)=0;
end
end
PDF_NPU=PDF_NPU';CDF_NPU=CDF_NPU';
end
function [gau]=dens_npr1(y,x,ambd,h,x1)
%Nonparametric adaptive density for a variable from the interval [x1,inf)
% x - the sample data doubled and sorted in the ascending order. Use
% "podwajanie.m" first to accmoplish that.
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
c=sqrt(2*pi);
if y<x1
gau=0;
else
gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h;
end
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,8 @@
733388.930241936 733736.185887097
733736.185887097 734054.28266129
734054.28266129 734409.490725806
734409.490725806 734621.555241936
734621.555241936 734907.84233871
734907.84233871 735355.828629032
735355.828629032 735586.448790323
735586.448790323 735843.577016129

View File

@ -0,0 +1,129 @@
close all;d=figure('Position',[300 50 1600 950])
% check whether the selected time windows are overlapping or not
TT=[];Tcat=Catalog(1).val;Ncat=Tcat(Tcat>=time_windows(1).Tstart & Tcat<=time_windows(length(ExPr)).Tend);
for i=1:length(MRPer);
TW1(i)=time_windows(i).Tstart;Tw2(i)=time_windows(i).Tend;
tplo(i)=mean([time_windows(i).Tstart time_windows(i).Tend]);meanM(i)=mean(time_windows(i).M);hold on
TT=[TT;time_windows(i).Time];
lambda(i)=HP(i).lamb;
if strcmp(HP(1).method,'GRU') || strcmp(HP(1).method,'GRT');yyaxis right;bval(i)=HP(i).b;end
end
%if numel(TT)==numel(Ncat)
DTW=TW1(2:length(TW1))-Tw2(1:length(Tw2)-1); %%% THIS SEEMS TO WORK!!!!
if isempty(find(DTW<0))
overlap='NO';
for i=1:length(MRPer);
subplot(3,1,1) % plot Mean return period
hold on;plot([time_windows(i).Tstart time_windows(i).Tend],[MRPer(i) MRPer(i)],'k-','LineWidth',2)
if i<length(MRPer);plot([time_windows(i).Tend time_windows(i+1).Tstart],[MRPer(i) MRPer(i+1)],'k--');end
datetick('x',20);title(['Mean Return Period for M\geq',answer3{1}],'FontSize',16);ylabel([HP(1).unit,'s'],'FontSize',18)
subplot(3,1,2) % plot Exceedance Probability
hold on;plot([time_windows(i).Tstart time_windows(i).Tend],[ExPr(i) ExPr(i)],'k-','LineWidth',2)
if i<length(ExPr);plot([time_windows(i).Tend time_windows(i+1).Tstart],[ExPr(i) ExPr(i+1)],'k--');end
datetick('x',20);title(['Exceedance Probability for M\geq',answer3{1},' within ',answer3{2}, ' ',HP(1).unit, '(s) period'],'FontSize',16);ylabel('probability','FontSize',14)
subplot(3,1,3) % plot Activity rate
hold on;yyaxis left;plot([time_windows(i).Tstart time_windows(i).Tend],[HP(i).lamb HP(i).lamb],'k-','LineWidth',2)
if i<length(ExPr);plot([time_windows(i).Tend time_windows(i+1).Tstart],[HP(i).lamb HP(i+1).lamb],'k--');end
datetick('x',20);title(['Activity Rate'],'FontSize',16);ylabel(['Events/',HP(1).unit],'FontSize',14,'Color','k')
set(gca,'YColor','k');
% plot b-value (GR) or mean M (NP)
if strcmp(HP(1).method,'GRU') || strcmp(HP(1).method,'GRT');yyaxis right;
plot([time_windows(i).Tstart time_windows(i).Tend],[HP(i).b HP(i).b],'-','LineWidth',2)
ylabel('b-value','FontSize',14);
else
yyaxis right;plot([time_windows(i).Tstart time_windows(i).Tend],[mean(time_windows(i).M) mean(time_windows(i).M)],'-','LineWidth',2)
ylabel('mean Magnitude','FontSize',14);
end
end
else
overlap='YES';
subplot(3,1,1) % plot Mean return period
plot(tplo,MRPer,'o','LineWidth',2,'MarkerSize',12);
datetick('x',20);title(['Mean Return Period for M\geq',answer3{1}],'FontSize',16);ylabel([HP(1).unit,'s'],'FontSize',18)
subplot(3,1,2) % plot Exceedance Probability
plot(tplo,ExPr,'o','LineWidth',2,'MarkerSize',12);
datetick('x',20);title(['Exceedance Probability for M\geq',answer3{1},' within ',answer3{2}, ' ',HP(1).unit, '(s) period'],'FontSize',16);ylabel('probability','FontSize',14)
subplot(3,1,3) % plot Activity rate
plot(tplo,lambda,'o','LineWidth',2,'MarkerSize',12);ylabel(['Events/',HP(1).unit],'FontSize',14)
if strcmp(HP(1).method,'GRU') || strcmp(HP(1).method,'GRT');
yyaxis right;plot(tplo,bval,'o','LineWidth',2,'MarkerSize',12); ylabel('b-value','FontSize',14);
else; yyaxis right;plot(tplo,meanM,'o','LineWidth',2,'MarkerSize',12)
ylabel('mean Magnitude','FontSize',14);
end
datetick('x',20);title(['Activity Rate'],'FontSize',16);
end
if isempty(PROD_Data)==0
subplot(3,1,1);yyaxis right;plot(PROD_Data(1).val,PROD_Data(s2).val,'-','Linewidth',1);ylabel(PROD_Data(s2).field,'interpreter','none','FontSize',14);
subplot(3,1,2);yyaxis right;plot(PROD_Data(1).val,PROD_Data(s2).val,'-','Linewidth',1);ylabel(PROD_Data(s2).field,'interpreter','none','FontSize',14);
end
subplot(3,1,3);xlabel('Date','FontSize',18)
% option to switch linear-log Y axis Scale
txt = uicontrol('Parent',d,...
'Style','text',...
'Position',[200 621 150 30],...
'String','Select Y Axis Scale:');
popup = uicontrol('Parent',d,...
'Style','popup',...
'Position',[350 630 120 25],...
'String',{'Linear';'Log'},...
'Callback',@popup_callback);
btn = uicontrol('Parent',d,...
'Position',[210 880 210 50],...
'String','SAVE and CLOSE',...
'FontSize',18,...
'ForeGroundColor','r',...
'FontWeight','Bold',...
'Callback',@savefig_callback);
choice = 'Linear';
% Wait for d to close before running to completion
uiwait(d);
function popup_callback(popup,event)
idx = popup.Value;
popup_items = popup.String;
% This code uses dot notation to get properties.
% Dot notation runs in R2014b and later.
% For R2014a and earlier:
% idx = get(popup,'Value');
% popup_items = get(popup,'String');
choice = char(popup_items(idx,:));
subplot(3,1,1);yyaxis left;
set(gca,'YScale',choice)
end
function savefig_callback(popup,event)
cd Outputs_SHA\
print(gcf,'SHA.jpeg','-djpeg','-r300')
savefig(gcf,'SHA.fig')
% This code uses dot notation to get properties.
% Dot notation runs in R2014b and later.
% For R2014a and earlier:
% idx = get(popup,'Value');
% popup_items = get(popup,'String');
cd ../
delete(gcf)
end

View File

@ -0,0 +1,77 @@
% ---- Save *.txt file with Parameters Report ----
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,'------------------------------------------------------------------------------------\n');
fprintf(fid,['<Magnitude Scale Selected >: ', Mtype,'\n']);
fprintf(fid,['<Time Unit >: ', list2{indx2},'\n']);
fprintf(fid,['<Magnitude Range >: ', num2str(Mc), ' to ', num2str(max(Cmag)),'\n']);
fprintf(fid,['<Magnitude Distribution Model >: ', list1{indx1},'\n']);
fprintf(fid,['<Magnitude (for EPP and MRP) >: ', answer3{1},'\n']);
fprintf(fid,['<Time Period (for EPR) >: ', answer3{2},' ',list2{indx2},'s', '\n']);
fprintf(fid,['<Time Window Creation Mode >: ', answer1,'\n']);
if strcmp(answer1,'Time')==1
fprintf(fid,['< Window Size >: ', answer{1},'(days) \n']);
fprintf(fid,['< Window Step >: ', answer{2},'(days) \n']);
elseif strcmp(answer1,'Events')==1
fprintf(fid,['< Window Size >: ', answer{1},'(events) \n']);
fprintf(fid,['< Window Step >: ', answer{2},'(days) \n']);
elseif strcmp(answer1,'Graphical')==1
fprintf(fid,['< Window Size >: variable \n']);
fprintf(fid,['< Window Step >: variable \n']);
end
fprintf(fid,['<Overlapping Time Windows >: ', overlap,'\n']);
fprintf(fid,'------------------------------------------------------------------------------------\n');
for j=1:numel(HP)
SN(j)=j;Nevents(j)=numel(time_windows(j).M);TS(j)=time_windows(j).Tstart;TE(j)=time_windows(j).Tend;
end
fprintf(fid,[' Set N Starting Date/Time Ending Date/Time events MRP EPR 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);
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);
end
end
fclose(fid);
% Save output structure time_window merged with HP
for i=1:length(HP)
SHA(i).Time=time_windows(i).Time;
SHA(i).M=time_windows(i).M;
SHA(i).Mmin=HP(i).mmin;
SHA(i).eps=HP(i).eps;
SHA(i).lambd=HP(i).lamb;
SHA(i).lambd_err=HP(i).lamb_err;
SHA(i).unit=HP(i).unit;
SHA(i).method=HP(i).method;
if strcmp(method,'GRU')==1 || strcmp(method,'GRT')==1
SHA(i).b=HP(i).b;
else
SHA(i).h=HP(i).h;
SHA(i).xx=HP(i).xx;
SHA(i).ambd=HP(i).ambd;
SHA(i).ierr=HP(i).ierr;
end
if strcmp(method,'GRT')==1 || strcmp(method,'NPT')==1
SHA(i).Mmax=HP(i).Mmax;
SHA(i).err=HP(i).err;
else
end
end
prompt={'\fontsize{12} Please enter output file name:'};
name='Extract Output Structure';
numlines=1;
defaultanswer={'SHA.mat'};
opts.Interpreter='tex';
answers=inputdlg(prompt,name,numlines,defaultanswer,opts);
save(char(answers),'SHA')
cd ../

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
Time ML Long Lat Depth

View File

@ -0,0 +1,717 @@
2013 08 23 00 00 00 139.89
2013 08 24 00 00 00 140.04
2013 08 25 00 00 00 140.32
2013 08 26 00 00 00 140.44
2013 08 27 00 00 00 140.34
2013 08 28 00 00 00 140.29
2013 08 29 00 00 00 140.42
2013 08 30 00 00 00 140.34
2013 08 31 00 00 00 140.21
2013 09 01 00 00 00 140.2
2013 09 02 00 00 00 140.3
2013 09 03 00 00 00 140.22
2013 09 04 00 00 00 140.16
2013 09 05 00 00 00 140.18
2013 09 06 00 00 00 140.19
2013 09 07 00 00 00 140.33
2013 09 08 00 00 00 140.32
2013 09 09 00 00 00 140.33
2013 09 10 00 00 00 140.38
2013 09 11 00 00 00 140.38
2013 09 12 00 00 00 140.92
2013 09 13 00 00 00 141.03
2013 09 14 00 00 00 140.95
2013 09 15 00 00 00 141.65
2013 09 16 00 00 00 141.27
2013 09 17 00 00 00 141.01
2013 09 18 00 00 00 142.7
2013 09 19 00 00 00 144.12
2013 09 20 00 00 00 144.04
2013 09 21 00 00 00 143.65
2013 09 22 00 00 00 143.16
2013 09 23 00 00 00 142.71
2013 09 24 00 00 00 142.21
2013 09 25 00 00 00 141.48
2013 09 26 00 00 00 141.46
2013 09 27 00 00 00 141.5
2013 09 28 00 00 00 141.29
2013 09 29 00 00 00 141.03
2013 09 30 00 00 00 140.56
2013 10 01 00 00 00 140.2
2013 10 02 00 00 00 145.84
2013 10 03 00 00 00 151.98
2013 10 04 00 00 00 155.71
2013 10 05 00 00 00 157.51
2013 10 06 00 00 00 158.13
2013 10 07 00 00 00 158.26
2013 10 08 00 00 00 158.1
2013 10 09 00 00 00 157.78
2013 10 10 00 00 00 157.36
2013 10 11 00 00 00 156.84
2013 10 12 00 00 00 156.28
2013 10 13 00 00 00 155.69
2013 10 14 00 00 00 154.99
2013 10 15 00 00 00 157.77
2013 10 16 00 00 00 158.99
2013 10 17 00 00 00 158.86
2013 10 18 00 00 00 158.67
2013 10 19 00 00 00 158.33
2013 10 20 00 00 00 158.13
2013 10 21 00 00 00 158.12
2013 10 22 00 00 00 157.84
2013 10 23 00 00 00 157.43
2013 10 24 00 00 00 156.91
2013 10 25 00 00 00 156.32
2013 10 26 00 00 00 155.68
2013 10 27 00 00 00 155.03
2013 10 28 00 00 00 154.33
2013 10 29 00 00 00 153.55
2013 10 30 00 00 00 152.81
2013 10 31 00 00 00 152.03
2013 11 01 00 00 00 151.16
2013 11 02 00 00 00 151.23
2013 11 03 00 00 00 149.37
2013 11 04 00 00 00 148.41
2013 11 05 00 00 00 147.61
2013 11 06 00 00 00 149.06
2013 11 07 00 00 00 154.63
2013 11 08 00 00 00 157.7
2013 11 09 00 00 00 158.46
2013 11 10 00 00 00 159.1
2013 11 11 00 00 00 159.46
2013 11 12 00 00 00 159.39
2013 11 13 00 00 00 159.14
2013 11 14 00 00 00 158.91
2013 11 15 00 00 00 163.76
2013 11 16 00 00 00 164.31
2013 11 17 00 00 00 164.34
2013 11 18 00 00 00 163.4
2013 11 19 00 00 00 162.6
2013 11 20 00 00 00 162.52
2013 11 21 00 00 00 162.12
2013 11 22 00 00 00 161.8
2013 11 23 00 00 00 161.6
2013 11 24 00 00 00 161.41
2013 11 25 00 00 00 161.21
2013 11 26 00 00 00 161.05
2013 11 27 00 00 00 160.83
2013 11 28 00 00 00 160.6
2013 11 29 00 00 00 160.97
2013 11 30 00 00 00 161.24
2013 12 01 00 00 00 161.25
2013 12 02 00 00 00 161.13
2013 12 03 00 00 00 160.96
2013 12 04 00 00 00 160.69
2013 12 05 00 00 00 160.33
2013 12 06 00 00 00 159.89
2013 12 07 00 00 00 159.37
2013 12 08 00 00 00 158.79
2013 12 09 00 00 00 158.28
2013 12 10 00 00 00 157.97
2013 12 11 00 00 00 157.95
2013 12 12 00 00 00 158.13
2013 12 13 00 00 00 158.58
2013 12 14 00 00 00 158.71
2013 12 15 00 00 00 158.99
2013 12 16 00 00 00 158.37
2013 12 17 00 00 00 159.5
2013 12 18 00 00 00 159.72
2013 12 19 00 00 00 159.95
2013 12 20 00 00 00 160.39
2013 12 21 00 00 00 160.82
2013 12 22 00 00 00 161.25
2013 12 23 00 00 00 161.54
2013 12 24 00 00 00 161.99
2013 12 25 00 00 00 162.37
2013 12 27 00 00 00 163.07
2013 12 28 00 00 00 163.41
2013 12 29 00 00 00 163.73
2013 12 30 00 00 00 164.04
2014 01 01 00 00 00 164.42
2014 01 02 00 00 00 163.74
2014 01 03 00 00 00 164.7
2014 01 04 00 00 00 164.74
2014 01 05 00 00 00 164.78
2014 01 06 00 00 00 164.9
2014 01 07 00 00 00 164.98
2014 01 08 00 00 00 164.96
2014 01 09 00 00 00 164.89
2014 01 10 00 00 00 164.88
2014 01 11 00 00 00 164.94
2014 01 13 00 00 00 165.34
2014 01 14 00 00 00 165.69
2014 01 15 00 00 00 165.82
2014 01 16 00 00 00 165.85
2014 01 17 00 00 00 165.74
2014 01 18 00 00 00 165.66
2014 01 19 00 00 00 165.58
2014 01 20 00 00 00 165.59
2014 01 21 00 00 00 165.62
2014 01 22 00 00 00 165.66
2014 01 23 00 00 00 165.73
2014 01 24 00 00 00 165.63
2014 01 25 00 00 00 165.53
2014 01 26 00 00 00 165.45
2014 01 27 00 00 00 165.38
2014 01 28 00 00 00 165.4
2014 01 29 00 00 00 165.55
2014 01 30 00 00 00 165.62
2014 01 31 00 00 00 165.58
2014 02 01 00 00 00 165.54
2014 02 02 00 00 00 165.49
2014 02 03 00 00 00 165.51
2014 02 04 00 00 00 165.43
2014 02 05 00 00 00 165.35
2014 02 06 00 00 00 165.3
2014 02 07 00 00 00 165.23
2014 02 08 00 00 00 165.07
2014 02 09 00 00 00 164.99
2014 02 10 00 00 00 164.97
2014 02 11 00 00 00 164.94
2014 02 12 00 00 00 164.95
2014 02 13 00 00 00 164.91
2014 02 14 00 00 00 164.93
2014 02 15 00 00 00 164.91
2014 02 16 00 00 00 164.7
2014 02 17 00 00 00 164.62
2014 02 18 00 00 00 164.49
2014 02 19 00 00 00 164.39
2014 02 20 00 00 00 164.38
2014 02 21 00 00 00 164.38
2014 02 22 00 00 00 164.3
2014 02 23 00 00 00 164.25
2014 02 24 00 00 00 164.24
2014 02 25 00 00 00 164.19
2014 02 26 00 00 00 164.16
2014 02 27 00 00 00 164.14
2014 02 28 00 00 00 164.05
2014 03 01 00 00 00 163.96
2014 03 02 00 00 00 163.99
2014 03 03 00 00 00 163.96
2014 03 04 00 00 00 163.93
2014 03 05 00 00 00 163.99
2014 03 06 00 00 00 164.04
2014 03 07 00 00 00 164
2014 03 08 00 00 00 163.85
2014 03 09 00 00 00 163.75
2014 03 10 00 00 00 163.66
2014 03 11 00 00 00 163.54
2014 03 12 00 00 00 163.37
2014 03 13 00 00 00 163.16
2014 03 14 00 00 00 162.94
2014 03 15 00 00 00 162.73
2014 03 16 00 00 00 162.75
2014 03 17 00 00 00 162.72
2014 03 18 00 00 00 162.26
2014 03 19 00 00 00 161.68
2014 03 20 00 00 00 161.27
2014 03 21 00 00 00 160.99
2014 03 22 00 00 00 160.67
2014 03 23 00 00 00 160.59
2014 03 24 00 00 00 160.76
2014 03 25 00 00 00 160.9
2014 03 26 00 00 00 161.01
2014 03 27 00 00 00 161.13
2014 03 28 00 00 00 161.11
2014 03 29 00 00 00 160.87
2014 03 30 00 00 00 160.62
2014 03 31 00 00 00 160.37
2014 04 01 00 00 00 160.12
2014 04 02 00 00 00 160.03
2014 04 03 00 00 00 160.15
2014 04 04 00 00 00 160.29
2014 04 05 00 00 00 160.5
2014 04 06 00 00 00 160.78
2014 04 07 00 00 00 160.86
2014 04 08 00 00 00 160.78
2014 04 09 00 00 00 160.69
2014 04 10 00 00 00 160.62
2014 04 11 00 00 00 160.36
2014 04 12 00 00 00 160.38
2014 04 13 00 00 00 160.51
2014 04 14 00 00 00 160.63
2014 04 15 00 00 00 160.73
2014 04 16 00 00 00 160.83
2014 04 17 00 00 00 160.8
2014 04 18 00 00 00 160.64
2014 04 19 00 00 00 160.44
2014 04 20 00 00 00 160.34
2014 04 21 00 00 00 160.22
2014 04 22 00 00 00 159.49
2014 04 23 00 00 00 158.81
2014 04 24 00 00 00 158.2
2014 04 25 00 00 00 158.25
2014 04 26 00 00 00 158.34
2014 04 27 00 00 00 158.45
2014 04 28 00 00 00 158.45
2014 04 29 00 00 00 158.59
2014 04 30 00 00 00 158.64
2014 05 01 00 00 00 158.74
2014 05 02 00 00 00 159.12
2014 05 03 00 00 00 159.52
2014 05 04 00 00 00 159.91
2014 05 05 00 00 00 160.2
2014 05 06 00 00 00 160.5
2014 05 07 00 00 00 160.82
2014 05 08 00 00 00 161.04
2014 05 09 00 00 00 161.27
2014 05 10 00 00 00 161.36
2014 05 11 00 00 00 161.5
2014 05 12 00 00 00 161.63
2014 05 13 00 00 00 161.83
2014 05 14 00 00 00 161.96
2014 05 15 00 00 00 161.89
2014 05 16 00 00 00 161.62
2014 05 17 00 00 00 161.59
2014 05 18 00 00 00 161.41
2014 05 19 00 00 00 161.2
2014 05 20 00 00 00 161.02
2014 05 21 00 00 00 160.81
2014 05 22 00 00 00 160.4
2014 05 23 00 00 00 159.66
2014 05 24 00 00 00 159.09
2014 05 25 00 00 00 158.79
2014 05 26 00 00 00 158.38
2014 05 27 00 00 00 157.86
2014 05 28 00 00 00 157.05
2014 05 29 00 00 00 156.29
2014 05 30 00 00 00 155.67
2014 05 31 00 00 00 155.03
2014 06 01 00 00 00 154.47
2014 06 02 00 00 00 154.21
2014 06 03 00 00 00 153.67
2014 06 04 00 00 00 153.02
2014 06 05 00 00 00 152.59
2014 06 06 00 00 00 152.23
2014 06 07 00 00 00 151.8
2014 06 08 00 00 00 151.61
2014 06 09 00 00 00 151.67
2014 06 10 00 00 00 151.38
2014 06 11 00 00 00 150.87
2014 06 12 00 00 00 150.24
2014 06 13 00 00 00 149.65
2014 06 14 00 00 00 149.27
2014 06 15 00 00 00 148.86
2014 06 16 00 00 00 148.54
2014 06 17 00 00 00 148.33
2014 06 18 00 00 00 148.48
2014 06 19 00 00 00 148.58
2014 06 20 00 00 00 148.56
2014 06 21 00 00 00 148.34
2014 06 22 00 00 00 147.96
2014 06 23 00 00 00 147.51
2014 06 24 00 00 00 147.04
2014 06 25 00 00 00 146.6
2014 06 26 00 00 00 146.17
2014 06 27 00 00 00 145.89
2014 06 28 00 00 00 145.96
2014 06 29 00 00 00 146.13
2014 06 30 00 00 00 146.39
2014 07 01 00 00 00 146.39
2014 07 02 00 00 00 146.4
2014 07 03 00 00 00 145.64
2014 07 04 00 00 00 145.25
2014 07 05 00 00 00 145.09
2014 07 06 00 00 00 145.28
2014 07 07 00 00 00 144.68
2014 07 08 00 00 00 144.73
2014 07 09 00 00 00 144.84
2014 07 10 00 00 00 145
2014 07 11 00 00 00 144.97
2014 07 12 00 00 00 144.6
2014 07 13 00 00 00 144.3
2014 07 14 00 00 00 144
2014 07 15 00 00 00 143.66
2014 07 16 00 00 00 143.24
2014 07 17 00 00 00 143.02
2014 07 18 00 00 00 143.22
2014 07 19 00 00 00 143.38
2014 07 20 00 00 00 143.47
2014 07 21 00 00 00 143.43
2014 07 22 00 00 00 143.01
2014 07 23 00 00 00 142.84
2014 07 24 00 00 00 143.36
2014 07 25 00 00 00 142.12
2014 07 26 00 00 00 141.72
2014 07 27 00 00 00 141.6
2014 07 28 00 00 00 141.95
2014 07 29 00 00 00 142.23
2014 07 30 00 00 00 142.76
2014 07 31 00 00 00 142.96
2014 08 01 00 00 00 143.06
2014 08 02 00 00 00 142.86
2014 08 03 00 00 00 142.63
2014 08 04 00 00 00 142.37
2014 08 05 00 00 00 142.08
2014 08 06 00 00 00 141.96
2014 08 07 00 00 00 142.19
2014 08 08 00 00 00 142.4
2014 08 09 00 00 00 142.58
2014 08 10 00 00 00 142.57
2014 08 11 00 00 00 142.17
2014 08 12 00 00 00 141.79
2014 08 13 00 00 00 141.43
2014 08 14 00 00 00 141.05
2014 08 15 00 00 00 140.7
2014 08 16 00 00 00 140.68
2014 08 17 00 00 00 140.93
2014 08 18 00 00 00 141.13
2014 08 19 00 00 00 141.1
2014 08 20 00 00 00 140.75
2014 08 21 00 00 00 140.69
2014 08 22 00 00 00 141.01
2014 08 23 00 00 00 141.33
2014 08 24 00 00 00 141.6
2014 08 25 00 00 00 141.8
2014 08 26 00 00 00 142.06
2014 08 27 00 00 00 142.39
2014 08 28 00 00 00 142.75
2014 08 29 00 00 00 143.02
2014 08 30 00 00 00 143.44
2014 08 31 00 00 00 143.87
2014 09 01 00 00 00 145.92
2014 09 02 00 00 00 146.24
2014 09 03 00 00 00 146.81
2014 09 04 00 00 00 147.26
2014 09 05 00 00 00 147.58
2014 09 06 00 00 00 147.71
2014 09 07 00 00 00 147.87
2014 09 08 00 00 00 148.08
2014 09 09 00 00 00 148.46
2014 09 10 00 00 00 148.58
2014 09 11 00 00 00 148.15
2014 09 12 00 00 00 147.39
2014 09 13 00 00 00 146.9
2014 09 14 00 00 00 146.85
2014 09 15 00 00 00 146.66
2014 09 16 00 00 00 145.9
2014 09 17 00 00 00 145.4
2014 09 18 00 00 00 145.19
2014 09 19 00 00 00 145.01
2014 09 20 00 00 00 145.11
2014 09 21 00 00 00 145.44
2014 09 22 00 00 00 145.72
2014 09 23 00 00 00 145.87
2014 09 24 00 00 00 146.57
2014 09 25 00 00 00 146.94
2014 09 26 00 00 00 147.25
2014 09 27 00 00 00 147.61
2014 09 28 00 00 00 147.92
2014 09 29 00 00 00 148.23
2014 09 30 00 00 00 148.53
2014 10 01 00 00 00 148.68
2014 10 02 00 00 00 148.67
2014 10 03 00 00 00 148.35
2014 10 04 00 00 00 147.9
2014 10 05 00 00 00 147.96
2014 10 06 00 00 00 148.34
2014 10 07 00 00 00 148.53
2014 10 08 00 00 00 149.56
2014 10 09 00 00 00 149.92
2014 10 10 00 00 00 149.94
2014 10 11 00 00 00 149.82
2014 10 12 00 00 00 149.55
2014 10 13 00 00 00 149.43
2014 10 14 00 00 00 148.95
2014 10 15 00 00 00 148.6
2014 10 16 00 00 00 148.33
2014 10 17 00 00 00 148.31
2014 10 18 00 00 00 148.4
2014 10 19 00 00 00 149.27
2014 10 20 00 00 00 149.57
2014 10 21 00 00 00 149.02
2014 10 22 00 00 00 148.84
2014 10 23 00 00 00 149.12
2014 10 24 00 00 00 149.12
2014 10 25 00 00 00 149.37
2014 10 26 00 00 00 150.5
2014 10 27 00 00 00 151.23
2014 10 28 00 00 00 151.17
2014 10 29 00 00 00 150.73
2014 10 30 00 00 00 150.42
2014 10 31 00 00 00 150.19
2014 11 01 00 00 00 150.07
2014 11 02 00 00 00 149.75
2014 11 03 00 00 00 149.66
2014 11 04 00 00 00 149.23
2014 11 05 00 00 00 148.96
2014 11 06 00 00 00 149.09
2014 11 07 00 00 00 149.34
2014 11 08 00 00 00 149.84
2014 11 09 00 00 00 150.31
2014 11 10 00 00 00 150.63
2014 11 11 00 00 00 150.76
2014 11 12 00 00 00 150.89
2014 11 13 00 00 00 151.55
2014 11 14 00 00 00 153.94
2014 11 15 00 00 00 156.7
2014 11 16 00 00 00 158.48
2014 11 17 00 00 00 159.22
2014 11 18 00 00 00 159.51
2014 11 19 00 00 00 159.47
2014 11 20 00 00 00 159.62
2014 11 21 00 00 00 159.73
2014 11 22 00 00 00 159.78
2014 11 23 00 00 00 160.01
2014 11 24 00 00 00 160.38
2014 11 25 00 00 00 160.44
2014 11 26 00 00 00 160.52
2014 11 27 00 00 00 160.65
2014 11 28 00 00 00 160.78
2014 11 29 00 00 00 160.98
2014 11 30 00 00 00 161.45
2014 12 01 00 00 00 162.55
2014 12 02 00 00 00 162.91
2014 12 03 00 00 00 163.15
2014 12 04 00 00 00 163.01
2014 12 05 00 00 00 163.36
2014 12 06 00 00 00 163.98
2014 12 07 00 00 00 164.71
2014 12 08 00 00 00 164.92
2014 12 09 00 00 00 165.15
2014 12 10 00 00 00 165.02
2014 12 11 00 00 00 164.78
2014 12 12 00 00 00 165.08
2014 12 13 00 00 00 165.33
2014 12 14 00 00 00 165.39
2014 12 15 00 00 00 165.25
2014 12 16 00 00 00 165.36
2014 12 17 00 00 00 165.8
2014 12 18 00 00 00 165.82
2014 12 19 00 00 00 165.67
2014 12 20 00 00 00 165.41
2014 12 21 00 00 00 165.2
2014 12 22 00 00 00 165.32
2014 12 23 00 00 00 165.57
2014 12 24 00 00 00 165.36
2014 12 25 00 00 00 165.31
2014 12 26 00 00 00 165.42
2014 12 27 00 00 00 165.75
2014 12 28 00 00 00 165.99
2014 12 29 00 00 00 166
2014 12 30 00 00 00 166.06
2014 12 31 00 00 00 166.79
2015 01 01 00 00 00 167.54
2015 01 02 00 00 00 168.16
2015 01 03 00 00 00 168.72
2015 01 04 00 00 00 169.3
2015 01 05 00 00 00 169.77
2015 01 06 00 00 00 170.17
2015 01 07 00 00 00 170.74
2015 01 08 00 00 00 171.51
2015 01 09 00 00 00 171.91
2015 01 10 00 00 00 172
2015 01 11 00 00 00 172
2015 01 12 00 00 00 171.97
2015 01 13 00 00 00 171.77
2015 01 14 00 00 00 171.53
2015 01 15 00 00 00 171.22
2015 01 16 00 00 00 170.97
2015 01 17 00 00 00 170.68
2015 01 18 00 00 00 170.65
2015 01 19 00 00 00 170.78
2015 01 20 00 00 00 170.93
2015 01 21 00 00 00 171.05
2015 01 22 00 00 00 171.07
2015 01 23 00 00 00 171.04
2015 01 24 00 00 00 170.99
2015 01 25 00 00 00 170.94
2015 01 26 00 00 00 170.91
2015 01 27 00 00 00 170.95
2015 01 28 00 00 00 170.93
2015 01 29 00 00 00 171.02
2015 01 30 00 00 00 171.05
2015 01 31 00 00 00 171.1
2015 02 01 00 00 00 171.28
2015 02 02 00 00 00 171.57
2015 02 03 00 00 00 171.29
2015 02 04 00 00 00 170.9
2015 02 05 00 00 00 170.82
2015 02 06 00 00 00 170.77
2015 02 07 00 00 00 170.73
2015 02 08 00 00 00 170.66
2015 02 09 00 00 00 170.6
2015 02 10 00 00 00 170.53
2015 02 11 00 00 00 170.4
2015 02 12 00 00 00 170.37
2015 02 13 00 00 00 170.34
2015 02 14 00 00 00 170.4
2015 02 15 00 00 00 170.58
2015 02 16 00 00 00 170.63
2015 02 17 00 00 00 170.64
2015 02 18 00 00 00 170.8
2015 02 19 00 00 00 170.88
2015 02 20 00 00 00 171.11
2015 02 21 00 00 00 171.33
2015 02 22 00 00 00 171.59
2015 02 23 00 00 00 171.72
2015 02 24 00 00 00 171.69
2015 02 25 00 00 00 171.53
2015 02 26 00 00 00 171.47
2015 02 27 00 00 00 171.46
2015 02 28 00 00 00 171.38
2015 03 01 00 00 00 171.37
2015 03 02 00 00 00 171.35
2015 03 03 00 00 00 171.27
2015 03 04 00 00 00 171.15
2015 03 05 00 00 00 171.04
2015 03 06 00 00 00 170.9
2015 03 07 00 00 00 170.82
2015 03 08 00 00 00 170.7
2015 03 09 00 00 00 170.57
2015 03 10 00 00 00 170.55
2015 03 11 00 00 00 170.69
2015 03 12 00 00 00 170.86
2015 03 13 00 00 00 170.95
2015 03 14 00 00 00 170.88
2015 03 15 00 00 00 170.76
2015 03 16 00 00 00 170.5
2015 03 17 00 00 00 170.29
2015 03 18 00 00 00 170.17
2015 03 19 00 00 00 169.91
2015 03 20 00 00 00 169.5
2015 03 21 00 00 00 169.28
2015 04 01 00 00 00 170.68
2015 04 02 00 00 00 170.36
2015 04 03 00 00 00 170.02
2015 04 04 00 00 00 169.7
2015 04 05 00 00 00 169.55
2015 04 06 00 00 00 169.41
2015 04 07 00 00 00 169.04
2015 04 08 00 00 00 168.37
2015 04 09 00 00 00 167.64
2015 04 10 00 00 00 167.32
2015 04 11 00 00 00 167.49
2015 04 12 00 00 00 167.63
2015 04 13 00 00 00 167.87
2015 04 14 00 00 00 168.05
2015 04 15 00 00 00 168.21
2015 04 16 00 00 00 168.34
2015 04 17 00 00 00 168.48
2015 04 18 00 00 00 168.61
2015 04 19 00 00 00 168.75
2015 04 20 00 00 00 168.89
2015 04 21 00 00 00 169.01
2015 04 22 00 00 00 169.18
2015 04 23 00 00 00 169.09
2015 04 24 00 00 00 168.78
2015 04 25 00 00 00 168.29
2015 04 26 00 00 00 167.85
2015 04 27 00 00 00 167.34
2015 04 28 00 00 00 167.01
2015 04 29 00 00 00 166.79
2015 04 30 00 00 00 166.7
2015 05 01 00 00 00 166.83
2015 05 02 00 00 00 166.65
2015 05 03 00 00 00 166.01
2015 05 04 00 00 00 165.45
2015 05 05 00 00 00 164.61
2015 05 06 00 00 00 163.86
2015 05 07 00 00 00 163.36
2015 05 08 00 00 00 163.02
2015 05 09 00 00 00 162.73
2015 05 10 00 00 00 162.81
2015 05 11 00 00 00 162.93
2015 05 12 00 00 00 162.76
2015 05 13 00 00 00 162.54
2015 05 14 00 00 00 162.36
2015 05 15 00 00 00 162.19
2015 05 16 00 00 00 162.03
2015 05 17 00 00 00 161.93
2015 05 18 00 00 00 161.79
2015 05 19 00 00 00 161.38
2015 05 20 00 00 00 160.79
2015 05 21 00 00 00 160.15
2015 05 22 00 00 00 159.43
2015 05 23 00 00 00 158.84
2015 05 24 00 00 00 158.38
2015 05 25 00 00 00 158
2015 05 26 00 00 00 157.48
2015 05 27 00 00 00 157.09
2015 05 28 00 00 00 156.77
2015 05 29 00 00 00 156.41
2015 05 30 00 00 00 156.06
2015 05 31 00 00 00 155.75
2015 06 01 00 00 00 155.45
2015 06 02 00 00 00 155.02
2015 06 03 00 00 00 154.79
2015 06 04 00 00 00 154.45
2015 06 05 00 00 00 154.18
2015 06 06 00 00 00 153.97
2015 06 07 00 00 00 153.78
2015 06 08 00 00 00 153.53
2015 06 09 00 00 00 153.28
2015 06 10 00 00 00 153.1
2015 06 11 00 00 00 152.48
2015 06 12 00 00 00 152.02
2015 06 13 00 00 00 152.06
2015 06 14 00 00 00 151.98
2015 06 15 00 00 00 152.06
2015 06 16 00 00 00 151.69
2015 06 17 00 00 00 151.11
2015 06 18 00 00 00 150.89
2015 06 19 00 00 00 150.73
2015 06 20 00 00 00 150.5
2015 06 21 00 00 00 150.41
2015 06 22 00 00 00 150.56
2015 06 23 00 00 00 150.56
2015 06 24 00 00 00 150.44
2015 06 25 00 00 00 150.18
2015 06 26 00 00 00 149.74
2015 06 28 00 00 00 149.24
2015 06 29 00 00 00 148.92
2015 06 30 00 00 00 148.5
2015 07 01 00 00 00 148.19
2015 07 02 00 00 00 148.16
2015 07 03 00 00 00 147.92
2015 07 04 00 00 00 147.4
2015 07 05 00 00 00 147.07
2015 07 06 00 00 00 146.79
2015 07 07 00 00 00 146.46
2015 07 08 00 00 00 146.11
2015 07 09 00 00 00 145.9
2015 07 10 00 00 00 146.13
2015 07 11 00 00 00 146.38
2015 07 12 00 00 00 146.58
2015 07 13 00 00 00 146.57
2015 07 14 00 00 00 146.36
2015 07 15 00 00 00 146.08
2015 07 16 00 00 00 145.89
2015 07 17 00 00 00 146.06
2015 07 18 00 00 00 146.2
2015 07 19 00 00 00 146.45
2015 07 21 00 00 00 146.53
2015 07 22 00 00 00 146.16
2015 07 23 00 00 00 145.81
2015 07 24 00 00 00 145.4
2015 07 25 00 00 00 145.02
2015 07 26 00 00 00 144.61
2015 07 27 00 00 00 144.41
2015 07 28 00 00 00 144.51
2015 07 29 00 00 00 144.65
2015 07 30 00 00 00 144.82
2015 07 31 00 00 00 144.75
2015 08 01 00 00 00 144.38
2015 08 02 00 00 00 144.01
2015 08 03 00 00 00 143.67
2015 08 04 00 00 00 143.49
2015 08 05 00 00 00 143.19
2015 08 06 00 00 00 143.28
2015 08 07 00 00 00 144.03
2015 08 08 00 00 00 144.44
2015 08 09 00 00 00 144.81
2015 08 10 00 00 00 145.19
2015 08 11 00 00 00 145.23
2015 08 12 00 00 00 145.14
2015 08 13 00 00 00 144.96
2015 08 14 00 00 00 144.69
2015 08 15 00 00 00 144.43
2015 08 16 00 00 00 144.29
2015 08 17 00 00 00 144.5
2015 08 18 00 00 00 144.68
2015 08 19 00 00 00 144.82
2015 08 20 00 00 00 144.8
2015 08 21 00 00 00 144.59
2015 08 22 00 00 00 144.34
2015 08 23 00 00 00 144.07
2015 08 24 00 00 00 143.76

View File

@ -0,0 +1 @@
Date Water_Level

Binary file not shown.

View File

@ -0,0 +1,520 @@
% 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
% TOOLBOX: "Hazard Analysis Toolbox" within SERA Project
% DOCUMENT: "READ_ME_SHAPE_ver2.docx"
% --------------------------------------------------------------------------------------------------------------------
% Time-and-Technology Dependent Seismic Hazard Assessment (SHA)
% --------------------------------------------------------------------------------------------------------------------
% INPUT:
% !!! ---------------------------- INPUT DATA REQUIREMENTS ----------------------------- !!!
% the program works with ASCII input data files (e.g. *.txt). The files needed are:
% > File with the parameters of seismic data [mandatory]
% > File with the parameters of production data [optional]
% > File specifying time windows for SHA analysis [optional]
% > Files(s) with the fields description of the corresponding parameters in the seismic data file
% > Files(s) with the fields description of the corresponding parameters in the production data files
% FOR DETAILS on data requirements please refer to the document:
% "READ_ME_SHAPE_ver2.pdf"
% --------------------------------------------------------------------------------------------------------------------
% OVERVIEW:THE PROGRAM takes as input a Seismic and optionally, a Production data parameters files to provides Seismic
% Hazard Assessment for specified time-windows, following User's specifications.
% --------------------------------------------------------------------------------------------------------------------
% AUTHORS: K. Leptokaropoulos,
% Last Updated: 09/2019, within SERA PROJECT, EU Horizon 2020 R&I
% programme under grant agreement No.730900
% CURRENT VERSION: v2.0 **** [WRAPPER (fast) STANDALONE VERSION!!]
%% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% PLEASE refer to the accompanying document:
% "READ_ME_SHAPE_ver2.pdf"
% for description of the Application and its requirements.
%% -----------------------------------------------------------------------------------------------------------------------
% DESCRIPTION: The Application performs time-dependent Seismic Hazard Analysis (SHA),
% taking into account the activity rate and the magnitude distribution of seismicity
% for selected time windows. The hazard parameters estimated are:
% 1) The Mean Return Period (MRP) of a given magnitude, M, which is defined as the
% average elapsed time between the occurrence of consecutive events of M and
% 2) The Exceedance Probability (EPR) of a given magnitude, M, within a given time
% period of length, T, which is defined as the probability of an earthquake of
% M to occur during T.
% These hazard parameters are estimated for different time windows which are constructed
% upon Users particular specifications. 4 different magnitude distribution models can
% be chosen. The input files must be in ASCII format (e.g. *.txt). A brief description
% of the preparation process is given here:
% !!! THE USER SETS THE PARAMETERS IN LINES 115-130 !!! then the following steps are executed
% (please see in the script for more comments and details for each STEP)
% STEP_1. Upload Data
% STEP_2. Select Magnidue Scale
% STEP_3. Filter Data for Mc
% STEP_4. TIME WINDOWS GENERATION
% STEP_5. SHA PARAMETERS ESTIMATION
% 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"
% ----------------------------------------------------------------------------------------------------------------------
%% OUTPUT:
% <> Output Report with summary of the Results as well as data and parameters used
% <> Output Figure with the results in *.mat and *.jpeg formats (optional)
% <> Output Matlab Structure with input parameter values and output results, having
% as many cells as the number of time windows generated.
% Structure fields are:
% - Time : vector with origin times of the events included in each time window
% - M : vector with events magnitudes
% - Mmin : Completeness magnitude
% - eps : Magnitude round-off interval
% - lambd : mean activity rate
% - lambd_err : events number sufficiency (0-all parametes estiamated, 1-all parameters set as NaNs)
% - unit : Time Unit
% - method : Magnitude Distribution Model
% - b : b-value of GR law
% [applies only when "method" is set to 'GRU' or 'GRT']
% - h : Kernel smoothing factor
% [applies only when "method" is set to 'NPU' or 'NPT']
% - xx : Background sample for kernel magnitude estimate
% [applies only when "method" is set to 'NPU' or 'NPT']
% - ambd : weigthing factors for the adaptive kernel
% [applies only when "method" is set to 'NPU' or 'NPT']
% - ierr : h convergence indicator (0-converges,1-multiple zeros, 2-no zeros)
% [applies only when "method" is set to 'NPU' or 'NPT']
% - Mmax : Upper limit of magnitude distribution (truncated)
% [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']
% -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
% 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, 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
% ---------------------------------------------------------------------------------------------------------------------
% 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.
% -------------------------------------------------------------------------------------------------------------------
clc;clear;
close all;
% PLEASE SET INPUT ARGUMENTS [LINES 115-130]
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
PROD_DATA='ST2_PROD_Data.txt'; % Production Data (non-seismic) File - NOTE: PROD_DATA=[] is valid as well
PROD_FIELDS='ST2_PROD_Fields.txt'; % Production Data (non-seismic) Fields File
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'
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'
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
%% -------------------------------------------------------------------------------------------------------------------------
if method=='GRT' & isempty(Mmax)==0 & MaG>Mmax | method=='NPT' & isempty(Mmax)==0 & MaG>Mmax
error('Mmax is smaller than the target magnitude (MaG), please change input')
end
%% STEP 1: Load data
[Catalog,PROD_Data,s1]=Data_Hand_A2M_ver2...
(SEIS_DATA,SEIS_FIELDS,PROD_DATA,PROD_FIELDS,PROD_FIELD);
%% STEP 2: Select Magnitude Scale
[Ctime,Cmag]=Select_Magnitude_Scale_ver2(Catalog,MScale);
%% STEP 3: Filter data for Mc
[Ctime,Cmag,Catalog]=FiltMc_ver2(Ctime,Cmag,Catalog,s1,Mc);
%% STEP 4: Create Time Windows
time_windows=struct;time_windows.Time=[];
to=Ctime-Ctime(1);tmin=min(to);tmax=max(to);
switch winmode
%% TIME
case 'Time'
if window_size>tmax;n=1;warning('time window is set larger than data time span');end
n=ceil((tmax-window_size)/dt);
for i=1:n
time_windows(i).Time=Ctime(to>=(i-1)*dt & to<(i-1)*dt+window_size);
time_windows(i).M=Cmag(to>=(i-1)*dt & to<(i-1)*dt+window_size);
time_windows(i).Tstart=Ctime(1)+(i-1)*dt;
time_windows(i).Tend=Ctime(1)+(i-1)*dt+window_size;
end
%% EVENTS
case 'Events'
if window_size>numel(to);window_size=numel(to);warning('events window is set larger than given data');end
n=ceil(tmax/dt);
for i=1:n
To=find(to>=(i-1)*dt);To=To(1);
if To<=length(Ctime)-window_size+1;
time_windows(i).Time=Ctime(To:To+window_size-1);
time_windows(i).M=Cmag(To:To+window_size-1);
time_windows(i).Tstart=Ctime(1)+(i-1)*dt;
time_windows(i).Tend=max(time_windows(i).Time);
end
end
%% FILE
case 'File'
cd TIME_WINDOWS
Twindows=dlmread(file_n);
T1=Twindows(:,1);T2=Twindows(:,2);n=numel(T1);
for i=1:n
time_windows(i).Time=Ctime(Ctime>=T1(i) & Ctime<T2(i));
time_windows(i).M=Cmag(Ctime>=T1(i) & Ctime<T2(i));
time_windows(i).Tstart=T1(i);
time_windows(i).Tend=T2(i);
end
cd ../
end
%% STEP 5: ESTIMATE HAZARD PARAMETERS
if strcmp(Tunit,'day');iop=0;elseif strcmp(Tunit,'month');iop=1;elseif strcmp(Tunit,'year');iop=2;
else; error('Please set "Tunit" Parameter as "day", "month" or "year"');end
%% RUN MAGDIST
[HP] = TDHMagDistWrapper(method, time_windows, Mc, iop,Mmax)
%% Harzard Parameters Estimate
[MRPer,ExPr]=TDHRetPeriodExcProbWrapper(method,MaG,Plength,Mc,HP)
%%
%% STEP 6: Ploting (optional)
Zplo_ver2
%% STEP 7: Save outputs
Zsave_output_ver2
%% -*-*-*-*-*-*-*-*-*-*-*-*-*- F U N C T I O N S -*-*-*-*-*-*-*-*-*-*-*-*-*-
%% ------------------------- DATA HANDLING FUNCTION --------------------------
function [Catalog,PROD_data,ss1]=Data_Hand_A2M_ver2...
(SEIS_DATA,SEIS_FIELDS,PROD_DATA,PROD_FIELDS,PROD_FIELD)
if isempty(PROD_DATA)
%% SEISMIC DATA
cd CATALOGS\
SData=load(SEIS_DATA);
SFields=fileread(SEIS_FIELDS);
cd ../
Na=length(SFields);if SFields(Na)~=' ';SFields(Na+1)=' ';end
[cou,c,Datime,Catalog]=Fields_dat(SData,SFields,1);
ss1=1:length(Catalog);% ss1=SetParams(Catalog);%Catalog=Catalog(ss1);
PROD_data=[];ss=[];s2=[];ss2=[];dstr2=[];
else
%% ------------------------------------------------------------------------------------------------------------------------------------
% BOTH -SEISMIC and PRODUCTION DATA
cd CATALOGS\ %Seismic Data
SData=load(SEIS_DATA);
SFields=fileread(SEIS_FIELDS);
cd ../
Na=length(SFields);if SFields(Na)~=' ';SFields(Na+1)=' ';end
[cou,c,Datime,Catalog]=Fields_dat(SData,SFields,1);
ss1=1:length(Catalog);
% ss1=SetParams(Catalog);%Catalog=Catalog(ss1);
cd PRODUCTION_DATA\ % Production (non-Seismic) Data
OData=load(PROD_DATA);
OFields=fileread(PROD_FIELDS);
cd ../
Na1=length(OFields);if OFields(Na1)~=' ';OFields(Na1+1)=' ';end
[cou1,c1,Datime1,PROD_data]=Fields_dat(OData,OFields,2);
end
% save('Catalog_ST2_Test','Catalog')
% save('Catalog_ST2_Test','Catalog')
%% ----------------------------------------- F U N C T I O N S -----------------------------------------
function [cou,c,Datime,OUT]=Fields_dat(indata,infields,iop)
Datime=datenum(indata(:,1),indata(:,2),indata(:,3),indata(:,4),indata(:,5),indata(:,6)); % Convert time to matlab format
% Define Fields
c=1;
for i=1:length(infields)-1
if strcmp(infields(i),' ')==1;cou(i)=0;
else cou(i)=c;end
if strcmp(infields(i),' ')==0 & strcmp(infields(i+1),' ')==1;c=c+1;end
end
if iop==1
OUT(1).field='Occurrence_Time';OUT(1).val=Datime;
elseif iop==2
OUT(1).field='Production_Time';OUT(1).val=Datime;
end
for i=2:c-1
OUT(i).field=infields(cou==i);
OUT(i).val=indata(:,i+5);
end
%Set Field Type for Magnitude Recognition
for i=1:size(OUT,2)
if strcmp(OUT(i).field,'ML') || strcmp(OUT(i).field,'Mw') || strcmp(OUT(i).field,'M') ...
|| strcmp(OUT(i).field,'Ms') || strcmp(OUT(i).field,'mb') || strcmp(OUT(i).field,'Md')
OUT(i).fieldType='Magnitude';
else
OUT(i).fieldType=[];
end
end
end
%% -----------------------------------------------------------------------------------------------------------
% ----------------------------------------------------------------------------------------------------------------
end
%%
function [Ctime,Cmag,Data]=FiltMc_ver2(Ctime,Cmag,Catalog,s1,Mc)
clc
id_time=findfield(Catalog,'Occurrence_Time');
%opts.Interpreter='tex';opts.Default='Yes';
%quest='Do you wish to filter Data for Mc?';
%answer=questdlg(quest,'Data Completenes','Yes','No',opts);
%if strcmp(answer,'Yes')
%% THIS HAS MOVED TO A SEPARATE FUNCTION IN THE BEGINNING OF THE APPLICATION
% cou=1;
% for i=1:length(Catalog)
% if strcmp(Catalog(i).fieldType,'Magnitude')==1
% C(cou).field=Catalog(i).field;cou=cou+1;
% end
% end
%
% % Check for no magnitude
% if cou==1;error('MyComponent:incorrectType',...
% 'No magnitude column detected!! Please check: Magnitude fields must be noted as one of the following:\nM , Mw , ML , Ms , mb , Md\n or select the entire sample for analysis');end
%
% %Select Parameters from Seismic Catalog -
% [ss1,ok]=listdlg('PromptString','Please Select M scale:',...
% 'ListString',{C.field}, 'SelectionMode','single');
%
% id=findfield(Catalog,C(ss1).field);
% Mtype=Catalog(id).field;
% Ctime=Catalog(id_time).val;
% id_M=findfield(Catalog,Mtype);
% Cmag=Catalog(id_M).val;
%%
cou=1;
for i=1:length(s1)
x=Catalog(s1(i)).val;x=x(Cmag>=Mc);
index=isnan(x)==0;
x=x(isnan(x)==0);
Data(cou).field=Catalog(s1(i)).field;
Data(cou).fieldType=Catalog(s1(i)).fieldType;
Data(cou).val=nan(size(index)); Data(cou).val(index)=x;
cou=cou+1;
end
Ctime=Ctime(Cmag>=Mc);Cmag=Cmag(Cmag>=Mc);
n=length(Ctime);
disp(['number of events: ',num2str(n)])
end
%% --------------------------------------------------------------------------------------
% finds a field defined by a certain (string) name
function [id] = findfield( catalog,field )
id=0;
j=1;
while j <= size(catalog,2) && id==0
if (strcmp(catalog(j).field,field)==1)
id=j;
end
j=j+1;
end
end
%%
function [Ctime,Cmag]=Select_Magnitude_Scale_ver2(Catalog,MType)
cou=1;
for i=1:length(Catalog)
if strcmp(Catalog(i).fieldType,'Magnitude')==1
C(cou).field=Catalog(i).field;cou=cou+1;
end
end
% Check for no magnitude
if cou==1;error('MyComponent:incorrectType',...
'No magnitude column detected!! Please check: Magnitude fields must be noted as one of the following:\nM , Mw , ML , Ms , mb , Md\n or select the entire sample for analysis');end
id=findfield(Catalog,MType);
id_time=findfield(Catalog,'Occurrence_Time');
Cmag=Catalog(id).val;Ctime=Catalog(id_time).val;
end
%% -----------!!!!!!!!!!! HAZARD PARAM<ETERS ESTIMATE FUNCTIONS !!!!!!!!!!!-----------
function [HP] = TDHMagDistWrapper(method, time_win_data, mmin, iop,Mmax)
cd SSH
for i=1:size(time_win_data,2)
mags_vec = time_win_data(i).M;
time_vec = time_win_data(i).Time;
HP(i).mmin = mmin;
HP(i).iop = iop;
HP(i).method = method;
switch method
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;
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;
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);
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;
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;
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;
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);
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;
warning('%s: %s', err.identifier, err.message);
end
end
% K12NOV2015
% Calculate lamb and lamb_all in case of 0, 1, or 2 events.
% It may be generalized in all cases. Rate is now calculated
% by division of the event number by the duration of the set
% - not the time difference between the first and last events.
if numel(mags_vec(mags_vec>=mmin))<3
HP(i).lamb_all= numel(mags_vec)/(time_win_data(i).Tend-time_win_data(i).Tstart);
HP(i).lamb= numel(mags_vec(mags_vec>=mmin))/(time_win_data(i).Tend-time_win_data(i).Tstart);
switch iop
case 0
%OK
case 1
HP(i).lamb_all=HP(i).lamb_all*30;
HP(i).lamb=HP(i).lamb*30;
case 2
HP(i).lamb_all=HP(i).lamb_all*365;
HP(i).lamb=HP(i).lamb*365;
end
end
% K12NOV2015
end
cd ../
end
%%
function [MRPer,ExPr]=TDHRetPeriodExcProbWrapper(meth,mag,time_period,Mmin,HP)
nn=size(HP,2);
if nn==0; 'All datasets are empty'
MRPer=[]; ExPr=[];
else
for i=1:nn
Mmax=HP(i).Mmax;
if HP(i).lamb_err==0;
try
[MRPer(i),ExPr(i)]=SingleRetPeriodExcProbWrapper(meth,mag,time_period,Mmin,HP(i),Mmax);
catch err
MRPer(i)=NaN; ExPr(i)=NaN;
warning('%s: %s', err.identifier, err.message);cd ../
end
else
MRPer(i)=NaN; ExPr(i)=NaN;
if MRPer(i)==inf;MRPer(i)=NaN;end %K 21OCT2016
end
end
end
end
%% Function - SingleRetPeriodExcProbWrapper
function [MRPer,ExPr]=SingleRetPeriodExcProbWrapper(meth,mag,time_period,Mmin,HP,Mmax)
cd SSH
%Md=3;Mu=3;dM=3;Mmin=0.6;
Md = mag;
Mu = mag;
dM = mag;
if isnan(Mmax) && isfield(HP,'Mmax')
Mmax = HP.Mmax;
end
m = []; rper = []; prob = [];
switch meth
case 'GRU'
[m,rper]=Ret_periodGRU(Md,Mu,dM,Mmin,HP.lamb,HP.eps,HP.b);
[m,prob]=ExcProbGRU(0,Md,Mu,dM,time_period,Mmin,HP.lamb,HP.eps,HP.b);
case 'GRT'
[m,rper]=Ret_periodGRT(Md,Mu,dM,Mmin,HP.lamb,HP.eps,HP.b,Mmax);
[m,prob]=ExcProbGRT(0,Md,Mu,dM,time_period,Mmin,HP.lamb,HP.eps,HP.b,Mmax);
case 'NPU'
[m,rper]=Ret_periodNPU(Md,Mu,dM,Mmin,HP.lamb,HP.eps,HP.h,HP.xx,HP.ambd);
[m,prob]=ExcProbNPU(0,Md,Mu,dM,time_period,Mmin,HP.lamb,HP.eps,HP.h,HP.xx,HP.ambd);
case 'NPT'
[m,rper]=Ret_periodNPT(Md,Mu,dM,Mmin,HP.lamb,HP.eps,HP.h,HP.xx,HP.ambd,Mmax);
[m,prob]=ExcProbNPT(0,Md,Mu,dM,time_period,Mmin,HP.lamb,HP.eps,HP.h,HP.xx,HP.ambd,Mmax);
end
if isempty(rper)
MRPer = NaN;
ExPr = NaN;
else
MRPer = rper(1);
ExPr = prob(1);
end
cd ../
end

View File

@ -0,0 +1,99 @@
% [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax)
%
%EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UPPER-BOUNDED G-R
% LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode.
%
% The exceedance probability of magnitude M' in the time period of
% length T' is the probability of an earthquake of magnitude M' or greater
% to occur in T'. Depending on the value of the parameter opt the
% exceedance probability values are calculated for a fixed time period T'
% and different magnitude values or for a fixed magnitude M' and different
% time period length values. In either case the independent variable vector
% starts from xd, up to xu with step dx. In either case the result is
% returned in the vector z.
%
%INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
%OUTPUT:
% x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1,
% x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [x,z]=ExcProbGRT(opt,xd,xu,dx,y,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end
%----------------------------------------------------------
beta=b*log(10);
if opt==0
if xd<Mmin; xd=Mmin;end
if xu>Mmax; xu=Mmax;end
end
x=(xd:dx:xu)';
if opt==0
z=1-exp(-lamb*y.*(1-Cdfgr(x,beta,Mmin-eps/2,Mmax)));
else
z=1-exp(-lamb*(1-Cdfgr(y,beta,Mmin-eps/2,Mmax)).*x);
end
end
function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
% beta - the distribution parameter
% t - vector of magnitudes (independent variable)
% y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1);
y(idx)=ones(size(idx));
end

View File

@ -0,0 +1,78 @@
% [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b)
%
%EVALUATES THE EXCEEDANCE PROBABILITY VALUES USING THE UNLIMITED G-R
% LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode.
%
% The exceedance probability of magnitude M' in the time period of
% length T' is the probability of an earthquake of magnitude M' or greater
% to occur in T'. Depending on the value of the parameter opt the
% exceedance probability values are calculated for a fixed time period T'
% and different magnitude values or for a fixed magnitude M' and different
% time period length values. In either case the independent variable vector
% starts from xd, up to xu with step dx. In either case the result is
% returned in the vector z.
%
%INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
%OUTPUT
% x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1,
% x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [x,z]=ExcProbGRU(opt,xd,xu,dx,y,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end
%----------------------------------------------------------
beta=b*log(10);
if opt==0
if xd<Mmin; xd=Mmin;end
end
x=(xd:dx:xu)';
if opt==0
z=1-exp(-lamb*y.*exp(-beta*(x-Mmin+eps/2)));
else
z=1-exp(-lamb*exp(-beta*(y-Mmin+eps/2)).*x);
end
end

View File

@ -0,0 +1,116 @@
% [x,z]=ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE
% EXCEEDANCE PROBABILITY VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2.
%
% The exceedance probability of magnitude M' in the time
% period of length T' is the probability of an earthquake of magnitude M'
% or greater to occur in T'.
%
% Depending on the value of the parameter opt the exceedance probability
% values are calculated for a fixed time period T' and different magnitude
% values or for a fixed magnitude M' and different time period length
% values. In either case the independent variable vector starts from
% xd, up to xu with step dx. In either case the result is returned in the
% vector z.
%
% REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% x - vector of changeable independent variable x=(xd:dx:xu)
% z - vector of exceedance probability values
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [x,z]=...
ExcProbNPT(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end
%----------------------------------------------------------
if opt==0
if xd<Mmin; xd=Mmin;end
if xu>Mmax; xu=Mmax;end
end
x=(xd:dx:xu)';
n=length(x);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
if opt==0
for i=1:n
CDF_NPT=2*(Dystr_npr(x(i),xx,ambd,h)...
-Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian;
z(i)=1-exp(-lamb*y.*(1-CDF_NPT));
end
else
CDF_NPT=2*(Dystr_npr(y,xx,ambd,h)...
-Dystr_npr(Mmin-eps/2,xx,ambd,h))./mian;
z=1-exp(-lamb*(1-CDF_NPT).*x);
if y>Mmax;z=zeros(size(x));end %K15DEC2015
end
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,105 @@
% [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE
% EXCEEDANCE PROBABILITY VALUES FOR THE UNBOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2.
% The exceedance probability of magnitude M' in the time period of length
% T' is the probability of an earthquake of magnitude M' or greater to
% occur in T'.
% Depending on the value of the parameter opt the exceedance probability
% values are calculated for a fixed time period T' and different magnitude
% values or for a fixed magnitude M' and different time period length
% values. In either case the independent variable vector starts from
% xd, up to xu with step dx. In either case the result is returned in the
% vector z.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
%
% OUTPUT:
% x - vector of changeable independent variable: magnitudes if opt=0,
% time period lengths if opt=1,
% x=(xd:dx:xu)
% z - vector of exceedance probability values of the same length as x
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [x,z]=ExcProbNPU(opt,xd,xu,dx,y,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dx<=0;error('Step must be greater than 0');end
%----------------------------------------------------------
x=(xd:dx:xu)';
n=length(x);
if opt==0
for i=1:n
CDF_NPU=2*(Dystr_npr(x(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
z(i)=1-exp(-lamb*y.*(1-CDF_NPU));
end
else
CDF_NPU=2*(Dystr_npr(y,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
z=1-exp(-lamb*(1-CDF_NPU).*x);
end
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,59 @@
% [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax)
%EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UPPER-BOUNDED
% G-R LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode.
%
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
% INPUT:
% Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_GRT(Td,Tu,dT,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
beta=b*log(10);
mian=(1-exp(-beta*(Mmax-Mmin+eps/2)));
m=Mmin-eps/2-1/beta*log((1-(1-1./(lamb*T))*mian));
end

View File

@ -0,0 +1,63 @@
% [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b)
%
%EVALUATES THE MAXIMUM CREDIBLE MAGNITUDE VALUES USING THE UNLIMITED
% G-R LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode.
%
% The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T.
%
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
%INPUT:
% Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
%
%OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_GRU(Td,Tu,dT,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
beta=b*log(10);
m=Mmin-eps/2+1/beta.*log(lamb*T);
end

View File

@ -0,0 +1,98 @@
% [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM
% CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2.
%
% The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
% REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_NPT(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
n=length(T);
interval=[Mmin-eps/2 Mmax-0.001];
for i=1:n
m(i)=fzero(@F_maxmagn,interval,[],xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i));
end
m=m';
end
function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D)
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian;
y=CDF_NPT-1+1/(lamb*D);
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,98 @@
% [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax) ---- (Octave Compatible Version)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MAXIMUM
% CREDIBLE MAGNITUDE VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2.
%
% The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
% REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% Td - starting period length for maximum credible magnitude calculations
% Tu - ending period length for maximum credible magnitude calculations
% dT - period length step for maximum credible magnitude calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_NPT_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
n=length(T);
interval=[Mmin-eps/2 Mmax-0.001];
for i=1:n
m(i)=fzero(@(t) F_maxmagn(t,xx,h,ambd,Mmin-eps/2,Mmax,lamb,T(i)),interval);
end
m=m';
end
function [y]=F_maxmagn(t,xx,h,ambd,xmin,Mmax,lamb,D)
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
CDF_NPT=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h))/mian;
y=CDF_NPT-1+1/(lamb*D);
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,98 @@
% [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2.
%
% The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
%INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
%
%OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_NPU(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
n=length(T);
interval=[Mmin-eps/2 10.0];
for i=1:n
m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i));
end
m=m';
end
function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D)
CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
y=CDF_NPU-1+1/(lamb*D);
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,99 @@
% [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd) ---- (Octave Comlatible Version)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MAXIMUM CREDIBLE MAGNITUDE VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2.
%
% The maximum credible magnitude for the period of length T
% is the magnitude value whose mean return period is T.
% The maximum credible magnitude values are calculated for periods of
% length starting from Td up to Tu with step dT.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
%INPUT:
% opt - determines the mode of calculations. opt=0 - fixed time period
% length (y), different magnitude values (x), opt=1 - fixed magnitude
% (y), different time period lengths (x)
% xd - starting value of the changeable independent variable
% xu - ending value of the changeable independent variable
% dx - step change of the changeable independent variable
% y - fixed independent variable value: time period length T' if opt=0,
% magnitude M' if opt=1
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
%
%OUTPUT:
% T - vector of independent variable (period lengths) T=(Td:dT:Tu)
% m - vector of maximum credible magnitudes of the same length as T
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [T,m]=Max_credM_NPU_O(Td,Tu,dT,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dT<=0;error('Time Step must be greater than 0');end
%----------------------------------------------------------
T=(Td:dT:Tu)';
n=length(T);
interval=[Mmin-eps/2 10.0];
for i=1:n
% m(i)=fzero(@F_maxmagn_NPU,interval,[],xx,h,ambd,Mmin-eps/2,lamb,T(i));
m(i)=fzero(@(t) F_maxmagn_NPU(t,xx,h,ambd,Mmin-eps/2,lamb,T(i)),interval);
end
m=m';
end
function [y]=F_maxmagn_NPU(t,xx,h,ambd,xmin,lamb,D)
CDF_NPU=2*(Dystr_npr(t,xx,ambd,h)-Dystr_npr(xmin,xx,ambd,h));
y=CDF_NPU-1+1/(lamb*D);
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,259 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin)
%
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd
% FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE
% DISTRIBUTION.
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx.
% See: the references below for a more comprehensive description.
%
% This is a beta version of the program. Further developments are foreseen.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level
%
% OUTPUT
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (the zero of the h functional
% has been found, ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken.
% h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude
% distribution
% ambd - the weigthing factors for the adaptive kernel
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=...
Nonpar(t,M,iop,Mmin)
lamb_err=0;
n=length(M);
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
if iop==0
lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1);
unit='day';
elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014
unit='month';
else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014
unit='year';
end
if nn<50
eps=0;ierr=0;h=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
n=0;
for i=1:length(M)
if M(i)>=Mmin;
n=n+1;
x(n)=M(i);
end
end
x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx);
clear x;
xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx);
[ambd]=scaling(xx,h);
end
function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
%
% m - input vector of magnitudes
% Mmin - catalog completeness level
% eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution
%
% m_corr - vector of randomized magnitudes
%
F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m));
w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta;
end
function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending
% order
x2=[-x+2*x0
x];
x2=sort(x2);
end
function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares
%method
% x - column data vector
% The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search
% MODIFIED JUNE 2014
ierr=0;
n=length(x);
x=sort(x);
interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
[hh(1),fval,exitflag]=fzero(@funct,interval,[],x);
% Extra zeros search
jj=1;
for kk=2:7
interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
jj=jj+1;
[hh(jj),fval,exitflag]=fzero(@funct,interval,[],x);
end
end
if jj>1;ierr=1;end
h=max(hh);
if exitflag==1;return;end
end
h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2;
end
function [fct]=funct(t,x)
p2=1.41421356;
n=length(x);
yy=zeros(size(x));
for i=1:n,
xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y);
end;
fct=sum(yy)-2*n;
clear xij y yy;
end
function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending
% order
% h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors
n=length(x);
c=sqrt(2*pi);
gau=zeros(1,n);
for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end
g=exp(mean(log(gau)));
ambd=sqrt(g./gau);
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end

View File

@ -0,0 +1,310 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=Nonpar(t,M,iop,Mmin)
%
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx AND CALCULATES THE WEIGHTING FACTORS - ambd
% FOR A USE OF THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE
% DISTRIBUTION.
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx.
% See: the references below for a more comprehensive description.
%
% This is a beta version of the program. Further developments are foreseen.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level
%
% OUTPUT
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (the zero of the h functional
% has been found, ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken.
% h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude
% distribution
% ambd - the weigthing factors for the adaptive kernel
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd]=...
Nonpar_O(t,M,iop,Mmin)
if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP
lamb_err=0;
%%% %%%%%%%%%%%%%MICHAL
xx=NaN;
ambd=NaN;
%%% %%%%%%%%%%%%%MICHAL
n=length(M);
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
% SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM;
% SL 03MAR2015 ----------------------------------
if nn<50
eps=0;ierr=0;h=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
n=0;
for i=1:length(M)
if M(i)>=Mmin;
n=n+1;
x(n)=M(i);
end
end
x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx);
clear x;
xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx);
[ambd]=scaling(xx,h);
% enai=dlmread('para.txt'); %for fixed xx,ambd to test in different platforms
% [ambd]=enai(:,1);
% xx=enai(:,2)';
% [h,ierr]=hopt(xx);
end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
%
% t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
%
% NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0
NM=(t2-t1);
unit='day';
elseif iop==1
V1=datevec(t1);
V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12;
unit='month';
else
V1=datevec(t1);
V2=datevec(t2);
NM2=V2(3);
if V2(2)>1
for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k);
end
end
day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2;
NM1=V1(3);
if V1(2)>1
for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k);
end
end
day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year';
end
end
function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
%
% m - input vector of magnitudes
% Mmin - catalog completeness level
% eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution
%
% m_corr - vector of randomized magnitudes
%
F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m));
w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta;
end
function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending
% order
x2=[-x+2*x0
x];
x2=sort(x2);
end
function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares
%method
% x - column data vector
% The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search
% MODIFIED JUNE 2014
ierr=0;
n=length(x);
x=sort(x);
interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
fun = @(t) funct(t,x); % FOR OCTAVE
x0 =interval; % FOR OCTAVE
[hh(1),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE
% Extra zeros search
jj=1;
for kk=2:7
interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
jj=jj+1;
fun = @(t) funct(t,x); % FOR OCTAVE
x0 =interval; % FOR OCTAVE
[hh(jj),fval,exitflag] = fzero(fun,x0); % FOR OCTAVE
end
end
if jj>1;ierr=1;end
h=max(hh);
if exitflag==1;return;end
end
h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2;
end
function [fct]=funct(t,x)
p2=1.41421356;
n=length(x);
yy=zeros(size(x));
for i=1:n,
xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y);
end;
fct=sum(yy)-2*n;
clear xij y yy;
end
function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending
% order
% h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors
n=length(x);
c=sqrt(2*pi);
gau=zeros(1,n);
for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end
g=exp(mean(log(gau)));
ambd=sqrt(g./gau);
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end

View File

@ -0,0 +1,373 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=
% Nonpar(t,M,iop,Mmin)
%
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND
% THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC
% ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE
% ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION.
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx.
% The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred.
% The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)).
%
% See: the references below for a more comprehensive description.
%
% This is a beta version of the program. Further developments are foreseen.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level
%
% OUTPUT
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (a zero of the h functional
% has been found), ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken.
% h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude
% distribution
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used.
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=...
Nonpar_tr(t,M,iop,Mmin)
lamb_err=0;
n=length(M);
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
if iop==0
lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1);
unit='day';
elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014
unit='month';
else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014
unit='year';
end
if nn<50
eps=0;ierr=0;h=0;Mmax=0;err=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
n=0;
for i=1:length(M)
if M(i)>=Mmin;
n=n+1;
x(n)=M(i);
end
end
x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx);
clear x;
xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx);
[ambd]=scaling(xx,h);
[Mmax,err]=Mmaxest(xx,h,Mmin-eps/2);
end
function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
%
% m - input vector of magnitudes
% Mmin - catalog completeness level
% eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution
%
% m_corr - vector of randomized magnitudes
%
F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m));
w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta;
end
function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending
% order
x2=[-x+2*x0
x];
x2=sort(x2);
end
function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares
%method
% x - column data vector
% The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search
% MODIFIED JUNE 2014
ierr=0;
n=length(x);
x=sort(x);
interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
[hh(1),fval,exitflag]=fzero(@funct,interval,[],x);
% Extra zeros search
jj=1;
for kk=2:7
interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
jj=jj+1;
[hh(jj),fval,exitflag]=fzero(@funct,interval,[],x);
end
end
if jj>1;ierr=1;end
h=max(hh);
if exitflag==1;return;end
end
h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2;
end
function [fct]=funct(t,x)
p2=1.41421356;
n=length(x);
yy=zeros(size(x));
for i=1:n,
xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y);
end;
fct=sum(yy)-2*n;
clear xij y yy;
end
function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending
% order
% h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors
n=length(x);
c=sqrt(2*pi);
gau=zeros(1,n);
for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end
g=exp(mean(log(gau)));
ambd=sqrt(g./gau);
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end
function [Mmax,ierr]=Mmaxest(x,h,Mmin)
% ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS
% x - row vector of magnitudes (basic sample).
% h - optimal smoothing factor
% Mmax - upper bound
% ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas
% estimation
% Uses function 'dystryb'
n=length(x);
ierr=1;
x=sort(x);
Mmax1=x(n);
for i=1:50,
d=normcdf((Mmin-x)./h);
mian=sum(normcdf((Mmax1-x)./h)-d);
Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d);
if abs(Mmax-Mmax1)<0.01
ierr=0;break;
end
Mmax1=Mmax;
end
if (ierr==1 || Mmax>9)
Mmax=2*x(n)-x(n-1);
ierr=1;
end
end
function [y]=dystryb(z,h,mian,x,d)
n=length(x);
m=length(z);
for i=1:m,
t=(z(i)-x)./h;
t=normcdf(t);
yy=sum(t-d);
y(i)=(yy/mian)^n;
end
end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated
% a,b - integration limits
% eps - accurracy
% varargin - other parameters of function to be integrated
% calka - integral
% ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12;
delta=CONST*abs(a-b);
calka=0.;
aa=a;
y=b-aa;
ier=0;
while abs(y)>delta,
bb=aa+y;
c1=0.5*(aa+bb);
c2=c1-aa;
s8=0.;
s16=0.;
for i=1:4,
u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
for i=5:12,
u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
s8=s8*c2;
s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y;
calka=0.;
ier=1;
else
calka=calka+s16;
aa=bb;
y=b-aa;
ier=0;
end
end
end

View File

@ -0,0 +1,431 @@
% [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=
% Nonpar_tr(t,M,iop,Mmin)
%
% BASED ON MAGNITUDE SAMPLE DATA M DETERMINES THE ROUND-OFF INTERVAL LENGTH
% OF THE MAGNITUDE DATA - eps, THE SMOOTHING FACTOR - h, CONSTRUCTS
% THE BACKGROUND SAMPLE - xx, CALCULATES THE WEIGHTING FACTORS - amb, AND
% THE END-POINT OF MAGNITUDE DISTRIBUTION Mmax FOR A USE OF THE NONPARAMETRIC
% ADAPTATIVE KERNEL ESTIMATORS OF MAGNITUDE DISTRIBUTION UNDER THE
% ASSUMPTION OF THE EXISTENCE OF THE UPPER LIMIT OF MAGNITUDE DISTRIBUTION.
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% NON-PARAMETRIC HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. The smoothing factor
% h, is estimated using the least-squares cross-validation for the Gaussian
% kernel function. The final form of the kernel is the adaptive kernel.
% In order to avoid repetitions, which cannot appear in a sample when the
% kernel estimators are used, the magnitude sample data are randomized
% within the magnitude round-off interval. The round-off interval length -
% eps is the least non-zero difference between sample data or 0.1 is the
% least difference if greater than 0.1. The randomization is done
% assuming exponential distribution of m in [m0-eps/2, m0+eps/2], where m0
% is the sample data point and eps is the length of roud-off inteval. The
% shape parameter of the exponential distribution is estimated from the whole
% data sample assuming the exponential distribution. The background sample
% - xx comprises the randomized values of magnitude doubled symmetrically
% with respect to the value Mmin-eps/2: length(xx)=2*length(M). Weigthing
% factors row vector for the adaptive kernel is of the same size as xx.
% The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred.
% The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)).
%
% See: the references below for a more comprehensive description.
%
% This is a beta version of the program. Further developments are foreseen.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes (sample data)
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - lower bound of the distribution - catalog completeness level
%
% OUTPUT
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 50 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of round-off interval of magnitudes.
% ierr - h-convergence indicator. ierr=0 if the estimation procedure of
% the optimal smoothing factor has converged (a zero of the h functional
% has been found), ierr=1 when multiple zeros of h functional were
% encountered - the largest h is accepted, ierr = 2 when h functional did
% not zeroe - the approximate h value is taken.
% h - kernel smoothing factor.
% xx - the background sample for the nonparametric estimators of magnitude
% distribution
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used.
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,ierr,h,xx,ambd,Mmax,err]=...
Nonpar_tr_O(t,M,iop,Mmin,Mmax)
if isempty(t) || numel(t)<3 isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP
lamb_err=0;
n=length(M);
t1=t(1);
%%% %%%%%%%%%%%%%MICHAL
xx=NaN;
ambd=NaN;
%%% %%%%%%%%%%%%%MICHAL
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
% SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM;
% SL 03MAR2015 ----------------------------------
if nn<50
eps=0;ierr=0;h=0;Mmax=0;err=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
n=0;
for i=1:length(M)
if M(i)>=Mmin;
n=n+1;
x(n)=M(i);
end
end
x=sort(x)';
beta=1/(mean(x)-Mmin+eps/2);
[xx]=korekta(x,Mmin,eps,beta);
xx=sort(xx);
clear x;
xx = podwajanie(xx,Mmin-eps/2);
[h,ierr]=hopt(xx);
[ambd]=scaling(xx,h);
if isempty(Mmax) %K30AUG2019 - Allow for manually set Mmax
[Mmax,err]=Mmaxest(xx,h,Mmin-eps/2);
else
err=0; %K30AUG2019
end
% enai=dlmread('paraT.txt'); %for fixed xx,ambd to test in different platforms
% [ambd]=enai(:,1);
% xx=enai(:,2)';
% [h,ierr]=hopt(xx);
% [Mmax,err]=Mmaxest(xx,h,Mmin-eps/2);
end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015 ----------------------------------
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
%
% t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
%
% NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0
NM=(t2-t1);
unit='day';
elseif iop==1
V1=datevec(t1);
V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12;
unit='month';
else
V1=datevec(t1);
V2=datevec(t2);
NM2=V2(3);
if V2(2)>1
for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k);
end
end
day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2;
NM1=V1(3);
if V1(2)>1
for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k);
end
end
day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year';
end
end
function [m_corr]=korekta(m,Mmin,eps,beta)
% RANDOMIZATION OF MAGNITUDE WITHIN THE ACCURACY INTERVAL
%
% m - input vector of magnitudes
% Mmin - catalog completeness level
% eps - accuracy of magnitude
% beta - the parameter of the unbounded exponential distribution
%
% m_corr - vector of randomized magnitudes
%
F1=1-exp(-beta*(m-Mmin-0.5*eps));
F2=1-exp(-beta*(m-Mmin+0.5*eps));
u=rand(size(m));
w=u.*(F2-F1)+F1;
m_corr=Mmin-log(1-w)./beta;
end
function x2 = podwajanie(x,x0)
% DOUBLES THE SAMPLE
% If the sample x(i) is is truncated from the left hand side and belongs
% to the interval [x0,inf) or it is truncated from the right hand side and
% belongs to the interval (-inf,x0]
% then the doubled sample is [-x(i)+2x0,x(i)]
% x - is the column data vector
% x2 - is the column vector of data doubled and sorted in the ascending
% order
x2=[-x+2*x0
x];
x2=sort(x2);
end
function [h,ierr]=hopt(x)
%Estimation of the optimal smoothing factor by means of the least squares
%method
% x - column data vector
% The result is an optimal smoothing factor
% ierr=0 - convergence, ierr=1 - multiple h, ierr=2 - approximate h is used
% The function calls the procedure FZERO for the function 'funct'
% NEW VERSION 2 - without a square matrix. Also equipped with extra zeros
% search
% MODIFIED JUNE 2014
ierr=0;
n=length(x);
x=sort(x);
interval=[0.000001 2*std(x)/n^0.2];
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
fun = @(t) funct(t,x); % for octave
x0 =interval; % for octave
[hh(1),fval,exitflag] = fzero(fun,x0); % for octave
% Extra zeros search
jj=1;
for kk=2:7
interval(1)=1.1*hh(jj);
interval(2)=interval(1)+(kk-1)*hh(jj);
x1=funct(interval(1),x);
x2=funct(interval(2),x);
if x1*x2<0
jj=jj+1;
fun = @(t) funct(t,x); % for octave
x0 =interval; % for octave
[hh(jj),fval,exitflag] = fzero(fun,x0); % for octave
end
end
if jj>1;ierr=1;end
h=max(hh);
if exitflag==1;return;end
end
h=0.891836*(mean(x)-x(1))/(n^0.2);
ierr=2;
end
function [fct]=funct(t,x)
p2=1.41421356;
n=length(x);
yy=zeros(size(x));
for i=1:n,
xij=(x-x(i)).^2/t^2;
y=exp(-xij/4).*((xij/2-1)/p2)-2*exp(-xij/2).*(xij-1);
yy(i)=sum(y);
end;
fct=sum(yy)-2*n;
clear xij y yy;
end
function [ambd]=scaling(x,h)
% EVALUATES A VECTOR OF SCALING FACTORS FOR THE NONPARAMETRIC ADAPTATIVE
% ESTIMATION
% x - the n dimensional column vector of data values sorted in the ascending
% order
% h - the optimal smoothing factor
% ambd - the resultant n dimensional row vector of local scaling factors
n=length(x);
c=sqrt(2*pi);
gau=zeros(1,n);
for i=1:n,
gau(i)=sum(exp(-0.5*((x(i)-x)/h).^2))/c/n/h;
end
g=exp(mean(log(gau)));
ambd=sqrt(g./gau);
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end
function [Mmax,ierr]=Mmaxest(x,h,Mmin)
% ESTIMATION OF UPPER BOUND USING NONPARAMETRIC DISTRIBUTION FUNCTIONS
% x - row vector of magnitudes (basic sample).
% h - optimal smoothing factor
% Mmax - upper bound
% ierr=0 if basic procedure converges, ierr=1 when Robsen & Whitlock Mmas
% estimation
% Uses function 'dystryb'
n=length(x);
ierr=1;
x=sort(x);
Mmax1=x(n);
for i=1:50,
d=normcdf((Mmin-x)./h);
mian=sum(normcdf((Mmax1-x)./h)-d);
Mmax=x(n)+moja_calka(@dystryb,x(1),Mmax1,0.00001,h,mian,x,d);
if abs(Mmax-Mmax1)<0.01
ierr=0;break;
end
Mmax1=Mmax;
end
if (ierr==1 || Mmax>9)
Mmax=2*x(n)-x(n-1);
ierr=1;
end
end
function [y]=dystryb(z,h,mian,x,d)
n=length(x);
m=length(z);
for i=1:m,
t=(z(i)-x)./h;
t=normcdf(t);
yy=sum(t-d);
y(i)=(yy/mian)^n;
end
end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated
% a,b - integration limits
% eps - accurracy
% varargin - other parameters of function to be integrated
% calka - integral
% ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12;
delta=CONST*abs(a-b);
calka=0.;
aa=a;
y=b-aa;
ier=0;
while abs(y)>delta,
bb=aa+y;
c1=0.5*(aa+bb);
c2=c1-aa;
s8=0.;
s16=0.;
for i=1:4,
u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
for i=5:12,
u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
s8=s8*c2;
s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y;
calka=0.;
ier=1;
else
calka=calka+s16;
aa=bb;
y=b-aa;
ier=0;
end
end
end

View File

@ -0,0 +1,83 @@
% [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax)
%
% EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UPPER-BOUNDED G-R LED
% MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distriobution Mmax as well as the
% activity rate of M>=Mmin events are calculated at start-up of the
% stationary hazard assessment services in the upper-bounded
% Gutenberg-Richter estimation mode.
%
% The mean return period of magnitude M is the average elapsed time between
% the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM.
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of earthquake magnitudes
% Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
% OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m,T]=Ret_periodGRT(Md,Mu,dM,Mmin,lamb,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
if Md<Mmin; Md=Mmin;end
if Mu>Mmax; Mu=Mmax;end
m=(Md:dM:Mu)';
beta=b*log(10);
T=1/lamb./(1-Cdfgr(m,beta,Mmin-eps/2,Mmax));
end
function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
% beta - the distribution parameter
% t - vector of magnitudes (independent variable)
% y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1);
y(idx)=ones(size(idx));
end

View File

@ -0,0 +1,59 @@
% [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b)
%
% EVALUATES THE MEAN RETURN PERIOD VALUES USING THE UNLIMITED G-R LED
% MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode.
%
% The mean return period of magnitude M is the average elapsed time between
% the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM.
%
%INPUT:
% Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
%
%OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m,T]=Ret_periodGRU(Md,Mu,dM,Mmin,lamb,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
if Md<Mmin; Md=Mmin;end
m=(Md:dM:Mu)';
beta=b*log(10);
T=1/lamb./exp(-beta*(m-Mmin+eps/2));
end

View File

@ -0,0 +1,94 @@
% [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax)
%
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES THE MEAN
% RETURN PERIOD VALUES FOR THE UPPER-BOUNDED NONPARAMETRIC
% DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2.
%
% The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM.
%
% REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m,T]=Ret_periodNPT(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
if Md<Mmin; Md=Mmin;end
if Mu>Mmax; Mu=Mmax;end
m=(Md:dM:Mu)';
n=length(m);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
for i=1:n
CDF_NPT=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian;
T(i)=1/lamb./(1-CDF_NPT);
end
T=T';
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,91 @@
% [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd)
%
%USING THE NONPARAMETRIC ADAPTATIVE KERNEL APPROACH EVALUATES
% THE MEAN RETURN PERIOD VALUES FOR THE UNBOUNDED
% NONPARAMETRIC DISTRIBUTION FOR MAGNITUDE.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2.
%
% The mean return period of magnitude M is the average
% elapsed time between the consecutive earthquakes of magnitude M.
% The mean return periods are calculated for magnitude starting from Md up
% to Mu with step dM.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
% INPUT:
% Md - starting magnitude for return period calculations
% Mu - ending magnitude for return period calculations
% dM - magnitude step for return period calculations
% Mmin - lower bound of the distribution - catalog completeness level
% lamb - mean activity rate for events M>=Mmin
% eps - length of the round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
%
%OUTPUT:
% m - vector of independent variable (magnitude) m=(Md:dM:Mu)
% T - vector od mean return periods of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m,T]=Ret_periodNPU(Md,Mu,dM,Mmin,lamb,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
if Md<Mmin; Md=Mmin;end
m=(Md:dM:Mu)';
n=length(m);
for i=1:n
CDF_NPU=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
T(i)=1/lamb./(1-CDF_NPU);
end
T=T';
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,250 @@
%
% [lamb_all,lamb,lmab_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin)
%
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE,
% THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE
% DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution and consequently the G-R
% b-value is estimated by maximum likelihood method (Aki-Utsu procedure).
% The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)).
% The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps is the least non-zero difference
% between sample data or 0.1 if the least difference is greater than 0.1.
%
% REFERENCES:
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally.
% Can take any value from [min(M), max(M)].
%
% OUTPUT:
%
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 15 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used.
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin)
n=length(M);
lamb_err=0;
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
if iop==0
lamb_all=n/round(t(n)-t(1));
lamb=nn/round(t2-t1);
unit='day';
elseif iop==1
lamb_all=30*n/(t(n)-t(1)); % K20OCT2014
lamb=30*nn/(t2-t1); % K20OCT2014
unit='month';
else
lamb_all=365*n/(t(n)-t(1)); % K20OCT2014
lamb=365*nn/(t2-t1); % K20OCT2014
unit='year';
end
if nn<15
eps=0;b=0;Mmax=0;err=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014
% x=sort(M,'descend');
% for i=1:n
% if x(i)<Mmin; break; end
% xx(i)=x(i); %
% end
clear x;
nn=length(xx);
Max_obs=max(xx);
beta0=0;
Mmax1=Max_obs;
for i=1:50,
beta=fzero(@bet_est,[0.05,4.0],[],mean(xx),Mmin-eps/2,Mmax1);
Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1);
if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001))
err=0;
break;
end
Mmax1=Mmax;
beta0=beta;
end
if i==50;
err=1.0;
Mmax=2*xx(1)-xx(2);
beta=fzero(@bet_est,1.0,[],mean(xx),Mmin-eps/2,Mmax);
end
b=beta/log(10);
clear xx
end
function [zero]=bet_est(b,ms,Mmin,Mmax)
%First derivative of the log likelihood function of the upper-bounded
% exponential distribution (truncated GR model)
% b - parameter of the distribution 'beta'
% ms - mean of the observed magnitudes
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
M_max_min=Mmax-Mmin;
e_m=exp(-b*M_max_min);
zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m);
end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated
% a,b - integration limits
% eps - accurracy
% varargin - other parameters of function to be integrated
% calka - integral
% ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12;
delta=CONST*abs(a-b);
calka=0.;
aa=a;
y=b-aa;
ier=0;
while abs(y)>delta,
bb=aa+y;
c1=0.5*(aa+bb);
c2=c1-aa;
s8=0.;
s16=0.;
for i=1:4,
u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
for i=5:12,
u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
s8=s8*c2;
s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y;
calka=0.;
ier=1;
else
calka=calka+s16;
aa=bb;
y=b-aa;
ier=0;
end
end
end
function [y]=f_podc(z,n,beta,Mmin,Mmax)
% Integrated function for Mmax estimation. Truncated GR model
% z - column vector of independent variable
% n - the size of 'z'
% beta - the distribution parameter
% Mmin - the catalog completeness level
% Mmax - the upper limit of the distribution
y=Cdfgr(z,beta,Mmin,Mmax).^n;
end
function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
% beta - the distribution parameter
% t - vector of magnitudes (independent variable)
% y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1);
y(idx)=ones(size(idx));
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end

View File

@ -0,0 +1,305 @@
%
% [lamb_all,lamb,lmab_err,unit,eps,b,Mmax,err]=TruncGR(t,M,iop,Mmin)
%
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE,
% THE GUTENBERG-RICHTER B-VALUE AND THE UPPER BOUND OF MAGNITUDE
% DISTRIBUTION USING THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UPPER-BOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution and consequently the G-R
% b-value is estimated by maximum likelihood method (Aki-Utsu procedure).
% The upper limit of the distribution Mmax is evaluated using
% the Kijko-Sellevol generic formula. If convergence is not reached the
% Whitlock @ Robson simplified formula is used:
% Mmaxest= 2(max obs M) - (second max obs M)).
% The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps is the least non-zero difference
% between sample data or 0.1 if the least difference is greater than 0.1.
%
% REFERENCES:
%Kijko, A., and M.A. Sellevoll (1989) Bull. Seismol. Soc. Am. 79, 3,645-654
%Lasocki, S., Urban, P. (2011) Acta Geophys 59, 659-673,
% doi: 10.2478/s11600-010-0049-y
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally.
% Can take any value from [min(M), max(M)].
%
% OUTPUT:
%
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 15 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
% err - error parameter on Mmax estimation, err=0 - convergence, err=1 -
% no converegence of Kijko-Sellevol estimator, Robinson @ Whitlock
% method used.
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [lamb_all,lamb,lamb_err,unit,eps,b,Mmax,err]=TruncGR_O(t,M,iop,Mmin,Mmax)
if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP
n=length(M);
lamb_err=0;
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
% SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM;
% SL 03MAR2015 ----------------------------------
if nn<15
eps=0;b=0;Mmax=0;err=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014
% x=sort(M,'descend');
% for i=1:n
% if x(i)<Mmin; break; end
% xx(i)=x(i); %
% end
clear x;
nn=length(xx);
Max_obs=max(xx);
beta0=0;
Mmax1=Max_obs;
if isempty(Mmax)==0 %%% K 28JUL2015
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax); %%% K 28JUL2015
x0 = 1; %[0.05,4.0]; %%% K 28JUL2015 - See exception line 153
beta = fzero(fun,x0); %%% K 28JUL2015
err=0; %%% K 28JUL2015
else %%% K 28JUL2015 - line 148
for i=1:50,
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax1);
x0 =1; %[0.05,4.0]; %%% K29JUL2015 - See exception line 153
beta = fzero(fun,x0);
Mmax=Max_obs+moja_calka('f_podc',Mmin,Max_obs,1e-5,nn,beta,Mmin-eps/2,Mmax1);
if ((abs(Mmax-Mmax1)<0.01)&&(abs(beta-beta0)<0.0001))
err=0;
break;
end
Mmax1=Mmax;
beta0=beta;
end
if i==50;
err=1.0;
Mmax=2*xx(1)-xx(2);
fun = @(b) bet_est(b,mean(xx),Mmin-eps/2,Mmax);
x0 =1;
beta = fzero(fun,x0);
end
end %%% K 28JUL2015
b=beta/log(10);
clear xx
% Exception for v-value
if b<0.05 || b>6.0; error('Unacceptable b-value, abort and select different dataset');end
beta;
end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
%
% t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
%
% NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0
NM=(t2-t1);
unit='day';
elseif iop==1
V1=datevec(t1);
V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12;
unit='month';
else
V1=datevec(t1);
V2=datevec(t2);
NM2=V2(3);
if V2(2)>1
for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k);
end
end
day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2;
NM1=V1(3);
if V1(2)>1
for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k);
end
end
day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year';
end
end
function [zero]=bet_est(b,ms,Mmin,Mmax)
%First derivative of the log likelihood function of the upper-bounded
% exponential distribution (truncated GR model)
% b - parameter of the distribution 'beta'
% ms - mean of the observed magnitudes
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
M_max_min=Mmax-Mmin;
e_m=exp(-b*M_max_min);
zero=1/b-ms+Mmin-M_max_min*e_m/(1-e_m);
end
function [calka,ier]=moja_calka(funfc,a,b,eps,varargin)
% Integration by means of 16th poit Gauss method. Adopted from CERNLIBRARY
% funfc - string with the name of function to be integrated
% a,b - integration limits
% eps - accurracy
% varargin - other parameters of function to be integrated
% calka - integral
% ier=0 - convergence, ier=1 - no conbergence
persistent W X CONST
W=[0.101228536290376 0.222381034453374 0.313706645877887 ...
0.362683783378362 0.027152459411754 0.062253523938648 ...
0.095158511682493 0.124628971255534 0.149595988816577 ...
0.169156519395003 0.182603415044924 0.189450610455069];
X=[0.960289856497536 0.796666477413627 0.525532409916329 ...
0.183434642495650 0.989400934991650 0.944575023073233 ...
0.865631202387832 0.755404408355003 0.617876244402644 ...
0.458016777657227 0.281603550779259 0.095012509837637];
CONST=1E-12;
delta=CONST*abs(a-b);
calka=0.;
aa=a;
y=b-aa;
ier=0;
while abs(y)>delta,
bb=aa+y;
c1=0.5*(aa+bb);
c2=c1-aa;
s8=0.;
s16=0.;
for i=1:4,
u=X(i)*c2;
s8=s8+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
for i=5:12,
u=X(i)*c2;
s16=s16+W(i)*(feval(funfc,c1+u,varargin{:})+feval(funfc,c1-u,varargin{:}));
end
s8=s8*c2;
s16=s16*c2;
if abs(s16-s8)>eps*(1+abs(s16))
y=0.5*y;
calka=0.;
ier=1;
else
calka=calka+s16;
aa=bb;
y=b-aa;
ier=0;
end
end
end
function [y]=f_podc(z,n,beta,Mmin,Mmax)
% Integrated function for Mmax estimation. Truncated GR model
% z - column vector of independent variable
% n - the size of 'z'
% beta - the distribution parameter
% Mmin - the catalog completeness level
% Mmax - the upper limit of the distribution
y=Cdfgr(z,beta,Mmin,Mmax).^n;
end
function [y]=Cdfgr(t,beta,Mmin,Mmax)
%CDF of the truncated upper-bounded exponential distribution (truncated G-R
% model
% Mmin - catalog completeness level
% Mmax - upper limit of the distribution
% beta - the distribution parameter
% t - vector of magnitudes (independent variable)
% y - CDF vector
mian=(1-exp(-beta*(Mmax-Mmin)));
y=(1-exp(-beta*(t-Mmin)))/mian;
idx=find(y>1);
y(idx)=ones(size(idx));
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end

View File

@ -0,0 +1,162 @@
% [lamb_all,lamb,lmab_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin)
%
% ESTIMATES THE MEAN ACTIVITY RATE WITHIN THE WHOLE SAMPLE AND WITHIN THE
% COMPLETE PART OF THE SAMPLE, THE ROUND-OFF ERROR OF MAGNITUDE AND THE
% GUTENBERG-RICHTER B-VALUE USING THE UNLIMITED G-R LED MAGNITUDE
% DISTRIBUTION MODEL
%
% !! THIS FUNCTION MUST BE EXECUTED AT START-UP OF THE UNBOUNDED
% GUTENBERG-RICHETR HAZARD ESTIMATION MODE !!
%
% AUTHOR: S. Lasocki ver 2 01/2015 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value is estimated by
% maximum likelihood method (Aki-Utsu procedure).
% The mean activity rate, lamb, is the number of events >=Mmin into the
% length of the period in which they occurred. Upon the value of the input
% parameter, iop, the used unit of time can be either day ot month or year.
% The round-off interval length - eps if the least non-zero difference
% between sample data or 0.1 is the least difference is greater than 0.1.
%
% INPUT:
% t - vector of earthquake occurrence times
% M - vector of magnitudes from a user selected catalog
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
% Mmin - catalog completeness level. Must be determined externally.
% can take any value from [min(M), max(M)].
%
% OUTPUT:
% lamb_all - mean activity rate for all events
% lamb - mean activity rate for events >= Mmin
% lamb_err - error paramter on the number of events >=Mmin. lamb_err=0
% for 7 or more events >=Mmin and the parameter estimation is
% continued, lamb_err=1 otherwise, all output paramters except
% lamb_all and lamb are set to zero and the function execution is
% terminated.
% unit - string with name of time unit used ('year' or 'month' or 'day').
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
function [lamb_all,lamb,lamb_err,unit,eps,b]=UnlimitGR(t,M,iop,Mmin)
if isempty(t) || numel(t)<3 || isempty(M(M>=Mmin)) %K03OCT
t=[1 2];M=[1 2]; end %K30SEP
lamb_err=0;
n=length(M);
t1=t(1);
for i=1:n
if M(i)>=Mmin; break; end
t1=t(i+1);
end
t2=t(n);
for i=n:1
if M(i)>=Mmin; break; end
t2=t(i-1);
end
nn=0;
for i=1:n
if M(i)>=Mmin
nn=nn+1;
end
end
% SL 03MAR2015 ----------------------------------
[NM,unit]=time_diff(t(1),t(n),iop);
lamb_all=n/NM;
[NM,unit]=time_diff(t1,t2,iop);
lamb=nn/NM;
% SL 03MAR2015 ----------------------------------
if nn<7
eps=0;b=0;
lamb_err=1;
return;
end
eps=magn_accur(M);
xx=M(M>=Mmin); %K21OCT2014
% x=sort(M,'descend');
% for i=1:n
% if x(i)<Mmin; break; end
% xx(i)=x(i); %
% end
clear x;
beta=1/(mean(xx)-Mmin+eps/2);
b=beta/log(10);
clear xx
end
function [NM,unit]=time_diff(t1,t2,iop) % SL 03MAR2015
% TIME DIFFERENCE BETWEEEN t1,t2 EXPRESSED IN DAY, MONTH OR YEAR UNIT
%
% t1 - start time (in MATLAB numerical format)
% t2 - end time (in MATLAB numerical format) t2>=t1
% iop - determines the used unit of time. iop=0 - 'day', iop=1 - 'month',
% iop=2 - 'year'
%
% NM - number of time units from t1 to t2
% unit - string with name of time unit used ('year' or 'month' or 'day').
if iop==0
NM=(t2-t1);
unit='day';
elseif iop==1
V1=datevec(t1);
V2=datevec(t2);
NM=V2(3)/eomday(V2(1),V2(2))+V2(2)+12-V1(2)-V1(3)/eomday(V1(1),V1(2))...
+(V2(1)-V1(1)-1)*12;
unit='month';
else
V1=datevec(t1);
V2=datevec(t2);
NM2=V2(3);
if V2(2)>1
for k=1:V2(2)-1
NM2=NM2+eomday(V2(1),k);
end
end
day2=365; if eomday(V2(1),2)==29; day2=366; end;
NM2=NM2/day2;
NM1=V1(3);
if V1(2)>1
for k=1:V1(2)-1
NM1=NM1+eomday(V1(1),k);
end
end
day1=365; if eomday(V1(1),2)==29; day1=366; end;
NM1=(day1-NM1)/day1;
NM=NM2+NM1+V2(1)-V1(1)-1;
unit='year';
end
end
function [eps]=magn_accur(M)
x=sort(M);
d=x(2:length(x))-x(1:length(x)-1);
eps=min(d(d>0));
if eps>0.1; eps=0.1;end
end

View File

@ -0,0 +1,64 @@
% [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax)
%
% EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE
% UNDER THE UPPER-BOUNDED G-R LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the upper-bounded Gutenberg-Richter
% relation leads to the upper truncated exponential distribution to model
% magnitude distribution from and above the catalog completness level
% Mmin. The shape parameter of this distribution, consequently the G-R
% b-value and the end-point of the distribution Mmax are calculated at
% start-up of the stationary hazard assessment services in the
% upper-bounded Gutenberg-Richter estimation mode.
%
% The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM.
%
%INPUT:
% Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
% Mmax - upper limit of magnitude distribution
%
%OUTPUT:
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_GRT - PDF vector of the same length as m
% CDF_GRT - CDF vector of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m, PDF_GRT, CDF_GRT]=dist_GRT(Md,Mu,dM,Mmin,eps,b,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
m=(Md:dM:Mu)';
beta=b*log(10);
mian=(1-exp(-beta*(Mmax-Mmin+eps/2)));
PDF_GRT=beta*exp(-beta*(m-Mmin+eps/2))/mian;
CDF_GRT=(1-exp(-beta*(m-Mmin+eps/2)))/mian;
idx=find(CDF_GRT<0);
PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=zeros(size(idx));
idx=find(CDF_GRT>1);
PDF_GRT(idx)=zeros(size(idx));CDF_GRT(idx)=ones(size(idx));
end

View File

@ -0,0 +1,61 @@
% [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b)
%
% EVALUATES THE DENSITY AND CUMULATIVE DISTRIBUTION FUNCTIONS OF MAGNITUDE
% UNDER THE UNLIMITED G-R LED MAGNITUDE DISTRIBUTION MODEL.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The assumption on the unlimited Gutenberg-Richter relation
% leads to the exponential distribution model of magnitude distribution
% from and above the catalog completness level Mmin. The shape parameter of
% this distribution and consequently the G-R b-value are calculated at
% start-up of the stationary hazard assessment services in the
% unlimited Gutenberg-Richter estimation mode.
%
% The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM.
%
%INPUT:
% Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level
% eps - length of the round-off interval of magnitudes.
% b - Gutenberg-Richter b-value
%
%OUTPUT:
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_GRT - PDF vector of the same length as m
% CDF_GRT - CDF vector of the same length as m
%
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m, PDF_GRU, CDF_GRU]=dist_GRU(Md,Mu,dM,Mmin,eps,b)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
m=(Md:dM:Mu)';
beta=b*log(10);
PDF_GRU=beta*exp(-beta*(m-Mmin+eps/2));
CDF_GRU=1-exp(-beta*(m-Mmin+eps/2));
idx=find(CDF_GRU<0);
PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=zeros(size(idx));
idx=find(CDF_GRU>1);
PDF_GRU(idx)=zeros(size(idx));CDF_GRU(idx)=ones(size(idx));
end

View File

@ -0,0 +1,116 @@
% [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax)
%
% USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY
% AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UPPER-BOUNDED MAGNITUDE
% DISTRIBUTION.
%
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution has a hard end point Mmax from the right hand
% side.The estimation makes use of the previously estimated parameters
% namely the mean activity rate lamb, the length of magnitude round-off
% interval, eps, the smoothing factor, h, the background sample, xx, the
% scaling factors for the background sample, ambd, and the end-point of
% magnitude distribution Mmax. The background sample,xx, comprises the
% randomized values of observed magnitude doubled symmetrically with
% respect to the value Mmin-eps/2.
%
% REFERENCES:
% Silverman B.W. (1986) Density Estimation for Statistics and Data Analysis,
% Chapman and Hall, London
% Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
% Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
%INPUT:
% Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
% Mmax - upper limit of magnitude distribution
%
% OUTPUT:
% m - vector of the independent variable (magnitude)
% PDF_NPT - PDF vector
% CDF_NPT - CDF vector
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m,PDF_NPT,CDF_NPT]=dist_NPT(Md,Mu,dM,Mmin,eps,h,xx,ambd,Mmax)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
m=(Md:dM:Mu)';
nn=length(m);
mian=2*(Dystr_npr(Mmax,xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
for i=1:nn
if m(i)<Mmin-eps/2
PDF_NPT(i)=0;CDF_NPT(i)=0;
elseif m(i)>Mmax
PDF_NPT(i)=0;CDF_NPT(i)=1;
else
PDF_NPT(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2)/mian;
CDF_NPT(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h))/mian;
end
end
PDF_NPT=PDF_NPT';CDF_NPT=CDF_NPT';
end
function [gau]=dens_npr1(y,x,ambd,h,x1)
%Nonparametric adaptive density for a variable from the interval [x1,inf)
% x - the sample data doubled and sorted in the ascending order. Use
% "podwajanie.m" first to accmoplish that.
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
c=sqrt(2*pi);
if y<x1
gau=0;
else
gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h;
end
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,114 @@
% [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd)
%
% USING THE NONPARAMETRIC ADAPTATIVE KERNEL ESTIMATORS EVALUATES THE DENSITY
% AND CUMULATIVE DISTRIBUTION FUNCTIONS FOR THE UNLIMITED MAGNITUDE
% DISTRIBUTION.
%
% AUTHOR: S. Lasocki 06/2014 within IS-EPOS project.
%
% DESCRIPTION: The kernel estimator approach is a model-free alternative
% to estimating the magnitude distribution functions. It is assumed that
% the magnitude distribution is unlimited from the right hand side.
% The estimation makes use of the previously estimated parameters of kernel
% estimation, namely the smoothing factor, the background sample and the
% scaling factors for the background sample. The background sample
% - xx comprises the randomized values of observed magnitude doubled
% symmetrically with respect to the value Mmin-eps/2
%
% The distribution function values are calculated for magnitude starting
% from Md up to Mu with step dM.
%
% REFERENCES:
%Silverman B.W. (1986) Density Estimation fro Statistics and Data Analysis,
% Chapman and Hall, London
%Kijko A., Lasocki S., Graham G. (2001) Pure appl. geophys. 158, 1655-1665
%Lasocki S., Orlecka-Sikora B. (2008) Tectonophysics 456, 28-37
%
%INPUT:
% Md - starting magnitude for distribution functions calculations
% Mu - ending magnitude for distribution functions calculations
% dM - magnitude step for distribution functions calculations
% Mmin - lower bound of the distribution - catalog completeness level
% eps - length of round-off interval of magnitudes.
% h - kernel smoothing factor.
% xx - the background sample
% ambd - the weigthing factors for the adaptive kernel
%
%
%OUTPUT
% m - vector of the independent variable (magnitude) m=(Md:dM:Mu)
% PDF_NPU - PDF vector of the same length as m
% CDF_NPU - CDF vector of the same length as m
%
% LICENSE
% This file is a part of the IS-EPOS e-PLATFORM.
%
% 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.
%
function [m, PDF_NPU, CDF_NPU]=dist_NPU(Md,Mu,dM,Mmin,eps,h,xx,ambd)
% -------------- VALIDATION RULES ------------- K_21NOV2016
if dM<=0;error('Magnitude Step must be greater than 0');end
%----------------------------------------------------------
m=(Md:dM:Mu)';
nn=length(m);
for i=1:nn
if m(i)>=Mmin-eps/2
PDF_NPU(i)=dens_npr1(m(i),xx,ambd,h,Mmin-eps/2);
CDF_NPU(i)=2*(Dystr_npr(m(i),xx,ambd,h)-Dystr_npr(Mmin-eps/2,xx,ambd,h));
else
PDF_NPU(i)=0;
CDF_NPU(i)=0;
end
end
PDF_NPU=PDF_NPU';CDF_NPU=CDF_NPU';
end
function [gau]=dens_npr1(y,x,ambd,h,x1)
%Nonparametric adaptive density for a variable from the interval [x1,inf)
% x - the sample data doubled and sorted in the ascending order. Use
% "podwajanie.m" first to accmoplish that.
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
c=sqrt(2*pi);
if y<x1
gau=0;
else
gau=2*sum(exp(-0.5*(((y-x)./ambd')./h).^2)./ambd')/c/n/h;
end
end
function [Fgau]=Dystr_npr(y,x,ambd,h)
%Nonparametric adaptive cumulative distribution for a variable from the
%interval (-inf,inf)
% x - the sample data
% ambd - the local scaling factors for the adaptive estimation
% h - the optimal smoothing factor
% y - the value of random variable X for which the density is calculated
% gau - the density value f(y)
n=length(x);
Fgau=sum(normcdf(((y-x)./ambd')./h))/n;
end

View File

@ -0,0 +1,5 @@
735470.75 735679.15
735679.15 735808.95
735808.95 735968.08
735968.08 736027.27
736027.27 736191.58

View File

@ -0,0 +1,137 @@
close all;d=figure('Position',[300 50 1600 950]);
% check whether the selected time windows are overlapping or not
TT=[];Tcat=Catalog(1).val;Ncat=Tcat(Tcat>=time_windows(1).Tstart & Tcat<=time_windows(length(ExPr)).Tend);
for i=1:length(MRPer);
TW1(i)=time_windows(i).Tstart;Tw2(i)=time_windows(i).Tend;
tplo(i)=mean([time_windows(i).Tstart time_windows(i).Tend]);meanM(i)=mean(time_windows(i).M);hold on
TT=[TT;time_windows(i).Time];
lambda(i)=HP(i).lamb;
if strcmp(HP(1).method,'GRU') || strcmp(HP(1).method,'GRT');yyaxis right;bval(i)=HP(i).b;end
end
if (strcmp(Plotopt,'ON'))
%if numel(TT)==numel(Ncat)
DTW=TW1(2:length(TW1))-Tw2(1:length(Tw2)-1); %%% THIS SEEMS TO WORK!!!!
if isempty(find(DTW<0))
overlap='NO';
for i=1:length(MRPer);
subplot(3,1,1) % plot Mean return period
hold on;plot([time_windows(i).Tstart time_windows(i).Tend],[MRPer(i) MRPer(i)],'k-','LineWidth',2)
if i<length(MRPer);plot([time_windows(i).Tend time_windows(i+1).Tstart],[MRPer(i) MRPer(i+1)],'k--');end
datetick('x',20);title(['Mean Return Period for M\geq',num2str(MaG)],'FontSize',16);ylabel([HP(1).unit,'s'],'FontSize',18)
subplot(3,1,2) % plot Exceedance Probability
hold on;plot([time_windows(i).Tstart time_windows(i).Tend],[ExPr(i) ExPr(i)],'k-','LineWidth',2)
if i<length(ExPr);plot([time_windows(i).Tend time_windows(i+1).Tstart],[ExPr(i) ExPr(i+1)],'k--');end
datetick('x',20);title(['Exceedance Probability for M\geq',num2str(MaG),' within ',num2str(Plength), ' ',Tunit,'(s) period'],'FontSize',16);ylabel('probability','FontSize',14)
subplot(3,1,3) % plot Activity rate
hold on;yyaxis left;plot([time_windows(i).Tstart time_windows(i).Tend],[HP(i).lamb HP(i).lamb],'k-','LineWidth',2)
if i<length(ExPr);plot([time_windows(i).Tend time_windows(i+1).Tstart],[HP(i).lamb HP(i+1).lamb],'k--');end
datetick('x',20);title(['Activity Rate'],'FontSize',16);ylabel(['Events/',HP(1).unit],'FontSize',14,'Color','k')
set(gca,'YColor','k');
% plot b-value (GR) or mean M (NP)
if strcmp(HP(1).method,'GRU') || strcmp(HP(1).method,'GRT');yyaxis right;
plot([time_windows(i).Tstart time_windows(i).Tend],[HP(i).b HP(i).b],'-','LineWidth',2)
ylabel('b-value','FontSize',14);
else
yyaxis right;plot([time_windows(i).Tstart time_windows(i).Tend],[mean(time_windows(i).M) mean(time_windows(i).M)],'-','LineWidth',2)
ylabel('mean Magnitude','FontSize',14);
end
end
else
overlap='YES';
subplot(3,1,1) % plot Mean return period
plot(tplo,MRPer,'o','LineWidth',2,'MarkerSize',12);
datetick('x',20);title(['Mean Return Period for M\geq',num2str(MaG)],'FontSize',16);ylabel([HP(1).unit,'s'],'FontSize',18)
subplot(3,1,2) % plot Exceedance Probability
plot(tplo,ExPr,'o','LineWidth',2,'MarkerSize',12);
datetick('x',20);title(['Exceedance Probability for M\geq',num2str(MaG),' within ',num2str(Plength), ' ',Tunit,'(s) period'],'FontSize',16);ylabel('probability','FontSize',14)
subplot(3,1,3) % plot Activity rate
plot(tplo,lambda,'o','LineWidth',2,'MarkerSize',12);ylabel(['Events/',HP(1).unit],'FontSize',14)
if strcmp(HP(1).method,'GRU') || strcmp(HP(1).method,'GRT');
yyaxis right;plot(tplo,bval,'o','LineWidth',2,'MarkerSize',12);ylabel('b-value','FontSize',14);
else; yyaxis right;plot(tplo,meanM,'o','LineWidth',2,'MarkerSize',12)
ylabel('mean Magnitude','FontSize',14);end
datetick('x',20);title('Activity Rate','FontSize',16);
end
if isempty(PROD_Data)==0
subplot(3,1,1);yyaxis right;plot(PROD_Data(1).val,PROD_Data(PROD_FIELD).val,'-','Linewidth',1);ylabel(PROD_Data(PROD_FIELD).field,'interpreter','none','FontSize',14);
subplot(3,1,2);yyaxis right;plot(PROD_Data(1).val,PROD_Data(PROD_FIELD).val,'-','Linewidth',1);ylabel(PROD_Data(PROD_FIELD).field,'interpreter','none','FontSize',14);
end
subplot(3,1,3);xlabel('Date','FontSize',18)
% option to switch linear-log Y axis Scale
txt = uicontrol('Parent',d,...
'Style','text',...
'Position',[200 621 150 30],...
'String','Select Y Axis Scale:');
popup = uicontrol('Parent',d,...
'Style','popup',...
'Position',[350 630 120 25],...
'String',{'Linear';'Log'},...
'Callback',@popup_callback);
btn = uicontrol('Parent',d,...
'Position',[210 880 210 50],...
'String','SAVE and CLOSE',...
'FontSize',18,...
'ForeGroundColor','r',...
'FontWeight','Bold',...
'Callback',@savefig_callback);
choice = 'Linear';
% Wait for d to close before running to completion
uiwait(d);
elseif (strcmp(Plotopt,'OFF'));close all
if numel(TT)==numel(Ncat)
overlap='NO';else; overlap='YES';end
end
function popup_callback(popup,event)
idx = popup.Value;
popup_items = popup.String;
% This code uses dot notation to get properties.
% Dot notation runs in R2014b and later.
% For R2014a and earlier:
% idx = get(popup,'Value');
% popup_items = get(popup,'String');
choice = char(popup_items(idx,:));
subplot(3,1,1);yyaxis left;
set(gca,'YScale',choice)
end
function savefig_callback(popup,event)
cd Outputs_SHA\
print(gcf,'SHA.jpeg','-djpeg','-r300')
savefig(gcf,'SHA.fig')
% This code uses dot notation to get properties.
% Dot notation runs in R2014b and later.
% For R2014a and earlier:
% idx = get(popup,'Value');
% popup_items = get(popup,'String');
cd ../
delete(gcf)
end

View File

@ -0,0 +1,74 @@
% ---- Save *.txt file with Parameters Report ----
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,'------------------------------------------------------------------------------------\n');
fprintf(fid,['<Magnitude Scale Selected >: ', MScale,'\n']);
fprintf(fid,['<Time Unit >: ', Tunit,'\n']);
fprintf(fid,['<Magnitude Range >: ', num2str(Mc), ' to ', num2str(max(Cmag)),'\n']);
fprintf(fid,['<Magnitude Distribution Model >: ', method,'\n']);
fprintf(fid,['<Magnitude (for EPP and MRP) >: ', num2str(MaG),'\n']);
fprintf(fid,['<Time Period (for EPR) >: ', num2str(Plength),' ',Tunit,'s','\n']);
fprintf(fid,['<Time Window Creation Mode >: ', winmode,'\n']);
if strcmp(winmode,'Time')==1
fprintf(fid,['< Window Size >: ', num2str(window_size),'(days) \n']);
fprintf(fid,['< Window Step >: ', num2str(dt),'(days) \n']);
elseif strcmp(winmode,'Events')==1
fprintf(fid,['< Window Size >: ', num2str(window_size),'(events) \n']);
fprintf(fid,['< Window Step >: ', num2str(dt),'(days) \n']);
elseif strcmp(winmode,'Graphical')==1
fprintf(fid,['< Window Size >: variable \n']);
fprintf(fid,['< Window Step >: variable \n']);
end
fprintf(fid,['<Overlapping Time Windows >: ', overlap,'\n']);
fprintf(fid,'------------------------------------------------------------------------------------\n');
for j=1:numel(HP)
SN(j)=j;Nevents(j)=numel(time_windows(j).M);TS(j)=time_windows(j).Tstart;TE(j)=time_windows(j).Tend;
end
fprintf(fid,[' Set N Starting Date/Time Ending Date/Time events MRP EPR 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);
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);
end
end
fclose(fid);
% Save output structure time_window merged with HP
for i=1:length(HP)
SHA(i).Time=time_windows(i).Time;
SHA(i).M=time_windows(i).M;
SHA(i).Mmin=HP(i).mmin;
SHA(i).eps=HP(i).eps;
SHA(i).lambd=HP(i).lamb;
SHA(i).lambd_err=HP(i).lamb_err;
SHA(i).unit=HP(i).unit;
SHA(i).method=HP(i).method;
if strcmp(method,'GRU')==1 || strcmp(method,'GRT')==1
SHA(i).b=HP(i).b;
else
SHA(i).h=HP(i).h;
SHA(i).xx=HP(i).xx;
SHA(i).ambd=HP(i).ambd;
SHA(i).ierr=HP(i).ierr;
end
if strcmp(method,'GRT')==1 || strcmp(method,'NPT')==1
SHA(i).Mmax=HP(i).Mmax;
SHA(i).err=HP(i).err;
else
end
end
save('SHA.mat','SHA')
cd ../