示例#1
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 */
示例#2
0
        } /* ReadNextScanLine */

        public void  SaveRawCtdData(StreamWriter sw,
                                    PicesMsgQueue msgQueue,
                                    ref bool successful
                                    )
        {
            ulong  bytesRead    = 0;
            ulong  bytesWritten = 0;
            ushort rec          = GetNextRecord();

            ulong tenMeg = 10 * 1024 * 1024;

            while (!eof)
            {
                bytesRead += 2;

                if ((msgQueue != null) && ((bytesRead % tenMeg) == 0))
                {
                    msgQueue.AddMsg("Bytes Read: " + bytesRead.ToString("##,###,###,##0") + "\t" +
                                    "Ctd-Data-Written: " + bytesWritten.ToString("##,###,###,##0")
                                    );
                }

                //if  (bytesRead >=  377711000)
                {
                    Sipper3DecodeRec dr = decodeRecs[rec];
                    if (!dr.ImageData())
                    {
                        byte deviceId = dr.SensorNum();
                        if ((deviceId == 16) && dr.Text())
                        {
                            sw.Write(dr.SensorData());
                            ++bytesWritten;
                        }
                    }
                }
                rec = GetNextRecord();
            }

            if (msgQueue != null)
            {
                msgQueue.AddMsg("");
                msgQueue.AddMsg("Done Scanning");
                msgQueue.AddMsg("Bytes Read: " + bytesRead.ToString("##,###,###,##0") + "\t" +
                                "Ctd-Data-Written: " + bytesWritten.ToString("##,###,###,##0")
                                );
            }

            successful = true;
        } /* SaveRawCtdData */
示例#3
0
        } /* AddCruiseToSeries */

        /// <summary>
        /// This next 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;

            timeInterval = (int)TimeInterval.Value;

            series = new List <DataSeriesToPlot> ();
            foreach (PlotRequest pr in plotRequests)
            {
                if (cancelRequested)
                {
                    break;
                }
                AddDeploymentToSeries(pr.deployment, pr.color);
            }

            if (plotCruise && (!cancelRequested))
            {
                AddCruiseToSeries();
            }

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

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

            buildPlotDataRunning = false;
            buildPlotDataDone    = true;
        } /* BuildPlotData */
示例#4
0
        } /* ForceCancelation */

        private void  LogMessagesAdd(String msg)
        {
            if (logMessages == null)
            {
                logMessages = new PicesMsgQueue("TrainingModelStatus");
            }
            logMessages.AddMsg(msg);
        }
示例#5
0
        Sipper3File  OpenSipperFile(String sipperFileName)
        {
            bool validSipper3 = false;

            Sipper3File sipperFile = null;

            try
            {
                sipperFile   = new Sipper3File(sipperFileName, null);
                validSipper3 = sipperFile.ValidateFormat();
            }
            catch (Exception e)
            {
                msgQueue.AddMsg("Exception opening SipperFile[" + sipperFileName + "]" + "\n" + e.ToString());
                sipperFile   = null;
                validSipper3 = false;
            }
            return(sipperFile);
        }
示例#6
0
        private float[]  CountsByDepth(PicesClass c,
                                       char classKeyToUse
                                       )
        {
            String predOrValStr = "Validated";

            if (classKeyToUse != 'V')
            {
                predOrValStr = "Predicted";
            }

            String msg = "Extracting Counts for \"" + c.Name + "\"" + "  " + predOrValStr;

            statusMsgs.AddMsg(msg);
            msgQueue.AddMsg(msg);

            uint[] counts = null;

            PicesSipperFileList sipperFiles = threadConn.SipperFileLoad(cruise, station, deployment);

            foreach (PicesSipperFile sf in sipperFiles)
            {
                if (cancelRequested)
                {
                    break;
                }

                msg = "Retrieving counts for Class[" + c.Name + "]  SipperFile[" + sf.SipperFileName + "]" + predOrValStr;
                statusMsgs.AddMsg("Retrieving counts for Class[" + c.Name + "]  SipperFile[" + sf.SipperFileName + "]");

                uint[] countsThisSipperFile
                    = threadConn.ImageGetDepthStatistics(group,          // PicesDataBaseImageGroup^  imageGroup,
                                                         sf.SipperFileName,
                                                         depthIncrement, // depthIncrements,
                                                         c,              // mlClass,
                                                         classKeyToUse,  // classKeyToUse,
                                                         probMin, probMax,
                                                         sizeMin, sizeMax
                                                         );

                counts = MergeTwoLists(counts, countsThisSipperFile);
            }

            if (cancelRequested)
            {
                return(null);
            }

            if (counts == null)
            {
                counts    = new uint[1];
                counts[0] = 0;
            }

            float[] countsFloat = new float[counts.Length];
            for (int idx = 0; idx < counts.Length; ++idx)
            {
                countsFloat[idx] = counts[idx];
            }

            if (!includeSubClasses)
            {
                return(countsFloat);
            }

            List <PicesClass> children = c.Children;

            if (children != null)
            {
                foreach (PicesClass pc in children)
                {
                    if (cancelRequested)
                    {
                        break;
                    }

                    float[] countsForChild = CountsByDepth(pc, classKeyToUse);
                    if (countsForChild != null)
                    {
                        countsFloat = MergeTwoLists(countsFloat, countsForChild);
                    }
                }
            }
            return(countsFloat);
        } /* CountsByDepth */
