-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths_attribute.m
192 lines (156 loc) · 6.21 KB
/
s_attribute.m
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
function seismic=s_attribute(seismic,action,attributes)
% Function computes functionals of the seismic traces and stores them in like-named
% header(s); if no output data set is provided, information about these functionals
% printed via the 'list' (short list) option of S_HEADER.
%
% Function is obsolete: use "s_attributes" instead.
%
% Written by: E. R.: April 11, 2000
% Last updated: September 18, 2005: Add L2-norm calculation
%
% seismic=s_attribute(seismic,action,attributes)
% INPUT
% seismic Seismic structure;
%
% action Defines action to take. Possible values are:
% 'add' Add header with mnemonic "type". Gives error message if
% header already exists
% 'add_ne' Add header with mnemonic "type". Replaces it if it already exists.
% 'Default: 'add_ne'
%
% attributes Cell array with one or more character strings describing the
% functional(s) to compute. Possible values are:
% 'amax' Compute the maximum absolute value of each trace and store
% it in header amax
% 'amean' Compute the mean of the absolute value of each trace and store it
% 'amedian' Compute the median of the absolute value of each trace and store
% it in header amedian
% 'amin' Compute the minimum absolute value of each trace and store
% it in header amin
% in header amean (same as 'aaa').
% 'l2norm' Compute the L2 norm of each trace, i.e.
% SQRT(sum of squares of the samples of each trace)
% 'max' Compute the maximum value of each trace and store it in header max
% 'mean' Compute the mean value of each trace and stores it in header mean
% 'median' Compute the median value of each trace and store it in
% header median
% 'min' Compute the minimum value of each trace and store it in
% header min
% 'minabs' Compute the absolute value of the minimum of each trace and store
% it in header minabs
% 'rms' Compute the rms value of each trace and store it in header rms
% 'trend' Compute the trend (robust estimate of the average gradient)
%
% Default: all functionals except trend
%
% OUTPUT
% seismic "Updated" seismic structure
%
alert('Function is obsolete: use "s_attributes" instead.')
if nargin < 1
error('At least one input argument (seismic structure) is required.')
end
if ~isstruct(seismic)
error('The first input argument must be a seismic structure.')
end
if ~isfield(seismic,'headers')
nh=0;
else
nh=size(seismic.headers,1);
end
if nargin == 1
action='add_ne';
end
if nargin < 3
attributes={'aaa','amax','amean','amedian','amin','l2norm', ...
'max','mean','median','min','minabs','rms'};
else
if ischar(attributes)
attributes={attributes};
end
end
htext=[action,':']; % Prepare text for history field
[nsamp,ntr]=size(seismic.traces);
for ii=1:length(attributes)
type=attributes{ii};
% Check if a header with the name "type" already exists and determine row of header
% and header_info to store new data
if ~isfield(seismic,'header_info')
idx=[];
else
idx=find(ismember(lower(seismic.header_info(:,1)),type));
end
if ~isempty(idx)
if strcmpi(action,'add')
error(['The header mnemonic ',type,' already exists in the header'])
end
else
idx=nh+1;
end
switch type
case {'amean','aaa'}
seismic.headers(idx,:)=mean(abs(seismic.traces));
seismic.header_info(idx,1:3)={type,'n/a','Mean of absolute values of trace'};
case 'amax'
seismic.headers(idx,:)=max(abs(seismic.traces));
seismic.header_info(idx,1:3)={type,'n/a','Maximum of absolute values of trace'};
case 'amedian'
seismic.headers(idx,:)=median(abs(seismic.traces));
seismic.header_info(idx,1:3)={type,'n/a','Median of absolute values of trace'};
case 'amin'
seismic.headers(idx,:)=abs(min(seismic.traces));
seismic.header_info(idx,1:3)={type,'n/a','Absolute value of trace minimum'};
case 'l2norm'
temp=zeros(1,ntr);
for ii=1:ntr
temp(ii)=norm(seismic.traces(:,ii));
end
seismic.headers(idx,:)=temp;
seismic.header_info(idx,1:3)={type,'n/a','Maximum of trace'};
case 'max'
seismic.headers(idx,:)=max(seismic.traces);
seismic.header_info(idx,1:3)={type,'n/a','L2 norm'};
case 'mean'
seismic.headers(idx,:)=mean(seismic.traces);
seismic.header_info(idx,1:3)={type,'n/a','Mean of trace'};
case 'median'
seismic.headers(idx,:)=median(seismic.traces);
seismic.header_info(idx,1:3)={type,'n/a','Median of trace'};
case 'min'
seismic.headers(idx,:)=min(seismic.traces);
seismic.header_info(idx,1:3)={type,'n/a','Minimum of trace'};
case 'minabs'
seismic.headers(idx,:)=min(abs(seismic.traces));
seismic.header_info(idx,1:3)={type,'n/a','Minimum of absolute values of trace'};
case 'rms'
seismic.headers(idx,:)=sqrt(sum(seismic.traces.^2)/nsamp);
%rms=seismic.headers(idx,:)%test
seismic.header_info(idx,1:3)={type,'n/a','RMS amplitude of trace'};
case 'trend'
scf=1000/seismic.step;
for ii=1:ntr
seismic.headers(idx,ii)=repeated_median_trend(seismic.traces(:,ii))*scf;
end
seismic.header_info(idx,1:3)={type,'1/sec','Trend'};
case 'logtrend'
scf=1000/seismic.step;
for ii=1:size(seismic.traces,2)
seismic.headers(idx,ii)=repeated_median_trend(log(seismic.traces(:,ii)+eps))*scf;
end
seismic.header_info(idx,1:3)={type,'1/sec','Logrithmic trend'};
otherwise
error(['Type ',type,' not (yet?) defined'])
end
nh=size(seismic.headers,1); % Update number of header mnemonics
htext=[htext,' ',type]; % Update text for history file
% test=max(seismic.headers(1,:)) %test
end % End FOR-loop
if nargout == 0 % If no output argument is specified
s_header(seismic,'list',attributes)
clear seismic
else
% Append history field
if isfield(seismic,'history')
seismic=s_history(seismic,'append',htext);
end
end