use of org.orekit.time.TimeScale in project SpriteOrbits by ProjectPersephone.
the class SpriteProp method main.
/**
* @param args
*/
public static void main(String[] args) {
PrintStream out = null;
try {
// set up orekit data
// for this to work, the orekit-data.zip file avaiable at the following URL
// must be put in the current working directory
// URL: https://www.orekit.org/forge/projects/orekit/files
File userDir = new File(System.getProperty("user.dir"));
File orekitZip = new File(userDir, "orekit-data.zip");
DataProvidersManager.getInstance().addProvider(new ZipJarCrawler(orekitZip));
// reference models
// this is the frame labeled J2K in the NASA page
final Frame eme2000 = FramesFactory.getEME2000();
final Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
final TimeScale utc = TimeScalesFactory.getUTC();
// central attraction coefficient MU
final double mu = Constants.EIGEN5C_EARTH_MU;
// set up some data, ideally, this should be provided as input to the program
// ISS orbit is from http://spaceflight.nasa.gov/realdata/sightings/SSapplications/Post/JavaSSOP/orbit/ISS/SVPOST.html
//
// Coasting Arc #15 (Orbit 3386)
// ---------------------------------------
//
// Vector Time (GMT): 2014/055/16:27:06.921
// Vector Time (MET): N/A
// Weight (LBS) : 911651.1
//
// ...
//
// J2K Cartesian
// --------------------------------
// X = 2998767.75
// Y = -6097451.56 meter
// ... Z = -141448.92
// XDOT = 4323.077242
// YDOT = 1994.291706 meter/sec
// ZDOT = 6000.774574
// we start small, we can increase this later
final int numberOfSprites = 12;
// (m/s)
final double relativeReleaseVelocity = 1.0;
final AbsoluteDate releaseDate = new // year, month, day
AbsoluteDate(// year, month, day
2014, // year, month, day
3, // year, month, day
1, // hours, minutes, seconds
12, // hours, minutes, seconds
0, // hours, minutes, seconds
0.0, utc);
final CartesianOrbit kickSatOrbit = new CartesianOrbit(new // position (m)
PVCoordinates(// position (m)
new Vector3D(2998767.75, -6097451.56, -141448.92), // velocity (m/s)
new Vector3D(4323.077242, 1994.291706, 6000.774574)), eme2000, new // year, day in year as NASA page above
AbsoluteDate(// year, day in year as NASA page above
new DateComponents(2014, 55), // hour in day
new TimeComponents(16, 27, 6.921), utc), mu);
// kg
final double kickSatMass = 10.0;
// m^2
final double kickSatCrossSection = 0.03;
// no units
final double kickSatDragCoeff = 2.2;
// kg
final double spriteMass = 0.01;
// m^2
final double spriteCrossSection = 2.5e-3;
// no units
final double spriteDragCoeff = 2.2;
SpriteProp spriteProp = new SpriteProp(numberOfSprites, kickSatOrbit, kickSatMass, kickSatCrossSection, kickSatDragCoeff, spriteMass, spriteCrossSection, spriteDragCoeff, relativeReleaseVelocity, releaseDate, itrf);
// days after release
final double propagationDuration = 0.2;
// seconds
final double step = 60.0;
// out = new PrintStream(new File(userDir, "sprites-prop.txt"));
out = new PrintStream(new File(userDir, "orbits.json"));
out.format(Locale.US, "[");
spriteProp.run(out, propagationDuration, step, utc);
out.format(Locale.US, "]");
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (OrekitException e) {
e.printStackTrace();
} finally {
if (out != null) {
out.close();
}
}
}
use of org.orekit.time.TimeScale in project SpriteOrbits by ProjectPersephone.
the class SpritePropOrig method main.
/**
* @param args
*/
public static void main(String[] args) {
PrintStream out = null;
try {
// set up orekit data
// for this to work, the orekit-data.zip file avaiable at the following URL
// must be put in the current working directory
// URL: https://www.orekit.org/forge/projects/orekit/files
File userDir = new File(System.getProperty("user.dir"));
File orekitZip = new File(userDir, "orekit-data.zip");
DataProvidersManager.getInstance().addProvider(new ZipJarCrawler(orekitZip));
// reference models
// this is the frame labeled J2K in the NASA page
final Frame eme2000 = FramesFactory.getEME2000();
final Frame itrf = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
final TimeScale utc = TimeScalesFactory.getUTC();
// central attraction coefficient MU
final double mu = Constants.EIGEN5C_EARTH_MU;
// set up some data, ideally, this should be provided as input to the program
// ISS orbit is from http://spaceflight.nasa.gov/realdata/sightings/SSapplications/Post/JavaSSOP/orbit/ISS/SVPOST.html
//
// Coasting Arc #15 (Orbit 3386)
// ---------------------------------------
//
// Vector Time (GMT): 2014/055/16:27:06.921
// Vector Time (MET): N/A
// Weight (LBS) : 911651.1
//
// ...
//
// J2K Cartesian
// --------------------------------
// X = 2998767.75
// Y = -6097451.56 meter
// ... Z = -141448.92
// XDOT = 4323.077242
// YDOT = 1994.291706 meter/sec
// ZDOT = 6000.774574
// we start small, we can increase this later
final int numberOfSprites = 12;
// (m/s)
final double relativeReleaseVelocity = 1.0;
final AbsoluteDate releaseDate = new // year, month, day
AbsoluteDate(// year, month, day
2014, // year, month, day
3, // year, month, day
1, // hours, minutes, seconds
12, // hours, minutes, seconds
0, // hours, minutes, seconds
0.0, utc);
final CartesianOrbit kickSatOrbit = new CartesianOrbit(new // position (m)
PVCoordinates(// position (m)
new Vector3D(2998767.75, -6097451.56, -141448.92), // velocity (m/s)
new Vector3D(4323.077242, 1994.291706, 6000.774574)), eme2000, new // year, day in year as NASA page above
AbsoluteDate(// year, day in year as NASA page above
new DateComponents(2014, 55), // hour in day
new TimeComponents(16, 27, 6.921), utc), mu);
// kg
final double kickSatMass = 10.0;
// m^2
final double kickSatCrossSection = 0.03;
// no units
final double kickSatDragCoeff = 2.2;
// kg
final double spriteMass = 0.01;
// m^2
final double spriteCrossSection = 2.5e-3;
// no units
final double spriteDragCoeff = 2.2;
SpritePropOrig spriteProp = new SpritePropOrig(numberOfSprites, kickSatOrbit, kickSatMass, kickSatCrossSection, kickSatDragCoeff, spriteMass, spriteCrossSection, spriteDragCoeff, relativeReleaseVelocity, releaseDate, itrf);
// days after release
final double propagationDuration = 0.2;
// seconds
final double step = 60.0;
out = new PrintStream(new File(userDir, "sprites-prop.txt"));
spriteProp.run(out, propagationDuration, step, utc);
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (OrekitException e) {
e.printStackTrace();
} finally {
if (out != null) {
out.close();
}
}
}
use of org.orekit.time.TimeScale 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.TimeScale in project Orekit by CS-SI.
the class MarshallSolarActivityFutureEstimation method loadData.
/**
* {@inheritDoc}
*/
public void loadData(final InputStream input, final String name) throws IOException, ParseException, OrekitException {
// select the groups we want to store
final int f107Group;
final int apGroup;
switch(strengthLevel) {
case STRONG:
f107Group = 3;
apGroup = 6;
break;
case AVERAGE:
f107Group = 4;
apGroup = 7;
break;
default:
f107Group = 5;
apGroup = 8;
break;
}
// read the data
final BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
boolean inData = false;
final TimeScale utc = TimeScalesFactory.getUTC();
DateComponents fileDate = null;
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
line = line.trim();
if (line.length() > 0) {
final Matcher matcher = dataPattern.matcher(line);
if (matcher.matches()) {
// we are in the data section
inData = true;
// extract the data from the line
final int year = Integer.parseInt(matcher.group(1));
final Month month = Month.parseMonth(matcher.group(2));
final AbsoluteDate date = new AbsoluteDate(year, month, 1, utc);
if (fileDate == null) {
// so we compute the file date by adding 6 months to its first entry
if (month.getNumber() > 6) {
fileDate = new DateComponents(year + 1, month.getNumber() - 6, 1);
} else {
fileDate = new DateComponents(year, month.getNumber() + 6, 1);
}
}
// check if there is already an entry for this date or not
boolean addEntry = false;
final Iterator<TimeStamped> iterator = data.tailSet(date).iterator();
if (iterator.hasNext()) {
final LineParameters existingEntry = (LineParameters) iterator.next();
if (existingEntry.getDate().equals(date)) {
// there is an entry for this date
if (existingEntry.getFileDate().compareTo(fileDate) < 0) {
// the entry was read from an earlier file
// we replace it with the new entry as it is fresher
iterator.remove();
addEntry = true;
}
} else {
// it is the first entry we get for this date
addEntry = true;
}
} else {
// it is the first entry we get for this date
addEntry = true;
}
if (addEntry) {
// we must add the new entry
data.add(new LineParameters(fileDate, date, Double.parseDouble(matcher.group(f107Group)), Double.parseDouble(matcher.group(apGroup))));
}
} else {
if (inData) {
// we consider the file is corrupted
throw new OrekitException(OrekitMessages.NOT_A_MARSHALL_SOLAR_ACTIVITY_FUTURE_ESTIMATION_FILE, name);
}
}
}
}
if (data.isEmpty()) {
throw new OrekitException(OrekitMessages.NOT_A_MARSHALL_SOLAR_ACTIVITY_FUTURE_ESTIMATION_FILE, name);
}
firstDate = data.first().getDate();
lastDate = data.last().getDate();
}
use of org.orekit.time.TimeScale in project Orekit by CS-SI.
the class TDMParserTest method validateTDMExample4.
/**
* Validation function for example 4.
* @param file Parsed TDMFile to validate
* @throws OrekitException if UTC time scale cannot be retrieved
*/
public static void validateTDMExample4(TDMFile file) throws OrekitException {
final TimeScale utc = TimeScalesFactory.getUTC();
// Header
Assert.assertEquals(1.0, file.getFormatVersion(), 0.0);
Assert.assertEquals(new AbsoluteDate("2005-191T23:00:00", utc).durationFrom(file.getCreationDate()), 0.0, 0.0);
Assert.assertEquals("NASA/JPL", file.getOriginator());
final List<String> headerComment = new ArrayList<String>();
headerComment.add("TDM example created by yyyyy-nnnA Nav Team (NASA/JPL)");
Assert.assertEquals(headerComment, file.getHeaderComment());
// Meta-Data
final TDMFile.TDMMetaData metaData = file.getObservationsBlocks().get(0).getMetaData();
Assert.assertEquals(CcsdsTimeScale.UTC, metaData.getTimeSystem());
Assert.assertEquals("DSS-24", metaData.getParticipants().get(1));
Assert.assertEquals("YYYY-NNNA", metaData.getParticipants().get(2));
Assert.assertEquals("SEQUENTIAL", metaData.getMode());
Assert.assertEquals("1,2,1", metaData.getPath());
Assert.assertEquals("START", metaData.getIntegrationRef());
Assert.assertEquals("COHERENT", metaData.getRangeMode());
Assert.assertEquals(2.0e+26, metaData.getRangeModulus(), 0.0);
Assert.assertEquals("RU", metaData.getRangeUnits());
Assert.assertEquals(7.7e-5, metaData.getTransmitDelays().get(1), 0.0);
Assert.assertEquals(0.0, metaData.getTransmitDelays().get(2), 0.0);
Assert.assertEquals(7.7e-5, metaData.getReceiveDelays().get(1), 0.0);
Assert.assertEquals(0.0, metaData.getReceiveDelays().get(2), 0.0);
Assert.assertEquals(46.7741, metaData.getCorrectionRange(), 0.0);
Assert.assertEquals("YES", metaData.getCorrectionsApplied());
final List<String> metaDataComment = new ArrayList<String>();
metaDataComment.add("Range correction applied is range calibration to DSS-24.");
metaDataComment.add("Estimated RTLT at begin of pass = 950 seconds");
metaDataComment.add("Antenna Z-height correction 0.0545 km applied to uplink signal");
metaDataComment.add("Antenna Z-height correction 0.0189 km applied to downlink signal");
Assert.assertEquals(metaDataComment, metaData.getComment());
// Data
final List<TDMFile.Observation> observations = file.getObservationsBlocks().get(0).getObservations();
// Reference data
final String[] keywords = { "TRANSMIT_FREQ_1", "TRANSMIT_FREQ_RATE_1", "RANGE", "PR_N0", "TRANSMIT_FREQ_1", "TRANSMIT_FREQ_RATE_1", "RANGE", "PR_N0", "TRANSMIT_FREQ_1", "TRANSMIT_FREQ_RATE_1", "RANGE", "PR_N0", "TRANSMIT_FREQ_1", "TRANSMIT_FREQ_RATE_1", "RANGE", "PR_N0" };
final String[] epochs = { "2005-191T00:31:51", "2005-191T00:31:51", "2005-191T00:31:51", "2005-191T00:31:51", "2005-191T00:34:48", "2005-191T00:34:48", "2005-191T00:34:48", "2005-191T00:34:48", "2005-191T00:37:45", "2005-191T00:37:45", "2005-191T00:37:45", "2005-191T00:37:45", "2005-191T00:40:42", "2005-191T00:40:42", "2005-191T00:40:42", "2005-191T00:40:42", "2005-191T00:58:24", "2005-191T00:58:24", "2005-191T00:58:24", "2005-191T00:58:24" };
final double[] values = { 7180064367.3536, 0.59299, 39242998.5151986, 28.52538, 7180064472.3146, 0.59305, 61172265.3115234, 28.39347, 7180064577.2756, 0.59299, 15998108.8168328, 28.16193, 7180064682.2366, 0.59299, 37938284.4138008, 29.44597, 7180065327.56141, 0.62085, 35478729.4012973, 30.48199 };
// Check consistency
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], observations.get(i).getKeyword());
Assert.assertEquals(new AbsoluteDate(epochs[i], utc).durationFrom(observations.get(i).getEpoch()), 0.0, 0.0);
Assert.assertEquals(values[i], observations.get(i).getMeasurement(), 0.0);
}
// Comment
final List<String> dataComment = new ArrayList<String>();
dataComment.add("This is a data comment");
Assert.assertEquals(dataComment, file.getObservationsBlocks().get(0).getObservationsComment());
}
Aggregations