Exemplo n.º 1
0
        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 */
Exemplo n.º 2
0
        } /* ClearHighLightedBucket*/

        private void  HighLightSizeBucket(int depthBin)
        {
            if ((ProfileChart.Series.Count < 1) || (depthBin < 0))
            {
                return;
            }

            if (depthBin >= depthProfile.Length)
            {
                return;
            }

            Series s = ProfileChart.Series[0];

            if (depthBin >= s.Points.Count)
            {
                return;
            }

            ClearHighLightedBucket();

            DataPoint dp = s.Points[depthBin];

            PicesImageSizeDistributionRow depthRow = sizeDistribution.GetDepthBin((uint)depthBin);

            if (depthRow == null)
            {
                return;
            }
            uint[] distribution = depthRow.Distribution();
            if ((distribution == null) || (distribution.Length <= selectedSizeBucket))
            {
                return;
            }

            double volSampled = 0.0f;

            if (depthBin < volumeSampled.Length)
            {
                volSampled = volumeSampled[depthBin];
            }
            double density = 0.0;

            if (volSampled > 0.0)
            {
                density = (double)distribution[selectedSizeBucket] / volSampled;
            }

            dp.Label          = density.ToString("###,##0.0") + "(" + dp.YValues[0].ToString("##0.0 m") + ")";
            dp.Color          = Color.Red;
            dp.Font           = dataPointFont;
            dp.MarkerStyle    = MarkerStyle.Circle;
            dp.MarkerSize     = s.MarkerSize * 3;
            dp.MarkerColor    = Color.Red;
            dp.LabelBackColor = Color.White;

            Series s2 = ProfileChart.Series[1];

            if (depthBin >= s2.Points.Count)
            {
                return;
            }

            DataPoint dp2 = s2.Points[depthBin];

            dp2.Label          = volSampled.ToString("#0.00") + "m^3";
            dp2.Color          = Color.Red;
            dp2.Font           = dataPointFont;
            dp2.MarkerStyle    = MarkerStyle.Circle;
            dp2.MarkerSize     = s.MarkerSize * 3;
            dp2.MarkerColor    = Color.Red;
            dp2.LabelBackColor = Color.White;

            selectedDepthBin = depthBin;
        } /* HighLightSizeBucket */
Exemplo n.º 3
0
        } /* 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 */
Exemplo n.º 4
0
        } /* 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 */