-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathradialStationFinder.m
63 lines (51 loc) · 1.81 KB
/
radialStationFinder.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
%CCCP
%Radial Station Finder
%function [list closest_station] = radialStationFinder(StartTime, EndTime,radius,channel,longitude,latitude);
%Beginnings of a function to generate data about stations surrounding a given point so that
%waveforms can be gathered
%Outputs a list of stations within the given radius, as well as the closest
%station to use for picks for the determinination of template arrivals.
%Stations are listed in descending order with respect to distance.
function [list, closest_station] = radialStationFinder(StartTime, EndTime,radius,channel,longitude,latitude)
list =[];
while isempty(list) == 1;
try
list = irisFetch.Stations('CHANNEL','*','*','*',channel,'IncludeRestricted',false,'StartBefore',StartTime,'EndAfter',EndTime,'Latitude',latitude,'Longitude',longitude,'MinimumRadius',0,'MaximumRadius',radius,'includeAvailability',true,'includePZ');
catch exception
fprintf('Trying again....\n');
end
end
delta = 1;
while delta ~= 0
delta = 0;
for i = 1:length(list)
item = list(i);
if strcmp(item.RestrictedStatus,'CLOSED') == 1;
list(i) = [];
delta = 1;
end
if strcmp(item.NetworkCode,'SY') == 1;
list(i) = [];
delta = 1;
end
if i >= length(list);
break
end
end
end
% item = list(length(list));
% if strcmp(item.RestrictedStatus,'CLOSED') == 1;
% list(i) = [];
% end
% if strcmp(item.NetworkCode,'SY') == 1;
% list(i) = [];
% end
for i = 1:length(list)
[arclen az] = distance([latitude,longitude],[list(i).Latitude,list(i).Longitude]);
list(i).radialDistance = arclen;
list(i).azimuth = az;
end
[dist, index] = sort([list(:).radialDistance],'descend');
list = list(index);
closest_station = list(length(list));
end