# Path: gprMax/constants.py



import argparse
import os
import sys
import h5py
import numpy as np
import matplotlib.pyplot as plt
from gprMax.constants import c, z0
rxstart = 0  # Index for rx points
for radius in range(0, len(radii)):
    index = 0
    # Observation points
    for pt in range(rxstart, rxstart + len(theta)):
        # Cartesian to spherical coordinate transform coefficients from (Kraus,1991,Electromagnetics,p.34)
        r1 = coords[pt, 0] / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2)
        r2 = coords[pt, 1] / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2)
        r3 = coords[pt, 2] / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2)
        theta1 = (coords[pt, 0] * coords[pt, 2]) / (np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2) * np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2))
        theta2 = (coords[pt, 1] * coords[pt, 2]) / (np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2) * np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2))
        theta3 = -(np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2) / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2))
        phi1 = -(coords[pt, 1] / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2))
        phi2 = coords[pt, 0] / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2)
        phi3 = 0

        # Fields in spherical coordinates
        Er[:, index] = Ex[:, pt] * r1 + Ey[:, pt] * r2 + Ez[:, pt] * r3
        Etheta[:, index] = Ex[:, pt] * theta1 + Ey[:, pt] * theta2 + Ez[:, pt] * theta3
        Ephi[:, index] = Ex[:, pt] * phi1 + Ey[:, pt] * phi2 + Ez[:, pt] * phi3
        Hr[:, index] = Hx[:, pt] * r1 + Hy[:, pt] * r2 + Hz[:, pt] * r3
        Htheta[:, index] = Hx[:, pt] * theta1 + Hy[:, pt] * theta2 + Hz[:, pt] * theta3
        Hphi[:, index] = Hx[:, pt] * phi1 + Hy[:, pt] * phi2 + Hz[:, pt] * phi3

        # Calculate metric for time-domain field pattern values
        if impscaling and coords[pt, 2] < 0:
            Ethetasum[index] = np.sum(Etheta[:, index]**2) / z1
            Hthetasum[index] = np.sum(Htheta[:, index]**2) / z1
        else:
            Ethetasum[index] = np.sum(Etheta[:, index]**2) / z0

# Path: gprMax/constants.py



# Path: user_libs/antenna_patterns/initial_save.py
import argparse
import os
import sys
import h5py
import numpy as np
import matplotlib.pyplot as plt
from gprMax.constants import c, z0

rxstart = 0  # Index for rx points
for radius in range(0, len(radii)):
    index = 0
    # Observation points
    for pt in range(rxstart, rxstart + len(theta)):
        # Cartesian to spherical coordinate transform coefficients from (Kraus,1991,Electromagnetics,p.34)
        r1 = coords[pt, 0] / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2)
        r2 = coords[pt, 1] / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2)
        r3 = coords[pt, 2] / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2)
        theta1 = (coords[pt, 0] * coords[pt, 2]) / (np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2) * np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2))
        theta2 = (coords[pt, 1] * coords[pt, 2]) / (np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2) * np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2))
        theta3 = -(np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2) / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2 + coords[pt, 2]**2))
        phi1 = -(coords[pt, 1] / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2))
        phi2 = coords[pt, 0] / np.sqrt(coords[pt, 0]**2 + coords[pt, 1]**2)
        phi3 = 0

        # Fields in spherical coordinates
        Er[:, index] = Ex[:, pt] * r1 + Ey[:, pt] * r2 + Ez[:, pt] * r3
        Etheta[:, index] = Ex[:, pt] * theta1 + Ey[:, pt] * theta2 + Ez[:, pt] * theta3
        Ephi[:, index] = Ex[:, pt] * phi1 + Ey[:, pt] * phi2 + Ez[:, pt] * phi3
        Hr[:, index] = Hx[:, pt] * r1 + Hy[:, pt] * r2 + Hz[:, pt] * r3
        Htheta[:, index] = Hx[:, pt] * theta1 + Hy[:, pt] * theta2 + Hz[:, pt] * theta3
        Hphi[:, index] = Hx[:, pt] * phi1 + Hy[:, pt] * phi2 + Hz[:, pt] * phi3

        # Calculate metric for time-domain field pattern values
        if impscaling and coords[pt, 2] < 0:
            Ethetasum[index] = np.sum(Etheta[:, index]**2) / z1
            Hthetasum[index] = np.sum(Htheta[:, index]**2) / z1
        else:
            Ethetasum[index] = np.sum(Etheta[:, index]**2) / z0

            Hthetasum[index] = np.sum(Htheta[:, index]**2) / z0