Package org.aavso.tools.vstar.data

Examples of org.aavso.tools.vstar.data.ValidObservation


  protected Listener<ObservationSelectionMessage> createObservationSelectionListener() {
    final JPanel parent = this;
    return new Listener<ObservationSelectionMessage>() {
      public void update(ObservationSelectionMessage message) {
        if (message.getSource() != parent) {
          ValidObservation ob = message.getObservation();
          Integer rowIndex = validDataModel
              .getRowIndexFromObservation(ob);
          if (rowIndex != null && rowIndex >= 0) {
            try {
              // Convert to view index!
View Full Code Here


      if (rows.length > 1) {
        // This is a multiple observation selection.
        List<ValidObservation> obs = new ArrayList<ValidObservation>();
        for (int row : rows) {
          row = validDataTable.convertRowIndexToModel(row);
          ValidObservation ob = validDataModel.getObservations().get(
              row);
          obs.add(ob);
        }
        MultipleObservationSelectionMessage message = new MultipleObservationSelectionMessage(
            obs, this);

        Mediator.getInstance()
            .getMultipleObservationSelectionNotifier()
            .notifyListeners(message);

        selectedObs.clear();
        selectedObs.addAll(obs);
        createFilterButton.setEnabled(true);
      } else {
        // This is a single observation selection.
        int row = validDataTable.getSelectedRow();

        if (row >= 0) {
          row = validDataTable.convertRowIndexToModel(row);
          ValidObservation ob = validDataModel.getObservations().get(
              row);
          lastObSelected = ob;
          ObservationSelectionMessage message = new ObservationSelectionMessage(
              ob, this);
          Mediator.getInstance().getObservationSelectionNotifier()
View Full Code Here

   * @see javax.swing.table.TableModel#getValueAt(int, int)
   */
  public Object getValueAt(int rowIndex, int columnIndex) {
    assert columnIndex < COLUMN_COUNT;

    ValidObservation ob = obs.get(rowIndex);

    Object value = null;

    switch (columnIndex) {
    case PHASE_COLUMN:
      if (rowIndex < obs.size() / 2) {
        value = NumericPrecisionPrefs.formatTime(ob
            .getPreviousCyclePhase());
      } else {
        value = NumericPrecisionPrefs.formatTime(ob.getStandardPhase());
      }
      break;
    case MEAN_COLUMN:
      // The mean magnitude.
      value = NumericPrecisionPrefs.formatMag(ob.getMagnitude()
          .getMagValue());
      break;
    case STDERR_COLUMN:
      // The standard error of the average.
      value = NumericPrecisionPrefs.formatMag(ob.getMagnitude()
          .getUncertainty());
      break;
    }

    return value;
View Full Code Here

        // so add a ValidObservation containing mean and error value
        // to the list.
        Bin bin = createMeanObservationForRange(observations,
            timeElementEntity, i + 1, maxIndex);

        ValidObservation ob = bin.getMeanObservation();

        // If the mean magnitude value is NaN (e.g. because
        // there was no valid data in the range in question),
        // it doesn't make sense to include this bin.
        if (!Double.isNaN(ob.getMag())) {
          // Notice that we add to the start of the list
          // to avoid having to reverse the list since we
          // are moving from right to left along the original
          // list.
          binnedObs.add(0, ob);
View Full Code Here

        // so add a ValidObservation containing mean and error value
        // to the list.
        Bin bin = createMeanObservationForRange(observations,
            timeElementEntity, minIndex, i - 1);

        ValidObservation ob = bin.getMeanObservation();

        // If the mean magnitude value is NaN (e.g. because
        // there was no valid data in the range in question),
        // it doesn't make sense to include this bin.
        if (!Double.isNaN(ob.getMag())) {
          binnedObs.add(ob);
          bins.add(bin.getMagnitudes());
        }

        if (i < observations.size()) {
View Full Code Here

   */
  public void retrieveObservations() throws ObservationReadError,
      InterruptedException {
    try {
      while (!wasInterrupted() && source.next()) {
        ValidObservation validOb = null;

        // If there's an error in an SQL row, create an invalid
        // observation for it.
        try {
          validOb = getNextObservation();
        } catch (SQLException e) {
          int uniqueId = source.getInt("unique_id");
          InvalidObservation invalidOb = new InvalidObservation(
              "Row with unique ID " + uniqueId, e
                  .getLocalizedMessage());
          invalidOb.setRecordNumber(source.getRow());
          invalidObservations.add(invalidOb);
          continue;
        }

        // TODO: When we do more field validation here,
        // we should do these checks in getNextObservation()
        // and just throw an exception; something like ValidationError?
        // May need to modify some validators to take types other than
        // string. Actually, another approach is to read all fields as
        // strings and then do *exactly* the same validation as for file
        // sourced data.

        if (validOb.getMagnitude().isBrighterThan()) {
          InvalidObservation invalidOb = new InvalidObservation("JD "
              + validOb.getJD(),
              "A \"Brighter Than\" observation.");
          invalidObservations.add(invalidOb);
        } else if (validOb.getHqUncertainty() != null
            && !uncertaintyRangePredicate.holds(validOb
                .getHqUncertainty())) {
          InvalidObservation invalidOb = new InvalidObservation("JD "
              + validOb.getJD(),
              "HQ uncertainty value out of range "
                  + uncertaintyRangePredicate.toString());
          invalidObservations.add(invalidOb);
        } else {
          // Okay. Accept this as a valid observation, but
          // ignore non-standard magnitude type observations.
          if (validOb.getMType() == MTypeType.STD) {
            addValidObservation(validOb);
            categoriseValidObservation(validOb);
          }
        }
        // TODO: Why am I not updating progress bar here? Need count(*).
 
View Full Code Here

   * the ResultSet getter methods instead of strings. We use the string
   * versions for clarity. We can change this to use named constants if it
   * proves to be too inefficient.
   */
  private ValidObservation getNextObservation() throws SQLException {
    ValidObservation ob = new ValidObservation();

    int recordNum = source.getInt("unique_id");
    if (!source.wasNull())
      ob.setRecordNumber(recordNum);

    ob.setDateInfo(new DateInfo(source.getDouble("jd")));
    ob.setMagnitude(getNextMagnitude());
    ob.setHqUncertainty(getNextPossiblyNullDouble("hq_uncertainty"));
    SeriesType band = SeriesType.Unspecified;
    String bandNum = getNextPossiblyNullString("band");
    if (bandNum != null && !"".equals(bandNum)) {
      int num = Integer.parseInt(bandNum);
      band = SeriesType.getSeriesFromIndex(num);
    }
    ob.setBand(band);
    ob.setObsCode(getNextPossiblyNullString("observer_code"));
    ob.setCommentCode(getNextPossiblyNullString("comment_code"));
    ob.setCompStar1(getNextPossiblyNullString("comp_star_1"));
    ob.setCompStar2(getNextPossiblyNullString("comp_star_2"));
    ob.setCharts(getNextPossiblyNullString("charts"));
    ob.setComments(getNextPossiblyNullString("comments"));

    ob.setTransformed("yes"
        .equals(getNextPossiblyNullString("transformed")) ? true
        : false);

    ob.setAirmass(getNextPossiblyNullString("airmass"));
    ob.setValidationType(getNextValidationType());
    ob.setCMag(getNextPossiblyNullString("cmag"));
    ob.setKMag(getNextPossiblyNullString("kmag"));

    Double hjd = getNextPossiblyNullDouble("hjd");
    ob.setHJD(hjd != null ? new DateInfo(hjd) : null);

    ob.setName(getNextPossiblyNullString("name"));

    // If mtype is null or 0, we use the ValidObservation's
    // constructed default (standard magnitude type).
    Integer mtype = getNextPossiblyNullInteger("mtype");
    if (mtype != null && mtype != 0) {
      if (mtype == 1) {
        ob.setMType(MTypeType.DIFF);
      } else if (mtype == 2) {
        ob.setMType(MTypeType.STEP);
      }
    }

    ob.setObsType(ObsType
        .getObsTypeFromAIDIndex(getNextPossiblyNullInteger("obstype")));

    String pubref = getNextPossiblyNullString("pubref");
    if (pubref != null) {
      ob.setADSRef(pubref);
    }

    String digitizer = getNextPossiblyNullString("digitizer");
    if (digitizer != null) {
      ob.setDigitizer(digitizer);
    }

    return ob;
  }
View Full Code Here

          double jd = Double.parseDouble(fields[0]);
          double mag = Double.parseDouble(fields[1]);
          double error = Double.parseDouble(fields[2]);

          ValidObservation ob = new ValidObservation();
          ob.setDateInfo(new DateInfo(jd));
          ob.setMagnitude(new Magnitude(mag, error));
          ob.setBand(series);
          ob.setRecordNumber(reader.getLineNumber());
          collectObservation(ob);
        }

        line = reader.readLine();
      }
View Full Code Here

        // if (rfil=='y') then {
        // write(9,250) tt+dt0,resid,obs(n),xvec(n),xm

        // Create model and residual "observations".

        ValidObservation modelOb = new ValidObservation();
        modelOb.setDateInfo(new DateInfo(tt + dt0));
        modelOb.setMagnitude(new Magnitude(xm, 0));
        modelOb.setComments(model.getDescription());
        modelOb.setBand(SeriesType.Model);
        modelObs.add(modelOb);

        ValidObservation residualOb = new ValidObservation();
        residualOb.setDateInfo(new DateInfo(tt + dt0));
        residualOb.setMagnitude(new Magnitude(resid, 0));
        residualOb.setComments(model.getDescription());
        residualOb.setBand(SeriesType.Residuals);
        residualObs.add(residualOb);

        // }
        ttl = tt;
        xml = xm;
View Full Code Here

    // Note: this is only necessary of a recipient of filtered observations
    // needs to perform lookups.
    Set<ValidObservation> matchingObs = new LinkedHashSet<ValidObservation>();

    for (int i = 0; i < obs.size(); i++) {
      ValidObservation ob = obs.get(i);

      boolean does_match = matches(ob);

      if (does_match) {
        // Use logical implication (p => q which is the same as !p or q,
        // where p is the observation's property and q is the inclusion
        // property relating to p) to check that our inclusion criteria
        // still permit a match for this observation. For example, taking
        // fainter-thans we have this truth table:
        //
        // observation is-fainter-than | include is-fainter-thans | result
        // ----------------------------+--------------------------+--------
        //                       False |                    False | True
        //                       False |                    True  | True
        //                       True  |                    False | False
        //                       True  |                    True  | True
        does_match &= !ob.getMagnitude().isFainterThan()
            || includeFainterThan;
        does_match &= !ob.isDiscrepant() || includeDiscrepant;
        does_match &= !ob.isExcluded() || includeExcluded;

        if (does_match) {
          matchingObs.add(ob);
        }
      }
View Full Code Here

TOP

Related Classes of org.aavso.tools.vstar.data.ValidObservation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.