Houston, we have a trunk.
[debian/gnuradio] / gr-radar / src / python / signal_levels.py
1 #!/usr/bin/env python
2
3 import sys
4 from math import pi, log10
5 from gnuradio.eng_notation import num_to_str
6
7 def power_density(transmitted_power, distance):
8     """
9     Estimate power density in Watts/meter.
10     Assume isotropic radiator (spherical radiation pattern).
11
12     @param transmitted_power: Watts
13     @param distance: distance from transmitter in meters
14
15     """
16     return transmitted_power / (4 * pi * distance * distance)
17
18
19 def ratio_of_target_return_to_direct(Rl, Rt, Rr, rcs):
20     """
21     Estimate relative strength of signal levels for direct and reflected
22     path in bistatic radar.  Assume all antenna factors are constant,
23     and hence 'wash out'.  Also assume that the antennas are isotropic
24     radiators (spherical radiation pattern).
25
26     @param Rl:  distance between Tx and Rx in meters
27     @param Rt:  distance between Tx and target in meters
28     @param Rr:  distance between Rx and target in meters
29     @param rcs: radar cross section in meters^2
30
31     @returns: ratio of reflected to direct in decibels
32     """
33     Tx_power = 1
34     direct_path_power_density = power_density(Tx_power, Rl)
35     power_at_target = power_density(Tx_power, Rt) * rcs
36     reflected_path_power_density = power_density(power_at_target, Rr)
37     return 10*log10(reflected_path_power_density / direct_path_power_density)
38
39
40 def print_header(f):
41     f.write("   Rl      Rt      Rr      rcs      dB\n")
42     f.write("-----------------------------------------\n")
43     
44 def print_result(f, Rl, Rt, Rr, rcs, dB):
45     f.write("%6sm %6sm %6sm %6s  %6s\n" %  tuple([num_to_str(x) for x in [Rl, Rt, Rr, rcs, dB]]))
46
47 def calc_print(f, Rl, Rt, Rr, rcs):
48     print_result(f, Rl, Rt, Rr, rcs, ratio_of_target_return_to_direct(Rl, Rt, Rr, rcs))
49     
50 def main():
51     f = sys.stdout
52     print_header(f)
53     calc_print(f, 40e3, 100e3, 100e3, 10.0)
54     calc_print(f, 40e3,  80e3,  80e3, 10.0)
55     calc_print(f, 40e3,  40e3,  40e3, 10.0)
56     calc_print(f, 40e3,  40e3,   8e3, 10.0)
57     calc_print(f, 40e3,  60e3,  20e3, 10.0)
58     calc_print(f, 40e3,  20e3,  60e3, 10.0)
59
60     
61 if __name__ == '__main__':
62     main()