Ejemplo n.º 1
0
        } /* LoadAllImages */

        /*
         * 2013-03-14  Kurt Kramer,  as per email from A. Remsen
         * Commenting out this procedure because the database only consists of Oil cruises
         * It was originally created when there were only a few deployments that had images
         * identified as oil.
         *
         *
         * private List<ImageEntry>  LoadOilDeploymentImages ()
         * {
         * RunLogAddMsg ("Loading Source Images\n");
         *
         * List<ImageEntry>  allImages = new List<ImageEntry> ();
         *
         * {
         *  List<String[]> sipperFileNamesList = new List<String[]>();
         *  sipperFileNamesList.Add(dbConn.SipperFileGetList ("SMP751001", "034", ""));
         *  sipperFileNamesList.Add(dbConn.SipperFileGetList ("SMP751001", "035", ""));
         *  sipperFileNamesList.Add(dbConn.SipperFileGetList ("SMP751001", "037", ""));
         *
         *  int  totalNumSipperFiles = sipperFileNamesList[0].Length + sipperFileNamesList[1].Length + sipperFileNamesList[2].Length;
         *  sipperFileNames = new String[totalNumSipperFiles];
         *  int  sipperFileNum = 0;
         *  foreach  (String[]  names in sipperFileNamesList)
         *  {
         *    foreach  (String  sipperFileName in names)
         *    {
         *      sipperFileNames[sipperFileNum] = sipperFileName;
         *      sipperFileNum++;
         *    }
         *  }
         * }
         *
         * foreach  (String sipperFileName in sipperFileNames)
         * {
         *  if  (cancelHarvesting)
         *    break;
         *
         *  RunLogAddMsg ("Loading Sipper File[" + sipperFileName + "]" + "\n");
         *
         *  PicesDataBaseImageList  images = dbConn.ImagesQuery (null,               // ImageGroup
         *                                                       sipperFileName,
         *                                                       selClass,           //
         *                                                       classKeyToUse,      //
         *                                                       0.0f, 1.0f,         //  Prob  Min and Max
         *                                                       sizeMin,  sizeMax,  //  Size  Min and Max
         *                                                       0,    0,            //  Depth Min and Max
         *                                                       0,                  //  restartImageFileName
         *                                                       -1,                 //  limit to load  -1 = Load All
         *                                                       false               //  false = Don't load thumbnail
         *                                                      );
         *
         *  if  (images == null)
         *  {
         *    RunLogAddMsg ("Loading Sipper File[" + sipperFileName + "]   No images found in database." + "\n");
         *  }
         *  else
         *  {
         *    foreach  (PicesDataBaseImage  i in images)
         *    {
         *      float  depth = i.Depth;
         *      if  (depth >= minimumDepth)
         *        allImages.Add (new ImageEntry (i.ImageId, depth));
         *    }
         *    RunLogAddMsg ("Loading Sipper File[" + sipperFileName + "]   [" + images.Count.ToString ("##,###,##0") + "] Loaded" + "\n");
         *  }
         * }
         *
         * return  allImages;
         * }  /* LoadOilDeploymentImages * /
         */



        //* Will build an array that will represent the times spent at each depth increment.
        //* This will be done by scanning the InstrumentData for all the sipper files involved
        //* and counting the number of scan lines at each depth.
        private double[]   LoadDepthTimeProfile(PicesDataBase connThread)
        {
            RunLogAddMsg("Extracting Depth/Time profile" + "\n");

            int numIncrements = (int)Math.Floor((float)maxDepth / (float)depthIncrement);

            double[] depthTimeProfile = new double[numIncrements];


            foreach (String sipperFileName in sipperFileNames)
            {
                if (cancelHarvesting)
                {
                    break;
                }

                RunLogAddMsg("Loading InstrumentData   Sipper File[" + sipperFileName + "]" + "\n");

                PicesInstrumentDataList data = connThread.InstrumentDataLoad(sipperFileName);
                if ((data == null) || (data.Count < 1))
                {
                    RunLogAddMsg("Loading InstrumentData   Sipper File[" + sipperFileName + "]  NO DATA LOADED" + "\n");
                }
                else
                {
                    RunLogAddMsg("Loading InstrumentData   Sipper File[" + sipperFileName + "]  [" + data.Count.ToString("###,##0") + "] Entries loaded" + "\n");
                    uint lastScanLine = data[0].ScanLine;
                    for (int idx = 1; idx < data.Count; idx++)
                    {
                        PicesInstrumentData id = data[idx];
                        uint scanLine          = id.ScanLine;
                        uint deltaScanLines    = scanLine - lastScanLine;

                        int depthIdx = (int)Math.Floor(id.Depth / depthIncrement);
                        if (depthIdx < 0)
                        {
                            depthIdx = 0;
                        }
                        else if (depthIdx >= depthTimeProfile.Length)
                        {
                            depthIdx = depthTimeProfile.Length - 1;
                        }

                        depthTimeProfile[depthIdx] += (double)deltaScanLines;

                        lastScanLine = scanLine;
                    }
                }
            }

            return(depthTimeProfile);
        } /* LoadDepthTimeProfile */
