From 6250179bc4c86e05c86a6ee4e160ea3c824f16f5 Mon Sep 17 00:00:00 2001 From: dernasherbrezon Date: Sat, 28 Sep 2024 22:45:33 +0100 Subject: [PATCH] some test to calculate az/el difference for different stale TLE --- .../CalculateAzElErrorForStaleTle.java | 124 ++++++++++++++++++ src/test/resources/39444_historical.txt | 104 +++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 src/test/java/ru/r2cloud/CalculateAzElErrorForStaleTle.java create mode 100644 src/test/resources/39444_historical.txt diff --git a/src/test/java/ru/r2cloud/CalculateAzElErrorForStaleTle.java b/src/test/java/ru/r2cloud/CalculateAzElErrorForStaleTle.java new file mode 100644 index 00000000..8285235b --- /dev/null +++ b/src/test/java/ru/r2cloud/CalculateAzElErrorForStaleTle.java @@ -0,0 +1,124 @@ +package ru.r2cloud; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.InputStreamReader; +import java.nio.file.FileSystems; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.TimeZone; + +import org.hipparchus.util.FastMath; +import org.orekit.bodies.GeodeticPoint; +import org.orekit.frames.TopocentricFrame; +import org.orekit.propagation.analytical.tle.TLEPropagator; +import org.orekit.time.TimeScalesFactory; + +import ru.r2cloud.predict.PredictOreKit; +import ru.r2cloud.rotctrld.Position; +import ru.r2cloud.util.Configuration; + +public class CalculateAzElErrorForStaleTle { + + public static void main(String[] args) throws Exception { + + Configuration config = new Configuration(CalculateAzElErrorForStaleTle.class.getClassLoader().getResourceAsStream("config-dev.properties"), System.getProperty("user.home") + File.separator + ".r2cloud", "config-common-test.properties", FileSystems.getDefault()); + config.setProperty("locaiton.lat", "51.721"); + config.setProperty("locaiton.lon", "5.030"); + config.setProperty("scheduler.orekit.path", "./src/test/resources/data/orekit-data"); + + Double lat = config.getDouble("locaiton.lat"); + Double lon = config.getDouble("locaiton.lon"); + + PredictOreKit predict = new PredictOreKit(config); + TopocentricFrame groundStation = predict.getPosition(new GeodeticPoint(FastMath.toRadians(lat), FastMath.toRadians(lon), 0.0)); + + long reqStart = 1727055832679L; + long reqEnd = 1727056477595L; + + Calendar start = Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.UK); + start.setTimeInMillis(reqStart); + + List calculateForDays = new ArrayList<>(); + calculateForDays.add(-2); + calculateForDays.add(-4); + calculateForDays.add(-8); + calculateForDays.add(-10); + calculateForDays.add(-20); + + List theMostRecent = new ArrayList<>(); + + Map> listOfCoordinates = new HashMap<>(); + try (BufferedReader r = new BufferedReader(new InputStreamReader(CalculateAzElErrorForStaleTle.class.getClassLoader().getResourceAsStream("39444_historical.txt")))) { + String line = null; + while ((line = r.readLine()) != null) { + org.orekit.propagation.analytical.tle.TLE tle = new org.orekit.propagation.analytical.tle.TLE(line, r.readLine()); + Date tleEpoch = tle.getDate().toDate(TimeScalesFactory.getUTC()); + int daysDiff = (int) ((tleEpoch.getTime() - reqStart) / (24 * 60 * 60 * 1000)); + if (!calculateForDays.contains(daysDiff) && daysDiff != -1) { + // skip not interesting day + continue; + } + System.out.println("processing TLE " + (-daysDiff) + " days ago: " + tleEpoch); + calculateForDays.remove(Integer.valueOf(daysDiff)); + TLEPropagator tlePropagator = TLEPropagator.selectExtrapolator(tle); + List current = new ArrayList<>(); + for (long curStart = reqStart; curStart < reqEnd; curStart += 1000) { + current.add(predict.getSatellitePosition(curStart, groundStation, tlePropagator)); + } + if (daysDiff == -1 && theMostRecent.isEmpty()) { + theMostRecent.addAll(current); + } else { + listOfCoordinates.put(daysDiff, current); + } + } + } + + System.out.println("saving the most recent trajectory"); + + // not necessary. just for testing purposes + try (BufferedWriter w = new BufferedWriter(new FileWriter("observation.csv"))) { + w.append("az,el\n"); + for (Position cur : theMostRecent) { + w.append(String.valueOf(cur.getAzimuth())).append(',').append(String.valueOf(cur.getElevation())).append('\n'); + } + } + + System.out.println("calculating difference..."); + + try (BufferedWriter w = new BufferedWriter(new FileWriter("diff.csv"))) { + for (int j = 0; j < theMostRecent.size(); j++) { + if (j == 0) { + int i = 0; + for (Entry> cur : listOfCoordinates.entrySet()) { + String daysAgo = String.valueOf(Math.abs(cur.getKey())); + if (i != 0) { + w.append(','); + } + w.append("az").append(daysAgo).append(",el").append(daysAgo); + i++; + } + w.append('\n'); + } + int i = 0; + for (Entry> cur : listOfCoordinates.entrySet()) { + if (i != 0) { + w.append(','); + } + w.append(String.valueOf(theMostRecent.get(j).getAzimuth() - cur.getValue().get(j).getAzimuth())).append(',').append(String.valueOf(theMostRecent.get(j).getElevation() - cur.getValue().get(j).getElevation())); + i++; + } + w.append('\n'); + } + } + } + +} diff --git a/src/test/resources/39444_historical.txt b/src/test/resources/39444_historical.txt new file mode 100644 index 00000000..60c9a8e2 --- /dev/null +++ b/src/test/resources/39444_historical.txt @@ -0,0 +1,104 @@ +1 39444U 13066AE 24245.62306633 .00017224 00000-0 15917-2 0 9997 +2 39444 97.7242 203.2987 0044266 244.9983 114.6636 14.93893000581513 +1 39444U 13066AE 24245.89098938 .00016203 00000-0 14977-2 0 9993 +2 39444 97.7245 203.5620 0044233 244.0412 115.6247 14.93900762581552 +1 39444U 13066AE 24245.89098938 .00016203 00000-0 14977-2 0 9993 +2 39444 97.7245 203.5620 0044233 244.0412 115.6247 14.93900762582148 +1 39444U 13066AE 24246.42683146 .00014887 00000-0 13762-2 0 9991 +2 39444 97.7247 204.0890 0044220 242.1416 117.5321 14.93915076581635 +1 39444U 13066AE 24246.89568804 .00016677 00000-0 15400-2 0 9995 +2 39444 97.7251 204.5501 0044219 240.4887 119.1920 14.93931901581701 +1 39444U 13066AE 24246.89568804 .00016677 00000-0 15400-2 0 9995 +2 39444 97.7251 204.5501 0044219 240.4887 119.1920 14.93931901582296 +1 39444U 13066AE 24247.43151926 .00015845 00000-0 14631-2 0 9990 +2 39444 97.7254 205.0772 0044222 238.6036 121.0855 14.93946711581781 +1 39444U 13066AE 24247.83338799 .00018328 00000-0 16902-2 0 9991 +2 39444 97.7257 205.4724 0044221 237.1883 122.5074 14.93962995581846 +1 39444U 13066AE 24248.43618491 .00019978 00000-0 18404-2 0 9999 +2 39444 97.7261 206.0654 0044237 235.0663 124.6398 14.93984263581934 +1 39444U 13066AE 24248.77106769 .00023196 00000-0 21341-2 0 9997 +2 39444 97.7263 206.3947 0044272 233.8750 125.8369 14.94000201581984 +1 39444U 13066AE 24248.83804369 .00020086 00000-0 18495-2 0 9996 +2 39444 97.7263 206.4607 0044278 233.6660 126.0469 14.93999755581997 +1 39444U 13066AE 24249.84267448 .00018884 00000-0 17378-2 0 9991 +2 39444 97.7268 207.4491 0044299 230.2006 129.5311 14.94036113582147 +1 39444U 13066AE 24249.84267448 .00018884 00000-0 17378-2 0 9991 +2 39444 97.7268 207.4491 0044299 230.2006 129.5311 14.94036113582732 +1 39444U 13066AE 24250.44544075 .00017831 00000-0 16405-2 0 9994 +2 39444 97.7269 208.0422 0044342 228.1083 131.6352 14.94057523582236 +1 39444U 13066AE 24250.84728001 .00018234 00000-0 16766-2 0 9999 +2 39444 97.7271 208.4375 0044398 226.7414 133.0098 14.94072791582881 +1 39444U 13066AE 24251.31608746 .00018745 00000-0 17225-2 0 9993 +2 39444 97.7271 208.8987 0044445 225.1572 134.6033 14.94090408582369 +1 39444U 13066AE 24251.85186098 .00019310 00000-0 17731-2 0 9994 +2 39444 97.7272 209.4259 0044511 223.3414 136.4303 14.94110860582442 +1 39444U 13066AE 24251.85186098 .00019310 00000-0 17731-2 0 9994 +2 39444 97.7272 209.4259 0044511 223.3414 136.4303 14.94110860583038 +1 39444U 13066AE 24252.45459817 .00018672 00000-0 17138-2 0 9994 +2 39444 97.7273 210.0191 0044599 221.3129 138.4715 14.94131535582534 +1 39444U 13066AE 24252.85641854 .00017161 00000-0 15753-2 0 9995 +2 39444 97.7272 210.4144 0044653 219.9455 139.8477 14.94143781582593 +1 39444U 13066AE 24252.85641854 .00017161 00000-0 15753-2 0 9995 +2 39444 97.7272 210.4144 0044653 219.9455 139.8477 14.94143781583189 +1 39444U 13066AE 24253.45914186 .00016904 00000-0 15509-2 0 9996 +2 39444 97.7271 211.0075 0044753 217.9024 141.9043 14.94164191582684 +1 39444U 13066AE 24253.86095283 .00017544 00000-0 16086-2 0 9991 +2 39444 97.7270 211.4031 0044784 216.5307 143.2856 14.94179150582747 +1 39444U 13066AE 24254.12882473 .00018092 00000-0 16581-2 0 9995 +2 39444 97.7268 211.6668 0044820 215.6127 144.2101 14.94188594583379 +1 39444U 13066AE 24254.86546390 .00016325 00000-0 14960-2 0 9997 +2 39444 97.7266 212.3918 0044927 213.1126 146.7281 14.94212650582896 +1 39444U 13066AE 24255.46816071 .00014373 00000-0 13174-2 0 9997 +2 39444 97.7263 212.9849 0045030 211.0875 148.7680 14.94229023582983 +1 39444U 13066AE 24255.46816071 .00014373 00000-0 13174-2 0 9997 +2 39444 97.7263 212.9849 0045030 211.0875 148.7680 14.94229023583579 +1 39444U 13066AE 24255.86995437 .00016192 00000-0 14825-2 0 9990 +2 39444 97.7263 213.3804 0045106 209.7557 150.1097 14.94243549583040 +1 39444U 13066AE 24256.60656588 .00035585 00000-0 32387-2 0 9994 +2 39444 97.7261 214.1054 0045230 207.2355 152.6493 14.94290083583155 +1 39444U 13066AE 24256.87442215 .00023562 00000-0 21500-2 0 9990 +2 39444 97.7261 214.3690 0045248 206.3163 153.5758 14.94286259583197 +1 39444U 13066AE 24256.87442215 .00023562 00000-0 21500-2 0 9990 +2 39444 97.7261 214.3690 0045248 206.3163 153.5758 14.94286259583782 +1 39444U 13066AE 24258.41454928 .00024116 00000-0 21961-2 0 9993 +2 39444 97.7257 215.8854 0045498 200.9288 159.0071 14.94350418583429 +1 39444U 13066AE 24258.81631366 .00014492 00000-0 13235-2 0 9991 +2 39444 97.7260 216.2808 0045476 199.5570 160.3908 14.94353883584075 +1 39444U 13066AE 24258.88327388 .00014597 00000-0 13330-2 0 9996 +2 39444 97.7261 216.3467 0045481 199.3412 160.6084 14.94356285583499 +1 39444U 13066AE 24259.61983314 .00015337 00000-0 13993-2 0 9993 +2 39444 97.7265 217.0718 0045548 196.7810 163.1906 14.94376715583601 +1 39444U 13066AE 24260.15550661 .00016186 00000-0 14757-2 0 9991 +2 39444 97.7267 217.5992 0045579 194.8890 165.0992 14.94391699584271 +1 39444U 13066AE 24260.35638314 .00013390 00000-0 12221-2 0 9993 +2 39444 97.7267 217.7970 0045608 194.1960 165.7982 14.94393697583717 +1 39444U 13066AE 24260.82509164 .00013952 00000-0 12726-2 0 9999 +2 39444 97.7271 218.2582 0045635 192.5425 167.4663 14.94407066583783 +1 39444U 13066AE 24261.36075201 .00034920 00000-0 31646-2 0 9999 +2 39444 97.7275 218.7857 0045682 190.7113 169.3139 14.94447063583862 +1 39444U 13066AE 24261.36075201 .00034920 00000-0 31646-2 0 9999 +2 39444 97.7275 218.7857 0045682 190.7113 169.3139 14.94447063584458 +1 39444U 13066AE 24261.82945186 .00017781 00000-0 16179-2 0 9998 +2 39444 97.7278 219.2469 0045719 189.0579 170.9821 14.94441435583939 +1 39444U 13066AE 24261.82945186 .00017781 00000-0 16179-2 0 9998 +2 39444 97.7278 219.2469 0045719 189.0579 170.9821 14.94441435584525 +1 39444U 13066AE 24262.43205808 .00015256 00000-0 13888-2 0 9995 +2 39444 97.7281 219.8402 0045763 186.9869 173.0719 14.94457338584023 +1 39444U 13066AE 24262.76683703 .00012048 00000-0 10982-2 0 9993 +2 39444 97.7284 220.1699 0045799 185.8412 174.2280 14.94462480584660 +1 39444U 13066AE 24262.83379279 .00010591 00000-0 96623-3 0 9999 +2 39444 97.7284 220.2358 0045811 185.6082 174.4631 14.94462353584086 +1 39444U 13066AE 24263.36943547 .00011283 00000-0 10286-2 0 9992 +2 39444 97.7286 220.7632 0045855 183.7564 176.3318 14.94474483584169 +1 39444U 13066AE 24263.83811865 .00013486 00000-0 12275-2 0 9998 +2 39444 97.7291 221.2249 0045893 182.1715 177.9314 14.94488037584239 +1 39444U 13066AE 24263.83811865 .00013486 00000-0 12275-2 0 9998 +2 39444 97.7291 221.2249 0045893 182.1715 177.9314 14.94488037584824 +1 39444U 13066AE 24264.64156851 .00010796 00000-0 98364-3 0 9990 +2 39444 97.7296 222.0162 0045975 179.4514 180.6765 14.94502714584357 +1 39444U 13066AE 24264.64156851 .00010796 00000-0 98364-3 0 9990 +2 39444 97.7296 222.0162 0045975 179.4514 180.6765 14.94502714584942 +1 39444U 13066AE 24265.44500922 .00011343 00000-0 10326-2 0 9991 +2 39444 97.7299 222.8075 0046046 176.7978 183.3546 14.94520285584478 +1 39444U 13066AE 24265.84672676 .00010048 00000-0 91532-3 0 9991 +2 39444 97.7299 223.2032 0046081 175.4958 184.6686 14.94526402585128 \ No newline at end of file