-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFun_LoadInfo.m
More file actions
59 lines (58 loc) · 1.72 KB
/
Copy pathFun_LoadInfo.m
File metadata and controls
59 lines (58 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
% Read earthquake source information from Info.txt
function [Event,epicenter,depth,mag,Type,SDR]=Fun_LoadInfo(PATH,Filename,inEa,inMt)
% Filename='Info.txt';
infoFile = fullfile(PATH,Filename);
if ~exist(infoFile, 'file')
error('Info.txt was not found: %s', infoFile);
end
fid = fopen(infoFile, 'r');
if fid < 0
error('Unable to open Info.txt: %s', infoFile);
end
% Read the first description line.
fgetl(fid);
% Read earthquake origin time.
epitime = strtrim(fgetl(fid));
% The KiK-net processing uses JST.
Event = [epitime, ' JST'];
% Read and discard the source-parameter header line.
fgetl(fid);
% Read all numerical source parameters.
Strings = fscanf(fid, '%f');
fclose(fid);
if mod(numel(Strings), 11) ~= 0
error(['The number of numerical values in Info.txt is not divisible ', ...
'by 11. Please check the source parameter format.']);
end
Strings = reshape(Strings, 11, [])';
if inEa < 1 || inEa > size(Strings, 1)
error('inEa = %d exceeds the number of earthquakes in Info.txt.', inEa);
end
% Assumed Info.txt source-column order:
% 1 Longitude
% 2 Latitude
% 3 Depth [km]
% 4-6 Strike / Dip / Rake of nodal plane I
% 7-9 Strike / Dip / Rake of nodal plane II
% 10 Moment magnitude
% 11 Fault type
% da_zh requires [Latitude, Longitude].
epicenter = [Strings(inEa, 2), Strings(inEa, 1)];
% Use scalar depth for the selected earthquake.
depth = Strings(inEa, 3);
% Moment magnitude.
mag = Strings(inEa, 10);
% Fault type:
% 1 = reverse / thrust
% 2 = strike-slip
% 3 = normal
Type = Strings(inEa, 11);
% Select a nodal plane.
if inMt == 1
SDR = Strings(inEa, 4:6);
elseif inMt == 2
SDR = Strings(inEa, 7:9);
else
error('inMt must be 1 or 2.');
end
end