use of org.orekit.data.DirectoryCrawler in project Orekit by CS-SI.
the class Phasing method main.
/**
* Program entry point.
* @param args program arguments
*/
public static void main(String[] args) {
try {
if (args.length != 1) {
System.err.println("usage: java fr.cs.examples.bodies.Phasing filename");
System.exit(1);
}
// configure Orekit
File home = new File(System.getProperty("user.home"));
File orekitData = new File(home, "orekit-data");
if (!orekitData.exists()) {
System.err.format(Locale.US, "Failed to find %s folder%n", orekitData.getAbsolutePath());
System.err.format(Locale.US, "You need to download %s from the %s page and unzip it in %s for this tutorial to work%n", "orekit-data.zip", "https://www.orekit.org/forge/projects/orekit/files", home.getAbsolutePath());
System.exit(1);
}
DataProvidersManager manager = DataProvidersManager.getInstance();
manager.addProvider(new DirectoryCrawler(orekitData));
// input/out
URL url = Phasing.class.getResource("/" + args[0]);
if (url == null) {
System.err.println(args[0] + " not found");
System.exit(1);
}
File input = new File(url.toURI().getPath());
new Phasing().run(input);
} catch (URISyntaxException use) {
System.err.println(use.getLocalizedMessage());
System.exit(1);
} catch (IOException ioe) {
System.err.println(ioe.getLocalizedMessage());
System.exit(1);
} catch (IllegalArgumentException iae) {
iae.printStackTrace(System.err);
System.err.println(iae.getLocalizedMessage());
System.exit(1);
} catch (ParseException pe) {
System.err.println(pe.getLocalizedMessage());
System.exit(1);
} catch (OrekitException oe) {
oe.printStackTrace(System.err);
System.err.println(oe.getLocalizedMessage());
System.exit(1);
}
}
use of org.orekit.data.DirectoryCrawler in project Orekit by CS-SI.
the class OrbitDetermination method main.
/**
* Program entry point.
* @param args program arguments (unused here)
*/
public static void main(String[] args) {
try {
// configure Orekit
File home = new File(System.getProperty("user.home"));
File orekitData = new File(home, "orekit-data");
if (!orekitData.exists()) {
System.err.format(Locale.US, "Failed to find %s folder%n", orekitData.getAbsolutePath());
System.err.format(Locale.US, "You need to download %s from the %s page and unzip it in %s for this tutorial to work%n", "orekit-data.zip", "https://www.orekit.org/forge/projects/orekit/files", home.getAbsolutePath());
System.exit(1);
}
DataProvidersManager manager = DataProvidersManager.getInstance();
manager.addProvider(new DirectoryCrawler(orekitData));
// input in tutorial resources directory/output (in user's home directory)
final String inputPath = OrbitDetermination.class.getClassLoader().getResource("orbit-determination.in").toURI().getPath();
final File input = new File(inputPath);
long t0 = System.currentTimeMillis();
new OrbitDetermination().run(input, home);
long t1 = System.currentTimeMillis();
System.out.println("wall clock run time (s): " + (0.001 * (t1 - t0)));
} catch (URISyntaxException urise) {
System.err.println(urise.getLocalizedMessage());
System.exit(1);
} catch (IOException ioe) {
System.err.println(ioe.getLocalizedMessage());
System.exit(1);
} catch (IllegalArgumentException iae) {
iae.printStackTrace(System.err);
System.err.println(iae.getLocalizedMessage());
System.exit(1);
} catch (OrekitException oe) {
System.err.println(oe.getLocalizedMessage());
System.exit(1);
} catch (ParseException pe) {
System.err.println(pe.getLocalizedMessage());
System.exit(1);
}
}
use of org.orekit.data.DirectoryCrawler in project Orekit by CS-SI.
the class DEFile method main.
/**
* Program entry point.
* @param args program arguments (unused here)
*/
public static void main(String[] args) {
try {
// configure Orekit
File home = new File(System.getProperty("user.home"));
File orekitData = new File(home, "orekit-data");
if (!orekitData.exists()) {
System.err.format(Locale.US, "Failed to find %s folder%n", orekitData.getAbsolutePath());
System.err.format(Locale.US, "You need to download %s from the %s page and unzip it in %s for this tutorial to work%n", "orekit-data.zip", "https://www.orekit.org/forge/projects/orekit/files", home.getAbsolutePath());
System.exit(1);
}
DataProvidersManager manager = DataProvidersManager.getInstance();
manager.addProvider(new DirectoryCrawler(orekitData));
String inName = null;
String outName = null;
List<String> constants = new ArrayList<String>();
boolean allConstants = false;
AbsoluteDate start = AbsoluteDate.PAST_INFINITY;
AbsoluteDate end = AbsoluteDate.FUTURE_INFINITY;
for (int i = 0; i < args.length; ++i) {
if ("-in".equals(args[i])) {
inName = args[++i];
} else if ("-help".equals(args[i])) {
displayUsage(System.out);
} else if ("-constant".equals(args[i])) {
constants.add(args[++i]);
} else if ("-all-constants".equals(args[i])) {
allConstants = true;
} else if ("-start".equals(args[i])) {
start = new AbsoluteDate(args[++i], TimeScalesFactory.getUTC());
} else if ("-end".equals(args[i])) {
end = new AbsoluteDate(args[++i], TimeScalesFactory.getUTC());
} else if ("-out".equals(args[i])) {
outName = args[++i];
} else {
System.err.println("unknown command line option \"" + args[i] + "\"");
displayUsage(System.err);
System.exit(1);
}
}
if (inName == null) {
displayUsage(System.err);
System.exit(1);
}
DEFile de = new DEFile(inName, outName);
de.processHeader();
System.out.println("header label 1 " + de.label1);
System.out.println("header label 2 " + de.label2);
System.out.println("header label 3 " + de.label3);
System.out.println("header start epoch " + de.headerStartEpoch.toString(de.timeScale) + " (" + de.timeScale.getName() + ")");
System.out.println("header end epoch " + de.headerFinalEpoch.toString(de.timeScale) + " (" + de.timeScale.getName() + ")");
for (String constant : constants) {
Double value = de.headerConstants.get(constant);
System.out.println(constant + " " + ((value == null) ? "not present" : value));
}
if (allConstants) {
for (Map.Entry<String, Double> entry : de.headerConstants.entrySet()) {
System.out.println(entry.getKey() + " " + entry.getValue());
}
}
int processed = de.processData(start, end);
System.out.println("data records: " + processed);
if (outName != null) {
de.write();
System.out.println(outName + " file created with " + de.selected.size() + " selected data records");
}
} catch (IOException ioe) {
ioe.printStackTrace(System.err);
} catch (OrekitException oe) {
oe.printStackTrace(System.err);
}
}
use of org.orekit.data.DirectoryCrawler in project Orekit by CS-SI.
the class PropagatorConversion method main.
/**
* Program entry point.
* @param args program arguments (unused here)
*/
public static void main(String[] args) {
try {
// configure Orekit
File home = new File(System.getProperty("user.home"));
File orekitData = new File(home, "orekit-data");
if (!orekitData.exists()) {
System.err.format(Locale.US, "Failed to find %s folder%n", orekitData.getAbsolutePath());
System.err.format(Locale.US, "You need to download %s from the %s page and unzip it in %s for this tutorial to work%n", "orekit-data.zip", "https://www.orekit.org/forge/projects/orekit/files", home.getAbsolutePath());
System.exit(1);
}
DataProvidersManager manager = DataProvidersManager.getInstance();
manager.addProvider(new DirectoryCrawler(orekitData));
// gravity field
NormalizedSphericalHarmonicsProvider provider = GravityFieldFactory.getNormalizedProvider(2, 0);
double mu = provider.getMu();
// inertial frame
Frame inertialFrame = FramesFactory.getEME2000();
// Initial date
AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, TimeScalesFactory.getUTC());
// Initial orbit (GTO)
// semi major axis in meters
final double a = 24396159;
// eccentricity
final double e = 0.72831215;
// inclination
final double i = FastMath.toRadians(7);
// perigee argument
final double omega = FastMath.toRadians(180);
// right ascention of ascending node
final double raan = FastMath.toRadians(261);
// mean anomaly
final double lM = 0;
Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame, initialDate, mu);
final double period = initialOrbit.getKeplerianPeriod();
// Initial state definition
final SpacecraftState initialState = new SpacecraftState(initialOrbit);
// Adaptive step integrator with a minimum step of 0.001 and a maximum step of 1000
final double minStep = 0.001;
final double maxStep = 1000.;
final double dP = 1.e-2;
final OrbitType orbType = OrbitType.CARTESIAN;
final double[][] tol = NumericalPropagator.tolerances(dP, initialOrbit, orbType);
final AbstractIntegrator integrator = new DormandPrince853Integrator(minStep, maxStep, tol[0], tol[1]);
// Propagator
NumericalPropagator numProp = new NumericalPropagator(integrator);
numProp.setInitialState(initialState);
numProp.setOrbitType(orbType);
// Force Models:
// 1 - Perturbing gravity field (only J2 is considered here)
ForceModel gravity = new HolmesFeatherstoneAttractionModel(FramesFactory.getITRF(IERSConventions.IERS_2010, true), provider);
// Add force models to the propagator
numProp.addForceModel(gravity);
// Propagator factory
PropagatorBuilder builder = new KeplerianPropagatorBuilder(initialOrbit, PositionAngle.TRUE, dP);
// Propagator converter
PropagatorConverter fitter = new FiniteDifferencePropagatorConverter(builder, 1.e-6, 5000);
// Resulting propagator
KeplerianPropagator kepProp = (KeplerianPropagator) fitter.convert(numProp, 2 * period, 251);
// Step handlers
StatesHandler numStepHandler = new StatesHandler();
StatesHandler kepStepHandler = new StatesHandler();
// Set up operating mode for the propagator as master mode
// with fixed step and specialized step handler
numProp.setMasterMode(60., numStepHandler);
kepProp.setMasterMode(60., kepStepHandler);
// Extrapolate from the initial to the final date
numProp.propagate(initialDate.shiftedBy(10. * period));
kepProp.propagate(initialDate.shiftedBy(10. * period));
// retrieve the states
List<SpacecraftState> numStates = numStepHandler.getStates();
List<SpacecraftState> kepStates = kepStepHandler.getStates();
// Print the results on the output file
File output = new File(new File(System.getProperty("user.home")), "elements.dat");
try (final PrintStream stream = new PrintStream(output, "UTF-8")) {
stream.println("# date Anum Akep Enum Ekep Inum Ikep LMnum LMkep");
for (SpacecraftState numState : numStates) {
for (SpacecraftState kepState : kepStates) {
if (numState.getDate().compareTo(kepState.getDate()) == 0) {
stream.println(numState.getDate() + " " + numState.getA() + " " + kepState.getA() + " " + numState.getE() + " " + kepState.getE() + " " + FastMath.toDegrees(numState.getI()) + " " + FastMath.toDegrees(kepState.getI()) + " " + FastMath.toDegrees(MathUtils.normalizeAngle(numState.getLM(), FastMath.PI)) + " " + FastMath.toDegrees(MathUtils.normalizeAngle(kepState.getLM(), FastMath.PI)));
break;
}
}
}
}
System.out.println("Results saved as file " + output);
File output1 = new File(new File(System.getProperty("user.home")), "elts_pv.dat");
try (final PrintStream stream = new PrintStream(output1, "UTF-8")) {
stream.println("# date pxn pyn pzn vxn vyn vzn pxk pyk pzk vxk vyk vzk");
for (SpacecraftState numState : numStates) {
for (SpacecraftState kepState : kepStates) {
if (numState.getDate().compareTo(kepState.getDate()) == 0) {
final double pxn = numState.getPVCoordinates().getPosition().getX();
final double pyn = numState.getPVCoordinates().getPosition().getY();
final double pzn = numState.getPVCoordinates().getPosition().getZ();
final double vxn = numState.getPVCoordinates().getVelocity().getX();
final double vyn = numState.getPVCoordinates().getVelocity().getY();
final double vzn = numState.getPVCoordinates().getVelocity().getZ();
final double pxk = kepState.getPVCoordinates().getPosition().getX();
final double pyk = kepState.getPVCoordinates().getPosition().getY();
final double pzk = kepState.getPVCoordinates().getPosition().getZ();
final double vxk = kepState.getPVCoordinates().getVelocity().getX();
final double vyk = kepState.getPVCoordinates().getVelocity().getY();
final double vzk = kepState.getPVCoordinates().getVelocity().getZ();
stream.println(numState.getDate() + " " + pxn + " " + pyn + " " + pzn + " " + vxn + " " + vyn + " " + vzn + " " + pxk + " " + pyk + " " + pzk + " " + vxk + " " + vyk + " " + vzk);
break;
}
}
}
}
System.out.println("Results saved as file " + output1);
} catch (OrekitException oe) {
System.err.println(oe.getLocalizedMessage());
System.exit(1);
} catch (IOException ioe) {
System.err.println(ioe.getLocalizedMessage());
System.exit(1);
}
}
use of org.orekit.data.DirectoryCrawler in project Orekit by CS-SI.
the class Frames1 method main.
public static void main(String[] args) {
try {
// configure Orekit
File home = new File(System.getProperty("user.home"));
File orekitData = new File(home, "orekit-data");
if (!orekitData.exists()) {
System.err.format(Locale.US, "Failed to find %s folder%n", orekitData.getAbsolutePath());
System.err.format(Locale.US, "You need to download %s from the %s page and unzip it in %s for this tutorial to work%n", "orekit-data.zip", "https://www.orekit.org/forge/projects/orekit/files", home.getAbsolutePath());
System.exit(1);
}
DataProvidersManager manager = DataProvidersManager.getInstance();
manager.addProvider(new DirectoryCrawler(orekitData));
// Initial state definition : date, orbit
TimeScale utc = TimeScalesFactory.getUTC();
AbsoluteDate initialDate = new AbsoluteDate(2008, 10, 01, 0, 0, 00.000, utc);
// gravitation coefficient
double mu = 3.986004415e+14;
// inertial frame for orbit definition
Frame inertialFrame = FramesFactory.getEME2000();
Vector3D posisat = new Vector3D(-6142438.668, 3492467.560, -25767.25680);
Vector3D velosat = new Vector3D(505.8479685, 942.7809215, 7435.922231);
PVCoordinates pvsat = new PVCoordinates(posisat, velosat);
Orbit initialOrbit = new CartesianOrbit(pvsat, inertialFrame, initialDate, mu);
// Propagator : consider a simple Keplerian motion
Propagator kepler = new KeplerianPropagator(initialOrbit);
// Earth and frame
Frame earthFrame = FramesFactory.getITRF(IERSConventions.IERS_2010, true);
BodyShape earth = new OneAxisEllipsoid(Constants.WGS84_EARTH_EQUATORIAL_RADIUS, Constants.WGS84_EARTH_FLATTENING, earthFrame);
// Station
final double longitude = FastMath.toRadians(45.);
final double latitude = FastMath.toRadians(25.);
final double altitude = 0.;
final GeodeticPoint station = new GeodeticPoint(latitude, longitude, altitude);
final TopocentricFrame staF = new TopocentricFrame(earth, station, "station");
System.out.println(" time doppler (m/s)");
// Stop date
final AbsoluteDate finalDate = new AbsoluteDate(initialDate, 6000, utc);
// Loop
AbsoluteDate extrapDate = initialDate;
while (extrapDate.compareTo(finalDate) <= 0) {
// We can simply get the position and velocity of spacecraft in station frame at any time
PVCoordinates pvInert = kepler.propagate(extrapDate).getPVCoordinates();
PVCoordinates pvStation = inertialFrame.getTransformTo(staF, extrapDate).transformPVCoordinates(pvInert);
// And then calculate the doppler signal
double doppler = Vector3D.dotProduct(pvStation.getPosition(), pvStation.getVelocity()) / pvStation.getPosition().getNorm();
System.out.format(Locale.US, "%s %9.3f%n", extrapDate, doppler);
extrapDate = extrapDate.shiftedBy(600);
}
} catch (OrekitException oe) {
System.err.println(oe.getMessage());
}
}
Aggregations