Skip to content

Commit

Permalink
Allow explicit setting of web services for dataselect and station cal…
Browse files Browse the repository at this point in the history
…ls used by the Trace method
  • Loading branch information
Chad Trabant committed Jul 1, 2017
1 parent 28b4aa0 commit e27937e
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions irisFetch.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
%}

properties (Constant = true)
VERSION = '2.0.8'; % irisFetch version number
VERSION = '2.0.9'; % irisFetch version number
DATE_FORMATTER = 'yyyy-mm-dd HH:MM:SS.FFF'; %default data format, in ms
MIN_JAR_VERSION = '2.0.4'; % minimum version of IRIS-WS jar required for compatibility
MIN_JAR_VERSION = '2.0.15'; % minimum version of IRIS-WS jar required for compatibility

VALID_QUALITIES = {'D','R','Q','M','B'}; % list of Qualities accepted by Traces
DEFAULT_QUALITY = 'B'; % default Quality for Traces
Expand Down Expand Up @@ -192,6 +192,14 @@ function SACfiles(network, station, location, channel, startDate, endDate, write
% settings are "sticky", so that all calls for waveform data or station metadata
% will go to that datacenter until a new one is specified.
%
% tr = irisFetch.Traces(..., 'DATASELECTURL:http://host/path/to/dataselect')
% will explicity set the URL to the fdsnws-dataselect web service to fetch
% time series data from.
%
% tr = irisFetch.Traces(..., 'STATIONURL:http://host/path/to/dataselect')
% will explicity set the URL to the fdsnws-station web service to fetch
% metadata data from.
%
% tr = irisFetch.Traces(..., 'WRITESAC:writeDir') will retrieve seismic traces
% and then write a SAC file to the directory specified by 'writeDir' for each
% trace structure. This method will also store the retrieved waveform data in
Expand Down Expand Up @@ -274,6 +282,7 @@ function SACfiles(network, station, location, channel, startDate, endDate, write
tracedata.setAppName(irisFetch.appName);
tracedata.setVerbosity(opts.verbosity);

% Set new base URL if specified
if ~isempty(opts.newbase)
if strcmp(opts.newbase(end),'/')
opts.newbase = opts.newbase(1:end-1);
Expand All @@ -282,6 +291,16 @@ function SACfiles(network, station, location, channel, startDate, endDate, write
dbPrint('Using services at base: %s\n', opts.newbase);
end

% Set specific service URLs if specified
if ~isempty(opts.dataselectURL)
tracedata.setWAVEFORM_URL(opts.dataselectURL)
dbPrint('Using dataselect service at: %s\n', opts.dataselectURL);
end
if ~isempty(opts.stationURL)
tracedata.setSTATION_URL(opts.stationURL)
dbPrint('Using station service at: %s\n', opts.stationURL);
end

if ~opts.useFederator
ts = getTheTraces(network, station, location, channel, startDate, endDate, opts);
else
Expand Down Expand Up @@ -350,7 +369,7 @@ function SACfiles(network, station, location, channel, startDate, endDate, write
case 'STATIONSERVICE'
tracedata.setSTATION_URL(url)
end
dbPrint('[%s] : %-10s > %s\n',currDataCenter, svc, url');
dbPrint('[%s] : %-10s > %s\n',currDataCenter, svc, url);
else
network = nets{row};
station = stas{row};
Expand Down Expand Up @@ -417,6 +436,12 @@ function flush()
if length(param)>7 && strcmpi(param(1:7),'http://')
% set the bases
opts.newbase = param;
elseif length(param) > 13 && strcmpi(param(1:13),'DATASELECTURL')
% expecting 'DATASELECTURL:http://host/path/to/dataselect'
opts.dataselectURL = param(15:end)
elseif length(param) > 10 && strcmpi(param(1:10),'STATIONURL')
% expecting 'STATIONURL:http://host/path/to/station'
opts.stationURL = param(12:end)
elseif length(param) >= 8 && strcmpi(param(1:8),'WRITESAC')
% expecting 'WRITESAC' or
% 'WRITESAC:full/directory/path'
Expand Down Expand Up @@ -511,6 +536,8 @@ function flush()
opts.username = '';
opts.userpwd = '';
opts.newbase = '';
opts.dataselectURL = '';
opts.stationURL = '';
opts.useFederator = false;
opts.writeDirectory = '';
opts.convertToMatlab = true;
Expand Down

0 comments on commit e27937e

Please sign in to comment.