public void BinCentreTest() { UnitGroup ug = new UnitGroup(VolumeUnit.ImperialBeerBarrel, AreaUnit.SquareInch, LengthUnit.Foot, LengthUnit.Meter); Histogram rTest1 = new Histogram(20, 1); Assert.AreEqual(rTest1.BinCentre(0, ug).As(ug.VertUnit), -9.5); Assert.AreEqual(rTest1.BinCentre(19, ug).As(ug.VertUnit), 9.5); }
private void GetDisplayValues(bool bArea) { // Note that the key to this dictionary is the histogram elevation values in their ORIGINAL units // while the elevation properties of the HistogramDisplayDataPoint should be in the display units histoData = new Dictionary <decimal, HistogramDisplayData>(); for (int bid = 0; bid < _thrHist.Count; bid++) { // Make a dictionary entry if we don't already have one decimal bincentre = (decimal)_thrHist.BinCentre(bid, DataUnits).As(DisplayUnits.VertUnit); if (!histoData.ContainsKey(bincentre)) { histoData[bincentre] = new HistogramDisplayData(bincentre); } if (bArea) { histoData[bincentre].Threshold = (decimal)(_thrHist.BinArea(bid, Project.ProjectManager.Project.CellArea).As(DisplayUnits.ArUnit)); } else { histoData[bincentre].Threshold = Math.Abs((decimal)_thrHist.BinVolume(bid, Project.ProjectManager.Project.CellArea, DataUnits).As(DisplayUnits.VolUnit)); } } if ((_rawHist != null)) { for (int bid = 0; bid < _rawHist.Count; bid++) { // Make a dictionary entry if we don't already have one decimal bincentre = (decimal)_rawHist.BinCentre(bid, DataUnits).As(DisplayUnits.VertUnit); if (!histoData.ContainsKey(bincentre)) { histoData[bincentre] = new HistogramDisplayData(bincentre); } if (bArea) { histoData[bincentre].Raw = (decimal)(_rawHist.BinArea(bid, Project.ProjectManager.Project.CellArea).As(DisplayUnits.ArUnit)) - histoData[bincentre].Threshold; } else { histoData[bincentre].Raw = Math.Abs((decimal)_rawHist.BinVolume(bid, Project.ProjectManager.Project.CellArea, DataUnits).As(DisplayUnits.VolUnit)) - histoData[bincentre].Threshold; } } } }