Skip to content

Commit

Permalink
Merge pull request #43 from geoscience-community-codes/core-work
Browse files Browse the repository at this point in the history
Core work essentially complete
  • Loading branch information
CelsoReyes committed Nov 12, 2015
2 parents 6d9833e + b57ca58 commit 184d007
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 490 deletions.
8 changes: 4 additions & 4 deletions classes/@SeismicTrace/legend.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function varargout = legend(T, varargin)
%legend Create a legend for a waveform graph.
%legend Create a legend for the graph of a trace.
% legend(traces) attempts to automatically create a legend based upon
% unique values within the waveforms. in order, the legend will
% unique values within the traces. in order, the legend will
% preferentially use station, channel, start time.
%
% legend(traces, field1, [field2, [..., fieldn]]) will create a legend,
Expand All @@ -12,8 +12,8 @@
% location, etc.)
%
% For additional control, use matlab's legend function by passing it
% cells & strings instead of a waveform.
% (hint:useful functions include waveform/get, strcat, sprintf, num2str)
% cells & strings instead of a trace.
% (hint:useful functions include strcat, sprintf, num2str)
%
% See also plot, legend

Expand Down
11 changes: 4 additions & 7 deletions classes/@SeismicTrace/plot.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,12 @@
p.KeepUnmatched = true;
p.CaseSensitive = false;
p.StructExpand = false;
if ismethod(p,'addParameter')
if verLessThan('matlab','8.2'); %r2013b
addParameter = @addParamValue;
end
addParameter(p,'autoscale', false);
addParameter(p,'xunit', 's');
addParameter(p,'fontsize', 10);
else % older usage: pre r2013b
addParamValue(p,'autoscale', false); %#ok<*NVREPL>
addParamValue(p,'xunit', 's');
addParamValue(p,'fontsize', 10);
end
p.parse(argList{:});
end

Expand Down Expand Up @@ -268,4 +265,4 @@
newParams = horzcat(fieldList,v);
end
end
end
end
26 changes: 22 additions & 4 deletions classes/@TraceFilter/TraceFilter.m
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
classdef TraceFilter
%TraceFilter Simple butterworth filtering for Traces
%
% TraceFilter Properties:
% type - describes the passband type of filter. ('B', 'L', or 'H')
% cutoff - upper and lower bounds for the filter
% poles - number of poles for the filter
%
% TraceFilter Methods:
% filtfilt - Zero-phase forward and reverse butterworth filtering.
%
% replaces filterobject
%
% see also: butter, filtfilt

properties
type = 'B'; % could be 'B'andpass, 'H'ighpass, or 'L'lowpass
cutoff = [0.8 5]; % filter cutoffs [lower bound, upper bound]
poles = 2;

poles = 2; % number of poles
end

methods
function f = TraceFilter(filtType, cutoff_, poles_)
%TRACEFILTER constructor for a filter object
%TRACEFILTER construct a TraceFilter
%
switch nargin
case 1
if isa(filtType,'filterobject')
Expand Down Expand Up @@ -82,14 +93,18 @@ function assertCutoffCountMatchesType(f)
% See also FILTFILT, BUTTER

% Check, if w is a number array, just quick & dirty it...
if isa(trace,'waveform')
disp('converting waveform(s) to SeismicTrace(s)');
trace = SeismicTrace(trace);
end
if isnumeric(trace)
WN = f.cutoff / NYQ;
[b, a] = getButter(f,WN);
trace = filtfilt(b, a, trace);

elseif isa(trace,'SeismicTrace')
assert(numel(f) == 1, 'can only filter using a single TraceFilter at a time');
assertCutoffCountMatchesType();
assertCutoffCountMatchesType(f);
HASGAP = arrayfun(@(x) any(isnan(x.data)), trace);
if any(HASGAP(:))
warning('Filterobject:filtfilt:hasNaN',...
Expand Down Expand Up @@ -161,4 +176,7 @@ function disp(f)
end
end
end
methods(Static)
cookbook() %run the filter cookbook
end
end
8 changes: 8 additions & 0 deletions classes/@TraceFilter/cookbook.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function cookbook()
%cookbook Cookbook for TraceFilter
% Demonstrates the usage of TraceFilter

disp('TraceFilter Cookbook')
disp(' - not created, yet -');
end

0 comments on commit 184d007

Please sign in to comment.