<jupyter_start><jupyter_text>***Introduction to Radar Using Python and MATLAB*** <NAME> - Copyright (C) 2019 Artech House Ovals of Cassini*** Referring to Figure 4.8, The Cassini ovals are a family of quartic curves, sometimes referred to as Cassini ellipses, described by a point such that the product of its distances from two fixed points a distance apart is a constant [8]. For bistatic systems, the system performance may be analyzed by plotting the Cassini ovals for various signal-to-noise ratios.  The Cassini ovals are governed by (Equation 4.65) \begin{equation}\label{eq:bistatic_range_product_polar}    (r_t\, r_r)^2 = \Big(\rho^2 + (D/2)^2\Big)^2 - \rho^2\, D^2\, \cos^2\theta\end{equation}*** Begin by getting the library path<jupyter_code>import lib_path<jupyter_output><empty_output><jupyter_text>Set the separation distance, ***D***, between the transmitting and receiving radars (m)<jupyter_code>separation_distance = 10e3<jupyter_output><empty_output><jupyter_text>Set the system temperature (K), bandwidth (Hz), noise_figure (dB), transmitting and receiving losses (dB), peak transmit power (W), transmitting and receiving antenna gain (dB), operating frequency (Hz), and bistatic target RCS (dBsm)<jupyter_code>system_temperature = 290

bandwidth = 10e6

noise_figure = 3

transmit_losses = 4

receive_losses = 6

peak_power = 100e3

transmit_antenna_gain = 30

receive_antenna_gain = 28

frequency = 1e9

bistatic_target_rcs = 10<jupyter_output><empty_output><jupyter_text>Set the number of points for plotting the Cassini ovals<jupyter_code>number_of_points = 100000<jupyter_output><empty_output><jupyter_text>Set the parameters for the Cassini ovals equation$$ r ^ 4 + a ^ 4 - 2 a ^ 2 r ^ 2(1 + cos(2 \theta)) = b ^ 4 $$ Import the `linspace` and `log10` routines along with some constants from `scipy` for the angle sweep<jupyter_code>from numpy import linspace, log10
from scipy.constants import pi, c, k
# Parameter "a"

a = 0.5 * separation_distance


# Full angle sweep

t = linspace(0, 2.0 * pi, number_of_points)<jupyter_output><empty_output><jupyter_text>Calculate the bistatic range factor and use this along with the separation distance to calculate SNR0 (where the factors ***a*** and ***b*** are equal)<jupyter_code># Calculate the wavelength (m)

wavelength = c / frequency


# Calculate the bistatic radar range factor

bistatic_range_factor = (peak_power * transmit_antenna_gain * receive_antenna_gain * wavelength ** 2 * 10.0 ** (bistatic_target_rcs / 10.0)) / ((4.0 * pi) ** 3 * k * system_temperature * bandwidth * 10.0 ** (noise_figure / 10.0) * transmit_losses * receive_losses)


# Calculate the signal to noise ratio at which a = b

SNR_0 = 10.0 * log10(16.0 * bistatic_range_factor / separation_distance ** 4)<jupyter_output><empty_output><jupyter_text>Create a list of the signal to noise ratios to plot<jupyter_code>SNR = [SNR_0 - 6, SNR_0 - 3, SNR_0, SNR_0 + 3]<jupyter_output><empty_output><jupyter_text>Import the `matplotlib` routines for plotting the Cassini ovals<jupyter_code>from matplotlib import pyplot as plt<jupyter_output><empty_output><jupyter_text>Import `sqrt`, `sin`, `cos`, `real`, and `imag` from `scipy` for plotting the Cassini ovals<jupyter_code>from numpy import sqrt, sin, cos, real, imag<jupyter_output><empty_output><jupyter_text>Display the resulting Cassini ovals<jupyter_code># Set the figure size

plt.rcParams["figure.figsize"] = (15, 10)


# Loop over all the desired signal to noise ratios

for s in SNR:
    

    # Convert to linear units

    snr = 10.0 ** (s / 10.0)

    
    # Parameter for Cassini ovals

    b = (bistatic_range_factor / snr) ** 0.25


    if a > b:


         # Calculate the +/- curves

         r1 = sqrt(a ** 2 * (cos(2.0 * t) + sqrt(cos(2 * t) ** 2 - 1.0 + (b / a) ** 4)))

         r2 = sqrt(a ** 2 * (cos(2.0 * t) - sqrt(cos(2 * t) ** 2 - 1.0 + (b / a) ** 4)))



         # Find the correct indices for imaginary parts = 0

         i1 = imag(r1) == 0

         i2 = imag(r2) == 0


         r1 = real(r1)

         r2 = real(r2)



         # Plot both parts of the curve

         label_text = "SNR = {:.1f}".format(s)

         plt.plot(r1[i1] * cos(t[i1]), r1[i1] * sin(t[i1]), 'k.', label=label_text)

         plt.plot(r2[i2] * cos(t[i2]), r2[i2] * sin(t[i2]), 'k.')


    else:


         # Calculate the range for the continuous curves

         r = sqrt(a ** 2 * cos(2 * t) + sqrt(b ** 4 - a ** 4 * sin(2.0 * t) ** 2))


         # Plot the continuous parts

         label_text = "SNR = {:.1f}".format(s)

         plt.plot(r * cos(t), r * sin(t), '.', label=label_text)


    # Add the text for Tx/Rx locations

    plt.text(-a, 0, 'Tx')

    plt.text(a, 0, 'Rx')


    # Set the plot title and labels

    plt.title('Ovals of Cassini', size=14)

    plt.xlabel('Range (km)', size=12)

    plt.ylabel('Range (km)', size=12)


    # Set the tick label size

    plt.tick_params(labelsize=12)


    # Turn on the grid

    plt.grid(linestyle=':', linewidth=0.5)


    # Add the legend

    plt.legend(loc='upper left', prop={'size': 10})<jupyter_output>c:\users\vmitc\appdata\local\programs\python\python36-32\lib\site-packages\numpy\core\numeric.py:492: ComplexWarning: Casting complex values to real discards the imaginary part
  return array(a, dtype, copy=False, order=order)
{'fraction_non_alphanumeric': 0.12429271972840437, 'fraction_numerical': 0.034515277253866467, 'mean_word_length': 3.790424570912376, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '94574', 'license': 'Apache-2.0', 'n_tokens_mistral': 2022, 'n_tokens_neox': 1812, 'n_words': 553, 'path': 'jupyter/Chapter04/ovals_of_cassini.ipynb', 'repo_name': 'miltondsantos/software', 'size': '5309'}