Ejemplo n.º 2
0
        } /* DatePicesInstrumentComparer */

        private void  SummarizeInstrumentDataForADeployment()
        {
            PicesInstrumentDataList data = dbConn.InstrumentDataLoad(cruiseName, stationName, deploymentNum);

            // We will assume that all entries are in order of date and time.  We want
            // to first decide where the break in UpCast and Down cast occur.

            if ((data == null) || (data.Count < 1))
            {
                MessageBox.Show("There is no Instrument Data for Cruise[" + cruiseName + "]  Station[" + stationName + " Deployment [" + deploymentNum + "]");
                return;
            }


            // Will now locate the InstrumentData record that separates the DownCast from the UpCast
            data.Sort(DatePicesInstrumentComparer);
            int   idx;
            float maxDepth    = -9999.9f;
            int   maxDepthIdx = -9999;

            for (idx = 0; idx < data.Count; idx++)
            {
                if (data[idx].Depth > maxDepth)
                {
                    maxDepth    = data[idx].Depth;
                    maxDepthIdx = idx;
                }
            }

            DateTime refTime      = new DateTime(1999, 1, 1);
            DateTime startTime    = new DateTime(1999, 1, 1);
            bool     startTimeSet = false;

            InstrumentDataList downCast = new InstrumentDataList();
            InstrumentDataList upCast   = new InstrumentDataList();

            for (idx = 0; idx < data.Count; idx++)
            {
                PicesInstrumentData pid = data[idx];
                if (pid.CtdDate.CompareTo(refTime) < 0)
                {
                    continue;
                }

                if ((idx % 4) == 0)
                {
                    if (!startTimeSet)
                    {
                        startTime    = pid.CtdDate;
                        startTimeSet = true;
                    }

                    if (idx <= maxDepthIdx)
                    {
                        downCast.Add(new InstrumentData(pid));
                    }
                    else
                    {
                        upCast.Add(new InstrumentData(pid));
                    }
                }
            }

            DateTime endTime = data[data.Count - 1].CtdDate;

            data = null;

            String title = cruiseName + "-" + stationName + "-" + deploymentNum + "  From [" + startTime.ToString("u") + "]  to  [" + endTime.ToString("u") + "]";

            {
                upCastPlot = new DepthPlot2(configRec, downCast, title + "    Down Cast");
                upCastPlot.Show(parent);
            }

            {
                downCastPlot = new DepthPlot2(configRec, upCast, title + "    Up Cast");
                downCastPlot.Show(parent);
            }
        } /* SummarizeInstrumentDataForADeployment */
Ejemplo n.º 3
0
        } /* LoadImageDepthStats */

        private void  SummarizeInstrumentDataForADeployment(PicesDataBase threadConn,
                                                            String cruiseName,
                                                            String stationName,
                                                            String deploymentNum
                                                            )
        {
            RunLogAddMsg("\nStart Report " + cruiseName + "-" + stationName + "-" + deploymentNum);

            PicesInstrumentDataList data = threadConn.InstrumentDataLoad(cruiseName, stationName, deploymentNum);

            // We will assume that all entries are in order of date and time.  We want
            // to first decide where the break in UpCast and Down cast occur.

            if (cancelBackGround)
            {
                return;
            }

            data = StripOutObviouslyBadrecs(data);
            if ((data == null) || (data.Count < 1))
            {
                RunLogAddMsg("There is no Instrument Data for Cruise[" + cruiseName + "]  Station[" + stationName + "]  Deployment [" + deploymentNum + "]");
                return;
            }

            RunLogAddMsg("Number Entries Loaded[" + data.Count.ToString() + "]");

            data.Sort(DatePicesInstrumentComparer);

            int   idx;
            float maxDepth    = -9999.9f;
            int   maxDepthIdx = -9999;

            for (idx = 0; idx < data.Count; idx++)
            {
                if (data[idx].Depth > maxDepth)
                {
                    maxDepth    = data[idx].Depth;
                    maxDepthIdx = idx;
                }
            }

            DateTime refTime      = new DateTime(1999, 1, 1);
            DateTime startTime    = new DateTime(1999, 1, 1);
            bool     startTimeSet = false;

            InstrumentDataList downCast = new InstrumentDataList();
            InstrumentDataList upCast   = new InstrumentDataList();


            for (idx = 0; idx < data.Count; idx++)
            {
                PicesInstrumentData pid = data[idx];
                if (pid.CtdDate.CompareTo(refTime) < 0)
                {
                    continue;
                }

                if (!startTimeSet)
                {
                    startTime    = pid.CtdDate;
                    startTimeSet = true;
                }

                if (idx <= maxDepthIdx)
                {
                    downCast.Add(new InstrumentData(pid));
                }
                else
                {
                    upCast.Add(new InstrumentData(pid));
                }
            }

            DateTime endTime = data[data.Count - 1].CtdDate;

            data = null;

            String title = cruiseName + "-" + stationName + "-" + deploymentNum + "  From [" + startTime.ToString("u") + "]  to  [" + endTime.ToString("u") + "]";

            reportFileName = OSservices.AddSlash(reportFileDir) +
                             cruiseName + "-" +
                             stationName + "-" +
                             deploymentNum;

            if (mlClass != null)
            {
                reportFileName += "-" + mlClass.Name;
            }
            reportFileName += "_InsrumentSumary.txt";

            System.IO.StreamWriter o = null;

            try
            {
                o = new System.IO.StreamWriter(reportFileName);
            }
            catch (Exception e)
            {
                RunLogAddMsg("Error opening file[" + reportFileName + "] for output." + "\n\n" + e.ToString());
                return;
            }

            if (threadConn != null)
            {
                o.WriteLine("DataBase" + "\t" + threadConn.Server.DataBaseName);
            }

            o.WriteLine("Cruise" + "\t" + cruiseName);
            o.WriteLine("Station" + "\t" + stationName);
            o.WriteLine("Deployment" + "\t" + deploymentNum);
            o.WriteLine("StartTime" + "\t" + startTime.ToString("u"));
            o.WriteLine("EndTime" + "\t" + endTime.ToString("u"));
            o.WriteLine();

            float scanRateMin = 0.0f;
            float scanRateMax = 0.0f;
            float scanRate    = 0.0f;


            RunLogAddMsg("Getting Particle Counts");

            List <ImagesDepthStats> downCastImageStats = null;
            List <ImagesDepthStats> upCastImageStats   = null;

            LoadImageDepthStats(threadConn, cruiseName, stationName, deploymentNum, ref downCastImageStats, ref upCastImageStats);

            RunLogAddMsg("Determining Scan Rate");
            FindScanRates(threadConn, cruiseName, stationName, deploymentNum, ref scanRateMin, ref scanRateMax);

            if (scanRateMin == scanRateMax)
            {
                scanRate = scanRateMin;
                RunLogAddMsg("ScanRate [" + scanRateMin.ToString("###,##0.00") + "]");
            }
            else
            {
                RunLogAddMsg("Scan Rates Were not consistent,  you should update Sipper Files.");
                RunLogAddMsg("   scanRateMin [" + scanRateMin.ToString("###,##0.00") + "]" +
                             "   scanRateMax [" + scanRateMax.ToString("###,##0.00") + "]"
                             );

                o.WriteLine("Scan Rates Were not consistent,  you should update Sipper Files.");
                o.WriteLine("   scanRateMin [" + scanRateMin.ToString("###,##0.00") + "]" +
                            "   scanRateMax [" + scanRateMax.ToString("###,##0.00") + "]"
                            );
                o.WriteLine();
            }

            o.WriteLine("ScanRate" + "\t" + scanRateMin.ToString("###,##0.00"));

            o.WriteLine();
            o.WriteLine();

            o.WriteLine("Depth" + "\t" +
                        "ScanLines" + "\t" +
                        "Duration" + "\t" +
                        "ImageCount" + "\t" +
                        "TotalPixelCount" + "\t" +
                        "FlowRate" + "\t" + "\t" +
                        "Temperature" + "\t" + "\t" +
                        "Oxygen" + "\t" + "\t" +
                        "OxygenSensor" + "\t" + "\t" +
                        "Salinity" + "\t" + "\t" +
                        "Density" + "\t" + "\t" +
                        "Fluoresce" + "\t" + "\t" +
                        "FluorensceSensor" + "\t" + "\t" +
                        "Transitivity" + "\t" + "\t" +
                        "TransmissivitySensor" + "\t" + "\t" +
                        "Turbidity" + "\t" + "\t" +
                        "TurbiditySensor" + "\t" + "\t" +
                        "RecordRate"
                        );

            WriteDepthSummary(o, downCast, downCastImageStats, scanRate);
            o.WriteLine();
            if (!cancelBackGround)
            {
                WriteDepthSummary(o, upCast, upCastImageStats, scanRate);
            }

            if (cancelBackGround)
            {
                o.WriteLine();
                o.WriteLine();
                o.WriteLine();
                o.WriteLine("Report Canceled by user request");
            }

            o.Close();
        } /* SummarizeInstrumentDataForADeployment */