当前位置:网站首页>平均风向风速计算(单位矢量法)
平均风向风速计算(单位矢量法)
2022-06-27 02:08:00 【这被禁忌的游戏】

单位矢量法计算公式:

C# 代码
static void Main(string[] args)
{
int[] Met_Dir_Test = {
259, 259, 259, 259, 259, 259, 259, 259, 259, 259 };
int[] Met_Dir = {
297, 317, 356, 23, 21, 19, 26, 32, 28, 30 };
double[] Met_Speed = {
2.5, 1.8, 2.9, 4.4, 4.5, 4.6, 4.0, 3.7, 4.3, 4.3 };
for (int i = 0; i < 360; i++)
{
for (int j = 0; j < Met_Dir_Test.Length; j++)
{
Met_Dir_Test[j] = i;
}
int Dir_Avg = Met_Dir_Average(Met_Dir_Test, Met_Speed);
Console.WriteLine(i + " 平均风向:" + Dir_Avg);
}
Console.WriteLine("平均风向:" + Met_Dir_Average(Met_Dir, Met_Speed));
Console.Read();
}
static int Met_Dir_Average(int[] Dir_Buf,double[] Speed_Buf)
{
double Dir_Avg = 0;
double SinSum = 0;
double CosSum = 0;
for (int i = 0; i < Dir_Buf.Length; i++)
{
if (Dir_Buf[i] == 0 && Speed_Buf[i] == 0)
continue;
SinSum += Math.Sin(Dir_Buf[i] / 180.0f * Math.PI);//将角度转换为弧度角再代入计算
CosSum += Math.Cos(Dir_Buf[i] / 180.0f * Math.PI);//将角度转换为弧度角再代入计算
}
Dir_Avg = SinSum / CosSum;
Dir_Avg = Math.Atan(SinSum / CosSum) / Math.PI * 180.0;
Dir_Avg = Math.Round(Dir_Avg);
/* 方位角还原 数学中根据象限对角度进行划分。分别通过计算所得的东西方位平均分量u与南北方位平均分量v的正负数值判断真实的角度所处的象限在根据象限属性进行角度修正即可获得正式的角度。 经过计算与事例论证现给出各个方位计算结果的修正值: ①u > 0; v > 0:真实角度处于第一象限修正值为 + 0°; ②u > 0; v < 0:真实角度处于第二象限修正值为 + 180°; ③u < 0; v < 0:真实角度处于第三象限修正值为 + 180°; ④u < 0; v > 0:真实角度处于第四象限修正值为 + 360°。 简单分析 当角度处于一象限时无需修正,计算值即使真值;角度处于第二、三象限时根据正切函数特性,可通过将计算值向右平移一个正切函数周期计算获得,即向正方向修正180°;角度处于第四象限时,正切函数的定义域在(-3π / 2,2π)上,实际通过反正切求得值域(即为正切的定义域)为(-π / 2,0)上,,根据正切函数周期、对称特性可知此时应在计算值上向正向修正 + 360°可还原数据。*/
if (SinSum > 0 && CosSum > 0) Dir_Avg += 0;
else if (SinSum > 0 && CosSum < 0) Dir_Avg += 180;
else if(SinSum < 0 && CosSum < 0) Dir_Avg += 180;
else if(SinSum < 0 && CosSum > 0) Dir_Avg += 360;
return (int)Dir_Avg;
}
风向平均值采样单位矢量法计算,风速平均值直接用算术平均方法计算就好了
边栏推荐
猜你喜欢

SQLite Reader 插件测试SQLite语法

企业数字化转型:信息化与数字化

pytorch 22 8种Dropout方法的简介 及 基于Dropout用4行代码快速实现DropBlock

P5.js death planet

Look! In June, 2022, the programming language ranking list was released! The first place is awesome

C language -- Design of employee information management system

H5 liquid animation JS special effect code

SQLite reader plug-in tests SQLite syntax

按键控制LED状态翻转

mmdetection ValueError: need at least one array to concatenate解决方案
随机推荐
达梦数据库的卸载
Flink学习2:应用场景
Learn the most basic operation of discodiffusion
Microsoft365开发人员申请
What if asreml-r does not converge in operation?
Memcached basics 15
“所有专业都在劝退”,对大学生最友好的竟然是它?
memcached基础10
我靠副业一个月挣了3W块:你看不起的行业,真的很挣钱!
Oracle/PLSQL: Trim Function
D's appendto packaging
dat.gui.js星星圆圈轨迹动画js特效
SQLite Reader 插件测试SQLite语法
memcached基础12
Flink学习3:数据处理模式(流批处理)
Binary tree OJ problem
Sample development of WiFi IOT Hongmeng development kit
二叉树oj题目
参数估计——《概率论及其数理统计》第七章学习报告(点估计)
Consumers pursue the iPhone because its cost performance exceeds that of domestic mobile phones