Skip to content

Commit

Permalink
Remove deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
christianheina committed Dec 27, 2024
1 parent e354e44 commit 35cdd2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,53 +30,7 @@
public class PhasedArrayAntenna {

private PhasedArrayAntenna() {
/* Hidden Constructor */ }

/**
* Create array factor
*
* @param frequency
* wavelength
* @param antennaArray
* antenna array to use when creating array factor
* @param angles
* angles used in the created array factor
*
* @return a field containing the array factor
*
* @deprecated As of 2024-03-13 this is replaced by
* {@link com.christianheina.communication.jantenna.phasedarray.ArrayFactor#newArrayFactorAsync(double, AntennaArray, List)
* newArrayFactorAsync(double frequency, AntennaArray antennaArray, List angles)}. This method will be
* supported until 2024-06-13 and removed 2024-09-13.
*/
@Deprecated
public static Field newArrayFactorAsync(double frequency, AntennaArray antennaArray, List<ThetaPhi> angles) {
return ArrayFactor.newArrayFactorAsync(frequency, antennaArray, angles);
}

/**
* Create array factor
*
* @param executorService
* the ExecutorService used for asynchronous array factor calculations
* @param frequency
* wavelength
* @param antennaArray
* antenna array to use when creating array factor
* @param angles
* angles used in the created array factor
*
* @return a field containing the array factor
*
* @deprecated As of 2024-03-13 this is replaced by
* {@link com.christianheina.communication.jantenna.phasedarray.ArrayFactor#newArrayFactorAsync(ExecutorService, double, AntennaArray, List)
* newArrayFactorAsync(ExecutorService executorService, double frequency, AntennaArray antennaArray,
* List angles)}. This method will be supported until 2024-06-13 and removed 2024-09-13.
*/
@Deprecated
public static Field newArrayFactorAsync(ExecutorService executorService, double frequency,
AntennaArray antennaArray, List<ThetaPhi> angles) {
return ArrayFactor.newArrayFactorAsync(executorService, frequency, antennaArray, angles);
/* Hidden Constructor */
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.testng.Assert;
import org.testng.annotations.Test;

import com.christianheina.communication.jantenna.commons.Constants;
import com.christianheina.communication.jantenna.commons.Field;
import com.christianheina.communication.jantenna.commons.ThetaPhi;
import com.christianheina.communication.jantenna.commons.Util;
Expand All @@ -43,78 +42,15 @@ public class PhasedArrayAntennaTest {
private static final String AVERAGE_EMBEDDED_FIELD_PATH = new File(PhasedArrayAntennaTest.class.getClassLoader()
.getResource("example_sphere_gaussian_model_field.json").getFile()).getPath();

@Test
public void newArrayFactorAsyncSuppliedExecutorServiceTest() {
double freq = 28 * Math.pow(10, 9);
// double lambda = Constants.VACCUM_SPEED_OF_LIGHT / freq;
List<ThetaPhi> angleList = ThetaPhi.equallySpacedSphere(1);
ThetaPhi steeringAngle = ThetaPhi.fromDegrees(90, 0);
AntennaArray antennaArray = AntennaArray.fromEquallySpacedArray(1, 24, 16, 0.5, freq,
WeightAlgorithm.newConjugateWeightAlgorithm(Util.calculateLambda(freq), steeringAngle));
Field field = PhasedArrayAntenna.newArrayFactorAsync(Executors.newSingleThreadExecutor(), freq, antennaArray,
angleList);
Assert.assertEquals(field.getThetaPhiList().size(), angleList.size());
field.getAvailableElectricFields().forEach(electricFieldName -> {
List<Complex> electricFieldList = field.getElectricField(electricFieldName);
double max = Double.MIN_VALUE;
List<ThetaPhi> maxAngleList = new ArrayList<>();
for (int i = 0; i < electricFieldList.size(); i++) {
if (electricFieldList.get(i).abs() >= max) {
max = electricFieldList.get(i).abs();
maxAngleList.add(angleList.get(i));
}
}
boolean hasAngleInList = false;
for (ThetaPhi thetaPhi : maxAngleList) {
if (thetaPhi.getTheta() == steeringAngle.getTheta() && thetaPhi.getPhi() == steeringAngle.getPhi()) {
hasAngleInList = true;
}
}
Assert.assertTrue(hasAngleInList);
});

}

@Test
public void newArrayFactorAsyncTest() {
double freq = 28 * Math.pow(10, 9);
double lambda = Constants.VACCUM_SPEED_OF_LIGHT / freq;
List<ThetaPhi> angleList = ThetaPhi.equallySpacedSphere(1);
ThetaPhi steeringAngle = ThetaPhi.fromDegrees(90, 0);
AntennaArray antennaArray = AntennaArray.fromEquallySpacedArray(1, 24, 16, lambda / 2, freq,
WeightAlgorithm.newConjugateWeightAlgorithm(lambda, steeringAngle));
Field field = PhasedArrayAntenna.newArrayFactorAsync(freq, antennaArray, angleList);
Assert.assertEquals(field.getThetaPhiList().size(), angleList.size());
field.getAvailableElectricFields().forEach(electricFieldName -> {
List<Complex> electricFieldList = field.getElectricField(electricFieldName);
double max = Double.MIN_VALUE;
List<ThetaPhi> maxAngleList = new ArrayList<>();
for (int i = 0; i < electricFieldList.size(); i++) {
if (electricFieldList.get(i).abs() >= max) {
max = electricFieldList.get(i).abs();
maxAngleList.add(angleList.get(i));
}
}
boolean hasAngleInList = false;
for (ThetaPhi thetaPhi : maxAngleList) {
if (thetaPhi.getTheta() == steeringAngle.getTheta() && thetaPhi.getPhi() == steeringAngle.getPhi()) {
hasAngleInList = true;
}
}
Assert.assertTrue(hasAngleInList);
});

}

@Test
public void newPhasedArrayTest() throws IOException {
double freq = 28 * Math.pow(10, 9);
List<ThetaPhi> angleList = ThetaPhi.equallySpacedSphere(1);
ThetaPhi steeringAngle = ThetaPhi.fromDegrees(90, 0);
AntennaArray antennaArray = AntennaArray.fromEquallySpacedArray(1, 24, 16, 0.5, freq,
WeightAlgorithm.newConjugateWeightAlgorithmFromLambda(Util.calculateLambda(freq), steeringAngle));
Field arrayFactor = PhasedArrayAntenna.newArrayFactorAsync(Executors.newSingleThreadExecutor(), freq,
antennaArray, angleList);
Field arrayFactor = ArrayFactor.newArrayFactorAsync(Executors.newSingleThreadExecutor(), freq, antennaArray,
angleList);
Field averageEmbeddedField = Field.loadJson(AVERAGE_EMBEDDED_FIELD_PATH);
Field phasedArrayField = PhasedArrayAntenna.newPhasedArray(averageEmbeddedField, arrayFactor);
Assert.assertEquals(phasedArrayField.getThetaPhiList().size(), angleList.size());
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/examples/ArrayFactorExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.christianheina.communication.jantenna.commons.ThetaPhi;
import com.christianheina.communication.jantenna.commons.Util;
import com.christianheina.communication.jantenna.phasedarray.AntennaArray;
import com.christianheina.communication.jantenna.phasedarray.PhasedArrayAntenna;
import com.christianheina.communication.jantenna.phasedarray.ArrayFactor;
import com.christianheina.communication.jantenna.phasedarray.weighting.WeightAlgorithm;

/**
Expand All @@ -40,6 +40,6 @@ public static void main(String[] args) {
List<ThetaPhi> angleList = ThetaPhi.equallySpacedSphere(1);
AntennaArray antennaArray = AntennaArray.fromEquallySpacedArray(1, 8, 4, 0.5, freq,
WeightAlgorithm.newConjugateWeightAlgorithm(lambda, ThetaPhi.fromDegrees(103, -1.5)));
Field field = PhasedArrayAntenna.newArrayFactorAsync(freq, antennaArray, angleList);
Field field = ArrayFactor.newArrayFactorAsync(freq, antennaArray, angleList);
}
}

0 comments on commit 35cdd2f

Please sign in to comment.