Skip to content

Commit

Permalink
added source code for gif animation
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinemlarson committed Mar 28, 2024
1 parent 6d56261 commit fae5e00
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -9,6 +9,9 @@ gnssrefl is an open source software package for GNSS interferometric reflectomet

![](docs/myAnimation.gif)

I made this animation ages ago - so it is in Matlab. I would be happy to host a link to
a version in python. The main code is [snr_simulation](docs/pages/snr_simulation.m)
and the helper function is [setFrame.m](docs/pages/set_Frame.m).

Documentation:

Expand Down
Binary file modified docs/myAnimation.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions docs/pages/sc_precourse2024.md
Expand Up @@ -109,8 +109,6 @@ to both of these codes.

You should read [the overview documentation](https://gnssrefl.readthedocs.io/en/latest/pages/understand.html)

And then the [quickLook documentation](https://gnssrefl.readthedocs.io/en/latest/pages/quickLook.html).

## What is a Reflection Zone

[Watch this video](https://www.youtube.com/watch?v=sygZMeCHHDg&t=23s)
Expand Down
31 changes: 31 additions & 0 deletions docs/pages/set_Frame.m
@@ -0,0 +1,31 @@
function [startX, bigNumber, Xaxis, Yaxis, SNR] = set_Frame(height,E,Am,atten)
%function [startX, bigNumber, Xaxis, Yaxis, SNR] = set_Frame(height,E,Am,atten)
% height - vertical distance of antenna phase center to surface
% E elevation angles in degrees
% Am amplitude of the multipath
% atten boolean if you want to attenuate amplitude as elevation angle increases
%
% returns some geometric values for the plot and the simulated SNR data in
% variable with that name

wavelength = 0.244; %GPS L2 wavelength

% this is how much longer the reflected signal (red) travels than
% the direct signal (blue)
path_del = 2*height.*sind(E);
psihat = 2*pi*path_del/wavelength; % radians

% simple attentuation
if atten
Am = 5*Am./E;
end

% this is the definition of SNR data
SNR = Am.*(cos(psihat) + sin(psihat));

Xaxis = ceil(height/tand(5));
Yaxis = 0.33*Xaxis;
% just so the ray comes from outside the plot, which is what i want.
% made up number
startX = 30*height;
bigNumber = 20*height;
79 changes: 79 additions & 0 deletions docs/pages/snr_simulation.m
@@ -0,0 +1,79 @@
clear all
close all
clc
%https://www.mathworks.com/matlabcentral/answers/1694690-how-to-save-figure-frames-as-gif-file
FS = 12;
% min and max elevation angles (degrees)
emin = 5;
emax = 20;
% range of angles to use in the simulation
E = emin:0.05:emax;

% Normalizing to amplitude of 1.
Am=1;
% use simple attenuation parameter.
% more realistic ones can be generated from the Nievinski simulator,
% but that has added complexity of surface type. Here I am only
% trying to show what is generating the frequency changes (which are
% directly related to reflector height.
attenuator = true;

% Setup to make movie
fig1=figure(1); % Create figure handle
set(gcf,'defaultaxesfontsize',FS)
winsize = get(fig1,'Position'); % Get Window Size
winsize(1:2) = [0 0];
incr = 10;
numframes = floor(length(E)/incr);
disp(['Number of frames' num2str(numframes)])

set(fig1,'NextPlot','replacechildren') % Ensure each plot is the same size

gifFile = '/Users/kristine/Downloads/myAnimation.gif';
exportgraphics(fig1, gifFile);


for height = [4, 10]
[startX, bigNumber, Xaxis, Yaxis, SNR] = set_Frame(height,E,Am,attenuator);
for i=1:numframes
index=i*incr;
k=1:index;
% how away is the reflected signal on the xaxis
Xd = height/tand(E(index));
% where does the direct signal start from
X3 = startX - Xd;
subplot(2,1,1)
% GPS antenna is black, reflected signal is red, direct signal is blue
plot([0 (0 + bigNumber*cosd(E(index)))], ...
[height (height + bigNumber*sind(E(index)))], 'b-', 'linewidth',2);hold on;
plot( [startX Xd 0], [X3*tand(E(index)) 0 height], 'r-',... % reflected signal
'linewidth',2); hold on;
plot([0 0], [0 height], 'k-', 'linewidth',2); hold on;
plot(0, height, 'k^','markerfacecolor','k','markersize',10);
hold off;

xlim([-1 Xaxis]), ylim([0 Yaxis])

legend('Direct Signal', 'Reflected Signal', 'Antenna','Location','NorthWest')
grid on;
xlabel('meters'), ylabel('meters')
title(['GNSS Reflection Geometry'],'FontWeight','normal');

subplot(2,1,2)

plot(E(k), SNR(k),'k-')
xlim([emin emax]), ylim([-2 2])
xlabel('Elevation Angle (deg)')
title(['H = ' num2str(height) ' meters-Simulated GPS L2 SNR Data'],...
'FontWeight','normal')
ylabel('Volts/Volts')
grid on


exportgraphics(fig1, gifFile, Append=true);
end
end
return



0 comments on commit fae5e00

Please sign in to comment.