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 TypeMethodDescriptionvoid
add
(double valueX, double valueY) Add a value to the histogramvoid
clear()
Clear the datadouble
getBinMaxX
(int bin) Get the "x" value of the right side of the bindouble
getBinMaxY
(int bin) Get the "y" value of the right side of the bindouble
getBinMidValueX
(int bin) Get the "x" value of the middle of the bindouble
getBinMidValueY
(int bin) Get the "y" value of the middle of the bindouble
getBinMinX
(int bin) Get the "x" value of the left side of the bindouble
getBinMinY
(int bin) Get the "y" value of the left side of the binint
getBinX
(double val) Get the x bin for a given x value.int
getBinY
(double val) Get the y bin for a given y value.long
getCount
(int xbin, int ybin) Get the count for a given bin doublelong[][]
Get the countsdouble
getFractionalValue
(int binX, int binY) Get the fractional value (fraction of max value) for use in a plotlong
Get the number on entries in the histogram (excluding out of range)long
Get the maximum count of any bindouble
getMaxX()
Get the maximum "x" value.double
getMaxY()
Get the maximum y value.double
getMinX()
Get the minimum "x" value.double
getMinY()
Get the minimum "y" value.double
getMinZ()
Get the minimum "z" value.getName()
Get the name of the histogramint
Get the number of x binsint
Get the number of x binslong
Get 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 binslong
Get the total count, including the out of rangegetXName()
Get the name for the x axis variablegetYName()
Get the name for the y axis variablevoid
Set the namestatic String
statusString
(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
-