Example 03 - Generation of a simple, artificial channel impulse response file

The main purpose of SNACS is to simulate GNSS signal propagation in different channels. We start by generating a simple channel impulse response (CIR) file. The CIR will contain a single component that rests at delay = 0 s for the duration of one second and starts to move then. This situation could describe a receiver that is solely receiving the line-of-sight (LOS) signal of a transmitter. After one second it starts to move away from the transmitter.

You can define the maximum speed of the vehicle. The acceleration is computed in a continuous way using the cosine function.

The file is saved in HDF5 format to snacs_cir_moving_los_v01.h5.

This is the corresponging MATLAB script:

1 % Example file for
2 %
3 % SNACS - The Satellite Navigation Radio Channel Simulator
4 %
5 % Copyright (C) 2010 F. M. Schubert
6 %
7 % This program is free software: you can redistribute it and/or modify
8 % it under the terms of the GNU General Public License as published by
9 % the Free Software Foundation, either version 3 of the License, or
10 % (at your option) any later version.
11 %
12 % This program is distributed in the hope that it will be useful,
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 % GNU General Public License for more details.
16 %
17 % You should have received a copy of the GNU General Public License
18 % along with this program. If not, see <http://www.gnu.org/licenses/>.
19 %
20 %
21 % This file generates an artifical times series with 1 line-of-sight path
22 % that begins to accelerate slowly up to a constant speed.
23 
24 
25 %% initialization
26 close all
27 clear all
28 clear classes
29 clc
30 
31 addpath('../helper_functions');
32 save_figures = true;
33 
34 %% parameter setting
35 
36 h5_filename = 'snacs_cir_moving_los_v01-2.h5';
37 
38 cir_rate = 500; % Hz
39 len = 20; % s
40 cir_amount = len * cir_rate;
41 
42 speed = 10; % in m/s
43 start_acceleration = 1.0; % in s
44 full_speed_at = 3.0; % in s
45 
46 c0 = 2.99e8; % speed of light in m/s
47 
48 carrier_frequency = 1.5e9; % in Hz
49 carrier_wavelength = c0 / carrier_frequency;
50 
51 %% write Parameters to HDF5 file
52 
53 simulation_parameters.c0 = c0;
54 simulation_parameters.cir_rate = cir_rate;
55 simulation_parameters.cir_amount = cir_amount;
56 
57 init_snacs_cir_file(h5_filename, simulation_parameters);
58 
59 %% parameter checks
60 
61 % TODO check for maximum vehicle speed:
62 maximum_possible_speed = c0 * cir_rate / carrier_frequency / 2; % sampling theorem
63 
64 cir_start_acceleration = start_acceleration * cir_rate;
65 cir_full_speed_at = full_speed_at * cir_rate;
66 cirs_acceleration = cir_full_speed_at - cir_start_acceleration;
67 
68 speeds = zeros(cir_amount, 1);
69 distances = zeros(cir_amount, 1);
70 los_complex_amplitudes = zeros(cir_amount, 1);
71 
72 %% generate channel impulse response
73 
74 wbh = waitbar(0, 'generating channel impulse response...');
75 
76 wb_update = cir_amount / 10;
77 
78 for k = 1:cir_amount
79  if (mod(k, wb_update) == 0) waitbar(k/cir_amount, wbh); end;
80 
81  cir_number = k-1; % k-1: CIR number should start at 0
82 
83  act_speed = 0;
84 
85  if (k < cir_start_acceleration)
86  % no movement, delay = 0:
87  delay = 0;
88  elseif ( (k >= cir_start_acceleration) && (k < cir_full_speed_at) )
89  % acceleration using a cos function:
90  speeds(k) = speed * (cos(pi + (k-cir_start_acceleration) / cirs_acceleration * pi) + 1)/2;
91 
92  % linear acceleration:
93 % speeds(k) = speed * (k-cir_start_acceleration) / cirs_acceleration;
94  elseif (k >= cir_full_speed_at)
95  % constant full speed:
96  speeds(k) = speed;
97  end
98 
99  % calculate distance using the speed. k * 1/cir_rate is the current
100  % time
101  distances(k) = speeds(k) * k * 1/cir_rate;
102 
103  % build struct for writing to HDF5 file:
104  los_struct = struct('delay', {0}, 'real', {0}, 'imag', {0});
105 
106  % calculate the line of sight complex amplitude:
107  los_complex_amplitudes(k) = 1.0 * exp(j * (2.0 * pi / carrier_wavelength) * distances(k));
108 
109  % calculate LOS delay from distance using speed of light:
110  los_struct.delay = distances(k) / c0;
111  los_struct.real = real(los_complex_amplitudes(k));
112  los_struct.imag = imag(los_complex_amplitudes(k));
113 
114  % write this CIR to file:
115  append_one_cir_to_cir_file(h5_filename, cir_number, los_struct);
116 end
117 
118 close(wbh)
119 
120 % write reference distances to file:
121 hdf5write(h5_filename, '/reference_range/range_absolut' , distances, 'WriteMode', 'append');
122 
123 %% plotting
124 
125 x_ax = 0:1/cir_rate:cir_amount/cir_rate - 1/cir_rate;
126 
127 f1 = figure;
128 title('Receiver Speed');
129 hold on;
130 plot(x_ax, speeds);
131 grid on;
132 xlabel('Time [s]');
133 ylabel('Speed [m/s]');
134 ylim([-10, speed + 20]);
135 
136 if save_figures save_figure_as_png('../../documentation/doxygen-sources/graphic/example03_receiver-speed.png'); end
137 
138 figure;
139 title('Distance Receiver - Transmitter');
140 hold on;
141 plot(x_ax, distances);
142 grid on;
143 xlabel('Time [s]');
144 ylabel('Distance [m]');
145 ylim([-10, distances(end) + 20]);
146 
147 if save_figures save_figure_as_png('../../documentation/doxygen-sources/graphic/example03_distance.png'); end
148 
149 figure;
150 title('Line-Of-Sight Amplitude');
151 hold on;
152 plot(x_ax, abs(los_complex_amplitudes));
153 grid on;
154 xlabel('Time [s]');
155 ylabel('Magnitude');
156 ylim([-10, los_complex_amplitudes(end) + 10]);
157 
158 if save_figures save_figure_as_png('../../documentation/doxygen-sources/graphic/example03_amplitude.png'); end
159 
160 figure;
161 title('Line-Of-Sight Phase');
162 hold on;
163 plot(x_ax, angle(los_complex_amplitudes));
164 grid on;
165 xlabel('Time [s]');
166 ylabel('Phase [rad]');
167 ylim([-4, 4]);
168 
169 if save_figures save_figure_as_png('../../documentation/doxygen-sources/graphic/example03_phase.png'); end

The output of the MATLAB script:

example03_receiver-speed.png
The resulting receiver speed
example03_distance.png
The distance receiver - transmitter
example03_amplitude.png
The amplitude of the generated CIR
example03_phase.png
The phase of the generated CIR