Given a satellite ID and date time, I am looking to figure out the position in Lat Long Alt.
There is one sp3 navigation file per day. https://cddis.nasa.gov/Data_and_Derived_Products/GNSS/orbit_products.html
- How do I load multiple days(Ephemeris files) into one Ephemeris object or one Propagator that has all the info ? If I load just one day’s navigation data file, the code below works from 12AM to 11:44PM. I get the position in ECEF x y z e.g. {-9,920,197.530017082; 17,398,299.940364283; 17,415,892.930824082}
However, I am not able to query times between 11:44PM and 11:59PM as it results in this error:
java -jar orekitsatpos.jar 18 “01-jan-2021 23:55:15”
Exception in thread “main” org.orekit.errors.TimeStampedCacheException: unable to generate new data after 2021-01-01T23:44:42.000Z, but data is requested for 2021-01-01T23:55:15.000Z which is 6.33E2 s after
at org.orekit.utils.ImmutableTimeStampedCache.getNeighbors(ImmutableTimeStampedCache.java:125)
at org.orekit.files.general.EphemerisSegmentPropagator.getPVCoordinates(EphemerisSegmentPropagator.java:98)
at satposition.SatPosition.main(SatPosition.java:59)
- Is there a built in method to get/convert position in Latitude, Longitude and Altitude instead of ECEF format or do we have to use another library?
public static void main(String[] args) {
//Process input arguments
int prn = Integer.parseInt(args[0]);
LocalDateTime dt = LocalDateTime.parse(args[1]);
//Initialize orekit
File orekitData = new File("resources/orekit-data-master");
DataProvidersManager manager = DataContext.getDefault().getDataProvidersManager();
manager.addProvider(new DirectoryCrawler(orekitData));
//File paths
File sp3FilePreviousDay = new File(getFilePath(SP3_BASEPATH, dt.minusDays(1)));
File sp3File = new File(getFilePath(SP3_BASEPATH, dt));
File sp3FileNextDay = new File(getFilePath(SP3_BASEPATH, dt.plusDays(1)));
// Load the SP3 file
SP3Parser parser = new SP3Parser();
SP3 sp3= parser.parse(new DataSource(sp3File)); //How to load additional files?
//Get Ephemeris
AbsoluteDate absDate = new AbsoluteDate(dt.getYear(), dt.getMonthValue(), dt.getDayOfMonth(),
dt.getHour(), dt.getMinute(), dt.getSecond(), TimeScalesFactory.getUTC());
SP3Ephemeris sp3Ephemeris = sp3.getSatellites().get("G"+prn);
Propagator propagator = sp3Ephemeris.getPropagator();
TimeStampedPVCoordinates tspvc = propagator.getPVCoordinates(absDate,FramesFactory.getITRF(IERSConventions.IERS_2010, false));
//Get Position
System.out.println(tspvc.getPosition());
}
private static int calculateGPSWeek(LocalDate date) {
LocalDate gpsWeekStartDate = LocalDate.parse("1980-01-06");
long days = date.toEpochDay() - gpsWeekStartDate.toEpochDay();
long gpsWeek = days / 7;
return (int) gpsWeek;
}
private static String getFilePath(String basePath, LocalDateTime dateTime) {
int year = dateTime.getYear();
int dayOfYear = dateTime.getDayOfYear();
int gpsWeek = calculateGPSWeek(dateTime.toLocalDate());
int dayOfWeek = dateTime.getDayOfWeek().getValue();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
String yearPath = String.format("%04d", year);
String dayOfYearPath = String.format("%03d", dayOfYear);
String gpsWeekPath = String.format("%04d", gpsWeek);
String dayOfWeekPath = String.format("%d", dayOfWeek);
return basePath + "/" + year + "/" + dayOfYearPath + "/igs" + gpsWeekPath + dayOfWeekPath+".sp3";
}