• 优势流


    import numpy as np
    import pandas as pd
    import matplotlib as plt
    import math

    from pandas import DataFrame

    Tidetag1 = float(input("请输入主退潮流方向"))
    tide = np.loadtxt('.B大潮.txt', dtype=float, usecols=(2, 3, 4)) # 导入数据
    # print(tide)
    testdir = np.linspace(0, 180, num=3600, endpoint=False) # 生成等间隔数据
    # print(testdir)
    tide1 = tide[:, 1] # 流速
    tide2 = (tide[:, 2]) # 流向
    tidetag = tide2 * 0 # 潮汐标志

    # print(tide1)
    # print(tide2)
    # for i in range(len(testdir)):
    # testsum = np.sum((abs(tide1[i]*np.sin((tide2[i]-testdir[i]/180)*math.pi))))
    # print(range(len(testdir)))
    a = len(tide2)
    b = len(testdir)
    testdir1 = np.full((a, b), np.nan)
    list1 = []
    # print(testdir1)
    # 形成弧度制转化
    # for i in range(len(testdir)):
    # testdir1[i] = np.deg2rad(testdir[i])
    # print(testdir)
    for j in range(len(tide2)):
    for m in range(len(testdir)):
    testdir1[j, m] = np.abs(tide1[j] * np.sin(np.deg2rad(tide2[j] - testdir[m])))
    # print(testdir1)

    a1 = (np.sum(testdir1, axis=0))
    a2 = np.argmax(a1)
    a3 = testdir[a2] ##分割线值
    print(a3)
    # print(testdir[421])
    if a3 <= Tidetag1 < (a3 + 180): # 分割线以下为退潮
    t = np.where((tide2 >= a3) & (tide2 < a3 + 180))
    for i in t:
    tidetag[i] = 1 # 退潮标记

    else:
    # 分割线以上为涨潮
    t = np.where((tide2 < a3) | (tide2 < a3 + 180))
    for i in t:
    tidetag[i] = 1 # 退潮标记
    print(tidetag) # 输出潮汐标志信息
    if a3 <= 90:
    axis_dir1 = a3 + 90
    else:
    axis_dir1 = a3 - 90
    print(axis_dir1)
    # 查询潮周期数据
    tag_change = 0
    tag_Start = 0
    tag_End_One = 0
    tag_End_Two = 0
    l = len(tide2)
    for i in range(1, l):
    if tidetag[i] != tidetag[i - 1]:
    tag_change += 1

    if tag_change == 1:
    tag_Start = i

    if tag_change == 3:
    tag_End_One = i - 1
    if tag_change == 5:
    tag_End_Two = i - 1

    print(tag_Start)
    print(tag_End_Two)
    print(tag_End_One)
    if (tag_End_One == 0) and (tag_End_Two == 0):
    Index_Cycle = np.nan
    Num_Cycle = 0
    elif tag_End_Two == 0:
    Index_Cycle = tag_End_One - tag_Start
    num_Cycle = 1
    else:
    Index_Cycle = tag_End_Two - tag_Start
    num_Cycle = 2
    print(num_Cycle)
    c1 = tag_Start
    c2 = tag_End_One
    c3 = tag_End_Two
    # 重置行列,提取某周期数据
    print(tidetag)
    # tidetag[0:c3] = tidetag[c1:c3 + 1]
    tidetag_new = tidetag[c1:c3]
    c = pd.DataFrame(tide, columns=['dep', 'vel', 'dir'])

    c['tidetag'] = tidetag
    #
    c4 = c[c1:c3+1] # 提取全周期值
    print(c4)
    d = c4[c4['tidetag'] == 1]
    f = c4[c4['tidetag'] == 0]
    d = d.reset_index(drop=True)
    f = f.reset_index(drop=True)
    #
    # # print(c4)
    # # #
    # # print(d)
    # # print(f)
    # # # 计算优势流
    # # # # 确认退潮和涨潮的流速流向以及水深等,并且形成array格式
    v_ebb = np.array(d['vel'])
    print(v_ebb)
    dir_ebb = np.array(d['dir'])
    print(dir_ebb)
    depth_ebb = np.array(d['dep'])
    print(depth_ebb)
    v_flood = np.array(f['vel'])
    dir_flood = np.array(f['dir'])
    depth_flood = np.array(f['dep'])
    q_ebb = np.sum(v_ebb * depth_ebb * np.abs(np.cos(np.deg2rad(dir_ebb - axis_dir1)))) / num_Cycle
    f_flood = np.sum(v_flood * depth_flood * np.abs(np.cos(np.deg2rad(dir_flood - axis_dir1)))) / num_Cycle

    print(f_flood)
    print(q_ebb)
    you = q_ebb / (f_flood + q_ebb)
    print(you)
    # # 计算涨落急流速流向
    # # #落潮
    # d1 = np.array(d)
    # max_x = np.array(np.argmax(d1, axis=0))
    # # print(max_x)
    # v_ebb_max = d1[max_x[1],1]
    # dir_ebb_max = d1[max_x[1],2]
    # depth_ebb_max = d1[max_x[1],0]
    # # print(v_ebb_max)
    # # print(dir_ebb_max)
    # # print(depth_ebb_max)
    #
    #
    # #涨潮
    # f1 = np.array(f)
    # max_x = np.array(np.argmax(f1, axis=0))
    # # print(max_x)
    # v_flood_max = f1[max_x[1],1]
    # dir_flood_max = f1[max_x[1],2]
    # depth_flood_max = f1[max_x[1],0]
    # # print(v_flood_max)
    # print(dir_flood_max)
    # print(depth_flood_max)





  • 相关阅读:
    Codefoces Gym 101652 【最大连续和】
    HYSBZ 4034 【树链剖分】+【线段树 】
    Codeforces Gym 101291C【优先队列】
    Codeforces gym 101291 M (最长交替子序列)【DP】
    HDU 3308 LCIS (经典区间合并)【线段树】
    POJ 3237 Tree (树链剖分+边权转点权)
    POJ 2763 Housewife Wind (树链剖分+边权转点权)
    P1054 等价表达式
    P1107 [BJWC2008]雷涛的小猫
    P1552 [APIO2012]派遣
  • 原文地址:https://www.cnblogs.com/chenyun-delft3d/p/14689128.html
Copyright © 2020-2023  润新知