} /* StdDev */ private ImagesDepthStats LocateImageDepthStats(List <ImagesDepthStats> imageStats, float depth ) { ImagesDepthStats result = null; if (imageStats == null) { return(null); } if (imageStats.Count < 2) { return(null); } float bucketSize = 1.0f; foreach (ImagesDepthStats ids in imageStats) { float top = ids.bucketDepth; float bot = top + bucketSize; if ((depth >= top) && (depth < bot)) { result = ids; break; } } return(result); } /* LocateImageDepthStats */
private void LoadImageDepthStats(PicesDataBase threadConn, String cruiseName, String stationName, String deploymentNum, ref List <ImagesDepthStats> downCast, ref List <ImagesDepthStats> upCast ) { String sqlStr = "call ImagesStatsByUpAndDownCast("; sqlStr += "\"" + cruiseName + "\"" + ", "; sqlStr += "\"" + stationName + "\"" + ", "; sqlStr += "\"" + deploymentNum + "\"" + ", "; if (mlClass == null) { sqlStr += "\"\", "; } else { sqlStr = "\"" + mlClass.Name + "\"" + ", "; } sqlStr += "1.0);"; downCast = null; upCast = null; String[] cols = { "UpCast", "BucketIdx", "BucketDepth", "ImageCount", "TotalPixelCount" }; String[][] results = threadConn.QueryStatement(sqlStr, cols); if (results == null) { RunLogAddMsg("Error Retrieving Images Cout Statistics."); RunLogAddMsg(threadConn.LastErrorDesc()); return; } downCast = new List <ImagesDepthStats> (); upCast = new List <ImagesDepthStats> (); foreach (String[] row in results) { bool goingUp = (row[0] == "1"); int bucketIdx = PicesKKStr.StrToInt(row[1]); float bucketDepth = PicesKKStr.StrToFloat(row[2]); int imageCount = PicesKKStr.StrToInt(row[3]); int totalPixelCount = PicesKKStr.StrToInt(row[4]); ImagesDepthStats stats = new ImagesDepthStats(goingUp, bucketIdx, bucketDepth, imageCount, totalPixelCount); if (!goingUp) { downCast.Add(stats); } else { upCast.Add(stats); } } return; } /* LoadImageDepthStats */
} /* LocateImageDepthStats */ private void WriteDepthSummary(System.IO.StreamWriter o, InstrumentDataList cast, List <ImagesDepthStats> imageStats, float scanRate ) { int zed = 0; cast.SortByDepth(); InstrumentData id = (InstrumentData)(cast[0]); while ((id != null) && (!cancelBackGround)) { id = (InstrumentData)cast[zed]; int lastDepth = (int)Math.Round(id.Depth()); uint scanLinesThisDepth = 0; List <float> flowRate = new List <float> (); List <float> temperature = new List <float> (); List <float> oxygen = new List <float> (); List <float> oxygenSensor = new List <float> (); List <float> salinity = new List <float> (); List <float> density = new List <float> (); List <float> fluorensce = new List <float> (); List <float> fluorensceSensor = new List <float> (); List <float> transmissivity = new List <float> (); List <float> transmissivitySensor = new List <float> (); List <float> turbidity = new List <float> (); List <float> turbiditySensor = new List <float> (); List <float> recordRate = new List <float> (); while ((lastDepth == (int)Math.Round(id.Depth())) && (id != null)) { if ((id.Temperature() > 0.0f) && (id.Temperature() <= 40.0f) && (id.Salinity() > 20.0f) && (id.Salinity() <= 40.0f) && (id.Density() > 18.0f) && (id.Density() <= 40.0f) && (id.Fluorescence() > -2.0f) ) { flowRate.Add(id.FlowRate1); temperature.Add(id.Temperature()); salinity.Add(id.Salinity()); density.Add(id.Density()); fluorensce.Add(id.Fluorescence()); fluorensceSensor.Add(id.FluorescenceSensor()); transmissivity.Add(id.Transmissivity()); transmissivitySensor.Add(id.TransmissivitySensor()); turbidity.Add(id.Turbidity()); turbiditySensor.Add(id.TurbiditySensor()); recordRate.Add(id.RecordingRate); oxygen.Add(id.Oxygen()); oxygenSensor.Add(id.OxygenSensor()); scanLinesThisDepth += 4096; } zed++; if (zed < cast.Count) { id = (InstrumentData)cast[zed]; } else { id = null; break; } } float timeAtThisDepth = 0.0f; if (scanRate > 0.0f) { timeAtThisDepth = scanLinesThisDepth / scanRate; } int imageCount = 0; int totalPixelCount = 0; ImagesDepthStats ids = LocateImageDepthStats(imageStats, lastDepth); if (ids != null) { if (ids.counted) { RunLogAddMsg("WriteDepthSummary Duplicate Use of Cast[" + (ids.upCast ? "Up":"Down") + "] Depth[" + ids.bucketDepth + "] Count[" + ids.imageCount + "]"); } else { imageCount = ids.imageCount; totalPixelCount = ids.totalPixelCount; ids.counted = true; } } o.WriteLine(lastDepth.ToString() + "\t" + scanLinesThisDepth.ToString() + "\t" + timeAtThisDepth.ToString() + "\t" + imageCount.ToString() + "\t" + totalPixelCount.ToString() + "\t" + Mean(flowRate).ToString() + "\t" + StdDev(flowRate).ToString() + "\t" + Mean(temperature).ToString() + "\t" + StdDev(temperature).ToString() + "\t" + Mean(oxygen).ToString() + "\t" + StdDev(oxygen).ToString() + "\t" + Mean(oxygenSensor).ToString() + "\t" + StdDev(oxygenSensor).ToString() + "\t" + Mean(salinity).ToString() + "\t" + StdDev(salinity).ToString() + "\t" + Mean(density).ToString() + "\t" + StdDev(density).ToString() + "\t" + Mean(fluorensce).ToString() + "\t" + StdDev(fluorensce).ToString() + "\t" + Mean(fluorensceSensor).ToString() + "\t" + StdDev(fluorensceSensor).ToString() + "\t" + Mean(transmissivity).ToString() + "\t" + StdDev(transmissivity).ToString() + "\t" + Mean(transmissivitySensor).ToString() + "\t" + StdDev(transmissivitySensor).ToString() + "\t" + Mean(turbidity).ToString() + "\t" + StdDev(turbidity).ToString() + "\t" + Mean(turbiditySensor).ToString() + "\t" + StdDev(turbiditySensor).ToString() + "\t" + Mean(recordRate).ToString() + "\t" + StdDev(recordRate).ToString() ); } foreach (ImagesDepthStats ids in imageStats) { if (!ids.counted) { RunLogAddMsg("WriteDepthSummary UnCounted [" + (ids.upCast ? "Up":"Down") + "] Depth[" + ids.bucketDepth + "] Count[" + ids.imageCount + "]"); o.WriteLine(ids.bucketDepth.ToString() + "\t" + "---" + "\t" + "---" + "\t" + ids.imageCount.ToString() + "\t" + ids.totalPixelCount.ToString() + "\t" ); } } } /* WriteDepthSummary */