Skip to content

Commit

Permalink
remove unused
Browse files Browse the repository at this point in the history
+ update satellite list
+ fixed tests
  • Loading branch information
dernasherbrezon committed Jul 21, 2024
1 parent 0120e6b commit 4015806
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 126 deletions.
44 changes: 0 additions & 44 deletions src/main/java/ru/r2cloud/predict/PredictOreKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.orekit.propagation.events.GroundFieldOfViewDetector;
import org.orekit.propagation.events.handlers.ContinueOnEvent;
import org.orekit.propagation.events.handlers.EventHandler;
import org.orekit.propagation.events.handlers.StopOnDecreasing;
import org.orekit.time.AbsoluteDate;
import org.orekit.time.TimeScalesFactory;
import org.orekit.utils.Constants;
Expand Down Expand Up @@ -115,23 +114,6 @@ public List<SatPass> calculateSchedule(AntennaConfiguration antenna, Date curren
}
}

public SatPass calculateNext(AntennaConfiguration antenna, Date current, TLEPropagator tlePropagator) {
TopocentricFrame baseStationFrame = getPosition();
if (baseStationFrame == null) {
return null;
}
AbsoluteDate initialDate = new AbsoluteDate(current, TimeScalesFactory.getUTC());
switch (antenna.getType()) {
case OMNIDIRECTIONAL:
case DIRECTIONAL:
return calculateNextOmnidirectional(antenna, initialDate, baseStationFrame, tlePropagator);
case FIXED_DIRECTIONAL:
return calculateNextFixedDirectional(antenna, initialDate, baseStationFrame, tlePropagator);
default:
throw new IllegalArgumentException("Unexpected value: " + antenna.getType());
}
}

