Esempio n. 1
0
        public DisplayPicesImages(PicesDataBase _dbConn,
                                  PicesImageSizeDistribution _sizeDistribution,
                                  int _selectedSizeIndex,
                                  float _depthMin,
                                  float _depthMax,
                                  PicesDataBaseImageList _picesImages
                                  )
        {
            InitializeComponent();
            thumbNails = new List <FlowLayoutPanel> ();

            dbConn            = _dbConn;
            sizeDistribution  = _sizeDistribution;
            picesImages       = _picesImages;
            selectedSizeIndex = _selectedSizeIndex;
            depthMin          = _depthMin;
            depthMax          = _depthMax;

            float[] startValues = sizeDistribution.SizeStartValues();
            float[] endValues   = sizeDistribution.SizeEndValues();

            if ((selectedSizeIndex >= 0) && (selectedSizeIndex < startValues.Length))
            {
                String t = "Size Range [" + startValues[selectedSizeIndex].ToString("###,##0.000") + " - " + endValues[selectedSizeIndex].ToString("#,###,##0.000") + "]";
                if (depthMax > 0.0f)
                {
                    t = t + "   Depth Range [" + depthMin.ToString("##0.0") + " - " + depthMax.ToString("##0.0") + "]";
                }
                Text = t;
            }

            UpdateDisplayTimer.Enabled = true;
        }
Esempio n. 2
0
        private void  SizeDistributionForAClass(PicesClass c,
                                                bool includeChildren,
                                                ref PicesImageSizeDistribution downCastAcumulated,
                                                ref PicesImageSizeDistribution upCastAcumulated
                                                )
        {
            statusMsgs.AddMsg("Extracting for Class[" + c.Name + "]");
            sbyte ch = (sbyte)statistic;
            PicesImageSizeDistribution classDownCast = null;
            PicesImageSizeDistribution classUpCast   = null;

            threadConn.ImagesSizeDistributionByDepth(this.cruise, this.station, this.deployment, c.Name,
                                                     0.0f, // MaxDepth
                                                     5.0f,
                                                     ch,
                                                     initialSizeValue,
                                                     growthRate,
                                                     (float)MaxSizeField.Value,
                                                     ref classDownCast,
                                                     ref classUpCast
                                                     );

            if (classDownCast != null)
            {
                if (downCastAcumulated == null)
                {
                    downCastAcumulated = classDownCast;
                }
                else
                {
                    downCastAcumulated.AddIn(classDownCast, runLog);
                }
            }

            if (classUpCast != null)
            {
                if (upCastAcumulated == null)
                {
                    upCastAcumulated = classUpCast;
                }
                else
                {
                    upCastAcumulated.AddIn(classUpCast, runLog);
                }
            }

            if (includeChildren)
            {
                foreach (PicesClass pc in  c.Children)
                {
                    if (cancelRequested)
                    {
                        break;
                    }
                    SizeDistributionForAClass(pc, includeChildren, ref downCastAcumulated, ref upCastAcumulated);
                }
            }
        } /* SizeDistributionForAClass */
        public ChartSizeDepthDistribution(String _cruise,
                                          String _station,
                                          String _deployment,
                                          PicesClass _classToPlot,
                                          bool _includeSubClasses,
                                          char _statistic,
                                          String _cast,
                                          PicesImageSizeDistribution _sizeDistribution,
                                          int _selectedSizeBucket
                                          )
        {
            cruise            = _cruise;
            station           = _station;
            deployment        = _deployment;
            classToPlot       = _classToPlot;
            includeSubClasses = _includeSubClasses;
            cast               = _cast;
            statistic          = _statistic;
            sizeDistribution   = _sizeDistribution;
            selectedSizeBucket = _selectedSizeBucket;
            sizeStartValues    = sizeDistribution.SizeStartValues();
            sizeEndValues      = sizeDistribution.SizeEndValues();
            depthProfile       = sizeDistribution.DepthProfileForSizeBin((uint)selectedSizeBucket);
            volumeSampled      = sizeDistribution.VolumeSampledByDepthBucket();

            if ((selectedSizeBucket >= 0) && (selectedSizeBucket < sizeDistribution.NumSizeBuckets))
            {
                sizeStart = sizeStartValues[selectedSizeBucket];
                sizeEnd   = sizeEndValues  [selectedSizeBucket];
            }

            runLog = new PicesRunLog();

            mainWinConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            InitializeComponent();
        }
Esempio n. 4
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 */
Esempio n. 5
0
        } /* SizeDistributionForAClass */

        /// <summary>
        /// This method will be ran as a separate thread; it is responsible for collecting all the data needed to generate the plot.
        /// </summary>
        private void  BuildPlotData()
        {
            if (buildPlotDataRunning)
            {
                return;
            }

            PicesDataBase.ThreadInit();

            threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            buildPlotDataRunning = true;

            classToPlot = PicesClassList.GetUniqueClass(ClassToPlot.Text, "");

            sbyte ch = (sbyte)statistic;

            downCast = null;
            upCast   = null;

            goalie.StartBlock();

            SizeDistributionForAClass(classToPlot,
                                      IncludeSubClasses.Checked,
                                      ref downCast,
                                      ref upCast
                                      );

            if (cast == "Down")
            {
                bucketsDisplayed = downCast;
            }

            else if (cast == "Up")
            {
                bucketsDisplayed = upCast;
            }

            else
            {
                bucketsDisplayed = new PicesImageSizeDistribution(downCast);
                bucketsDisplayed.AddIn(upCast, runLog);
            }

            integratedDensityDistribution = bucketsDisplayed.IntegratedDensityDistribution();

            threadConn.Close();
            threadConn = null;
            GC.Collect();
            PicesDataBase.ThreadEnd();

            goalie.EndBlock();

            if (cancelRequested)
            {
                statusMsgs.AddMsg("Plotting of data CANCELLED!!!");
            }
            else
            {
                statusMsgs.AddMsg("Building of plot data completed !!!");
            }

            buildPlotDataRunning = false;
            buildPlotDataDone    = true;
        } /* BuildPlotData */
Esempio n. 6
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 */