Example #1
0
  public void readOrbitData() throws IOException {

    if (_productFile instanceof DorisOrbitProductFile) {

      final DorisOrbitProductFile dorisProdFile = (DorisOrbitProductFile) _productFile;
      final Record orbitRecord = dorisProdFile.readOrbitData();

      OrbitVector orb = null;
      final SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss.SSSSSS");
      final ArrayList<OrbitVector> orbitVectorList = new ArrayList<OrbitVector>();

      final int numFields = orbitRecord.getNumFields();
      for (int i = 0; i < numFields; ++i) {

        final Field f = orbitRecord.getFieldAt(i);

        final String fieldName = f.getName();
        if (fieldName.contains("blank")) {
          continue;
        } else if (fieldName.contains("utc_time")) {
          orb = new OrbitVector();
          try {
            orb.utcTime = ProductData.UTC.parse(f.getData().getElemString()).getMJD();
          } catch (ParseException e) {
            throw new IllegalFileFormatException("Failed to parse UTC time " + e.getMessage());
          }
        } else if (fieldName.contains("delta_ut1")) {
          if (orb != null) orb.delta_ut1 = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("abs_orbit")) {
          if (orb != null)
            orb.absOrbit = Integer.parseInt(f.getData().getElemString().replace("+", ""));
        } else if (fieldName.contains("x_pos")) {
          if (orb != null) orb.xPos = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("y_pos")) {
          if (orb != null) orb.yPos = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("z_pos")) {
          if (orb != null) orb.zPos = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("x_vel")) {
          if (orb != null) orb.xVel = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("y_vel")) {
          if (orb != null) orb.yVel = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("z_vel")) {
          if (orb != null) orb.zVel = Double.parseDouble(f.getData().getElemString());
        } else if (fieldName.contains("qual_flags")) {
          if (orb != null) orb.qualFlags = f.getData().getElemString();
          orbitVectorList.add(orb);
        }
      }

      dataRecords = orbitVectorList.toArray(new OrbitVector[orbitVectorList.size()]);

      recordTimes = new double[dataRecords.length];
      for (int i = 0; i < dataRecords.length; i++) {
        recordTimes[i] = dataRecords[i].utcTime;
      }
    }
  }