Commit 0169bb6a authored by Bryan Cazabonne's avatar Bryan Cazabonne
Browse files

Fixed again rollover when parsing CRD files.

parent f2ba8ebf
Pipeline #2098 passed with stages
in 15 minutes and 3 seconds
......@@ -43,6 +43,7 @@ import org.orekit.time.AbsoluteDate;
import org.orekit.time.DateComponents;
import org.orekit.time.TimeComponents;
import org.orekit.time.TimeScale;
import org.orekit.utils.Constants;
import org.orekit.utils.units.Unit;
import org.orekit.utils.units.UnitsConverter;
......@@ -196,6 +197,9 @@ public class CRDParser {
/** End Of File reached indicator. */
private boolean done;
/** Last parsed range measurement. */
private RangeMeasurement lastRange;
/**
* Constructor.
*/
......@@ -205,6 +209,7 @@ public class CRDParser {
this.done = false;
this.version = 1;
this.startEpoch = DateComponents.J2000_EPOCH;
this.lastRange = null;
// Initialise empty object
this.file = new CRD();
......@@ -734,11 +739,19 @@ public class CRDParser {
// Check secOfDay for rollover
dayShift = dayShift + checkRollover(lastSecOfDay, secOfDay);
// Initialise a new Range measurement
final AbsoluteDate epoch = new AbsoluteDate(pi.startEpoch, new TimeComponents(secOfDay), pi.timeScale).shiftedBy(dayShift * 86400);
AbsoluteDate epoch = new AbsoluteDate(pi.startEpoch, new TimeComponents(secOfDay), pi.timeScale);
if (pi.lastRange != null) {
final double duration = epoch.durationFrom(pi.lastRange.getDate());
if (duration < 0) {
epoch = epoch.shiftedBy(Constants.JULIAN_DAY);
}
}
final RangeMeasurement range = new RangeMeasurement(epoch, timeOfFlight, epochEvent);
pi.dataBlock.addRangeData(range);
lastSecOfDay = secOfDay;
pi.lastRange = range;
}
/** {@inheritDoc} */
......@@ -774,10 +787,19 @@ public class CRDParser {
// Check secOfDay for rollover
dayShift = dayShift + checkRollover(lastSecOfDay, secOfDay);
// Initialise a new Range measurement
final AbsoluteDate epoch = new AbsoluteDate(pi.startEpoch, new TimeComponents(secOfDay), pi.timeScale).shiftedBy(dayShift * 86400);
AbsoluteDate epoch = new AbsoluteDate(pi.startEpoch, new TimeComponents(secOfDay), pi.timeScale);
if (pi.lastRange != null) {
final double duration = epoch.durationFrom(pi.lastRange.getDate());
if (duration < 0) {
epoch = epoch.shiftedBy(Constants.JULIAN_DAY);
}
}
final RangeMeasurement range = new RangeMeasurement(epoch, timeOfFlight, epochEvent, snr);
pi.dataBlock.addRangeData(range);
lastSecOfDay = secOfDay;
pi.lastRange = range;
}
/** {@inheritDoc} */
......@@ -1042,6 +1064,7 @@ public class CRDParser {
pi.header = new CRDHeader();
pi.configurationRecords = new CRDConfiguration();
pi.dataBlock = new CRDDataBlock();
pi.lastRange = null;
}
......
......@@ -569,8 +569,8 @@ public class CRDParserTest {
final RangeMeasurement rangeFirst = rangeBlock.get(0);
final RangeMeasurement rangeLast = rangeBlock.get(rangeBlock.size() - 1);
DateComponents startEpoch = new DateComponents(2019, 04, 21);
DateComponents lastEpoch = new DateComponents(2019, 04, 22);
DateComponents startEpoch = new DateComponents(2019, 04, 19);
DateComponents lastEpoch = new DateComponents(2019, 04, 20);
double firstSecOfDay = 77387.019063653420;
double lastSecOfDay = 694.119563650340;
final AbsoluteDate firstDate = new AbsoluteDate(startEpoch, new TimeComponents(firstSecOfDay), DataContext.getDefault().getTimeScales().getUTC());
......@@ -580,7 +580,63 @@ public class CRDParserTest {
Assert.assertEquals(firstDate, rangeFirst.getDate());
Assert.assertEquals(lastDate, rangeLast.getDate());
}
@Test
public void testIssue886Bis() throws IOException {
final String ex = "/ilrs/Rollover.frd";
final CRD file = new CRDParser().parse(new DataSource(ex, () -> getClass().getResourceAsStream(ex)));
// Verify each block
// Block 1
CRDDataBlock block = file.getDataBlocks().get(0);
List<RangeMeasurement> rangeBlock = block.getRangeData();
RangeMeasurement rangeFirst = rangeBlock.get(0);
RangeMeasurement rangeLast = rangeBlock.get(rangeBlock.size() - 1);
DateComponents startEpoch = new DateComponents(2022, 6, 6);
DateComponents lastEpoch = new DateComponents(2022, 6, 6);
double firstSecOfDay = 43410.8898329;
double lastSecOfDay = 43444.1690476;
AbsoluteDate firstDate = new AbsoluteDate(startEpoch, new TimeComponents(firstSecOfDay), DataContext.getDefault().getTimeScales().getUTC());
AbsoluteDate lastDate = new AbsoluteDate(lastEpoch, new TimeComponents(lastSecOfDay), DataContext.getDefault().getTimeScales().getUTC());
Assert.assertEquals(firstDate, rangeFirst.getDate());
Assert.assertEquals(lastDate, rangeLast.getDate());
// Block 2
block = file.getDataBlocks().get(1);
rangeBlock = block.getRangeData();
rangeFirst = rangeBlock.get(0);
rangeLast = rangeBlock.get(rangeBlock.size() - 1);
startEpoch = new DateComponents(2022, 6, 6);
lastEpoch = new DateComponents(2022, 6, 6);
firstSecOfDay = 26579.400543200001;
lastSecOfDay = 26618.200540700000;
firstDate = new AbsoluteDate(startEpoch, new TimeComponents(firstSecOfDay), DataContext.getDefault().getTimeScales().getUTC());
lastDate = new AbsoluteDate(lastEpoch, new TimeComponents(lastSecOfDay), DataContext.getDefault().getTimeScales().getUTC());
Assert.assertEquals(firstDate, rangeFirst.getDate());
Assert.assertEquals(lastDate, rangeLast.getDate());
// Block 3
block = file.getDataBlocks().get(2);
rangeBlock = block.getRangeData();
rangeFirst = rangeBlock.get(0);
rangeLast = rangeBlock.get(rangeBlock.size() - 1);
startEpoch = new DateComponents(2021, 1, 26);
lastEpoch = new DateComponents(2021, 1, 27);
firstSecOfDay = 86181.271863631440;
lastSecOfDay = 1007.946763625370;
firstDate = new AbsoluteDate(startEpoch, new TimeComponents(firstSecOfDay), DataContext.getDefault().getTimeScales().getUTC());
lastDate = new AbsoluteDate(lastEpoch, new TimeComponents(lastSecOfDay), DataContext.getDefault().getTimeScales().getUTC());
Assert.assertEquals(firstDate, rangeFirst.getDate());
Assert.assertEquals(lastDate, rangeLast.getDate());
}
@Before
public void setUp() {
......
h1 CRD 2 2022 6 6 12
h2 SISL 7838 36 3 4 ILRS
h3 lageos1 7603901 1155 8820 0 1 -1
h4 0 2022 6 6 11 55 52 2022 6 6 12 4 4 0 0 0 0 1 0 2 0
h5 1 22 060500 HTS 15601
c0 0 532.000 std lzr rcv tmr swv met ctg
c1 0 lzr Nd-Yag 1064.00 1000.00 3.00 28.0 -1 -1
c2 0 rcv mcp 532.000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0
c3 0 tmr DST_FURY-10M-SP1 Agilent_5071A Eventech_A033-ET 0033027 -1
c5 0 swv WSRS v115 WSRS v114
c6 0 met Ota_Keiki OW-7-420 -1 Ota_Keiki OW-1-1 W1121A1008 Ota_Keiki OW-4 21I00-9754
c7 0 ctg Inter-1l 0.00000 -1 -1 3.00 WSRS v114
40 43198.1199390 0 std 7069 6809 0.000 144518.0 8.0 53.0 0.467 0.083 -7.7 3 2 0 3 79.9
41 42877.7819645 0 std 3541 3403 0.000 144518.0 8.0 53.0 0.467 0.083 -7.7 3 2 0 1 75.6
41 43777.5819051 0 std 3528 3406 0.000 144518.0 8.0 53.0 0.467 0.083 -7.7 3 2 0 2 84.7
10 43410.8898329 0.044490825842 std 2 0 0 0 -1 -1
20 43410.8898329 988.50 292.50 88 1
10 43414.0166733 0.044516958122 std 2 0 0 0 -1 -1
20 43414.0166733 988.50 292.50 88 1
10 43425.5350385 0.044614562676 std 2 0 0 0 -1 -1
20 43425.5350385 988.50 292.50 88 1
10 43433.7716159 0.044685645365 std 2 0 0 0 -1 -1
20 43433.7716159 988.50 292.50 88 1
10 43444.1690476 0.044776899232 std 2 0 0 0 -1 -1
20 43444.1690476 988.50 292.50 88 1
50 std 104.0 -0.052 -0.302 47.4 0
h8
h1 CRD 2 2022 6 6 8
h2 GODL 7105 7 25 3 ILRS
h3 lageos1 7603901 1155 8820 0 1 1
h4 0 2022 6 6 7 22 59 2022 6 6 7 42 6 0 0 0 0 1 0 2 0
h5 1 22 060500 SGF 15701
c0 0 532.000 new la1 mcp ti1 swm met cac
c1 0 la1 Nd:Yag 1064.00 5.00 100.00 150.0 15.00 1
c2 0 mcp MCP-PMT 532.000 12.0 3096.0 31.0 a-1log 400.0 1.00 80.0 30.00 none -1 -1 0
c3 0 ti1 SRS_FS740 SRS_FS740 Cybi_ETM -1 0.0
c5 0 swm sattrk 6.10 HPLDP,GNP 9.11.3,2.8.3
c6 0 met Paroscientific MET-4 117555 Paroscientific MET-4 117555 Paroscientific MET-4 117555
c7 0 cac C 170.52590 1.00 0.1643 -1 HPLDP 9.11.3
20 27726.601 1009.80 284.20 93. 0
40 26288.100538356230 0 new 4044 4009 170.5259 86955.5 2.0 28.0 -1 -1 -1 2 2 0 3 -1
41 23458.300539571792 0 new 2931 2903 170.5259 86954.8 -1 28.0 -1 -1 -1 2 2 0 1 -1
41 29208.800536952913 0 new 1113 1106 170.5259 86956.8 -1 28.0 -1 -1 -1 2 2 0 2 -1
20 26579.401 1009.70 284.50 93. 0
30 26579.401 29.5782 21.7581 0 1 0 -1 -1
10 26579.400543200001 0.056426965955 new 2 2 0 0 533 701
20 26580.801 1009.70 284.50 93. 0
30 26580.801 29.5327 21.7913 0 1 0 -0.0325000 0.0237143
10 26580.800543199999 0.056409046425 new 2 2 0 0 601 845
20 26592.201 1009.70 284.50 93. 0
30 26592.201 29.1601 22.0615 0 1 0 -0.0326842 0.0237018
10 26592.200541300001 0.056263874255 new 2 2 0 0 425 767
20 26603.401 1009.70 284.50 93. 0
30 26603.401 28.7904 22.3257 0 1 0 -0.0330089 0.0235893
10 26603.400541399998 0.056122551405 new 2 2 0 0 276 729
20 26612.201 1009.70 284.50 93. 0
30 26612.201 28.4972 22.5326 0 1 0 -0.0333182 0.0235114
10 26612.200540300000 0.056012427065 new 2 2 0 0 389 782
20 26618.201 1009.70 284.50 93. 0
30 26618.201 28.2960 22.6732 0 1 0 -0.0335333 0.0234333
10 26618.200540700000 0.055937808325 new 2 2 0 0 466 783
20 26619.401 1009.70 284.50 93. 0
30 26619.401 28.2556 22.7012 0 1 0 -0.0336666 0.0233333
50 new 85.2 0.152 0.066 -1 0
h8
H1 CRD 2 2021 01 27 09
H2 GRZL 7839 34 02 4 EUROLAS
H3 lageos1 7603901 1155 8820 0 1 1
H4 0 2021 01 26 23 55 51 2021 01 27 00 34 18 0 0 0 0 1 0 2 0
00 trunc from https://edc.dgfi.tum.de/en/data/frd2/67997/
C0 0 532.000 0902 2kHz C_SPAD1 GPS -1 VSLA -1
C1 0 2kHz Nd:Van 1064 2000 0.400 10 10 1
C2 0 C_SPAD1 SPAD 532.0 20 5.0 400 +1V 10 0.3 35 300 WinClean2.2 -1 -1 -1
C3 0 GPS HP58503A HP58503A Graz_Dassault NoSN 0.077
C6 0 VSLA Vaisala PTU300 L1110324 Vaisala PTU300 L1110324 Vaisala PTU300 L1110324
20 86151.000 956.42 273.00 67.1 1
20 2058.000 956.51 272.77 68.1 1
10 86181.271863631440 0.058145452724 0902 2 2 0 0 -1 -1
10 86181.274863626340 0.058145400815 0902 2 2 0 0 -1 -1
10 86181.299363626630 0.058144977528 0902 2 2 0 0 -1 -1
10 86181.303863627840 0.058144899840 0902 2 2 0 0 -1 -1
10 86181.305863620250 0.058144865237 0902 2 2 0 0 -1 -1
10 86181.311363625340 0.058144770230 0902 2 2 0 0 -1 -1
10 86181.323363624050 0.058144562804 0902 2 2 0 0 -1 -1
10 86181.326363620350 0.058144511084 0902 2 2 0 0 -1 -1
10 86181.337363629140 0.058144321031 0902 2 2 0 0 -1 -1
10 1003.245563627690 0.045568867753 0902 2 2 0 0 -1 -1
10 1007.660063630440 0.045566386809 0902 2 2 0 0 -1 -1
10 1007.768863621630 0.045566330272 0902 2 2 0 0 -1 -1
10 1007.778863631650 0.045566325031 0902 2 2 0 0 -1 -1
10 1007.809963625390 0.045566308923 0902 2 2 0 0 -1 -1
10 1007.814463621470 0.045566306639 0902 2 2 0 0 -1 -1
10 1007.911163620190 0.045566256655 0902 2 2 0 0 -1 -1
10 1007.922163617800 0.045566251042 0902 2 2 0 0 -1 -1
10 1007.946763625370 0.045566238343 0902 2 2 0 0 -1 -1
H8
H9
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment