Exemplo n.º 1
0
  /**
   * _more_
   *
   * @param stormTrack _more_
   * @param param _more_
   * @return _more_
   */
  protected LineState makeLine(StormTrack stormTrack, StormParam param) {
    List<Real> values = new ArrayList<Real>();
    List<DateTime> times = stormTrack.getTrackTimes();
    List<StormTrackPoint> trackPoints = stormTrack.getTrackPoints();
    double min = 0;
    double max = 0;
    Unit unit = null;
    for (int pointIdx = 0; pointIdx < times.size(); pointIdx++) {
      Real value = trackPoints.get(pointIdx).getAttribute(param);
      if (value == null) {
        continue;
      }
      if (unit == null) {
        unit = ((RealType) value.getType()).getDefaultUnit();
      }
      values.add(value);
      double dvalue = value.getValue();
      //            System.err.print(","+dvalue);
      if ((pointIdx == 0) || (dvalue > max)) {
        max = dvalue;
      }
      if ((pointIdx == 0) || (dvalue < min)) {
        min = dvalue;
      }
    }
    if (values.size() == 0) {
      return null;
    }
    //        System.err.println("");
    String paramLabel = param.toString();
    String label = stormTrack.getWay().toString(); // +":" + paramLabel;
    LineState lineState = new LineState();
    lineState.setRangeIncludesZero(true);
    if (stormTrack.getWay().isObservation()) {
      lineState.setWidth(2);
    } else {
      lineState.setWidth(1);
    }
    lineState.setRange(new Range(min, max));
    lineState.setChartName(paramLabel);
    lineState.setAxisLabel("[" + unit + "]");

    //        System.err.println (param + " " +  StormDataSource.TYPE_STORMCATEGORY);
    if (Misc.equals(param, StormDataSource.PARAM_STORMCATEGORY)) {
      //            lineState.setShape(LineState.LINETYPE_BAR);
      lineState.setLineType(LineState.LINETYPE_BAR);
      lineState.setLineType(LineState.LINETYPE_AREA);
    } else {
      lineState.setLineType(LineState.LINETYPE_SHAPES_AND_LINES);
      lineState.setShape(LineState.SHAPE_LARGEPOINT);
    }

    lineState.setColor(stormDisplayState.getWayDisplayState(stormTrack.getWay()).getColor());
    lineState.setName(label);
    lineState.setTrack(times, values);
    return lineState;
  }
Exemplo n.º 2
0
 /** evaluate the bracket function; e.g., A1[5] or A1[A2] */
 public static Data brackets(visad.Field f, Real r) {
   Data value = null;
   try {
     RealType rt = (RealType) r.getType();
     value = f.getSample((int) r.getValue());
   } catch (VisADException exc) {
     if (FormulaVar.DEBUG) exc.printStackTrace();
   } catch (RemoteException exc) {
     if (FormulaVar.DEBUG) exc.printStackTrace();
   }
   return value;
 }
Exemplo n.º 3
0
  /**
   * Computes the output property. A {@link java.beans.PropertyChangeEvent} is fired for the output
   * property if it differs from the previous value.
   *
   * @throws VisADException if a VisAD failure occurs.
   * @throws RemoteException if a Java RMI exception occurs.
   */
  void clock() throws VisADException, RemoteException {

    Set domainSet = buoyProfile.getDomainSet();
    Real oldLfc;
    Real newLfc;
    double[] pressures = domainSet.getDoubles()[0];
    float[] buoys = buoyProfile.getFloats()[0];

    /* Eliminate non-finite pressures and buoyancies. */
    int n = 0;

    for (int i = 0; i < pressures.length; i++) {
      if ((pressures[i] != pressures[i]) || (buoys[i] != buoys[i])) {
        n++;
      }
    }

    if (n > 0) {
      double[] tmpPres = new double[pressures.length - n];
      float[] tmpBuoy = new float[tmpPres.length];

      n = 0;

      for (int i = 0; i < pressures.length; i++) {
        if ((pressures[i] != pressures[i]) || (buoys[i] != buoys[i])) {
          continue;
        }

        tmpPres[n] = pressures[i];
        tmpBuoy[n] = buoys[i];

        n++;
      }

      pressures = tmpPres;
      buoys = tmpBuoy;
    }

    if (pressures.length <= 1) {
      newLfc = missingLfc;
    } else {
      Unit presUnit = domainSet.getSetUnits()[0];
      boolean ascending = pressures[0] > pressures[1];

      if (!ascending) {

        /*
         * The profile is descending.  Make the temporary value arrays
         * ascending.
         */
        for (int i = 0, j = pressures.length; i < pressures.length / 2; i++) {
          --j;

          double pres = pressures[i];

          pressures[i] = pressures[j];
          pressures[j] = pres;

          float buoy = buoys[i];

          buoys[i] = buoys[j];
          buoys[j] = buoy;
        }
      }

      /*
       * Descend from the top to positive buoyancy.
       */
      int i = buoys.length;

      while ((--i >= 0) && (buoys[i] <= 0)) ;

      if (i < 0) {

        /*
         * There is no positively buoyant region.
         */
        newLfc = missingLfc;
      } else {

        /*
         * Descend to first non-positive buoyant region.
         */
        while ((--i >= 0) && (buoys[i] > 0)) ;

        if (i < 0) {

          /*
           * There is no non-positive buoyant region.
           */
          newLfc = missingLfc;
        } else {

          /*
           * Interpolate the LFC.
           */
          double pressure =
              pressures[i + 1]
                  / Math.exp(
                      buoys[i + 1]
                          * (Math.log(pressures[i] / pressures[i + 1])
                              / (buoys[i] - buoys[i + 1])));

          newLfc = new Real((RealType) missingLfc.getType(), pressure, presUnit);
        }
      }
    }

    synchronized (this) {
      oldLfc = lfc;
      lfc = newLfc;
    }

    firePropertyChange(OUTPUT_PROPERTY_NAME, oldLfc, newLfc);
  }