示例#1
0
  private static void go() {
    int n1 = 101;
    int n2 = 101;
    // float[][] f = sin(rampfloat(0.0f,0.1f,0.1f,n1,n2));
    float[][] f = zerofloat(n1, n2);

    PlotPanel.Orientation orientation = PlotPanel.Orientation.X1DOWN_X2RIGHT;
    PlotPanel panel = new PlotPanel(orientation);

    PixelsView pv = panel.addPixels(f);
    pv.setInterpolation(PixelsView.Interpolation.NEAREST);
    pv.setColorModel(ColorMap.JET);

    panel.addColorBar("time");
    panel.setVLabel("depth (km)");
    panel.setHLabel("distance (km)");

    PlotFrame frame = new PlotFrame(panel);
    frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE);
    frame.setSize(800, 700);
    frame.setFontSize(24);
    frame.setVisible(true);

    ModeManager mm = frame.getModeManager();
    ImageEditMode iem = new ImageEditMode(mm, pv, 0.0f, f);
    iem.setActive(true);
  }
 /**
  * Computes and plots correlation functions
  *
  * @param tauMax is the maximum time for correlation functions
  */
 public void computeCorrelation(int tauMax) {
   plotFrame.clearData();
   double energyAccumulator = 0, magnetizationAccumulator = 0;
   double energySquaredAccumulator = 0, magnetizationSquaredAccumulator = 0;
   for (int t = 0; t < numberOfPoints; t++) {
     energyAccumulator += energy[t];
     magnetizationAccumulator += magnetization[t];
     energySquaredAccumulator += energy[t] * energy[t];
     magnetizationSquaredAccumulator += magnetization[t] * magnetization[t];
   }
   double averageEnergySquared = Math.pow(energyAccumulator / numberOfPoints, 2);
   double averageMagnetizationSquared = Math.pow(magnetizationAccumulator / numberOfPoints, 2);
   // compute normalization factors
   double normE = (energySquaredAccumulator / numberOfPoints) - averageEnergySquared;
   double normM = (magnetizationSquaredAccumulator / numberOfPoints) - averageMagnetizationSquared;
   for (int tau = 1; tau <= tauMax; tau++) {
     double c_MAccumulator = 0;
     double c_EAccumulator = 0;
     int counter = 0;
     for (int t = 0; t < numberOfPoints - tau; t++) {
       c_MAccumulator += magnetization[t] * magnetization[t + tau];
       c_EAccumulator += energy[t] * energy[t + tau];
       counter++;
     }
     // correlation function defined so that c(0) = 1 and c(infinity) -> 0
     plotFrame.append(0, tau, ((c_MAccumulator / counter) - averageMagnetizationSquared) / normM);
     plotFrame.append(1, tau, ((c_EAccumulator / counter) - averageEnergySquared) / normE);
   }
   plotFrame.setVisible(true);
 }
示例#3
0
  private static void test2() {
    int n1 = 11;
    int n2 = 11;
    float d1 = 1.0f / (float) max(1, n1 - 1);
    float d2 = 1.0f / (float) max(1, n2 - 1);
    float[][] f0 = rampfloat(0.0f, d1, d2, n1, n2);
    float[][] f1 = zerofloat(n1, n2);
    float[][] f2 = zerofloat(n1, n2);
    // float[][] f1 = rampfloat(0.0f,d1,d2,n1,n2);
    // float[][] f2 = rampfloat(0.0f,d1,d2,n1,n2);

    Sampling s1 = new Sampling(n1, 0.5, 0.25 * (n1 - 1));
    Sampling s2 = new Sampling(n2, 0.5, 0.25 * (n2 - 1));

    PlotPanel panel = new PlotPanel(1, 2);
    PixelsView pv0 = panel.addPixels(0, 0, new float[][][] {f0, f1, f2});
    pv0.setInterpolation(PixelsView.Interpolation.NEAREST);
    pv0.setClips(0, 0.0f, 2.0f);
    pv0.setClips(1, 0.0f, 2.0f);
    pv0.setClips(2, 0.0f, 2.0f);
    pv0.set(new float[][][] {f0, f1, f2}); // should have no effect!

    PixelsView pv0b = panel.addPixels(0, 0, s1, s2, new float[][][] {f1, f0, f2});
    pv0b.setInterpolation(PixelsView.Interpolation.LINEAR);
    pv0b.setClips(0, 0.0f, 2.0f);
    pv0b.setClips(1, 0.0f, 2.0f);
    pv0b.setClips(2, 0.0f, 2.0f);

    PixelsView pv1 = panel.addPixels(0, 1, new float[][][] {f1, f2, f0});
    pv1.setInterpolation(PixelsView.Interpolation.LINEAR);
    pv1.setClips(0, 0.0f, 2.0f);
    pv1.setClips(1, 0.0f, 2.0f);
    pv1.setClips(2, 0.0f, 2.0f);

    PixelsView pv1b = panel.addPixels(0, 1, s1, s2, new float[][][] {f1, f0, f2});
    pv1b.setInterpolation(PixelsView.Interpolation.NEAREST);
    pv1b.setClips(0, 0.0f, 2.0f);
    pv1b.setClips(1, 0.0f, 2.0f);
    pv1b.setClips(2, 0.0f, 2.0f);

    PlotFrame frame = new PlotFrame(panel);
    frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    // frame.paintToPng(300,6,"junk.png");
  }
示例#4
0
  private static void test1() {
    int n1 = 11;
    int n2 = 11;
    float d1 = 1.0f / (float) max(1, n1 - 1);
    float d2 = 1.0f / (float) max(1, n2 - 1);
    float[][] f = rampfloat(0.0f, d1, d2, n1, n2);

    Sampling s1 = new Sampling(n1, 0.5, 0.25 * (n1 - 1));
    Sampling s2 = new Sampling(n2, 0.5, 0.25 * (n2 - 1));

    PlotPanel panel = new PlotPanel(1, 2);
    PixelsView pv0 = panel.addPixels(0, 0, f);
    pv0.setInterpolation(PixelsView.Interpolation.NEAREST);
    pv0.setColorModel(ColorMap.JET);
    pv0.setPercentiles(0.0f, 100.0f);
    f = mul(10.0f, f);
    pv0.set(f);

    PixelsView pv0b = panel.addPixels(0, 0, s1, s2, f);
    pv0b.setInterpolation(PixelsView.Interpolation.LINEAR);
    pv0b.setColorModel(ColorMap.GRAY);
    pv0b.setPercentiles(0.0f, 100.0f);

    PixelsView pv1 = panel.addPixels(0, 1, f);
    pv1.setInterpolation(PixelsView.Interpolation.LINEAR);
    pv1.setColorModel(ColorMap.GRAY);
    pv1.setPercentiles(0.0f, 100.0f);
    f = mul(10.0f, f);
    pv1.set(f);

    PixelsView pv1b = panel.addPixels(0, 1, s1, s2, f);
    pv1b.setInterpolation(PixelsView.Interpolation.NEAREST);
    pv1b.setColorModel(ColorMap.JET);
    pv1b.setPercentiles(0.0f, 100.0f);

    PlotFrame frame = new PlotFrame(panel);
    frame.setDefaultCloseOperation(PlotFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    // frame.paintToPng(300,6,"junk.png");
  }