Package cnuphys.splot.pdata
Class Histo2DData
java.lang.Object
cnuphys.splot.pdata.Histo2DData
-
Constructor Summary
ConstructorsConstructorDescriptionHisto2DData(String name, String xname, String yname, double[] gridX, double[] gridY) The data for a 2D histogram where the bin spacing is arbitrary (i.e., not uniform)Histo2DData(String name, String xname, String yname, double valMinX, double valMaxX, int numBinsX, double valMinY, double valMaxY, int numBinsY) The data for a 2D histogram where the bin spacing is uniform. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(double valueX, double valueY) Add a value to the histogramvoidclear()Clear the datadoublegetBinMaxX(int bin) Get the "x" value of the right side of the bindoublegetBinMaxY(int bin) Get the "y" value of the right side of the bindoublegetBinMidValueX(int bin) Get the "x" value of the middle of the bindoublegetBinMidValueY(int bin) Get the "y" value of the middle of the bindoublegetBinMinX(int bin) Get the "x" value of the left side of the bindoublegetBinMinY(int bin) Get the "y" value of the left side of the binintgetBinX(double val) Get the x bin for a given x value.intgetBinY(double val) Get the y bin for a given y value.longgetCount(int xbin, int ybin) Get the count for a given bin doublelong[][]Get the countsdoublegetFractionalValue(int binX, int binY) Get the fractional value (fraction of max value) for use in a plotlongGet the number on entries in the histogram (excluding out of range)longGet the maximum count of any bindoublegetMaxX()Get the maximum "x" value.doublegetMaxY()Get the maximum y value.doublegetMinX()Get the minimum "x" value.doublegetMinY()Get the minimum "y" value.doublegetMinZ()Get the minimum "z" value.getName()Get the name of the histogramintGet the number of x binsintGet the number of x binslongGet the number on entries in the histogram that were out of rangegetRectangle(double x, double y) Get the world rectangle containing the given x and y valuesgetRectangle(int binX, int binY) Get the world rectangle corresponding to the given binslongGet the total count, including the out of rangegetXName()Get the name for the x axis variablegetYName()Get the name for the y axis variablevoidSet the namestatic StringstatusString(PlotCanvas canvas, Histo2DData histo, Point mousePoint, Point2D.Double wp) Get the status string
-
Constructor Details
-
Histo2DData
public Histo2DData(String name, String xname, String yname, double valMinX, double valMaxX, int numBinsX, double valMinY, double valMaxY, int numBinsY) The data for a 2D histogram where the bin spacing is uniform.- Parameters:
name- the namexname- the x variable nameyname- the y variable namevalMin- the data minvalMax- the data maxnumBins- the number of bins
-
Histo2DData
The data for a 2D histogram where the bin spacing is arbitrary (i.e., not uniform)- Parameters:
name- the curve name of the histogramxname- the x variable nameyname- the y variable namegrid- the binning grid. It must be in ascending order but is otherwise arbitrary.
-
-
Method Details
-
getName
Get the name of the histogram- Returns:
- the name of the histogram
-
setName
Set the name- Parameters:
name- the name of the histogram
-
clear
public void clear()Clear the data -
getCounts
public long[][] getCounts()Get the counts- Returns:
- the counts array
-
getGoodCount
public long getGoodCount()Get the number on entries in the histogram (excluding out of range)- Returns:
- the number of entries
-
getTotalCount
public long getTotalCount()Get the total count, including the out of range- Returns:
- the total count, including the out of range
-
getOutOfRangeCount
public long getOutOfRangeCount()Get the number on entries in the histogram that were out of range- Returns:
- the number of entries out of range
-
getMinX
public double getMinX()Get the minimum "x" value. This is the minimum of the range being binned.- Returns:
- the minimum "x" value
-
getMaxX
public double getMaxX()Get the maximum "x" value. This is the maximum of the range being binned.- Returns:
- the maximum "x" value
-
getMinY
public double getMinY()Get the minimum "y" value. This is the minimum of the range being binned.- Returns:
- the minimum "x" value
-
getMaxY
public double getMaxY()Get the maximum y value. This is the maximum of the range being binned.- Returns:
- the maximum "y" value
-
getMinZ
public double getMinZ()Get the minimum "z" value. The z axis corresponds to "counts", so this always returns 0 -
getMaxCount
public long getMaxCount()Get the maximum count of any bin- Returns:
- the count of the bin with the most counts.
-
add
public void add(double valueX, double valueY) Add a value to the histogram- Parameters:
value- the value to ad
-
getNumberBinsX
public int getNumberBinsX()Get the number of x bins- Returns:
- the number of x bins
-
getNumberBinsY
public int getNumberBinsY()Get the number of x bins- Returns:
- the number of x bins
-
getBinMidValueX
public double getBinMidValueX(int bin) Get the "x" value of the middle of the bin- Parameters:
bin- the bin in question- Returns:
- the x mid value
-
getBinMidValueY
public double getBinMidValueY(int bin) Get the "y" value of the middle of the bin- Parameters:
bin- the bin in question- Returns:
- the y mid value
-
getBinMaxY
public double getBinMaxY(int bin) Get the "y" value of the right side of the bin- Parameters:
bin- the bin in question- Returns:
- the y value of the right side
-
getBinMaxX
public double getBinMaxX(int bin) Get the "x" value of the right side of the bin- Parameters:
bin- the bin in question- Returns:
- the x value of the right side
-
getBinMinX
public double getBinMinX(int bin) Get the "x" value of the left side of the bin- Parameters:
bin- the bin in question- Returns:
- the x value of the left side
-
getBinMinY
public double getBinMinY(int bin) Get the "y" value of the left side of the bin- Parameters:
bin- the bin in question- Returns:
- the y value of the left side
-
getBinX
public int getBinX(double val) Get the x bin for a given x value. Will return the zero-based bin number or OUTOFRANGE.- Parameters:
val- the x value.- Returns:
- return the x bin: [0..(numBinX-1)] or an error
-
getBinY
public int getBinY(double val) Get the y bin for a given y value. Will return the zero-based bin number or OUTOFRANGE.- Parameters:
val- the y value.- Returns:
- return the y bin: [0..(numBinY-1)] or an error
-
getRectangle
Get the world rectangle containing the given x and y values- Parameters:
x- the x valuey- the y value- Returns:
- the world rectangle, or
null.
-
getRectangle
Get the world rectangle corresponding to the given bins- Parameters:
binX- the x binbinY- the y bin- Returns:
- the world rectangle, or
null.
-
getFractionalValue
public double getFractionalValue(int binX, int binY) Get the fractional value (fraction of max value) for use in a plot- Parameters:
binX- the x binbinY- the y bin- Returns:
- the fractional value (fraction of max value).
-
statusString
public static String statusString(PlotCanvas canvas, Histo2DData histo, Point mousePoint, Point2D.Double wp) Get the status string- Parameters:
canvas- the plot canvashisto- the histo data objectmousePoint- where the mouse iswp- the data coordinates of the mouse- Returns:
- a status string
-
getCount
public long getCount(int xbin, int ybin) Get the count for a given bin double- Parameters:
xbin- the x binybin- the y bin- Returns:
- the count for that bin double
-
getXName
Get the name for the x axis variable- Returns:
- the name for the x axis variable
-
getYName
Get the name for the y axis variable- Returns:
- the name for the y axis variable
-