} /* ConfigurationLoad */ private void ConfigurationSave() { if (dataFieldAssignments == null) { return; } if (String.IsNullOrEmpty(configFileName)) { return; } System.IO.StreamWriter o = null; try{ o = new System.IO.StreamWriter(configFileName); } catch (Exception) { o = null; return; } o.WriteLine("//ImageViewer Configuration File"); o.WriteLine("//"); o.WriteLine("//DateTime Saved" + "\t" + DateTime.Now.ToString("F")); o.WriteLine("//"); o.WriteLine("DataLabel0" + "\t" + PicesInstrumentData.FieldName(dataFieldAssignments[0])); o.WriteLine("DataLabel1" + "\t" + PicesInstrumentData.FieldName(dataFieldAssignments[1])); o.WriteLine("DataLabel2" + "\t" + PicesInstrumentData.FieldName(dataFieldAssignments[2])); o.WriteLine("DataLabel3" + "\t" + PicesInstrumentData.FieldName(dataFieldAssignments[3])); o.Close(); o = null; } /* ConfigurationSave*/
} /* Show */ private int DatePicesInstrumentComparer(PicesInstrumentData i1, PicesInstrumentData i2 ) { if (i1.CtdDate < i2.CtdDate) { return(-1); } else if (i1.CtdDate > i2.CtdDate) { return(1); } else if (i1.Depth < i2.Depth) { return(-1); } else if (i1.Depth > i2.Depth) { return(1); } return(i1.ScanLine.CompareTo(i2.ScanLine)); } /* DatePicesInstrumentComparer */
private void BuildDataFieldList() { int origWindowHeight = this.Height; int origDataFieldListHeight = DataFieldList.Height; int origWindowWidth = this.Width; int origDataFieldListWidth = DataFieldList.Width; int fieldNum = 0; for (fieldNum = 0; fieldNum < PicesInstrumentData.NumFields(); fieldNum++) { DataFieldList.Items.Add(PicesInstrumentData.FieldName(fieldNum)); } DataFieldList.SelectedItem = selectedDataField; int totalHeightNeeded = PicesInstrumentData.NumFields() * DataFieldList.ItemHeight + 30; DataFieldList.Height = totalHeightNeeded; int newWindowHeight = DataFieldList.Height + (origWindowHeight - origDataFieldListHeight); int newWindowWidth = DataFieldList.Width + (origWindowWidth - origDataFieldListWidth); this.Height = newWindowHeight; this.Width = newWindowWidth; }
public PredictionBreakDownDisplay(PicesDataBase _dbConn, PicesDataBaseImage _image, PicesRaster _raster, TrainingModel2 _trainingModel, PicesInstrumentData _instrumentData, /*!< Instrument data that goes with image, if null will read from database. */ PicesRunLog _runLog ) { if (_runLog == null) { runLog = new PicesRunLog(); } else { runLog = _runLog; } if (_image == null) { return; } fileName = _image.ImageFileName; instrumentData = _instrumentData; trainingModel = _trainingModel; PicesRaster raster = _raster; if (_dbConn != null) { if (raster == null) { raster = _dbConn.ImageFullSizeFind(fileName); } if (instrumentData == null) { instrumentData = _dbConn.InstrumentDataGetByScanLine(_image.SipperFileName, _image.TopLeftRow); } dbFeatureVector = _dbConn.FeatureDataRecLoad(fileName); } if (raster == null) { return; } //raster = raster.ConnectedComponent (); featureCalcImages = new PicesRasterList(); featureVector = new PicesFeatureVector(raster, fileName, featureCalcImages, runLog); if (instrumentData != null) { featureVector.AddInstrumentData(instrumentData); } InitializeComponent(); }
/// <summary> /// Using supplied 'Raster' data it will call each currently active model and return there predictions. /// </summary> /// <param name="raster">Raster of image to predict. .</param> /// <param name="instrumentData">Instrument data that was recorded with the 'raster' .</param> /// <param name="imageFileName">Name of the image file.</param> /// <param name="model1Predictions">The model1 predictions.</param> /// <param name="model2Predictions">The model2 predictions.</param> /// <param name="runLog">The run log.</param> public static void MakePredictions(PicesRaster raster, InstrumentData instrumentData, String imageFileName, ref PicesPredictionList model1Predictions, ref PicesPredictionList model2Predictions, PicesRunLog runLog ) { model1Predictions = null; model2Predictions = null; if (!ModelsAreAvailable()) { return; } ParsedImageFileName pifn = PicesFeatureVector.ParseImageFileName(imageFileName); String sipperFileName = pifn.sipperFileName; uint scanLineNum = pifn.scanLineNum; PicesFeatureVector fv = new PicesFeatureVector(raster, imageFileName, null, runLog); if (instrumentData != null) { fv.AddInstrumentData(instrumentData.Depth(), instrumentData.Salinity(), instrumentData.Oxygen(), instrumentData.Fluorescence() ); } else { PicesDataBase dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); PicesInstrumentData pid = dbConn.InstrumentDataGetByScanLine(sipperFileName, scanLineNum); if (pid != null) { fv.AddInstrumentData(pid); } pid = null; dbConn.Close(); dbConn = null; } if (model1 != null) { model1Predictions = model1.PredictProbabilities(fv); } if (model2 != null) { model2Predictions = model2.PredictProbabilities(fv); } fv = null; return; } /* MakePredictions */
} /* CreateFeatureDataFileThread */ void MakeSureDepthFieldIsIncluded(PicesFeatureVectorList data) { PicesDataBase dbConn = null; PicesRunLog runLog = new PicesRunLog(dialogMsgQueue); data.SortByImageFileName(); String curSipperFileName = ""; float curSipperFileDepth = 0.0f; foreach (PicesFeatureVector fv in data) { if (fv.Depth == 0.0f) { if (dbConn == null) { dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); } uint sacnLineNum = 0; uint scanCol = 0; String nextSipperFileName = ""; PicesFeatureVector.ParseImageFileName(fv.ExampleFileName, ref nextSipperFileName, ref sacnLineNum, ref scanCol); if (nextSipperFileName != curSipperFileName) { curSipperFileDepth = 0.0f; curSipperFileName = nextSipperFileName; PicesSipperFile sf = dbConn.SipperFileRecLoad(curSipperFileName); if (sf != null) { curSipperFileDepth = sf.Depth; } } PicesInstrumentData id = dbConn.InstrumentDataGetByScanLine(curSipperFileName, sacnLineNum); if ((id == null) || (id.Depth == 0.0)) { fv.Depth = curSipperFileDepth; } else { fv.Depth = id.Depth; } } } if (dbConn != null) { dbConn.Close(); dbConn = null; GC.Collect(); } } /* MakeSureDepthFieldIsIncluded */
private PicesPredictionList PredictClasses(PicesFeatureVector fv, PicesPrediction pred1, PicesPrediction pred2, String imageFileName, String imageFileRootName ) { PicesFeatureVector fvToUse = fv; PicesPredictionList probPredList = null; if (fvToUse.FeatureDataMissing) { fvToUse = null; // Feature data is missing. we need to compute from original image. PicesDataBaseImage pdbi = DbConn().ImageLoad(imageFileRootName); if (pdbi != null) { PicesRaster pr = DbConn().ImageFullSizeFind(imageFileRootName); if (pr == null) { ErrorMsgsAdd("Failed to Load FullSize image [" + imageFileRootName + "]"); } else { fvToUse = new PicesFeatureVector(pr, imageFileName, null, runLog); // Since we had to compute the FeatureDatya from the raster image we now need to // get the instrument data that matches it. PicesInstrumentData id = DbConn().InstrumentDataGetByScanLine(pdbi.SipperFileName, pdbi.TopLeftRow); if (id != null) { fvToUse.AddInstrumentData(id); } DbConn().FeatureDataInsertRow(pdbi.SipperFileName, fvToUse); pr.Dispose(); } pr = null; } } if (fvToUse != null) { classifier.PredictClass(fvToUse, pred1, pred2); probPredList = classifier.PredictProbabilities(fvToUse); } else { pred1.MLClass = PicesClassList.GetUnKnownClassStatic(); pred1.Probability = 1.0f; pred2.MLClass = PicesClassList.GetUnKnownClassStatic(); pred2.Probability = 0.0f; } return(probPredList); } /* PredictClasses */
private void ConfigurationLoad() { configFileName = OSservices.AddSlash(PicesSipperVariables.ConfigurationDirectory()) + "ImageViewer.cfg"; System.IO.StreamReader i = null; dataFieldAssignments = new int[4]; dataFieldAssignments[0] = PicesInstrumentData.GetFieldNum("Depth"); dataFieldAssignments[1] = PicesInstrumentData.GetFieldNum("Temperature"); dataFieldAssignments[2] = PicesInstrumentData.GetFieldNum("Oxygen"); dataFieldAssignments[3] = PicesInstrumentData.GetFieldNum("Salinity"); try { i = new System.IO.StreamReader(configFileName); } catch (Exception) { i = null; } if (i != null) { String nextLine = null; while (true) { try { nextLine = i.ReadLine(); } catch (Exception) { break; } if (nextLine == null) { break; } nextLine = nextLine.Trim(); if ((nextLine.Length < 3) || (nextLine.Substring(0, 2) == "//")) { continue; } String[] fields = nextLine.Split('\t'); if (fields.Length != 2) { continue; } String fieldName = fields[0]; String fieldValue = fields[1]; switch (fieldName) { case "DataLabel0": dataFieldAssignments[0] = PicesInstrumentData.GetFieldNum(fieldValue); break; case "DataLabel1": dataFieldAssignments[1] = PicesInstrumentData.GetFieldNum(fieldValue); break; case "DataLabel2": dataFieldAssignments[2] = PicesInstrumentData.GetFieldNum(fieldValue); break; case "DataLabel3": dataFieldAssignments[3] = PicesInstrumentData.GetFieldNum(fieldValue); break; } } i.Close(); } } /* ConfigurationLoad */
public PredictionBreakDownDisplayDual(PicesDataBase _dbConn, String _fileName, TrainingModel2 _trainingModel, PicesInstrumentData _instrumentData, /**< Instrument data that goes with image, if null will read from dtabase. */ PicesRunLog _runLog ) { if (_runLog == null) { runLog = new PicesRunLog(); } else { runLog = _runLog; } fileName = _fileName; instrumentData = _instrumentData; trainingModel = _trainingModel; PicesDataBase dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); PicesRaster raster = dbConn.ImageFullSizeFind(fileName); if (raster == null) { return; } if (_dbConn != null) { dbFeatureVector = _dbConn.FeatureDataRecLoad(_fileName); if (instrumentData == null) { PicesDataBaseImage image = dbConn.ImageLoad(fileName); if (image != null) { instrumentData = dbConn.InstrumentDataGetByScanLine(image.SipperFileName, image.TopLeftRow); } } } featureVector = new PicesFeatureVector(raster, fileName, null, runLog); if (instrumentData != null) { featureVector.AddInstrumentData(instrumentData); } dbConn.Close(); dbConn = null; GC.Collect(); InitializeComponent(); }
} /* 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 */
} /* ConfigurationSave*/ private void UpdateDataFields() { if ((instrumentData == null) || (dataFieldAssignments == null)) { return; } for (int x = 0; x < DataLabels.Length; x++) { DataLabels [x].Text = PicesInstrumentData.FieldName(dataFieldAssignments[x]); displayDataFields[x].Text = instrumentData.FieldToStr(dataFieldAssignments[x]); } } /* UpdatedataFields*/
public InstrumentData(PicesInstrumentData picesData) { data = new float[numDataFields]; UpdateCTDDataFields(picesData.CTDBattery, // _batteryVolt, picesData.Conductivity, picesData.Density, picesData.Depth, picesData.Fluorescence, picesData.FluorescenceSensor, picesData.Oxygen, picesData.CdomFluorescence, picesData.CdomFluorescenceSensor, picesData.OxygenSensor, picesData.Pressure, picesData.Salinity, picesData.SoundVelocity, picesData.Temperature, picesData.Transmissivity, picesData.TransmissivitySensor, picesData.Turbidity, picesData.TurbiditySensor, picesData.CtdDate ); byteOffset = picesData.ByteOffset; FlowRate1 = picesData.FlowRate1; FlowRate2 = picesData.FlowRate2; longitude = picesData.Longitude; latitude = picesData.Latitude; RecordingRate = picesData.RecordRate; scanLine = (int)picesData.ScanLine; data[PitchIndex] = picesData.Pitch; data[RollIndex] = picesData.Roll; data[IlluminationIndex] = picesData.Illumination; data[RecordingRateIndex] = picesData.RecordRate; data[Bat1LevelIndex] = picesData.Bat1Level; data[Bat2LevelIndex] = picesData.Bat2Level; data[Bat3LevelIndex] = picesData.Bat3Level; data[Bat4LevelIndex] = picesData.Bat4Level; this.latitude = picesData.Latitude; this.longitude = picesData.Longitude; this.activeBattery = picesData.ActiveBattery; cropLeft = picesData.CropLeft; cropRight = picesData.CropRight; activeColumns = picesData.ActiveColumns; } /* InstrumentData */
private void SelectDataField(int dataLabelNum) { String existingSelField = DataLabels[dataLabelNum].Text; SelectAInstrumentDataField f = new SelectAInstrumentDataField(existingSelField); f.ShowDialog(); string newSelectedDataFieldStr = f.SelectedDataField; int fieldIdxNew = PicesInstrumentData.GetFieldNum(newSelectedDataFieldStr); if (fieldIdxNew >= 0) { dataFieldAssignments[dataLabelNum] = fieldIdxNew; DataLabels[dataLabelNum].Text = PicesInstrumentData.FieldName(fieldIdxNew); ConfigurationSave(); } UpdateDataFields(); } /* SelectDataField */
} /* MakePredictions */ public static void MakePredictions(PicesRaster raster, ref PicesPrediction model1Prediction1, ref PicesPrediction model1Prediction2, ref PicesPrediction model2Prediction1, ref PicesPrediction model2Prediction2, PicesRunLog runLog ) { String imageFileName = raster.FileName; ParsedImageFileName pifn = PicesFeatureVector.ParseImageFileName(imageFileName); String sipperFileName = pifn.sipperFileName; uint scanLineNum = pifn.scanLineNum; PicesFeatureVector fv = new PicesFeatureVector(raster, imageFileName, null, runLog); { PicesDataBase dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); PicesInstrumentData pid = dbConn.InstrumentDataGetByScanLine(sipperFileName, scanLineNum); if (pid != null) { fv.AddInstrumentData(pid); } pid = null; dbConn.Close(); dbConn = null; } MakePredictions(fv, ref model1Prediction1, ref model1Prediction2, ref model2Prediction1, ref model2Prediction2, runLog ); fv = null; }
private void SavePlanktonDataFile(PicesDataBaseImageList planktonData) { String errMsg = ""; StreamWriter sw = null; try { sw = new StreamWriter(dataFileName); } catch (Exception e1) { errMsg = e1.ToString(); } if (sw == null) { errMsg = "Could not open Data File[" + dataFileName + "]\n" + errMsg; return; } sw.WriteLine("//This file was generated by the PICESComander application."); sw.WriteLine(); sw.WriteLine("DateTime" + "\t" + DateTime.Now.ToString("yyyy/MM/dd - hh:mm:ss")); sw.WriteLine("DataBase" + "\t" + dbConn.ServerDescription()); sw.WriteLine("MachineName" + "\t" + System.Environment.MachineName); sw.WriteLine(); sw.WriteLine("//Selection Criteria"); WriteValue(sw, "GroupName", GroupName.Text); WriteValue(sw, "CruiseName", CruiseName.Text); WriteValue(sw, "StationName", StationName.Text); WriteValue(sw, "DeploymentNum", DeploymentNum.Text); WriteValue(sw, "SipperFile", SipperFile.Text); if (mlClass != null) { WriteValue(sw, "MLClass", mlClass.Name); } sw.WriteLine("Probability Min-Max" + "\t" + (100.0f * probMin).ToString("##0.00") + "\t" + (100.0f * probMax).ToString("##0.00")); if ((depthMin > 0.0f) || (depthMax > 0.0f)) { sw.WriteLine("Depth" + "\t" + depthMin.ToString("###0.00") + "\t" + depthMax.ToString("###0.00")); } if ((sizeMin > 0) || (sizeMax > 0)) { sw.WriteLine("Size" + "\t" + sizeMin.ToString("#####0") + "\t" + sizeMax.ToString("######0")); } sw.WriteLine("ClassKeyToUse" + "\t" + classKeyToUse.ToString()); sw.WriteLine(); sw.WriteLine("Count" + "\t" + planktonData.Count); sw.WriteLine(); sw.WriteLine("//Following specifies column headers."); sw.Write("ImageFileName"); sw.Write("\t"); sw.Write("Class1Name"); sw.Write("\t"); sw.Write("Class1Prob"); sw.Write("\t"); sw.Write("Class2Name"); sw.Write("\t"); sw.Write("Class2Prob"); sw.Write("\t"); sw.Write("Depth(M)"); sw.Write("\t"); sw.Write("PixelCount"); sw.Write("\t"); sw.Write("Height"); sw.Write("\t"); sw.Write("Width"); sw.Write("\t"); sw.Write("TopLeftRow"); sw.Write("\t"); sw.Write("TopLeftCol"); sw.Write("\t"); sw.Write("CtdDate"); sw.Write("\t"); sw.Write("Latitude"); sw.Write("\t"); sw.Write("Longitude"); sw.Write("\t"); sw.Write("Temperature(C)"); sw.WriteLine(); planktonData.Sort(PicesDataBaseImageList.SortOrderType.soSpatial, false); PicesInstrumentData id = null; uint nextScanLineThreshold = 0; String lastSipperFileName = ""; foreach (PicesDataBaseImage i in planktonData) { if ((i.TopLeftRow >= nextScanLineThreshold) || (i.SipperFileName != lastSipperFileName) ) { uint scanLineCleared = 0; uint scanLine = i.TopLeftRow; scanLine = 4096 * (uint)(scanLine / 4096); id = dbConn.InstrumentDataGetByScanLine(i.SipperFileName, scanLine); lastSipperFileName = i.SipperFileName; if (id == null) { scanLineCleared = scanLine; } else { scanLineCleared = id.ScanLine; if (scanLineCleared > scanLine) { if ((scanLineCleared - scanLine) > 4096) { id = null; } } } nextScanLineThreshold = scanLineCleared + 4096; } sw.Write(i.ImageFileName); sw.Write("\t"); sw.Write(i.Class1Name); sw.Write("\t"); sw.Write(i.Class1Prob.ToString("p")); sw.Write("\t"); sw.Write(i.Class2Name); sw.Write("\t"); sw.Write(i.Class2Prob.ToString("p")); sw.Write("\t"); sw.Write(i.Depth); sw.Write("\t"); sw.Write(i.PixelCount); sw.Write("\t"); sw.Write(i.Height); sw.Write("\t"); sw.Write(i.Width); sw.Write("\t"); sw.Write(i.TopLeftRow); sw.Write("\t"); sw.Write(i.TopLeftCol); if (id != null) { sw.Write("\t"); sw.Write(id.CtdDate.ToString("yyyy/MM/dd - HH:mm:ss")); sw.Write("\t"); sw.Write(id.Latitude); sw.Write("\t"); sw.Write(id.Longitude); sw.Write("\t"); sw.Write(id.Temperature); } sw.WriteLine(); ++imagesWritten; } sw.WriteLine("//All Data Written."); sw.Close(); }
public ImageViewer(PicesRaster _raster, PicesDataBaseImage _image, PicesClassList _classes ) { runLog = new PicesRunLog(); raster = _raster; classes = _classes; dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); image = _image; sizeCoordinates = image.SizeCoordinates; if (raster == null) { raster = PicesRaster.GetOrigSipperImage(image.SipperFileName, image.ByteOffset, image.TopLeftRow, image.TopLeftCol, image.Height, image.Width, image.ConnectedPixelDist, runLog ); } if (raster == null) { MessageBox.Show("Could not locate source image or SipperFile[" + image.SipperFileName + "]"); return; } { uint scanLine = image.TopLeftRow; scanLine = 4096 * (uint)(scanLine / 4096); instrumentData = dbConn.InstrumentDataGetByScanLine(image.SipperFileName, image.TopLeftRow); sipperFile = dbConn.SipperFileRecLoad(image.SipperFileName); } double pixelsPerScanLine = pixelsPerScanLineDefault; if (instrumentData != null) { if (instrumentData.ActiveColumns > 0) { pixelsPerScanLine = instrumentData.ActiveColumns; } if (instrumentData.FlowRate1 > 0.0) { flowRate1 = instrumentData.FlowRate1; } } if (sipperFile != null) { if (sipperFile.ScanRate > 0.0) { scanRate = sipperFile.ScanRate; } deployment = dbConn.SipperDeploymentLoad(sipperFile.CruiseName, sipperFile.StationName, sipperFile.DeploymentNum); if (deployment != null) { chamberWidth = deployment.ChamberWidth; } } if ((dataFieldAssignments == null) || (DataLabels == null)) { ConfigurationLoad(); } InitializeComponent(); if (image != null) { extractionLogEntry = dbConn.LogEntriesSelect(image.ExtractionLogEntryId); classLogEntry = dbConn.LogEntriesSelect(image.ClassLogEntryId); } mmPerPixelAccrossChamber = chamberWidth * mmPerMeter / pixelsPerScanLine; mmPerPixelWithFlow = mmPerMeter * flowRate1 / scanRate; DataLabels = new Label[4]; DataLabels[0] = DataLabel0; DataLabels[1] = DataLabel1; DataLabels[2] = DataLabel2; DataLabels[3] = DataLabel3; displayDataFields = new TextBox[4]; displayDataFields[0] = DataField0; displayDataFields[1] = DataField1; displayDataFields[2] = DataField2; displayDataFields[3] = DataField3; UpdateDataFields(); ImageFileName.Text = image.ImageFileName; }
} /* 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 */
} /* 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 */