Package org.aavso.tools.vstar.data

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


    // Visual format observation reader.
    private ValidObservation readNextVisualObservation(String[] fields,
        int obNum) throws ObservationValidationError {

      ValidObservation observation = commonReadNextObservation(fields,
          obNum);

      observation.setBand(SeriesType.Visual);

      String commentCode = fields[3].trim();
      if (!isNA(commentCode)) {
        commentCode = commentCodeValidator.validate(commentCode);
        if (commentCode != null) {
          observation.setCommentCode(commentCode);
        }
      }

      String comp1 = fields[4].trim();
      if (!isNA(comp1)) {
        observation.setCompStar1(comp1);
      }

      String comp2 = fields[5].trim();
      if (!isNA(comp2)) {
        observation.setCompStar2(comp2);
      }

      String chart = fields[6].trim();
      if (!isNA(chart)) {
        observation.setCharts(chart);
      }

      if (fields.length == 8) {
        // The visual format doesn't say that if N/A, "na" must be
        // used in this field like the Extended format does, so we
View Full Code Here


    // Common (to extended and visual formats) observation reader.
    // Reads: name, date, magnitude. Sets record number, observer code.
    private ValidObservation commonReadNextObservation(String[] fields,
        int obNum) throws ObservationValidationError {
      ValidObservation observation = new ValidObservation();

      String name = fields[0].trim();

      observation.setRecordNumber(obNum);
      observation.setName(name);
      observation.setObsCode(obscode);

      // TODO: handle "calendar" date format.
      if (!"JD".equals(dateType) && !"HJD".equals(dateType)) {
        throw new ObservationValidationError("Unsupported date type: "
            + dateType);
      } else {
        DateInfo dateInfo = julianDayValidator.validate(fields[1]
            .trim());
        observation.setDateInfo(dateInfo);
      }

      Magnitude magnitude = magnitudeFieldValidator.validate(fields[2]
          .trim());
      observation.setMagnitude(magnitude);

      return observation;
    }
View Full Code Here

*/
public class CustomFilterTest extends CustomFilterPluginBase {

  @Override
  protected void filter(List<ValidObservation> obs) {
    ValidObservation last = null;

    for (ValidObservation curr : obs) {
      if (last != null) {
        int lastIntegerJD = (int) last.getJD();
        SeriesType lastBand = last.getBand();
        SeriesType currBand = curr.getBand();
        if (lastIntegerJD % 9 == 0
            && (currBand == SeriesType.Johnson_V || currBand == SeriesType.Johnson_B)
            && (lastBand == SeriesType.Johnson_V || lastBand == SeriesType.Johnson_B)) {
          addToSubset(curr);
View Full Code Here

        for (int i = 0; i < objectNodes.getLength(); i++) {

          Element obElt = (Element) objectNodes.item(i);
          NodeList obDataNodes = obElt.getChildNodes();

          ValidObservation ob = new ValidObservation();

          for (int j = 0; j < obDataNodes.getLength(); j++) {
            try {
              Element datum = (Element) obDataNodes.item(j);
              String name = datum.getNodeName();
              String value = datum.getTextContent();

              if (name.equals("jd")) {
                double jd = Double.parseDouble(value);
                DateInfo date = new DateInfo(jd);
                ob.setDateInfo(date);
              } else if (name.equals("magnitude")) {
                double magnitude = Double.parseDouble(value);
                double uncertainty = 0;
                Magnitude mag = new Magnitude(magnitude,
                    uncertainty);
                ob.setMagnitude(mag);
              }
            } catch (NumberFormatException e) {
              // TODO: create invalid od
            }
          }

          // TODO: get band

          ob.setBand(SeriesType.Visual);

          collectObservation(ob);
        }
      } catch (MalformedURLException e) {
        throw new ObservationReadError(
View Full Code Here

          // The Lowess fitter requires a strictly increasing sequence
          // on the domain (i.e. JD values), i.e. no duplicates.
          Map<Double, Double> jdToMagMap = new TreeMap<Double, Double>();

          for (int i = 0; i < obs.size(); i++) {
            ValidObservation ob = obs.get(i);
            // This means that the last magnitude for a JD wins!
            jdToMagMap.put(ob.getJD(), ob.getMag());
          }

          double[] xvals = new double[jdToMagMap.size()];
          double[] yvals = new double[jdToMagMap.size()];

          int index = 0;
          for (Double jd : jdToMagMap.keySet()) {
            xvals[index] = jd;
            yvals[index++] = jdToMagMap.get(jd);
          }

          try {
            final LoessInterpolator interpolator = new LoessInterpolator();
            function = interpolator.interpolate(xvals, yvals);

            fit = new ArrayList<ValidObservation>();
            residuals = new ArrayList<ValidObservation>();
            double sumSqResiduals = 0;

            String comment = "From Lowess fit";

            // Create fit and residual observations and
            // compute the sum of squares of residuals for
            // Akaike and Bayesean Information Criteria.
            for (int i = 0; i < xvals.length && !interrupted; i++) {
              double jd = xvals[i];
              double mag = yvals[i];

              double y = function.value(jd);

              ValidObservation fitOb = new ValidObservation();
              fitOb.setDateInfo(new DateInfo(jd));
              fitOb.setMagnitude(new Magnitude(y, 0));
              fitOb.setBand(SeriesType.Model);
              fitOb.setComments(comment);
              fit.add(fitOb);

              ValidObservation resOb = new ValidObservation();
              resOb.setDateInfo(new DateInfo(jd));
              double residual = mag - y;
              resOb.setMagnitude(new Magnitude(residual, 0));
              resOb.setBand(SeriesType.Residuals);
              resOb.setComments(comment);
              residuals.add(resOb);

              sumSqResiduals += (residual * residual);
            }

 
View Full Code Here

        for (ValidObservation ob : obs) {
          if (interrupted)
            break;

          ValidObservation phOb = new ValidObservation();

          double jd = ob.getDateInfo().getJulianDay();
          phOb.setDateInfo(new DateInfo(jd));

          Magnitude mag = new Magnitude(ob.getMagnitude()
              .getMagValue(), ob.getMagnitude().getUncertainty());
          phOb.setMagnitude(mag);

          phObs.add(phOb);
        }

        // Choose an epoch value.
View Full Code Here

      String ellipticity = fields[9].trim();
      String plateNum = fields[10];
      String versionID = fields[11];
      String flags = fields[12].trim();

      ValidObservation ob = new ValidObservation();
      ob.setDateInfo(new DateInfo(hjd));
      ob.setMagnitude(new Magnitude(mag, magErr));
      if (magErr >= magErrThreshold) {
        ob.setExcluded(true);
      }
      ob.setBand(series);
      ob.setRecordNumber(lineNum);
     
      ob.addDetail("LIMITING MAG", limitingMag, "Limiting Mag");
      ob.addDetail("RA", RA, "RA");
      ob.addDetail("DEC", Dec, "Dec");
      ob.addDetail("THETA J2000", thetaJ2000, "Theta J2000");
      ob.addDetail("ELLIPTICITY", ellipticity, "Ellipticity");
      ob.addDetail("PLATE", plateNum, "Plate");
      ob.addDetail("VERSION ID", versionID, "Version ID");
      ob.addDetail("FLAGS", flags, "Flags");
      collectObservation(ob);
    }
View Full Code Here

    if (entity instanceof XYItemEntity) {
      XYItemEntity item = (XYItemEntity) entity;
      // Dataset may not be same as primary observation model, e.g.
      // could be model function dataset (continuous model).
      if (item.getDataset() == obsModel) {
        ValidObservation ob = obsModel.getValidObservation(item
            .getSeriesIndex(), item.getItem());

        String xyMsg = String.format(xyMsgFormat, NumericPrecisionPrefs
            .formatTime(ob.getJD()), ob.getDateInfo()
            .getCalendarDate(), NumericPrecisionPrefs.formatMag(ob
            .getMag()));
        item.setToolTipText(xyMsg);
      }
    }
  }
View Full Code Here

    final ObservationAndMeanPlotModel model = this;

    return new Listener<DiscrepantObservationMessage>() {
      public void update(DiscrepantObservationMessage info) {
        ValidObservation ob = info.getObservation();

        // Did we go to or from being discrepant?
        if (ob.isDiscrepant()) {
          // Now marked as discrepant so move observation from
          // its designated band series to the discrepant series.
          removeObservationFromSeries(ob, ob.getBand());
          addObservationToSeries(ob, SeriesType.DISCREPANT);
        } else {
          // Was marked as discrepant, now is not, so move
          // observation from the discrepant series to its
          // designated band series.
          removeObservationFromSeries(ob, SeriesType.DISCREPANT);
          addObservationToSeries(ob, ob.getBand());
        }

        fireDatasetChanged();

        // If the discrepant observation's band is the source of the
View Full Code Here

  // magnitude.
  public void chartMouseMoved(ChartMouseEvent event) {
    ChartEntity entity = event.getEntity();
    if (entity instanceof XYItemEntity) {
      XYItemEntity item = (XYItemEntity) entity;
      ValidObservation ob = obsModel.getValidObservation(item
          .getSeriesIndex(), item.getItem());
      String xyMsg = String.format(xyMsgFormat, NumericPrecisionPrefs
          .formatTime(ob.getStandardPhase()), NumericPrecisionPrefs
          .formatMag(ob.getMag()));
      item.setToolTipText(xyMsg);
    }
  }
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.