-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputeShowerDistance.m
executable file
·41 lines (36 loc) · 1.19 KB
/
computeShowerDistance.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
function [antid dist ] = computeShowerDistance(theta,phi,posCore,posAnt)
% Compute distance to shower for all antennas in layout
% Shower caras (theta, phi, xcore [x, y, z]) following TREND conventions
% posAnt = [id x y z]
% OMH 19/11/2015
SharedGlobals;
DISPLAY = 0;
%% Load antenna position
if ~exist('posAnt')
posAnt = load('coord_antennas_TREND50.txt');
disp 'Loading antenna positions...'
%posAnt = load('coord_antennas_GRANDproto.txt');
end
antid = posAnt(:,1);
posDet = posAnt(:,2:4);
%% Compute COre position
if length(posCore) == 2
posCore(3) = getElevation(posCore(1),posCore(2));
end
posCore = (ones(length(antid),1)*posCore);
%% Compute distance to Core
dX = posDet - posCore;
cp = cosd(phi);
sp = sind(phi);
ct = cosd(theta);
st = sind(theta);
u = [ -sp*st, cp*st, ct ]; %% Warning!!!! This is different from usual since here x=WE & y=SN
U = ones( length(antid), 1 )*u;
dist = sqrt( sum( dX.^2, 2 ) - sum( dX.*U, 2 ).^2 ); %Distance from antennas to shower axis
if DISPLAY == 1
in = find(posDet(:,3)>0);
plot(antid(in),dist(in),'+k','MarkerSize',6)
xlabel('Antenna ID')
ylabel('Distance to shower [m]')
grid on
end