} /* WriteTabDelToStream */ private void WriteForGnuplotToStream(TextWriter tw, PicesImageSizeDistribution sizeDistribution, bool printDensity, bool plotVolumeSpectrum ) { uint numDepthBins = (uint)sizeDistribution.NumDepthBins; uint numSizeBins = (uint)sizeDistribution.NumSizeBuckets; float[] startValues = bucketsDisplayed.SizeStartValues(); float[] endValues = bucketsDisplayed.SizeEndValues(); uint maxValuesLen = (uint)Math.Max(startValues.Length, endValues.Length); uint minValuesLen = (uint)Math.Min(startValues.Length, endValues.Length); double depthBinSize = sizeDistribution.DepthBinSize; for (int sizeIdx = 0; sizeIdx < minValuesLen; ++sizeIdx) { double size = (startValues[sizeIdx] + endValues[sizeIdx]) / 2.0; for (uint depthBinIdx = 0; depthBinIdx < numDepthBins; ++depthBinIdx) { double depth = depthBinSize * depthBinIdx; PicesImageSizeDistributionRow row = sizeDistribution.GetDepthBin(depthBinIdx); if (row == null) { tw.WriteLine(size + " " + depth + " " + "0"); continue; } uint[] distriution = row.Distribution(); float volumneSampled = row.VolumneSampled; double zed = 0.0; if (plotVolumeSpectrum) { double density = 0.0; if ((distriution[sizeIdx] > 0) && (volumneSampled != 0.0f)) { density = (double)distriution[sizeIdx] / (double)volumneSampled; } double nV = density * Math.PI * Math.Pow(size, 3.0) / 6.0; double nVd = nV * size; zed = Math.Log10(nVd); } else { if (printDensity) { if ((distriution[sizeIdx] > 0) && (volumneSampled != 0.0f)) { zed = (float)Math.Log10(1.0f + (float)distriution[sizeIdx] / (float)volumneSampled); } } else { zed = (float)Math.Log10(1.0 + (double)distriution[sizeIdx]); } } tw.WriteLine(size + " " + depth + " " + zed); } tw.WriteLine(); } } /* WriteForGnuplotToStream */
private void WriteTabDelToStream(TextWriter tw, PicesImageSizeDistribution sizeDistribution, bool printDensity ) { uint x = 0; uint numDepthBins = (uint)sizeDistribution.NumDepthBins; uint numSizeBins = (uint)sizeDistribution.NumSizeBuckets; float[] startValues = bucketsDisplayed.SizeStartValues(); float[] endValues = bucketsDisplayed.SizeEndValues(); uint maxValuesLen = (uint)Math.Max(startValues.Length, endValues.Length); uint minValuesLen = (uint)Math.Min(startValues.Length, endValues.Length); String hl1 = "" + "\t" + "Volume" + "\t" + "Image" + "\t" + "Total" + "\t" + "Total"; String hl2 = "Depth(m)" + "\t" + "Sampled(m^3)" + "\t" + "Count" + "\t" + "Pixels" + "\t" + "FilledArea"; for (x = 0; x < minValuesLen; ++x) { hl1 += ("\t" + startValues[x]); hl2 += ("\t" + endValues [x]); } tw.WriteLine(hl1); tw.WriteLine(hl2); for (uint depthBinIdx = 0; depthBinIdx < numDepthBins; ++depthBinIdx) { PicesImageSizeDistributionRow row = sizeDistribution.GetDepthBin(depthBinIdx); if (row == null) { continue; } uint[] distriution = row.Distribution(); float volumneSampled = row.VolumneSampled; tw.Write(row.Depth + "\t" + volumneSampled + "\t" + row.ImageCount + "\t" + row.TotalPixels + "\t" + row.TotalFilledArea ); for (x = 0; x < distriution.Length; ++x) { tw.Write("\t"); if (printDensity) { float zed = 0.0f; if ((distriution[x] > 0) && (volumneSampled != 0.0f)) { zed = (float)Math.Log10(1.0f + (float)distriution[x] / (float)volumneSampled); } tw.Write(zed); } else { tw.Write(distriution[x]); } } tw.WriteLine(); } } /* WriteTabDelToStream */
} /* SuperScriptExponent */ private void UpdateChartAreas() { goalie.StartBlock(); bool plotLogDensity = PlotLogDensity.Checked; String t1 = "Abundance by Size"; switch (statistic) { case '0': t1 = "Abundance by Size"; break; case '1': t1 = "Abundance by Diameter (ESD)"; break; case '2': t1 = "Abundance by Volume (EBv"; break; case '3': t1 = "Abundance by Estimated Ellipsoid Volume"; break; } String t2 = cruise + "-" + station; if (!String.IsNullOrEmpty(deployment)) { t2 += ("-" + deployment); } t2 += (" " + classToPlot.Name); t2 += " "; t2 += (cast + "-Cast" + " Size-Range(" + sizeStart.ToString() + " - " + sizeEnd.ToString() + ")"); ProfileChart.Titles.Clear(); ProfileChart.Titles.Add(new Title(t1, Docking.Top, titleFont, Color.Black)); ProfileChart.Titles.Add(new Title(t2, Docking.Top, titleFont, Color.Black)); //ProfileChart.Titles.Add (new Title (t3, Docking.Top, titleFont, Color.Black)); ProfileChart.Series.Clear(); ChartArea ca1 = ProfileChart.ChartAreas[0]; ChartArea ca2 = ProfileChart.ChartAreas[1]; Series s = new Series("Size Distribution"); s.ChartArea = "ChartArea1"; s.ChartType = SeriesChartType.Line; Series s2 = new Series("Volume Sampled"); s2.ChartArea = "ChartArea2"; s2.ChartType = SeriesChartType.Line; float minX = float.MaxValue; float minY = float.MaxValue; float maxX = float.MinValue; float maxY = float.MinValue; int numDepthBins = sizeDistribution.NumDepthBins; for (uint depthBin = 0; depthBin < numDepthBins; ++depthBin) { PicesImageSizeDistributionRow row = sizeDistribution.GetDepthBin(depthBin); if (row == null) { continue; } float depth = row.Depth; double density = 0.0; if (depthBin < depthProfile.Length) { density = (double)depthProfile[depthBin]; } if (plotLogDensity) { density = (float)Math.Log10(density + 1.0); } minX = Math.Min(minX, (float)density); maxX = Math.Max(maxX, (float)density); minY = Math.Min(minY, depth); maxY = Math.Max(maxY, depth); DataPoint dp = new DataPoint(density, depth); s.Points.Add(dp); double vs = 0.0; if (depthBin < volumeSampled.Length) { vs = volumeSampled[depthBin]; } DataPoint dp2 = new DataPoint(vs, depth); s2.Points.Add(dp2); } s.XAxisType = AxisType.Primary; s.YAxisType = AxisType.Primary; s2.XAxisType = AxisType.Primary; s2.YAxisType = AxisType.Primary; s2.Color = Color.Black; if (plotLogDensity) { ca1.AxisX.Title = SubInSuperScriptExponent("Log 10 Abundance"); } else { ca1.AxisX.Title = SubInSuperScriptExponent("Abundance"); } ca1.AxisY.Title = SubInSuperScriptExponent("Depth (Meters)"); ca1.AxisY.LabelStyle.Format = "##,##0"; ca1.AxisX.IsLogarithmic = false; ca1.AxisX.Minimum = 0.0; //ca1.AxisX.Maximum = maxX; ca1.AxisX.LabelStyle.Angle = 90; ca1.AxisX.LabelStyle.Font = axisLabelFont; ca1.AxisX.TitleFont = axisLabelFont; ca1.AxisY.Minimum = 0.0; ca1.AxisY.IsLogarithmic = false; ca1.AxisY.LabelStyle.Font = axisLabelFont; ca1.AxisY.TitleFont = axisLabelFont; if (plotLogDensity) { ca1.AxisX.LabelStyle.Format = "##,##0.0"; } else { ca1.AxisX.LabelStyle.Format = "##,##0"; } ca2.AxisX.Title = SubInSuperScriptExponent("Volume Sampled (mm-3)"); ca2.AxisX.Minimum = 0.0; ca2.AxisX.IsLogarithmic = false; ca2.AxisX.LabelStyle.Font = axisLabelFont; ca2.AxisX.TitleFont = axisLabelFont; ca2.AxisX.LabelStyle.Format = "##0.00"; ca2.AxisX.LabelStyle.Angle = 90; s.BorderWidth = 2; ProfileChart.Series.Add(s); ProfileChart.Series.Add(s2); try { ProfileChart.ChartAreas[0].RecalculateAxesScale(); } catch (Exception e) { runLog.Writeln(e.ToString()); } goalie.EndBlock(); } /* UpdateChartAreas */