Ejemplo n.º 1
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.º 2
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 */