DivingSport 板


LINE

PADI RDP表 https://elearning.padi.com/company0/tools/RDP_Table%20Met.pdf 因为自然语言讲起来比较罗嗦,如果用程式语言根据RDP的数据和演算法来实作 其实看的懂得人 反而会觉得更清楚 在此利用 python 来示范怎麽实作 RDP 和其应用(解习题) == 利用线上的 python interpreter 去跑,只需要开浏览器,什麽都不用安装 https://www.programiz.com/python-programming/online-compiler/ 想要看什麽资料就直接print出来就好 连GUI都不用去设计,很快就可以让程式运作起来得到我们想要的答案 == 程式 = 资料 + 演算法 我们先思考怎麽去将RDP上的资料表示 因为RDP就是一种 look-up table,所以自然而然在 python 会用dictionary 去实作 而我们可以列出几个dic: padi_table1 surface_table padi_table2 max_bottom_times 然後再根据RDP上面的数据去输入key:value == 接下来我们来思考需要 def 哪些运算 get_depth_group的挑战是 输入一个深度 找出集合中和他最接近但是不小於的数字 def get_depth_group(depth): depths = sorted(padi_table_1.keys()) last_dep = 0 for d in depths: if last_dep < depth <= d: return d last_dep = d print(last_dep) print("depth group is " + str(get_depth_group(30))) 也就是如果想知道如果我一开始想下 30 公尺,那应该要查表上的哪个深度 我们把中间比较的过程也print出来,则output会是 10 12 14 16 18 20 22 25 depth group is 30 == max_bottom_times = {10: 219, 12: 147, 14: 98, 16: 72, 18: 56, 20: 45, 22: 37, 25: 29, 30: 20, 35: 14, 40: 9} def max_bottom_time(depth): dep_group = get_depth_group(depth) return max_bottom_times[dep_group] max_bottom_times => 我们想要知道每一个深度的最大滞底时间 超过这个时间就要进deco了 (在表格上是涂黑) 先建立起 max_bottom_times的 dictionary print(max_bottom_time(28)) 结果是 20 == def get_nearest_time_frame(dive_time, depth): times = sorted([int(x) for x in padi_table_1[depth].keys()]) last_time = 0 for t in times: if last_time < dive_time <= t: return t last_time = t 确定深度,往下找那一列的时间,然後一样找不小於的时间 print( get_nearest_time_frame(18, 30)) output: 19 == def get_end_pres(time, depth): depth = get_depth_group(depth) time = str(get_nearest_time_frame(time, depth)) pressure = padi_table_1[depth][time] return pressure print(get_end_pres(18, 30)) output: M 得到结束时的压力等级是M == # 给定下潜前後的压力等级,计算需要的 SI 区间 def get_interval(pressure_i, pressure_e): interval = surface_table[pressure_i][pressure_e] return interval print(get_interval(‘M’,’B’)) output: ['01:26', '02:14’] 所以我就知道如果要从压力等级 M 变成 B SI 要介於 01:26 - 02:13 (时:分) == # 把时间区间的时:分格式转成秒,方便电脑比较时间长短 def time2secs(str_time): hour_seconds = int(str_time.split(':')[0])*60*60 min_seconds = int(str_time.split(':')[1])*60 return hour_seconds + min_seconds print(time2secs("02:13”)) output: 7980 也就是说 2小时13分 = 7980 秒 就是利用 split的method去利用中间的冒号把小时跟分钟分开 然後小时乘上 60*60 分钟乘上 60 最後加总就变成秒 == # 如果知道起始的压力等级和水面休息时间,计算休息後的新压力等级 def pressure_after_time(start_p, surf_time): surf_time *= 60 if surf_time >= 3*60*60: return 'A' intervals = surface_table[start_p] for x in intervals.keys(): interval = intervals[x] if time2secs(interval[0]) <= surf_time <= time2secs(interval[1]): return x print(pressure_after_time(“M", 60)) output: D 也就是原本是M,休息60分钟後,压力等级变成D == 如果下一潜想要下某个深度待某个时间,则压力等级至少要是多少才不会超过 NDL 这时候你就要去看该深度的 ABT (actual bottom time) 刚好大过这个时间 def min_d2_start_pressure(d2_depth, d2_time): closest_depth = get_depth_group(d2_depth) max_times = padi_table_2[closest_depth] for x in sorted(max_times.keys(), reverse=True): abt = max_times[x][1] if d2_time > abt: continue else: return x print(min_d2_start_pressure(14, 50)) output: M == #如果知道下潜之前的压力等级,然後预计下一潜要潜的深度和时间,那麽SI至少要多久? def min_surface(d1_end_p, d2_depth, d2_time): d2_start_p = min_d2_start_pressure(d2_depth, d2_time) if d1_end_p < d2_start_p: return 0 else: surface_interval = get_interval(d1_end_p, d2_start_p) get_min_minutes = time2secs(surface_interval[0]) / 60 return get_min_minutes print(min_surface(“M”,14, 60) output: 15.0 也就是休息15分钟後,压力等级会从M变成J,而J的压力等级下14m的 ABT最多可以61,刚好超过60 == #如果知道SI过後的新压力等级,然後下一潜想下的深度和时间,求下一潜结束後的新压力等级 def repeat_dive_end_pressure(si_p_end, d2_depth, d2_time): closest_depth = get_depth_group(d2_depth) bottom_time_adjustment = padi_table_2[closest_depth][si_p_end][0] adjusted_time = d2_time + bottom_time_adjustment return get_end_pres(adjusted_time, closest_depth) print(repeat_dive_end_pressure(“J", 20, 15)) output: R 也就是SI後压力等级J,下20公尺15分钟,这时候加上RNT 25分钟变成40分钟的TBT 然後切换回表1 查看下20公尺 40分钟後,压力等级会是R --



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 49.216.230.87 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/DivingSport/M.1604331944.A.6F4.html ※ 编辑: magicfx (49.216.230.87 台湾), 11/02/2020 23:46:17 ※ 编辑: magicfx (49.216.230.87 台湾), 11/02/2020 23:46:45
1F:推 Youan: 先...先推不然人家以为我看不懂 11/03 00:31
2F:推 tsao790504: 推推! 刚好正在学python 11/03 01:53
3F:推 jal: 我以为我走错版惹... 11/03 02:57
4F:推 tyson147258: 懂了 11/03 10:22
5F:推 Piiter: 等等来自己写写看 11/03 19:34







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BuyTogether站内搜寻

TOP