|
@@ -52,15 +52,15 @@ public class SeaSJ
|
|
|
}
|
|
|
|
|
|
// 交付类方法
|
|
|
- public static List<double[]> GetDrift(NCread nCread, double[] initialPosition, double dt, double totalTime, int times, int latitudes, int longitudes, int days, int hour, double initlatitudes, double initlongitudes)
|
|
|
+ public static List<double[]> GetDrift(NCread nCread, double[] initialPosition, double dt, double totalTime, int times, int latitudes, int longitudes, int times1, int latitudes1, int longitudes1, int times2, int latitudes2, int longitudes2, int times3, int latitudes3, int longitudes3, int days, int hour, double initlatitudes, double initlongitudes)
|
|
|
{
|
|
|
// run 获取轨迹的函数
|
|
|
// initialPosition --> 初始位置; dt --> 时间步长; totalTime --> 总时长
|
|
|
- List<double[]> trajectory = CalculateDriftTrajectory(nCread, initialPosition, dt, totalTime, times, latitudes, longitudes, days, hour, initlatitudes, initlongitudes);
|
|
|
+ List<double[]> trajectory = CalculateDriftTrajectory(nCread, initialPosition, dt, totalTime, times, latitudes, longitudes, times1, latitudes1, longitudes1, times2, latitudes2, longitudes2, times3, latitudes3, longitudes3, days, hour, initlatitudes, initlongitudes);
|
|
|
return trajectory;
|
|
|
}
|
|
|
|
|
|
- public static List<double[]> CalculateDriftTrajectory(NCread nCread, double[] initialPosition, double dt, double totalTime, int times, int latitudes, int longitudes, int days, int hour, double initlatitudes, double initlongitudes)
|
|
|
+ public static List<double[]> CalculateDriftTrajectory(NCread nCread, double[] initialPosition, double dt, double totalTime, int times, int latitudes, int longitudes, int times1, int latitudes1, int longitudes1, int times2, int latitudes2, int longitudes2, int times3, int latitudes3, int longitudes3, int days, int hour, double initlatitudes, double initlongitudes)
|
|
|
{
|
|
|
int timeSteps = (int)(totalTime / dt);
|
|
|
List<double[]> trajectory = new List<double[]>();
|
|
@@ -72,20 +72,36 @@ public class SeaSJ
|
|
|
|
|
|
int outputTime = 3600 * t;
|
|
|
// 动态获取当前位置的风力和洋流数据
|
|
|
- double[] windVelocity = GetWindVelocityFromAPI(nCread, currentPos[0], currentPos[1], outputTime, times, latitudes, longitudes, days, hour);
|
|
|
- double[] currentVelocity = GetCurrentVelocityFromAPI(nCread, currentPos[0], currentPos[1], outputTime, times, latitudes, longitudes, days, hour);
|
|
|
-
|
|
|
+ double[] windVelocity = GetWindVelocityFromAPI(nCread, currentPos[0], currentPos[1], outputTime, times, latitudes, longitudes, times1, latitudes1, longitudes1, days, hour);
|
|
|
+ double[] currentVelocity = GetCurrentVelocityFromAPI(nCread, currentPos[0], currentPos[1], outputTime, times2, latitudes2, longitudes2, times3, latitudes3, longitudes3, days, hour);
|
|
|
+ //foreach (var item in windVelocity)
|
|
|
+ //{
|
|
|
+ // Console.WriteLine("windVelocity:" + item);
|
|
|
+ //}
|
|
|
+ //foreach (var item in currentVelocity)
|
|
|
+ //{
|
|
|
+ // Console.WriteLine("currentVelocity:" + item);
|
|
|
+ //}
|
|
|
// 计算漂移速度(m/s)
|
|
|
double[] driftVelocity = {
|
|
|
currentVelocity[0] + windVelocity[0],
|
|
|
currentVelocity[1] + windVelocity[1]
|
|
|
};
|
|
|
-
|
|
|
+ //foreach (var item in driftVelocity)
|
|
|
+ //{
|
|
|
+ // Console.WriteLine("driftVelocity:" + item);
|
|
|
+ //}
|
|
|
// 更新位置(漂移速度单位是m/s,需要转换成经纬度的变化量)
|
|
|
double[] newPosition = {
|
|
|
currentPos[0] + (driftVelocity[0] * dt * 3600) / ((6371000 * Math.Cos(currentPos[0] * Math.PI / 180)) * 180 / Math.PI), // 纬度变化量
|
|
|
currentPos[1] + (driftVelocity[1] * dt * 3600) / ((6371000 * Math.Cos(currentPos[1] * Math.PI / 180)) * 180 / Math.PI) // 经度变化量
|
|
|
};
|
|
|
+ //foreach (var item in newPosition)
|
|
|
+ //{
|
|
|
+ // Console.WriteLine("newPosition:" + item);
|
|
|
+ //}
|
|
|
+ //Console.WriteLine("currentPos[0]:" + (driftVelocity[0] * dt * 3600) / ((6371000 * Math.Cos(currentPos[0] * Math.PI / 180)) * 180 / Math.PI));
|
|
|
+ //Console.WriteLine("currentPos[1]:" + (driftVelocity[1] * dt * 3600) / ((6371000 * Math.Cos(currentPos[1] * Math.PI / 180)) * 180 / Math.PI));
|
|
|
|
|
|
trajectory.Add(newPosition);
|
|
|
}
|
|
@@ -93,7 +109,7 @@ public class SeaSJ
|
|
|
return trajectory;//(纬度,经度)
|
|
|
}
|
|
|
|
|
|
- public static double[] GetWindVelocityFromAPI(NCread windNCread, double latitude, double longitude, double temptime, int times, int latitudes, int longitudes, int days, int hour)
|
|
|
+ public static double[] GetWindVelocityFromAPI(NCread windNCread, double latitude, double longitude, double temptime, int times, int latitudes, int longitudes, int times1, int latitudes1, int longitudes1, int days, int hour)
|
|
|
{
|
|
|
float[] longitudeArray = windNCread.longitudeArray;//经度一维数组来源自文件'Text_readNC.cs'
|
|
|
float[] latitudeArray = windNCread.latitudeArray;//纬度一维数组来源自文件'Text_readNC.cs'
|
|
@@ -141,13 +157,23 @@ public class SeaSJ
|
|
|
return new double[] { windX, windY };
|
|
|
}
|
|
|
|
|
|
- public static double[] GetCurrentVelocityFromAPI(NCread CurrentNCread, double latitude, double longitude, double temptime, int times, int latitudes, int longitudes, int days, int hour)
|
|
|
+ public static double[] GetCurrentVelocityFromAPI(NCread CurrentNCread, double latitude, double longitude, double temptime, int times2, int latitudes2, int longitudes2, int times3, int latitudes3, int longitudes3, int days, int hour)
|
|
|
{
|
|
|
float[] longitudeArray = CurrentNCread.longitudeArray;//经度一维数组来源自文件'Text_readNC.cs'
|
|
|
float[] latitudeArray = CurrentNCread.latitudeArray;//纬度一维数组来源自文件'Text_readNC.cs'
|
|
|
float[][][] u10Array = CurrentNCread.u10Array;//风的10米U(向东)分量三维数组来源自文件'Text_readNC.cs'
|
|
|
float[][][] v10Array = CurrentNCread.v10Array;//风的10米V(向北)分量三维数组来源自文件'Text_readNC.cs'
|
|
|
float[][][] p140208Array = CurrentNCread.p140208Array;//海洋上空的自由对流速度三维数组来源自文件'Text_readNC.cs'
|
|
|
+ //foreach (var item in p140208Array)
|
|
|
+ //{
|
|
|
+ // foreach (var item1 in item)
|
|
|
+ // {
|
|
|
+ // foreach (var item2 in item1)
|
|
|
+ // {
|
|
|
+ // Console.WriteLine("p140208Array:" + item2);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
float[][][] mwdArray = CurrentNCread.mwdArray;//平均波向(单位:度;0度表示北方,90度表示东方)三维数组来源自文件'Text_readNC.cs'
|
|
|
|
|
|
int longitudeNum = 0;
|
|
@@ -155,7 +181,7 @@ public class SeaSJ
|
|
|
int temptimeNum = 0;
|
|
|
//定义NC文件中读取不到的坐标点海洋数据信息(后续可采用插值法等)
|
|
|
//经度连续化
|
|
|
- for (int i = 0; i < longitudes - 1; i++)
|
|
|
+ for (int i = 0; i < longitudes2 - 1; i++)
|
|
|
{
|
|
|
if (longitude >= longitudeArray[i] && longitude < longitudeArray[i + 1])
|
|
|
{
|
|
@@ -165,7 +191,7 @@ public class SeaSJ
|
|
|
}
|
|
|
|
|
|
//纬度连续化
|
|
|
- for (int i = 0; i < latitudes - 1; i++)
|
|
|
+ for (int i = 0; i < latitudes2 - 1; i++)
|
|
|
{
|
|
|
if (latitude >= latitudeArray[i] && latitude < latitudeArray[i + 1])
|
|
|
{
|
|
@@ -175,7 +201,7 @@ public class SeaSJ
|
|
|
}
|
|
|
|
|
|
//时间连续化
|
|
|
- for (int i = 0; i < times - 1; i++)
|
|
|
+ for (int i = 0; i < times2 - 1; i++)
|
|
|
{
|
|
|
if (temptime >= 3600 * i && temptime < 3600 * (i + 1))
|
|
|
{
|
|
@@ -183,9 +209,20 @@ public class SeaSJ
|
|
|
}
|
|
|
}
|
|
|
temptimeNum += (days - 1) * 24 + hour;
|
|
|
+ //foreach (var item in p140208Array)
|
|
|
+ //{
|
|
|
+ // Console.WriteLine("p140208Array:" + (double)p140208Array[0][1][2]);
|
|
|
+ //}
|
|
|
+ //Console.WriteLine("p140208Array:" + (double)p140208Array[2640][1][2]);
|
|
|
double currentSpeed = (double)p140208Array[temptimeNum][latitudeNum][longitudeNum];
|
|
|
+ Random random = new Random();
|
|
|
+ if (currentSpeed > 10)
|
|
|
+ currentSpeed = random.NextDouble();
|
|
|
+ //Console.WriteLine("temptimeNum:" + temptimeNum + "_" + "latitudeNum:" + latitudeNum + "_" + "longitudeNum:" + longitudeNum);
|
|
|
double currentDirection = (double)mwdArray[temptimeNum][latitudeNum][longitudeNum];
|
|
|
-
|
|
|
+ //double currentSpeed = (double)p140208Array[2401][0][0];
|
|
|
+ //Console.WriteLine("currentSpeed:" + currentSpeed);
|
|
|
+ //Console.WriteLine("currentDirection:" + currentDirection);
|
|
|
double currentDirectionInRadians = currentDirection * (Math.PI / 180);
|
|
|
double currentX = currentSpeed * Math.Cos(currentDirectionInRadians);
|
|
|
double currentY = currentSpeed * Math.Sin(currentDirectionInRadians);
|
|
@@ -194,7 +231,7 @@ public class SeaSJ
|
|
|
}
|
|
|
|
|
|
//海浪高度获取
|
|
|
- public static double GetWaveHeightFromAPI(NCread WaveNCread, double latitude, double longitude, double temptime, int times, int latitudes, int longitudes, int days, int hour)//temptime:仿真时间(秒)
|
|
|
+ public static double GetWaveHeightFromAPI(NCread WaveNCread, double latitude, double longitude, double temptime, int times4, int latitudes4, int longitudes4, int days, int hour)//temptime:仿真时间(秒)
|
|
|
{
|
|
|
float[] longitudeArray = WaveNCread.longitudeArray;//经度一维数组来源自文件'Text_readNC.cs'
|
|
|
float[] latitudeArray = WaveNCread.latitudeArray;//纬度一维数组来源自文件'Text_readNC.cs'
|
|
@@ -206,7 +243,7 @@ public class SeaSJ
|
|
|
|
|
|
//定义NC文件中读取不到的坐标点海洋数据信息(后续可采用插值法等)
|
|
|
//经度连续化
|
|
|
- for (int i = 0; i < longitudes - 1; i++)
|
|
|
+ for (int i = 0; i < longitudes4 - 1; i++)
|
|
|
{
|
|
|
if (longitude >= longitudeArray[i] && longitude < longitudeArray[i + 1])
|
|
|
{
|
|
@@ -216,7 +253,7 @@ public class SeaSJ
|
|
|
}
|
|
|
|
|
|
//纬度连续化
|
|
|
- for (int i = 0; i < latitudes - 1; i++)
|
|
|
+ for (int i = 0; i < latitudes4 - 1; i++)
|
|
|
{
|
|
|
if (latitude >= latitudeArray[i] && latitude < latitudeArray[i + 1])
|
|
|
{
|
|
@@ -226,7 +263,7 @@ public class SeaSJ
|
|
|
}
|
|
|
|
|
|
//时间连续化
|
|
|
- for (int i = 0; i < times - 1; i++)
|
|
|
+ for (int i = 0; i < times4 - 1; i++)
|
|
|
{
|
|
|
if (temptime >= 3600 * i && temptime < (3600 * (i + 1)))
|
|
|
{
|