Skip to content

Commit

Permalink
adding the basic feko read function
Browse files Browse the repository at this point in the history
  • Loading branch information
nmahesh1412 committed Aug 14, 2023
1 parent 4ff6808 commit 56fb2a4
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pyuvdata/uvbeam/feko_beam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import numpy as np
import glob

def read_feko(file_name_prefix,freq_p,theta_p,phi_p):
"""
Reads in a typical feko output file and returns numpy arrays of the power beam and efield beams.
"""
beam_square = np.zeros((freq_p,theta_p,phi_p))
etheta_square90 = np.zeros((freq_p,theta_p,phi_p),dtype = 'complex')
ephi_square90 = np.zeros((freq_p,theta_p,phi_p),dtype = 'complex')

f1 = open(file_name_prefix)


z = theta_p*phi_p +10# ---> change this to no.of theta * no.of phi + No.of header lines
c=0
for line in f1:
if c%z ==0:
co=0
if c % z >= 10:
x = list(map(float,line.split()))
beam_square[int(c/z), co%181,int(co/181)] = 10**(x[8]/10)##*** beam_square [freq,theta,phi]***
etheta_square90[int(c/z), co%181,int(co/181)] = x[2] + 1j*(x[3])
ephi_square90[int(c/z), co%181,int(co/181)] = x[4] + 1j*x[5]
co = co+1
c = c+1

return beam_square, etheta_square90, ephi_square90

0 comments on commit 56fb2a4

Please sign in to comment.