public void Add(InstrumentStatsByDepth p) { binId = p.binId; binDepth = p.binDepth; scanLines += p.scanLines; volumeSampled += p.volumeSampled; temperatureMean += p.temperatureMean; salinityMean += p.salinityMean; densityMean += p.densityMean; fluorescenceMean += p.fluorescenceMean; fluorescenceSensorMean += p.fluorescenceSensorMean; oxygenMean += p.oxygenMean; depthMean += p.depthMean; transmisivityMean += p.transmisivityMean; turbidityMean += p.turbidityMean; cdomFluorescenceMean += p.cdomFluorescenceMean; ++count; }
} /* PrintTabDelDistributionMatrix */ public void PrintByClassCollumns(System.IO.StreamWriter o, List <uint> scanLinesPerMeterDepth, List <InstrumentStatsByDepth> volumePerMeterDepth, bool printDensity, /**< Indicates to print density rather than counts. */ PicesClassList summarizeClasses /**< List of classes that we need to print summary columns for. */ ) { PicesClassList classes = BuildMLClassList(); int cIDX; // Find the first and last buckets with activity int firstBucket = -1; int lastBucket = 0; for (int bucketIDX = 0; bucketIDX < bucketCount; bucketIDX++) { int bucketTotal = 0; for (cIDX = 0; cIDX < classes.Count; cIDX++) { PicesClass mlClass = classes[cIDX]; ClassTotals classTotals = totals.LookUp(mlClass.Name); bucketTotal += classTotals.BucketCount(bucketIDX); } if (bucketTotal > 0) { if (firstBucket < 0) { firstBucket = bucketIDX; } lastBucket = bucketIDX; } } if (firstBucket < 0) { o.WriteLine(); o.WriteLine(); o.WriteLine("SizeDistribution::PrintByClassCollumns *** There is no SizeDistribution Data ***"); o.WriteLine(); return; } int[] finalTotals = new int[classes.Count]; int[] summaryTotals = null; for (int zed = 0; zed < classes.Count; zed++) { finalTotals[zed] = 0; } if (summarizeClasses != null) { summaryTotals = new int[summarizeClasses.Count]; for (int zed = 0; zed < summaryTotals.Length; ++zed) { summaryTotals[zed] = 0; } } int grandTotal = 0; String[] headLines = classes.ExtractThreeTitleLines(); String[] summaryHeadLines = null; if (summarizeClasses == null) { summaryHeadLines = new String[3]; summaryHeadLines[0] = ""; summaryHeadLines[1] = ""; summaryHeadLines[2] = ""; } else { String[] temp = summarizeClasses.ExtractTwoTitleLines(); summaryHeadLines = new String[3]; summaryHeadLines[2] = temp[1]; summaryHeadLines[1] = temp[0]; summaryHeadLines[0] = ""; for (int x = 0; x < summarizeClasses.Count; ++x) { if (x > 0) { summaryHeadLines[0] += "\t"; } summaryHeadLines[0] += "Summary"; } } String s1 = "Abundance by Class"; if (printDensity) { s1 = "Abundance/m-3"; } String temperatureUOM = PicesInstrumentData.TemperatureUnit; String fluorescenceUOM = PicesInstrumentData.FluorescenceUnit; String densityUOM = PicesInstrumentData.DensityUnit; String oxygenUOM = PicesInstrumentData.OxygenUnit; String salinityUOM = PicesInstrumentData.SalinityUnit; String transmisivityUMO = PicesInstrumentData.TransmisivityUnit; String turbidityUMO = PicesInstrumentData.TurbidityUnit; String cdomFluorescenceUMO = PicesInstrumentData.CdomFluorescenceUnit; // [O2 (ml/L) * 44.64]/1.027 = O2 umol/kg o.WriteLine("" + "\t" + "" + "\t" + "" + "\t" + s1); o.WriteLine("" + "\t" + "" + "\t" + "Volume" + "\t" + headLines[0] + "\t" + "" + "\t" + "" + "\t" + "" + "\t" + summaryHeadLines[0] + "\t" + "" + "\t" + s1); o.WriteLine("" + "\t" + "Scan" + "\t" + "filtered" + "\t" + headLines[1] + "\t" + "" + "\t" + "All" + "\t" + "" + "\t" + summaryHeadLines[1] + "\t" + "" + "\t" + "Temperature" + "\t" + "Salinity" + "\t" + "Density" + "\t" + "Fluorescence" + "\t" + "FluorescenceSensor" + "\t" + "Oxygen" + "\t" + "Oxygen" + "\t" + "Transitivity" + "\t" + "Turbidity" + "\t" + "CdomFluorescence"); o.WriteLine("Depth(m)" + "\t" + "Lines" + "\t" + "m-3" + "\t" + headLines[2] + "\t" + "" + "\t" + "Classes" + "\t" + "" + "\t" + summaryHeadLines[2] + "\t" + "" + "\t" + temperatureUOM + "\t" + salinityUOM + "\t" + densityUOM + "\t" + fluorescenceUOM + "\t" + "Volts" + "\t" + oxygenUOM + "\t" + "umol/kg" + "\t" + transmisivityUMO + "\t" + turbidityUMO + "\t" + cdomFluorescenceUMO); ulong totalScanLines = 0; double totalVolume = 0.0f; int imageSize = firstBucket * bucketSize; for (int bucketIDX = firstBucket; bucketIDX <= lastBucket; bucketIDX++) { int nextImageSize = imageSize + bucketSize; ulong scanLinesDepthForThisBucket = 0; if (scanLinesPerMeterDepth != null) { for (int x = imageSize; x < Math.Min(nextImageSize, scanLinesPerMeterDepth.Count); x++) { scanLinesDepthForThisBucket += scanLinesPerMeterDepth[x]; } } InstrumentStatsByDepth totalThisBucketIdx = new InstrumentStatsByDepth(bucketIDX); double volumeDepthForThisBucket = 0.0; if (volumePerMeterDepth != null) { if (bucketIDX < volumePerMeterDepth.Count) { totalThisBucketIdx.Add(volumePerMeterDepth[bucketIDX]); } for (int x = imageSize; x < Math.Min(nextImageSize, volumePerMeterDepth.Count); x++) { if (x < volumePerMeterDepth.Count) { volumeDepthForThisBucket += volumePerMeterDepth[x].volumeSampled; } } } totalThisBucketIdx.ComputeMean(); o.Write(imageSize.ToString() + "\t" + scanLinesDepthForThisBucket.ToString() + "\t" + volumeDepthForThisBucket.ToString("##,##0.000") ); totalScanLines += scanLinesDepthForThisBucket; totalVolume += volumeDepthForThisBucket; int bucketTotal = 0; int intIDX = 0; for (cIDX = 0; cIDX < classes.Count; cIDX++) { PicesClass mlClass = classes[cIDX]; ClassTotals classTotals = totals.LookUp(mlClass.Name); int qtyThisBucket = classTotals.BucketCount(bucketIDX); double densityThisBucket = 0.0; if (volumeDepthForThisBucket != 0.0) { densityThisBucket = classTotals.BucketCount(bucketIDX) / volumeDepthForThisBucket; } if (printDensity) { o.Write("\t" + densityThisBucket.ToString("#####0.000")); } else { o.Write("\t" + qtyThisBucket.ToString()); } bucketTotal += qtyThisBucket; finalTotals[intIDX] += qtyThisBucket; grandTotal += qtyThisBucket; intIDX++; } o.Write("\t" + ""); { if (printDensity) { double densityThisBucket = 0.0; if (volumeDepthForThisBucket != 0.0) { densityThisBucket = bucketTotal / volumeDepthForThisBucket; } o.Write("\t" + densityThisBucket.ToString("#####0.000")); } else { o.Write("\t" + bucketTotal); } } o.Write("\t" + ""); if ((summarizeClasses != null) && (summarizeClasses.Count > 0)) { int zed = 0; foreach (PicesClass pc in summarizeClasses) { int qtyThisBucket = SumUpFamilyOfClassesForBucket(pc, bucketIDX); summaryTotals[zed] = qtyThisBucket; if (printDensity) { double densityThisBucket = 0.0; if (volumeDepthForThisBucket != 0.0) { densityThisBucket = qtyThisBucket / volumeDepthForThisBucket; } o.Write("\t" + densityThisBucket.ToString("#####0.000")); } else { o.Write("\t" + qtyThisBucket.ToString()); } ++zed; } } o.Write("\t" + ""); if (totalThisBucketIdx != null) { o.Write("\t" + totalThisBucketIdx.temperatureMean.ToString("###0.000") + "\t" + totalThisBucketIdx.salinityMean.ToString("###0.000") + "\t" + totalThisBucketIdx.densityMean.ToString("###0.000") + "\t" + totalThisBucketIdx.fluorescenceMean.ToString("###0.000") + "\t" + totalThisBucketIdx.fluorescenceSensorMean.ToString("###0.000") + "\t" + totalThisBucketIdx.oxygenMean.ToString("###0.000") + "\t" + totalThisBucketIdx.Oxygen_molPerKg.ToString("###0.000") + "\t" + totalThisBucketIdx.transmisivityMean.ToString("###0.000") + "\t" + totalThisBucketIdx.turbidityMean.ToString("###0.000") + "\t" + totalThisBucketIdx.cdomFluorescenceMean.ToString("###0.000") ); } imageSize = nextImageSize; o.WriteLine(); } { o.WriteLine(); o.Write("Final Totals" + "\t" + totalScanLines + "\t" + totalVolume); for (uint x = 0; x < classes.Count; x++) { double density = 0; if (totalVolume != 0.0) { density = finalTotals[x] / totalVolume; } if (printDensity) { o.Write("\t" + ""); } else { o.Write("\t" + finalTotals[x]); } } o.Write("\t"); double grandTotalDensity = 0.0; if (totalVolume != 0.0) { grandTotalDensity = grandTotal / totalVolume; } if (printDensity) { o.Write("\t" + grandTotalDensity.ToString("#####0.000")); } else { o.Write("\t" + grandTotal.ToString()); } o.Write("\t"); if (summaryTotals != null) { for (uint x = 0; x < summaryTotals.Length; ++x) { o.Write("\t"); if (printDensity) { if (totalVolume != 0.0) { o.Write((summaryTotals[x] / totalVolume).ToString("#####0.000")); } else { o.Write(0.0); } } else { o.Write(summaryTotals[x]); } } } o.WriteLine(); } classes = null; } /* ReportByClassCollumns */