Java Matrix Sum SumIntegrateHistogram_25(float[][][] histo_array)

Here you can find the source of SumIntegrateHistogram_25(float[][][] histo_array)

Description

Get I and sigI by integrating the data in the histo_array using 25 slices, centered on the peak.

License

Open Source License

Declaration

public static float[] SumIntegrateHistogram_25(float[][][] histo_array) 

Method Source Code

//package com.java2s;
/* /*from   w  w w  . j  a va 2  s  .c  o  m*/
 * File: EV_IntegrateUtils.java
 *
 * Copyright (C) 2012, Dennis Mikkelson
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
 *
 * Contact : Dennis Mikkelson <mikkelsond@uwstout.edu>
 *           Department of Mathematics, Statistics and Computer Science
 *           University of Wisconsin-Stout
 *           Menomonie, WI 54751, USA
 *
 * This work was supported by the Spallation Neutron Source Division
 * of Oak Ridge National Laboratory, Oak Ridge, TN, USA.
 *
 *  Last Modified:
 * 
 *  $Author: dennis $
 *  $Date: 2012/11/09 15:40:55 $            
 *  $Revision: 1.2 $
 */

public class Main {
    /**
     *  Get I and sigI by integrating the data in the histo_array using 25 slices,
     *  centered on the peak.  This assumes that the histogram array came from 
     *  the PeakEventList.get*Histogram() method, using 25 slices to cover the 
     *  full range of data in the |Q|/tof direction.  The total counts on the
     *  first 5 and last 5 disks provide the background estimate and the total
     *  counts in the middle three slices provide the peak + background estimate. 
     */
    public static float[] SumIntegrateHistogram_25(float[][][] histo_array) {
        int n_pages = histo_array.length;
        float[] sums = new float[n_pages];
        for (int page = 0; page < n_pages; page++) {
            sums[page] = 0;
            float[][] arr = histo_array[page];
            for (int row = 0; row < histo_array[0].length; row++)
                for (int col = 0; col < histo_array[0][0].length; col++)
                    sums[page] += arr[row][col];

            //      System.out.println("Page = " + page + "   Sum = " + sums[page] );
        }

        // HACK: Currently assumes 25 pages in histogram

        float back = 0;
        int back_vol = 0;
        for (int page = 0; page < 5; page++) {
            back += sums[page];
            back += sums[n_pages - 1 - page];
            back_vol += 2;
        }

        float raw_signal = 0;
        int raw_vol = 0;
        for (int page = 5; page < n_pages - 5; page++) {
            raw_signal += sums[page];
            raw_vol++;
        }

        float ratio = (float) raw_vol / (float) back_vol;
        float signal = raw_signal - ratio * back;

        float sigma_signal = (float) Math.sqrt(raw_signal + ratio * ratio
                * back);

        float[] result = { signal, sigma_signal };
        return result;
    }
}

Related

  1. sumArrayDim(double[][] array, int dimToSummarize)
  2. sumArrays(double a[][], double b[][], String sign)
  3. sumAxis1(double[][] X)
  4. sumCols(boolean[][] inputMatrix)
  5. sumDimension(double[][] matrix, int dim)
  6. sumLines(double a[][])
  7. sumMetrix(double[][] total, double[][] element)
  8. sumOfMatrixElements(double[][] m)
  9. sumRow(int[][] matrix, int u)