把c#函数转为python函数private void CalculatePartial_AvgVelocity_Width() { int index = -1; List<Result_Line> vLines = ResultLineList.Where(line => line.VLineOrder != null).ToList(); for (int i = 0; i < vLines.Count; i++) { index = ResultLineList.IndexOf(vLines[i]); if (vLines[i].VLineOrder == -9999) { continue; } else if (vLines[i - 1].VLineOrder == -9999) { //float leftAlpha = GetInshoreCoefficient(-9999, vLines[i].WaterLvl); float leftAlpha = NumValid.PrecisionConvert_Coefficient(GetInshoreCoefficient(-9999, vLines[i - 1].InitPointDistance)); vLines[i].PartialAvgVelocity = NumValid.PrecisionConvert_Velocity((float)(leftAlpha * vLines[i].AvgVelocity)); } else if (vLines[i].VLineOrder == 9999) { //float rightAlpha = GetInshoreCoefficient(9999, vLines[i].WaterLvl); float rightAlpha = NumValid.PrecisionConvert_Coefficient(GetInshoreCoefficient(9999, vLines[i].InitPointDistance)); vLines[i].PartialAvgVelocity = NumValid.PrecisionConvert_Velocity((float)(rightAlpha * vLines[i - 1].AvgVelocity)); } else { var temp = (vLines[i - 1].AvgVelocity + vLines[i].AvgVelocity) / 2f; vLines[i].PartialAvgVelocity = NumValid.PrecisionConvert_Velocity((float)temp); } ResultLineList[index] = vLines[i]; ResultLineList[index].WidthBetweenVLine = NumValid.PrecisionConvert_Width(vLines[i].InitPointDistance - vLines[i - 1].InitPointDistance); } }
时间: 2024-04-23 20:23:22 浏览: 105
vc调用python函数的例子
5星 · 资源好评率100%
def calculate_partial_avg_velocity_width():
index = -1
v_lines = [line for line in result_line_list if line.VLineOrder is not None]
for i in range(len(v_lines)):
index = result_line_list.index(v_lines[i])
if v_lines[i].VLineOrder == -9999:
continue
elif v_lines[i - 1].VLineOrder == -9999:
left_alpha = precision_convert_coefficient(get_inshore_coefficient(-9999, v_lines[i - 1].InitPointDistance))
v_lines[i].PartialAvgVelocity = precision_convert_velocity(left_alpha * v_lines[i].AvgVelocity)
elif v_lines[i].VLineOrder == 9999:
right_alpha = precision_convert_coefficient(get_inshore_coefficient(9999, v_lines[i].InitPointDistance))
v_lines[i].PartialAvgVelocity = precision_convert_velocity(right_alpha * v_lines[i - 1].AvgVelocity)
else:
temp = (v_lines[i - 1].AvgVelocity + v_lines[i].AvgVelocity) / 2
v_lines[i].PartialAvgVelocity = precision_convert_velocity(temp)
result_line_list[index] = v_lines[i]
result_line_list[index].WidthBetweenVLine = precision_convert_width(v_lines[i].InitPointDistance - v_lines[i - 1].InitPointDistance)
阅读全文