本文整理汇总了C#中Variable.GetMissingValue方法的典型用法代码示例。如果您正苦于以下问题:C# Variable.GetMissingValue方法的具体用法?C# Variable.GetMissingValue怎么用?C# Variable.GetMissingValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variable
的用法示例。
在下文中一共展示了Variable.GetMissingValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SplitSecondDimension
public static Point[][] SplitSecondDimension(Variable variable)
{
if (variable == null)
throw new ArgumentNullException("variable");
if (variable.Rank != 2)
throw new ArgumentException("Only 2d variables are supported");
int n = variable.GetShape()[1];
int m = variable.GetShape()[0];
Array d = variable.GetData();
Point[][] pts = new Point[n][];
for (int i = 0; i < n; i++)
{
List<Point> tmp = new List<Point>(m);
if (variable.TypeOfData == typeof(float))
{
float[,] dt = (float[,])d;
object mvObj = variable.GetMissingValue();
if (mvObj == null)
{
for (int j = 0; j < m; j++)
if (!Double.IsNaN(dt[j, i]))
tmp.Add(new Point(j, dt[j, i]));
}
else
{
float mv;
try
{
mv = Convert.ToSingle(mvObj);
}
catch (Exception exc)
{
Trace.WriteLine("PolyPolyline: cannot convert missing value attribute to float: " + exc.Message);
mv = float.NaN;
}
for (int j = 0; j < m; j++)
if (dt[j, i] != mv)
tmp.Add(new Point(j, dt[j, i]));
}
}
else if (variable.TypeOfData == typeof(double))
{
double[,] dt = (double[,])d;
object mvObj = variable.GetMissingValue();
if (mvObj == null)
{
for (int j = 0; j < m; j++)
if (!Double.IsNaN(dt[j, i]))
tmp.Add(new Point(j, dt[j, i]));
}
else
{
double mv;
try
{
mv = Convert.ToDouble(mvObj);
}
catch (Exception exc)
{
Trace.WriteLine("PolyPolyline: cannot convert missing value attribute to double: " + exc.Message);
mv = double.NaN;
}
for (int j = 0; j < m; j++)
if (dt[j, i] != mv)
tmp.Add(new Point(j, dt[j, i]));
}
}
else
{
object mv = variable.GetMissingValue();
for (int j = 0; j < m; j++)
{
object obj = d.GetValue(j, i);
if (!Object.Equals(obj, mv))
tmp.Add(new Point(j, Convert.ToDouble(obj)));
}
}
pts[i] = tmp.ToArray();
}
return pts;
}