示例#7
0
 private void  RunLogAddMsg(String msg)
 {
     runLogMsgQueue.AddMsg(msg);
 } /* RunLogAddMsg */
示例#8
0
        } /* GradeAgainstGroundTruth */

        private void  GradeAgainstCrossValidationRun()
        {
            if (curSelModel == null)
            {
                curSelModel = new PicesTrainingConfigManaged(configFileName, runLog);
            }

            if (!curSelModel.Valid())
            {
                MessageBox.Show("Configuration File[" + configFileName + "] is not valid");
                return;
            }

            bool changesMade            = false;
            PicesFeatureVectorList data = curSelModel.LoadFeatureDataFromTrainingLibraries(changesMade);

            if (cancelProcessing)
            {
                data = null;
                return;
            }

            if (data == null)
            {
                MessageBox.Show("No data was loaded from Configuration File[" + configFileName + "] is not valid");
                return;
            }

            PicesFeatureVectorList examples = data.StratifyAmoungstClasses(numOfFolds);

            int imageCount       = examples.Count;
            int numImagesPerFold = (imageCount + numOfFolds - 1) / numOfFolds;

            int firstInGroup = 0;

            int foldNum;

            for (foldNum = 0; foldNum < numOfFolds; foldNum++)
            {
                int lastInGroup;

                // If We are doing the last Fold Make sure that we are including all the examples
                // that have not been tested.
                if (foldNum == (numOfFolds - 1))
                {
                    lastInGroup = imageCount;
                }
                else
                {
                    lastInGroup = firstInGroup + numImagesPerFold - 1;
                }

                PicesFeatureVectorList trainingImages = new PicesFeatureVectorList();
                PicesFeatureVectorList testImages     = new PicesFeatureVectorList();

                for (int x = 0; (x < imageCount) && (!cancelProcessing); x++)
                {
                    PicesFeatureVector newImage = new PicesFeatureVector(examples[x]);

                    if ((x >= firstInGroup) && (x <= lastInGroup))
                    {
                        testImages.Add(newImage);
                    }
                    else
                    {
                        trainingImages.Add(newImage);
                    }
                }

                if (cancelProcessing)
                {
                    break;
                }

                CrossValidate(testImages, trainingImages, foldNum);

                firstInGroup = firstInGroup + numImagesPerFold;
            }

            if (!cancelProcessing)
            {
                if (trainingModel != null)
                {
                    trainingModel = null;
                }

                msgQueue.AddMsg("\n" + "Building Final Classifier for User Query");
                trainingModel = new TrainingModel2(runLog, curSelModel);
                trainingModel.BuildTrainingModel(data);
            }

            if ((!cancelProcessing) && (trainingModel != null) && (!trainingModel.Valid))
            {
                MessageBox.Show("Error Loading Training Model;  refer to dialog box");
                cancelProcessing = true;
            }

            else if (!cancelProcessing)
            {
                confusionMatrix.SetTrainingModel(trainingModel);
            }

            // We no longer need the Training Model or Ground Truth loaded
            BlockStart();
            data = null;
            BlockEnd();
        } /* GradeAgainstCrossValidationRun */
 private void  AddMsgToDialogMsgQueue(String s)
 {
     dialogMsgQueue.AddMsg(s);
 } /* AddMsgToDialogMsgQueue */