List of usage examples for org.apache.commons.math3.exception.util DummyLocalizable DummyLocalizable
public DummyLocalizable(final String source)
From source file:org.orekit.data.SimpleTimeStampedTableParser.java
/** Parse a stream. * @param stream stream containing the table * @param name name of the resource file (for error messages only) * @return parsed table/*from ww w . j a va 2 s. c o m*/ * @exception OrekitException if stream is null or the table cannot be parsed */ public List<T> parse(final InputStream stream, final String name) throws OrekitException { if (stream == null) { throw new OrekitException(OrekitMessages.UNABLE_TO_FIND_FILE, name); } // regular lines are simply a space separated list of numbers final StringBuilder builder = new StringBuilder("^\\p{Space}*"); for (int i = 0; i < columns; ++i) { builder.append("("); builder.append(REAL_TYPE_PATTERN); builder.append(")"); builder.append((i < columns - 1) ? "\\p{Space}+" : "\\p{Space}*$"); } final Pattern regularLinePattern = Pattern.compile(builder.toString()); try { // setup the reader final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); final List<T> table = new ArrayList<T>(); for (String line = reader.readLine(); line != null; line = reader.readLine()) { // replace unicode minus sign ('') by regular hyphen ('-') for parsing // such unicode characters occur in tables that are copy-pasted from PDF files line = line.replace('\u2212', '-'); final Matcher regularMatcher = regularLinePattern.matcher(line); if (regularMatcher.matches()) { // we have found a regular data line final double[] rawFields = new double[columns]; for (int i = 0; i < columns; ++i) { rawFields[i] = Double.parseDouble(regularMatcher.group(i + 1)); } table.add(converter.convert(rawFields)); } } if (table.isEmpty()) { throw new OrekitException(OrekitMessages.NOT_A_SUPPORTED_IERS_DATA_FILE, name); } return table; } catch (IOException ioe) { throw new OrekitException(ioe, new DummyLocalizable(ioe.getMessage())); } }
From source file:org.orekit.files.ccsds.OEMParser.java
/** {@inheritDoc} */ public OEMFile parse(final InputStream stream, final String fileName) throws OrekitException { try {// w w w. j a v a 2 s. c om final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); // initialize internal data structures final ParseInfo pi = new ParseInfo(); pi.fileName = fileName; final OEMFile file = pi.file; // set the additional data that has been configured prior the parsing by the user. pi.file.setMissionReferenceDate(getMissionReferenceDate()); pi.file.setMuSet(getMu()); pi.file.setConventions(getConventions()); for (String line = reader.readLine(); line != null; line = reader.readLine()) { ++pi.lineNumber; if (line.trim().length() == 0) { continue; } pi.keyValue = new KeyValue(line, pi.lineNumber, pi.fileName); if (pi.keyValue.getKeyword() == null) { throw new OrekitException(OrekitMessages.CCSDS_UNEXPECTED_KEYWORD, pi.lineNumber, pi.fileName, line); } switch (pi.keyValue.getKeyword()) { case CCSDS_OEM_VERS: file.setFormatVersion(pi.keyValue.getDoubleValue()); break; case META_START: file.addEphemeridesBlock(); pi.lastEphemeridesBlock = file.getEphemeridesBlocks() .get(file.getEphemeridesBlocks().size() - 1); pi.lastEphemeridesBlock.getMetaData().setLaunchYear(getLaunchYear()); pi.lastEphemeridesBlock.getMetaData().setLaunchNumber(getLaunchNumber()); pi.lastEphemeridesBlock.getMetaData().setLaunchPiece(getLaunchPiece()); break; case START_TIME: pi.lastEphemeridesBlock.setStartTime(parseDate(pi.keyValue.getValue(), pi.lastEphemeridesBlock.getMetaData().getTimeSystem())); break; case USEABLE_START_TIME: pi.lastEphemeridesBlock.setUseableStartTime(parseDate(pi.keyValue.getValue(), pi.lastEphemeridesBlock.getMetaData().getTimeSystem())); break; case USEABLE_STOP_TIME: pi.lastEphemeridesBlock.setUseableStopTime(parseDate(pi.keyValue.getValue(), pi.lastEphemeridesBlock.getMetaData().getTimeSystem())); break; case STOP_TIME: pi.lastEphemeridesBlock.setStopTime(parseDate(pi.keyValue.getValue(), pi.lastEphemeridesBlock.getMetaData().getTimeSystem())); break; case INTERPOLATION: pi.lastEphemeridesBlock.setInterpolationMethod(pi.keyValue.getValue()); break; case INTERPOLATION_DEGREE: pi.lastEphemeridesBlock.setInterpolationDegree(Integer.parseInt(pi.keyValue.getValue())); break; case META_STOP: file.setMuUsed(); parseEphemeridesDataLines(reader, pi); break; case COVARIANCE_START: parseCovarianceDataLines(reader, pi); break; default: boolean parsed = false; parsed = parsed || parseComment(pi.keyValue, pi.commentTmp); parsed = parsed || parseHeaderEntry(pi.keyValue, file, pi.commentTmp); if (pi.lastEphemeridesBlock != null) { parsed = parsed || parseMetaDataEntry(pi.keyValue, pi.lastEphemeridesBlock.getMetaData(), pi.commentTmp); } if (!parsed) { throw new OrekitException(OrekitMessages.CCSDS_UNEXPECTED_KEYWORD, pi.lineNumber, pi.fileName, line); } } } file.checkTimeSystems(); return file; } catch (IOException ioe) { throw new OrekitException(ioe, new DummyLocalizable(ioe.getMessage())); } }
From source file:org.orekit.files.ccsds.OMMParser.java
/** {@inheritDoc} */ public OMMFile parse(final InputStream stream, final String fileName) throws OrekitException { try {/*from w w w . j a va 2s.com*/ final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); // initialize internal data structures final ParseInfo pi = new ParseInfo(); pi.fileName = fileName; final OMMFile file = pi.file; // set the additional data that has been configured prior the parsing by the user. pi.file.setMissionReferenceDate(getMissionReferenceDate()); pi.file.setMuSet(getMu()); pi.file.setConventions(getConventions()); pi.file.getMetaData().setLaunchYear(getLaunchYear()); pi.file.getMetaData().setLaunchNumber(getLaunchNumber()); pi.file.getMetaData().setLaunchPiece(getLaunchPiece()); for (String line = reader.readLine(); line != null; line = reader.readLine()) { ++pi.lineNumber; if (line.trim().length() == 0) { continue; } pi.keyValue = new KeyValue(line, pi.lineNumber, pi.fileName); if (pi.keyValue.getKeyword() == null) { throw new OrekitException(OrekitMessages.CCSDS_UNEXPECTED_KEYWORD, pi.lineNumber, pi.fileName, line); } switch (pi.keyValue.getKeyword()) { case CCSDS_OMM_VERS: file.setFormatVersion(pi.keyValue.getDoubleValue()); break; case MEAN_ELEMENT_THEORY: file.getMetaData().setMeanElementTheory(pi.keyValue.getValue()); break; case MEAN_MOTION: file.setMeanMotion(pi.keyValue.getDoubleValue() * FastMath.PI / 43200.0); break; case EPHEMERIS_TYPE: file.setTLERelatedParametersComment(pi.commentTmp); pi.commentTmp.clear(); file.setEphemerisType(Integer.parseInt(pi.keyValue.getValue())); break; case CLASSIFICATION_TYPE: file.setClassificationType(pi.keyValue.getValue().charAt(0)); break; case NORAD_CAT_ID: file.setNoradID(Integer.parseInt(pi.keyValue.getValue())); break; case ELEMENT_SET_NO: file.setElementSetNo(pi.keyValue.getValue()); break; case REV_AT_EPOCH: file.setRevAtEpoch(Integer.parseInt(pi.keyValue.getValue())); break; case BSTAR: file.setbStar(pi.keyValue.getDoubleValue()); break; case MEAN_MOTION_DOT: file.setMeanMotionDot(pi.keyValue.getDoubleValue() * FastMath.PI / 1.86624e9); break; case MEAN_MOTION_DDOT: file.setMeanMotionDotDot(pi.keyValue.getDoubleValue() * FastMath.PI / 5.3747712e13); break; default: boolean parsed = false; parsed = parsed || parseComment(pi.keyValue, pi.commentTmp); parsed = parsed || parseHeaderEntry(pi.keyValue, file, pi.commentTmp); parsed = parsed || parseMetaDataEntry(pi.keyValue, file.getMetaData(), pi.commentTmp); parsed = parsed || parseGeneralStateDataEntry(pi.keyValue, file, pi.commentTmp); if (!parsed) { throw new OrekitException(OrekitMessages.CCSDS_UNEXPECTED_KEYWORD, pi.lineNumber, pi.fileName, line); } } } reader.close(); return file; } catch (IOException ioe) { throw new OrekitException(ioe, new DummyLocalizable(ioe.getMessage())); } }
From source file:org.orekit.files.ccsds.OPMParser.java
/** {@inheritDoc} */ public OPMFile parse(final InputStream stream, final String fileName) throws OrekitException { try {/*from w w w . j av a2 s . com*/ final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); // initialize internal data structures final ParseInfo pi = new ParseInfo(); pi.fileName = fileName; final OPMFile file = pi.file; // set the additional data that has been configured prior the parsing by the user. pi.file.setMissionReferenceDate(getMissionReferenceDate()); pi.file.setMuSet(getMu()); pi.file.setConventions(getConventions()); pi.file.getMetaData().setLaunchYear(getLaunchYear()); pi.file.getMetaData().setLaunchNumber(getLaunchNumber()); pi.file.getMetaData().setLaunchPiece(getLaunchPiece()); for (String line = reader.readLine(); line != null; line = reader.readLine()) { ++pi.lineNumber; if (line.trim().length() == 0) { continue; } pi.keyValue = new KeyValue(line, pi.lineNumber, pi.fileName); if (pi.keyValue.getKeyword() == null) { throw new OrekitException(OrekitMessages.CCSDS_UNEXPECTED_KEYWORD, pi.lineNumber, pi.fileName, line); } switch (pi.keyValue.getKeyword()) { case CCSDS_OPM_VERS: file.setFormatVersion(pi.keyValue.getDoubleValue()); break; case X: pi.x = pi.keyValue.getDoubleValue() * 1000; break; case Y: pi.y = pi.keyValue.getDoubleValue() * 1000; break; case Z: pi.z = pi.keyValue.getDoubleValue() * 1000; break; case X_DOT: pi.x_dot = pi.keyValue.getDoubleValue() * 1000; break; case Y_DOT: pi.y_dot = pi.keyValue.getDoubleValue() * 1000; break; case Z_DOT: pi.z_dot = pi.keyValue.getDoubleValue() * 1000; break; case MAN_EPOCH_IGNITION: if (pi.maneuver != null) { file.addManeuver(pi.maneuver); } pi.maneuver = new OPMFile.Maneuver(); pi.maneuver.setEpochIgnition(parseDate(pi.keyValue.getValue(), file.getTimeSystem())); if (!pi.commentTmp.isEmpty()) { pi.maneuver.setComment(pi.commentTmp); pi.commentTmp.clear(); } break; case MAN_DURATION: pi.maneuver.setDuration(pi.keyValue.getDoubleValue()); break; case MAN_DELTA_MASS: pi.maneuver.setDeltaMass(pi.keyValue.getDoubleValue()); break; case MAN_REF_FRAME: final CCSDSFrame manFrame = parseCCSDSFrame(pi.keyValue.getValue()); if (manFrame.isLof()) { pi.maneuver.setRefLofType(manFrame.getLofType()); } else { pi.maneuver.setRefFrame(manFrame.getFrame(getConventions(), isSimpleEOP())); } break; case MAN_DV_1: pi.maneuver.setdV(new Vector3D(pi.keyValue.getDoubleValue() * 1000, pi.maneuver.getDV().getY(), pi.maneuver.getDV().getZ())); break; case MAN_DV_2: pi.maneuver.setdV(new Vector3D(pi.maneuver.getDV().getX(), pi.keyValue.getDoubleValue() * 1000, pi.maneuver.getDV().getZ())); break; case MAN_DV_3: pi.maneuver.setdV(new Vector3D(pi.maneuver.getDV().getX(), pi.maneuver.getDV().getY(), pi.keyValue.getDoubleValue() * 1000)); break; default: boolean parsed = false; parsed = parsed || parseComment(pi.keyValue, pi.commentTmp); parsed = parsed || parseHeaderEntry(pi.keyValue, file, pi.commentTmp); parsed = parsed || parseMetaDataEntry(pi.keyValue, file.getMetaData(), pi.commentTmp); parsed = parsed || parseGeneralStateDataEntry(pi.keyValue, file, pi.commentTmp); if (!parsed) { throw new OrekitException(OrekitMessages.CCSDS_UNEXPECTED_KEYWORD, pi.lineNumber, pi.fileName, line); } } } file.setPosition(new Vector3D(pi.x, pi.y, pi.z)); file.setVelocity(new Vector3D(pi.x_dot, pi.y_dot, pi.z_dot)); if (pi.maneuver != null) { file.addManeuver(pi.maneuver); } reader.close(); return file; } catch (IOException ioe) { throw new OrekitException(ioe, new DummyLocalizable(ioe.getMessage())); } }
From source file:org.orekit.files.sp3.SP3Parser.java
/** {@inheritDoc} */ public SP3File parse(final InputStream stream) throws OrekitException { try {//from w w w .ja va 2 s. c om return parseInternal(stream); } catch (IOException e) { throw new OrekitException(e, new DummyLocalizable(e.getMessage())); } }
From source file:org.orekit.forces.drag.DTM2000.java
/** Store the DTM model elements coefficients in internal arrays. * @exception OrekitException if some resource file reading error occurs */// w w w.ja v a 2 s. c o m private static void readcoefficients() throws OrekitException { final int size = NLATM + 1; tt = new double[size]; h = new double[size]; he = new double[size]; o = new double[size]; az2 = new double[size]; o2 = new double[size]; az = new double[size]; t0 = new double[size]; tp = new double[size]; dtt = new double[size]; dh = new double[size]; dhe = new double[size]; dox = new double[size]; daz2 = new double[size]; do2 = new double[size]; daz = new double[size]; dt0 = new double[size]; dtp = new double[size]; Arrays.fill(dtt, Double.NaN); Arrays.fill(dh, Double.NaN); Arrays.fill(dhe, Double.NaN); Arrays.fill(dox, Double.NaN); Arrays.fill(daz2, Double.NaN); Arrays.fill(do2, Double.NaN); Arrays.fill(daz, Double.NaN); Arrays.fill(dt0, Double.NaN); Arrays.fill(dtp, Double.NaN); final InputStream in = DTM2000.class.getResourceAsStream(DTM2000); if (in == null) { throw new OrekitException(OrekitMessages.UNABLE_TO_FIND_RESOURCE, DTM2000); } BufferedReader r = null; try { r = new BufferedReader(new InputStreamReader(in, "UTF-8")); r.readLine(); r.readLine(); for (String line = r.readLine(); line != null; line = r.readLine()) { final int num = Integer.parseInt(line.substring(0, 4).replace(' ', '0')); line = line.substring(4); tt[num] = Double.parseDouble(line.substring(0, 13).replace(' ', '0')); line = line.substring(13 + 9); h[num] = Double.parseDouble(line.substring(0, 13).replace(' ', '0')); line = line.substring(13 + 9); he[num] = Double.parseDouble(line.substring(0, 13).replace(' ', '0')); line = line.substring(13 + 9); o[num] = Double.parseDouble(line.substring(0, 13).replace(' ', '0')); line = line.substring(13 + 9); az2[num] = Double.parseDouble(line.substring(0, 13).replace(' ', '0')); line = line.substring(13 + 9); o2[num] = Double.parseDouble(line.substring(0, 13).replace(' ', '0')); line = line.substring(13 + 9); az[num] = Double.parseDouble(line.substring(0, 13).replace(' ', '0')); line = line.substring(13 + 9); t0[num] = Double.parseDouble(line.substring(0, 13).replace(' ', '0')); line = line.substring(13 + 9); tp[num] = Double.parseDouble(line.substring(0, 13).replace(' ', '0')); } } catch (IOException ioe) { throw new OrekitException(ioe, new DummyLocalizable(ioe.getMessage())); } finally { if (r != null) { try { r.close(); } catch (IOException ioe) { throw new OrekitException(ioe, new DummyLocalizable(ioe.getMessage())); } } } }
From source file:org.orekit.propagation.analytical.EcksteinHechlerPropagatorTest.java
@Test(expected = PropagationException.class) public void wrongAttitude() throws OrekitException { KeplerianOrbit orbit = new KeplerianOrbit(1.0e10, 1.0e-4, 1.0e-2, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14); AttitudeProvider wrongLaw = new AttitudeProvider() { private static final long serialVersionUID = 5918362126173997016L; public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException { throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException()); }//w w w. j av a2s . c om }; EcksteinHechlerPropagator propagator = new EcksteinHechlerPropagator(orbit, wrongLaw, provider); propagator.propagate(AbsoluteDate.J2000_EPOCH.shiftedBy(10.0)); }
From source file:org.orekit.propagation.analytical.KeplerianPropagatorTest.java
@Test(expected = PropagationException.class) public void wrongAttitude() throws PropagationException { KeplerianOrbit orbit = new KeplerianOrbit(1.0e10, 1.0e-4, 1.0e-2, 0, 0, 0, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14); AttitudeProvider wrongLaw = new AttitudeProvider() { private static final long serialVersionUID = 5918362126173997016L; public Attitude getAttitude(PVCoordinatesProvider pvProv, AbsoluteDate date, Frame frame) throws OrekitException { throw new OrekitException(new DummyLocalizable("gasp"), new RuntimeException()); }/*w w w.j a v a2 s .co m*/ }; KeplerianPropagator propagator = new KeplerianPropagator(orbit, wrongLaw); propagator.propagate(AbsoluteDate.J2000_EPOCH.shiftedBy(10.0)); }
From source file:org.orekit.propagation.analytical.KeplerianPropagatorTest.java
@Test(expected = PropagationException.class) public void testException() throws PropagationException { final KeplerianOrbit orbit = new KeplerianOrbit(7.8e6, 0.032, 0.4, 0.1, 0.2, 0.3, PositionAngle.TRUE, FramesFactory.getEME2000(), AbsoluteDate.J2000_EPOCH, 3.986004415e14); KeplerianPropagator propagator = new KeplerianPropagator(orbit); OrekitStepHandlerMultiplexer multiplexer = new OrekitStepHandlerMultiplexer(); propagator.setMasterMode(multiplexer); multiplexer.add(new OrekitStepHandler() { public void init(SpacecraftState s0, AbsoluteDate t) { }//from w w w. ja v a 2 s . com public void handleStep(OrekitStepInterpolator interpolator, boolean isLast) throws PropagationException { if (isLast) { throw new PropagationException((Throwable) null, new DummyLocalizable("dummy error")); } } }); propagator.setMasterMode(new OrekitStepHandler() { public void init(SpacecraftState s0, AbsoluteDate t) { } public void handleStep(OrekitStepInterpolator interpolator, boolean isLast) throws PropagationException { if (isLast) { throw new PropagationException((Throwable) null, new DummyLocalizable("dummy error")); } } }); propagator.propagate(orbit.getDate().shiftedBy(-3600)); }
From source file:org.orekit.SolarInputs97to05.java
private void read(BufferedReader rFlux, BufferedReader rAp) throws IOException, OrekitException { rFlux.readLine();//from w w w .j av a2s .co m rFlux.readLine(); rFlux.readLine(); rFlux.readLine(); rAp.readLine(); String lineAp; String[] flux; String[] ap; Calendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("UTC")); cal.set(0, 0, 0, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); AbsoluteDate date = null; boolean first = true; for (String lineFlux = rFlux.readLine(); lineFlux != null; lineFlux = rFlux.readLine()) { flux = lineFlux.trim().split("\\s+"); lineAp = rAp.readLine(); if (lineAp == null) { throw new OrekitException( new DummyLocalizable("inconsistent JB2006 and geomagnetic indices files")); } ap = lineAp.trim().split("\\s+"); int fluxYear = Integer.parseInt(flux[0]); int fluxDay = Integer.parseInt(flux[1]); int apYear = Integer.parseInt(ap[11]); if (fluxDay != Integer.parseInt(ap[0])) { throw new OrekitException( new DummyLocalizable("inconsistent JB2006 and geomagnetic indices files")); } if (((fluxYear < 2000) && ((fluxYear - 1900) != apYear)) || ((fluxYear >= 2000) && ((fluxYear - 2000) != apYear))) { throw new OrekitException( new DummyLocalizable("inconsistent JB2006 and geomagnetic indices files")); } cal.set(Calendar.YEAR, fluxYear); cal.set(Calendar.DAY_OF_YEAR, fluxDay); date = new AbsoluteDate(cal.getTime(), TimeScalesFactory.getUTC()); if (first) { first = false; firstDate = date; } data.add(new LineParameters(date, new double[] { Double.parseDouble(ap[3]), Double.parseDouble(ap[4]), Double.parseDouble(ap[5]), Double.parseDouble(ap[6]), Double.parseDouble(ap[7]), Double.parseDouble(ap[8]), Double.parseDouble(ap[9]), Double.parseDouble(ap[10]), }, Double.parseDouble(flux[3]), Double.parseDouble(flux[4]), Double.parseDouble(flux[5]), Double.parseDouble(flux[6]), Double.parseDouble(flux[7]), Double.parseDouble(flux[8]))); } lastDate = date; }