Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindStressPRM
{
/// <summary>
/// Cell obj for regular prognostic wind field
/// Объект ячейки для поля прогностического ветра на высоте 10м на регулярной сетке
/// </summary>
public class PrognosticCell
{
/// <summary>
/// U - component of wind velocity, m/s
/// U - компонента скорости ветра, м/с
/// </summary>
public double VelocityX { get; private set; }
/// <summary>
/// V - component of wind velocity, m/s
/// V - компонента скорости ветра, м/с
/// </summary>
public double VelocityY { get; private set; }
/// <summary>
/// Cell center coordinates
/// Координаты центра ячейки
/// </summary>
public Coordinate Coordinate { get; private set; }
/// <summary>
/// designated constructor
/// </summary>
/// <param name="coord"> Coordinate pair</param>
/// <param name="vX"> U component</param>
/// <param name="vY"> V component</param>
public PrognosticCell(Coordinate coord, double vX, double vY)
{
this.Coordinate = coord;
this.VelocityX = vX;
this.VelocityY = vY;
if (!(this.CheckValue()))
{
throw new System.ArgumentException("Prognostic wind velocities are incorrect");
}
}
/// <summary>
/// Проверка полей на валидность
/// </summary>
/// <returns></returns>
public bool CheckValue()
{
bool res1 = Double.IsNaN(VelocityX);
bool res2 = Double.IsNaN(VelocityY);
if (res1 != res2)
{
return false;
}
// пустые данные
if (res1 == res2 == true)
{
return true;
}
///Скорость ветра на высоте 10м от поверхности на Земле не может превышать 70м/c
return Math.Abs(Math.Pow(VelocityX, 2) + Math.Pow(VelocityY, 2)) <= 4900;
}
}
}