diff --git a/WindStressPRM/WindStressPRM.cs b/WindStressPRM/WindStressPRM.cs index 3e63db283dd50ae879315d121fbf089cec302ffe..ecbd4ce141b55ff897cc2b0370d49e4a8e8fdf58 100644 --- a/WindStressPRM/WindStressPRM.cs +++ b/WindStressPRM/WindStressPRM.cs @@ -121,7 +121,7 @@ namespace WindStressPRM return false; } // пустые данные - if (res1) { + if (res1 == res2 == true) { return true; } ///Скорость ветра на высоте 10м от поверхности на Земле не может превышать 70м/c @@ -178,17 +178,23 @@ namespace WindStressPRM /// <returns></returns> public bool CheckValue() { - bool c5 = Double.IsNaN(Wind5); - bool c10 = Double.IsNaN(Wind10); - bool c15 = Double.IsNaN(Wind15); - if (c5 != c10 || c5 != c15 || c5 != c10) { - return false; + double w5 = Wind5; + double w10 = Wind10; + double w15 = Wind15; + if (Double.IsNaN(w5)) // if is Nan - zerofied it. + { + w5 = 0; } - if (c5) { - return true; + if (Double.IsNaN(w10)) + { + w10 = 0; + } + if (Double.IsNaN(w15)) + { + w15 = 0; } // ветер по модулю не должен превышать 70м/с - return Math.Abs(Wind5) < 70 && Math.Abs(Wind10) < 70 && Math.Abs(Wind15) < 70; + return Math.Abs(w5) < 70 && Math.Abs(w10) < 70 && Math.Abs(w15) < 70; } } /// <summary> @@ -523,14 +529,7 @@ namespace WindStressPRM //fill output Output output = new Output(); output.DisabledStations = new List<PowerStation>(); - output.DisabledLines = new List<Powerline>(); - foreach (Powerline line in input.PowerLines) - { - if (line.IsBroken) - { - output.DisabledLines.Add(line); - } - } + output.DisabledLines = prmBrokenLines; foreach (PowerStation powerStation in input.PowerStations) { //stations of type pole can be disabled if the line is broken @@ -720,6 +719,13 @@ namespace WindStressPRM double uwind = interpol(coords, FunctionType.FunctionVelocityX); double vwind = interpol(coords, FunctionType.FunctionVelocityY); double climwind = interpol(coords, climateType); + if (Double.IsNaN(uwind) || Double.IsNaN(vwind) || Double.IsNaN(climwind)) + { + // interpolation fail. we can't say everything about here + // discussion: also we can save these points for detail analysis + res = false; + continue; + } double umod = Math.Sqrt(uwind * uwind + vwind * vwind); ; double angleline = Math.Atan2((coord2.Y - coord1.Y), (coord2.X - coord1.X)); double anglewind = Math.Atan2(vwind, uwind) - angleline; @@ -954,7 +960,8 @@ namespace WindStressPRM // tests indicates that value at test-cell is missed. if (testTopRight && testTopLeft && testBotLeft && testBotRight) { - throw new Exception("Current value in such a bad place, you need to fill these place with raster values"); + // Current value in such a bad place, you need to fill these place with raster values + return Double.NaN; } int count = 0; if (testBotLeft)