Window algorithm for bidimensional arrays
This function uses a window algorithm to obtain the weights and phases of each element in a bidimensional array. The results of the function define the pointing of the array in the given direction.
void bidirectional_window(double d1, int N1, double d2, int N2, double theta, double phi, double A, double B) { //d1:element spacing of array x in units of lambda
//N1:number of array elements of array x
//d2:element spacing of array y in units of lambda
//N2:number of array elements of array y
//theta:beam angle (in degrees)
//phi:azimut angle (in degrees)
//A:minimum amplitude of the window
//B:maximum amplitude of the window
//By default, A=1.0 B=2.
//This function uses an window algorithm to calculate the weights and phases in an bidirectional array of antennas
int N=N1*N2;
Cmplx[] a=new Cmplx[N1];
Cmplx[] b=new Cmplx[N2];
Cmplx[][] c=new Cmplx[N1][N2];
Cmplx[] pesos=new Cmplx[N];
a=window(d1, theta, phi, N1, A, B, 1); //call to the window.java and store in a the results (complex numbers) of the array in x
b=window(d2, theta, phi, N2, A, B, 2); //call to the window.java and store in b the results (complex numbers) of the array in y
double[] fase=new double[N];
double[] y=new double[N]; //vectors of N elements double type
int cont=0; //initialize cont to 0
for (int i=0; i<N1; i++){
for (int j=0; j<N2; j++){
c[i][j]=Cmplx.mul(a[i],b[j]); //multiply the values of array x and array y to obtain the two-directional results
pesos[cont]=c[i][j]; //store these results in order
cont=cont+1; //increment cont
}
}
for (int n=0; n<N; n++){
y[n]=(Cmplx.abs(pesos[n])); //find the absolute of the complexes, that is, the weights
fase[n]=(Math.atan2(pesos[n].imag, pesos[n].real)); //find the phase in radians
if (fase[n]<0){ // if the phase is less than 0
fase[n]=2*Math.PI+fase[n]; //add 2*pi
}
fase[n]=Math.toDegrees(fase[n]); //find the phase in degrees
}
writeFile("./mydatafiles/window_bi.txt", y,fase); //write the weigths and phases in a text file
}