Skip to content

Instantly share code, notes, and snippets.

import numpy as np
def los_to_earth(position, pointing):
"""Find the intersection of a pointing vector with the Earth
Finds the intersection of a pointing vector u and starting point s with the WGS-84 geoid
Args:
position (np.array): length 3 array defining the starting point location(s) in meters
from sympy.solvers import solve
from sympy import symbols
x, y, z, u, v, w, a, b, c, d = symbols('x y z u v w a b c d')
solutions = solve((x + d*u)**2/a**2 + (y + d*v)**2/b**2 + (z + d*w)**2/c**2 - 1, d)
print(solutions[0])
print(solutions[1])
Fs = 10; % Sampling frequency
Ts = 1/Fs; % Sampling period
N = 32; % Total number of samples
n = 0:N-1; % Samples
t = Ts*(n); % Sampled times
y = cos(2*pi*t) + .2*cos(2*pi*1.5*t); % Discrete signal
N = length(y); % The new total number of samples
Y = fft(y); % The fft of the signal
df = 1/(N*Ts); % The frequency resolution
Fs = 10; % Sampling frequency
Ts = 1/Fs; % Sampling period
N = 32; % Total number of samples
n = 0:N-1; % Samples
t = Ts*(n); % Sampled times
y = cos(2*pi*t); % Discrete signal
N = length(y); % The new total number of samples
Y = fft(y); % The fft of the signal
df = 1/(N*Ts); % The frequency resolution
Fs = 10; % Sampling frequency
Ts = 1/Fs; % Sampling period
N = 128; % Total number of samples
n = 0:N-1; % Samples
t = Ts*(n); % Sampled times
fc1 = 1; % Frequency of first sinusoid
fc2 = 1.5; % Frequency of second sinusoid
y1 = cos(2*pi*fc1*t); % Discrete first sinusoid
y2 = cos(2*pi*fc2*t); % Discrete second sinusoid
Fs = 10; % Sampling frequency
Ts = 1/Fs; % Sampling period
N = 16; % Total number of samples
n = 0:N-1; % Samples
t = Ts*(n); % Sampled times
fc1 = 1; % Frequency of first sinusoid
fc2 = 1.5; % Frequency of second sinusoid
y1 = cos(2*pi*fc1*t); % Discrete first sinusoid
y2 = cos(2*pi*fc2*t); % Discrete second sinusoid
% The 3D function
z = zeros(16,32); z(2:3,2:3) = ones(2);
Nx = size(z,2);
Ny = size(z,1);
% Plot surface
figure
subplot(2,1,1), surf(z)
view(0,90), title('Unshifted Signal')
xlabel('x')
% The 2D signal
y = [ 1 -1 4 8 zeros(1,12)];
N = length(y);
% Plot unshifted signal
figure
subplot(2,1,1), stem(y), title('Unshifted Signal')
% Frequency domain samples
f = 0:N-1;
MF = ifft(fft(yN).*fft(conj(fliplr(yref))));
plot(MF,'m')
xlim([1,256])
title('Matched Filter Output')
% The reference signal
yref = [ones(1,56),zeros(1,200)];
% Initialize movie
v = VideoWriter('test.avi','Uncompressed AVI');
v.FrameRate = 10;
open(v)
figure('Position',[100 100 850 600])
MF(1) = sum(yN.*yref);
subplot(2,1,1), plot(yref+4,'g')