Created
March 23, 2017 14:30
-
-
Save johngrantuk/7548df40f8047abcc67d827b191e912c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def FieldSumHorn(ElementArray, Freq): | |
""" | |
Summation of field contributions from each horn element in array, at frequency freq for theta 0°-95°, phi 0°-360°. | |
Horn pattern estimate using cos q(theta) function. | |
Element = xPos, yPos, zPos, ElementAmplitude, ElementPhaseWeight | |
Returns arrayFactor[theta, phi, elementSum] | |
""" | |
arrayFactor = np.ones((360, 95)) | |
Lambda = 3e8 / Freq | |
for theta in range(95): | |
for phi in range(360): # For all theta/phi positions | |
elementSum = 1e-9 + 0j | |
xff, yff, zff = sph2cart1(999, math.radians(theta), math.radians(phi)) # Find point in far field | |
for element in ElementArray: # For each element in array, find local theta/phi, calculate field contribution and add to summation for point | |
if theta > 90: | |
hornFunction = 0 # Assume no radiation behind horn for simplification | |
else: | |
xlocal = xff - element[0] # Calculate local position in cartesian | |
ylocal = yff - element[1] | |
zlocal = zff - element[2] | |
r, thetaLocal, phiLocal = cart2sph1(xlocal, ylocal, zlocal) # Convert local position to spherical | |
hornFunction = math.cos(thetaLocal) ** 28 # Horn q function, q = 28 | |
if hornFunction != 0: # Sum each elements contribution | |
relativePhase = CalculateRelativePhase(element, Lambda, math.radians(theta), math.radians(phi)) # Find relative phase for current element | |
elementSum += element[3] * hornFunction * math.e ** ((relativePhase + element[4]) * 1j) # Element contribution = Amp * e^j(Phase + Phase Weight) | |
arrayFactor[phi][theta] = elementSum.real | |
return arrayFactor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment