Example #1
0
 private XYDataset filterData(XYSeriesCollection series) {
   XYSeriesCollection ret = new XYSeriesCollection();
   if (getSmoothRB().isSelected()) {
     ret = series;
     ret = IstiUtilsMath.varismooth(ret);
   } else if (getRawAndSmoothRB().isSelected()) {
     XYSeries smoothedSeries = IstiUtilsMath.varismooth(series).getSeries(0);
     smoothedSeries.setKey("smoothed series");
     ret.addSeries(smoothedSeries);
     ret.addSeries(series.getSeries(0));
   } else if (getRawRB().isSelected()) {
     ret = series;
   }
   return ret;
 }
  private XYSeriesCollection createDataset() {
    dataset = new XYSeriesCollection();
    // for (int series = 0; series < res.length; series++) {
    // one for each frame

    baselist = "";
    flowlist = "";
    EnumMap<ResultType, WellFlowDataResult> subresults = null;
    if (subtract > -1) {
      subresults = flowmap.get(subtract);
    }
    p("Creating dataset for flows " + flows);
    for (int flow : flows) {
      EnumMap<ResultType, WellFlowDataResult> results = flowmap.get(flow);
      boolean done = false;
      p("processing flow " + flow);
      if (results != null) {
        for (ResultType key : results.keySet()) {
          // p("got "+key.getName());
          if (key.isShow()) {
            String base = null;
            WellFlowDataResult dataresult = results.get(key);
            if (!done) {
              done = true;
              flowlist += flow + " ";
              if (dataresult.isPrerun()) {
                baselist = " prerun";
              } else if (dataresult.isBfPost()) {
                baselist = " bf post ";
              } else if (dataresult.isBfPre()) {
                baselist = " bf pre";
              }
              if (dataresult.isAcq()) {
                base = "" + context.getBase(flow);
                baselist += base;
              }
            }

            WellFlowDataResult subresult = null;
            if (subresults != null) {
              subresult = subresults.get(key);
            }
            //   p("adding to series " + dataresult.getName() + ":" +
            // Arrays.toString(dataresult.getData()));
            double[] nframedata = dataresult.getData();
            double[] ndata = new double[nframedata.length];
            double[] sdata = null;
            if (subresult != null) {
              p("SUBTRACTING FLOW " + subtract);
              sdata = subresult.getData();
            }
            String serieskey = dataresult.getName() + " flow " + dataresult.getFlow();
            if (base != null) {
              serieskey += " " + base;
            }
            XYSeries seriesres = new XYSeries(serieskey);
            seriesres.setKey(serieskey);
            for (int f = 0; f < nframedata.length; f++) {
              long ts = dataresult.getTimestamps()[f];
              ndata[f] = nframedata[f] - nframedata[0];
              if (sdata != null) {
                ndata[f] = ndata[f] - (sdata[f] - sdata[0]);
              }
              seriesres.add(ts, ndata[f]);
            }
            dataset.addSeries(seriesres);
          }
        }
        //  else p("Not showing "+key.getName());

      } else p("NO results for flow " + flow);
    }

    //   }
    return dataset;
  }