private static List<SatPass> calculateFixedDirectional(AntennaConfiguration antenna, AbsoluteDate initialDate, TopocentricFrame baseStationFrame, TLEPropagator tlePropagator, @SuppressWarnings("rawtypes") EventHandler handler) {
// orekit expects azimuth in counter clock wise degrees
double azimuthRadians = FastMath.toRadians(Util.convertAzimuthToDegress(antenna.getAzimuth()));
Expand All @@ -154,14 +136,6 @@ private static List<SatPass> calculateFixedDirectional(AntennaConfiguration ante
return convert(initialDate, logger.getLoggedEvents());
}

private static SatPass calculateNextFixedDirectional(AntennaConfiguration antenna, AbsoluteDate initialDate, TopocentricFrame baseStationFrame, TLEPropagator tlePropagator) {
List<SatPass> result = calculateFixedDirectional(antenna, initialDate, baseStationFrame, tlePropagator, new StopOnDecreasing<>());
if (result.isEmpty()) {
return null;
}
return result.get(0);
}

private static List<SatPass> calculateOmnidirectional(AntennaConfiguration antenna, AbsoluteDate initialDate, TopocentricFrame baseStationFrame, TLEPropagator tlePropagator) {
List<SatPass> result = new ArrayList<>();
List<AbsoluteDate> max = new ArrayList<>();
Expand Down Expand Up @@ -196,24 +170,6 @@ public Action eventOccurred(SpacecraftState s, ElevationExtremumDetector detecto
return result;
}

private static SatPass calculateNextOmnidirectional(AntennaConfiguration antenna, AbsoluteDate initialDate, TopocentricFrame baseStationFrame, TLEPropagator tlePropagator) {
MaxElevationHandler maxElevationHandler = new MaxElevationHandler(antenna.getGuaranteedElevation());
ElevationExtremumDetector maxDetector = new ElevationExtremumDetector(600, 1, baseStationFrame).withMaxIter(48 * 60).withHandler(maxElevationHandler);
tlePropagator.clearEventsDetectors();
tlePropagator.addEventDetector(new EventSlopeFilter<EventDetector>(maxDetector, FilterType.TRIGGER_ONLY_DECREASING_EVENTS));
try {
tlePropagator.propagate(initialDate, new AbsoluteDate(initialDate, PREDICT_INTERVAL_SECONDS));
} catch (Exception e) {
LOG.error("unable to calculate next observation. Most likely TLE is stale", e);
return null;
}
if (maxElevationHandler.getDate() == null) {
return null;
}

return findStartEnd(tlePropagator, baseStationFrame, maxElevationHandler.getDate(), antenna);
}

private static SatPass findStartEnd(TLEPropagator tlePropagator, TopocentricFrame baseStationFrame, AbsoluteDate maxElevationTime, AntennaConfiguration antenna) {
MinElevationHandler minElevationHandler = new MinElevationHandler();
ElevationDetector boundsDetector = new ElevationDetector(600, 1, baseStationFrame).withConstantElevation(FastMath.toRadians(antenna.getMinElevation())).withHandler(minElevationHandler);
Expand Down
100 changes: 40 additions & 60 deletions src/main/resources/satellites.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
[
{
"id": "R2CLOUD388",
"name": "GALASSIA-2",
"noradId": "57486",
"enabled": false,
"transmitters": [
{
"modulation": "GFSK",
"framing": "AX100",
"beaconClass": "ru.r2cloud.jradio.csp.CspBeacon",
"frequency": 436400000,
"bandwidth": 20000,
"baudRates": [
1200
],
"status": "ENABLED"
}
]
},
{
"id": "R2CLOUD387",
"name": "SCOOB-II",
"noradId": "57484",
"enabled": false,
"transmitters": [
{
"modulation": "GFSK",
"framing": "AX25G3RUH",
"beaconClass": "ru.r2cloud.jradio.ax25.Ax25Beacon",
"frequency": 437500000,
"bandwidth": 20000,
"baudRates": [
9600
],
"assistedHeader": "AAEAAAEAAAEAAQEAAAEAAQABAAEBAAEAAAEAAAABAQAAAAAAAAABAAAAAAAAAAEAAAAAAAABAQAAAAEAAAAAAQABAQAAAAABAAAAAQABAAEAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQABAAAAAAEBAQEBAAAAAAAAAAAAAAEBAQE=",
"status": "ENABLED"
}
]
},
{
"id": "R2CLOUD385",
"name": "MONITOR-2 (RS39S)",
Expand Down Expand Up @@ -2605,44 +2644,6 @@
}
]
},
{
"id": "R2CLOUD234",
"name": "DIAMOND GREEN",
"noradId": "42785",
"enabled": false,
"transmitters": [
{
"modulation": "GFSK",
"framing": "AX100",
"beaconClass": "ru.r2cloud.jradio.csp.CspBeacon",
"frequency": 401150000,
"bandwidth": 20000,
"baudRates": [
9600
],
"status": "ENABLED"
}
]
},
{
"id": "R2CLOUD233",
"name": "DIAMOND BLUE",
"noradId": "42786",
"enabled": false,
"transmitters": [
{
"modulation": "GFSK",
"framing": "AX100",
"beaconClass": "ru.r2cloud.jradio.csp.CspBeacon",
"frequency": 401150000,
"bandwidth": 20000,
"baudRates": [
9600
],
"status": "ENABLED"
}
]
},
{
"id": "R2CLOUD232",
"name": "PTD-3 (TYVAK-0125)",
Expand Down Expand Up @@ -3309,27 +3310,6 @@
}
]
},
{
"id": "R2CLOUD172",
"name": "MIET-AIS (RS28S)",
"noradId": "53377",
"enabled": true,
"transmitters": [
{
"modulation": "GFSK",
"framing": "USP",
"beaconClass": "ru.r2cloud.jradio.sputnix.SputnixBeacon",
"frequency": 437900000,
"bandwidth": 20000,
"baudRates": [
4800,
2400,
9600
],
"status": "ENABLED"
}
]
},
{
"id": "R2CLOUD171",
"name": "RESHUCUBE (RS8S)",
Expand Down Expand Up @@ -4277,7 +4257,7 @@
"baudRates": [
1200
],
"deviation": -600,
"deviation": -300,
"afCarrier": 1500,
"status": "ENABLED"
}
Expand Down
34 changes: 12 additions & 22 deletions src/test/java/ru/r2cloud/satellite/PredictOreKitTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ru.r2cloud.satellite;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -34,7 +34,9 @@ public class PredictOreKitTest {
@Test
public void testMeoOrbit() throws Exception {
TLEPropagator astroBio = TLEPropagator.selectExtrapolator(new org.orekit.propagation.analytical.tle.TLE("1 84002U 22194.52504630 .00000000 00000-0 00000-0 0 00", "2 84002 70.1600 50.0000 0000815 30.0000 147.0000 6.38669028 02"));
assertPosition("16:00:57", "16:45:56", predict.calculateNext(antenna, getDate("29-09-2022 14:54:00"), astroBio));
List<SatPass> result = predict.calculateSchedule(antenna, getDate("29-09-2022 14:54:00"), astroBio);
assertFalse(result.isEmpty());
assertPosition("16:00:57", "16:45:56", result.get(0));
}

@Test
Expand All @@ -49,15 +51,19 @@ public void testCalculateBatch() throws Exception {
public void testPredictWithoutBaseStationCoordinates() throws Exception {
config.remove("locaiton.lat");
config.remove("locaiton.lon");

assertNull(predict.calculateNext(antenna, getDate("29-09-2017 14:54:00"), noaa15));
List<SatPass> result = predict.calculateSchedule(antenna, getDate("29-09-2017 14:54:00"), noaa15);
assertTrue(result.isEmpty());
}

// expected pass times taken from wxtoimg
@Test
public void testSameAsWxToImg() throws Exception {
assertPosition("18:05:57", "18:17:12", predict.calculateNext(antenna, getDate("29-09-2017 14:54:00"), noaa15));
assertPosition("19:46:56", "19:56:34", predict.calculateNext(antenna, getDate("29-09-2017 19:00:00"), noaa15));
List<SatPass> result = predict.calculateSchedule(antenna, getDate("29-09-2017 14:54:00"), noaa15);
assertFalse(result.isEmpty());
assertPosition("18:05:57", "18:17:12", result.get(0));
result = predict.calculateSchedule(antenna, getDate("29-09-2017 19:00:00"), noaa15);
assertFalse(result.isEmpty());
assertPosition("19:46:56", "19:56:34", result.get(0));
}

@Test
Expand All @@ -68,8 +74,6 @@ public void testFixedDirectionalAntenna() throws Exception {
antenna.setElevation(0.0);
antenna.setBeamwidth(45);
TLEPropagator propagator = TLEPropagator.selectExtrapolator(new org.orekit.propagation.analytical.tle.TLE("1 43881U 18111F 24042.67399199 .00015427 00000+0 10192-2 0 9994", "2 43881 97.6384 310.9432 0012514 108.3312 251.9278 15.07433805280400"));
assertPosition("11:29:31", "11:33:11", predict.calculateNext(antenna, getDate("12-02-2024 11:20:00"), propagator));
assertPosition("11:30:00", "11:33:11", predict.calculateNext(antenna, getDate("12-02-2024 11:30:00"), propagator));
List<SatPass> schedule = predict.calculateSchedule(antenna, getDate("12-02-2024 11:20:00"), propagator);
assertEquals(4, schedule.size());
assertPosition("11:29:31", "11:33:11", schedule.get(0));
Expand All @@ -86,20 +90,6 @@ public void testStaleTle() throws Exception {
antenna.setGuaranteedElevation(10);
List<SatPass> result = predict.calculateSchedule(antenna, getDate("21-07-2024 14:07:37"), createPropagatorForStaleTle());
assertTrue(result.isEmpty());
assertNull(predict.calculateNext(antenna, getDate("21-07-2024 20:06:37"), createPropagatorForStaleTle()));
}

// it looks like Orekit has some state,
// calling new propagator with different dates
// cause different exceptions
@Test
public void testStaleTle2() throws Exception {
config.setProperty("locaiton.lat", "51.82");
config.setProperty("locaiton.lon", "-0.05");
antenna.setMinElevation(2);
antenna.setGuaranteedElevation(10);
predict.calculateSchedule(antenna, getDate("21-07-2024 00:06:37"), createPropagatorForStaleTle());
assertNull(predict.calculateNext(antenna, getDate("21-07-2024 20:06:37"), createPropagatorForStaleTle()));
}

private static Date getDate(String str) throws Exception {
Expand Down

0 comments on commit 4015806

Please sign in to comment.