use of org.orekit.time.DateTimeComponents in project Orekit by CS-SI.
the class NRLMSISE00 method getDensity.
/**
* {@inheritDoc}
*/
@Override
public double getDensity(final AbsoluteDate date, final Vector3D position, final Frame frame) throws OrekitException {
// check if data are available :
if ((date.compareTo(inputParams.getMaxDate()) > 0) || (date.compareTo(inputParams.getMinDate()) < 0)) {
throw new OrekitException(OrekitMessages.NO_SOLAR_ACTIVITY_AT_DATE, date, inputParams.getMinDate(), inputParams.getMaxDate());
}
// compute day number in current year and the seconds within the day
final DateTimeComponents dtc = date.getComponents(TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true));
final int doy = dtc.getDate().getDayOfYear();
final double sec = dtc.getTime().getSecondsInLocalDay();
// compute geodetic position (km and °)
final GeodeticPoint inBody = earth.transform(position, frame, date);
final double alt = inBody.getAltitude() / 1000.;
final double lon = FastMath.toDegrees(inBody.getLongitude());
final double lat = FastMath.toDegrees(inBody.getLatitude());
// compute local solar time
final double lst = localSolarTime(date, position, frame);
// get solar activity data and compute
final Output out = new Output(doy, sec, lat, lon, lst, inputParams.getAverageFlux(date), inputParams.getDailyFlux(date), inputParams.getAp(date));
out.gtd7d(alt);
// return the local density
return out.getDensity(TOTAL_MASS);
}
use of org.orekit.time.DateTimeComponents in project Orekit by CS-SI.
the class DEFile method write.
private void write() throws IOException {
if (!selected.isEmpty()) {
if (outName != null) {
try (OutputStream out = new FileOutputStream(outName)) {
// patch header epoch
System.arraycopy(selected.get(0), DATA_START_RANGE_OFFSET, first, HEADER_START_EPOCH_OFFSET, 8);
System.arraycopy(selected.get(selected.size() - 1), DATE_END_RANGE_OFFSET, first, HEADER_END_EPOCH_OFFSET, 8);
// patch header labels
final AbsoluteDate start = extractDate(first, HEADER_START_EPOCH_OFFSET, bigEndian);
final DateTimeComponents sc = start.getComponents(timeScale);
final AbsoluteDate end = extractDate(first, HEADER_END_EPOCH_OFFSET, bigEndian);
final DateTimeComponents ec = end.getComponents(timeScale);
System.arraycopy(padString("THIS IS NOT A GENUINE JPL DE FILE," + " THIS IS AN EXCERPT WITH A LIMITED TIME RANGE", HEADER_LABEL_SIZE), 0, first, HEADER_LABEL_1_OFFSET, HEADER_LABEL_SIZE);
System.arraycopy(padString(String.format(Locale.US, "Start Epoch: JED= %.1f %4d-%s-%02d %02d:%02d:%02.0f", (start.durationFrom(AbsoluteDate.JULIAN_EPOCH)) / Constants.JULIAN_DAY, sc.getDate().getYear(), sc.getDate().getMonthEnum().getUpperCaseAbbreviation(), sc.getDate().getDay(), sc.getTime().getHour(), sc.getTime().getMinute(), sc.getTime().getSecond()), HEADER_LABEL_SIZE), 0, first, HEADER_LABEL_2_OFFSET, HEADER_LABEL_SIZE);
System.arraycopy(padString(String.format(Locale.US, "Final Epoch: JED= %.1f %4d-%s-%02d %02d:%02d:%02.0f", (end.durationFrom(AbsoluteDate.JULIAN_EPOCH)) / Constants.JULIAN_DAY, ec.getDate().getYear(), ec.getDate().getMonthEnum().getUpperCaseAbbreviation(), ec.getDate().getDay(), ec.getTime().getHour(), ec.getTime().getMinute(), ec.getTime().getSecond()), HEADER_LABEL_SIZE), 0, first, HEADER_LABEL_3_OFFSET, HEADER_LABEL_SIZE);
// write patched header
out.write(first);
out.write(second);
// write selected data
for (byte[] data : selected) {
out.write(data);
}
}
}
}
}
use of org.orekit.time.DateTimeComponents in project Orekit by CS-SI.
the class KlobucharModelTest method compareExpectedValue.
@Test
public void compareExpectedValue() throws IllegalArgumentException, OrekitException {
final double latitude = FastMath.toRadians(40);
final double longitude = FastMath.toRadians(-100);
final double altitude = 0.;
final double elevation = 20.;
final double azimuth = 210.;
final AbsoluteDate date = new AbsoluteDate(new DateTimeComponents(2000, 1, 1, 20, 45, 0), utc);
final GeodeticPoint geo = new GeodeticPoint(latitude, longitude, altitude);
final double delayMeters = model.pathDelay(date, geo, FastMath.toRadians(elevation), FastMath.toRadians(azimuth));
Assert.assertEquals(23.784, delayMeters, 0.001);
}
use of org.orekit.time.DateTimeComponents in project Orekit by CS-SI.
the class NRLMSISE00 method getDensity.
/**
* {@inheritDoc}
*/
@Override
public <T extends RealFieldElement<T>> T getDensity(final FieldAbsoluteDate<T> date, final FieldVector3D<T> position, final Frame frame) throws OrekitException {
// check if data are available :
final AbsoluteDate dateD = date.toAbsoluteDate();
if ((dateD.compareTo(inputParams.getMaxDate()) > 0) || (dateD.compareTo(inputParams.getMinDate()) < 0)) {
throw new OrekitException(OrekitMessages.NO_SOLAR_ACTIVITY_AT_DATE, dateD, inputParams.getMinDate(), inputParams.getMaxDate());
}
// compute day number in current year and the seconds within the day
final TimeScale ut1 = TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true);
final DateTimeComponents dtc = dateD.getComponents(ut1);
final int doy = dtc.getDate().getDayOfYear();
final T sec = date.durationFrom(new AbsoluteDate(dtc.getDate(), TimeComponents.H00, ut1));
// compute geodetic position (km and °)
final FieldGeodeticPoint<T> inBody = earth.transform(position, frame, date);
final T alt = inBody.getAltitude().divide(1000.);
final T lon = inBody.getLongitude().multiply(180.0 / FastMath.PI);
final T lat = inBody.getLatitude().multiply(180.0 / FastMath.PI);
// compute local solar time
final T lst = localSolarTime(dateD, position, frame);
// get solar activity data and compute
final FieldOutput<T> out = new FieldOutput<>(doy, sec, lat, lon, lst, inputParams.getAverageFlux(dateD), inputParams.getDailyFlux(dateD), inputParams.getAp(dateD));
out.gtd7d(alt);
// return the local density
return out.getDensity(TOTAL_MASS);
}
use of org.orekit.time.DateTimeComponents in project Orekit by CS-SI.
the class StreamingOemWriter method dateToString.
/**
* Convert a date to a string with more precision.
*
* @param components to convert to a String.
* @return the String form of {@code date} with at least 9 digits of precision.
*/
static String dateToString(final DateTimeComponents components) {
final TimeComponents time = components.getTime();
final int hour = time.getHour();
final int minute = time.getMinute();
final double second = time.getSecond();
// Decimal formatting classes could be static final if they were thread safe.
final DecimalFormatSymbols locale = new DecimalFormatSymbols(STANDARDIZED_LOCALE);
final DecimalFormat twoDigits = new DecimalFormat("00", locale);
final DecimalFormat precise = new DecimalFormat("00.0########", locale);
return components.getDate().toString() + "T" + twoDigits.format(hour) + ":" + twoDigits.format(minute) + ":" + precise.format(second);
}
Aggregations