# Exercise 3: wave height from fetch, and fetch from wave height. import math FT_M = 0.3048 MILE_KM = 1.609344 def height_m(fetch_km): fetch_miles = fetch_km / MILE_KM return 1.5 * math.sqrt(fetch_miles) * FT_M def fetch_km_for(height_in_m): feet = height_in_m / FT_M return (feet / 1.5) ** 2 * MILE_KM print("heights from fetch (km):") for km in (5, 20, 50, 100, 200): note = "" if km <= 100 else " (beyond the 100 km the observations were for)" print(" ", km, "km ->", round(height_m(km), 2), "m" + note) print("fetch needed for a given height:") for h in (2, 4, 6, 8, 10): print(" ", h, "m ->", round(fetch_km_for(h)), "km") print("largest height from observed fetches up to 100 km:", round(height_m(100), 2), "m") print("fetch ratio for double the height:", round(fetch_km_for(4) / fetch_km_for(2), 2)) # heights from fetch (km): # 5 km -> 0.81 m # 20 km -> 1.61 m # 50 km -> 2.55 m # 100 km -> 3.6 m # 200 km -> 5.1 m (beyond the 100 km the observations were for) # fetch needed for a given height: # 2 m -> 31 km # 4 m -> 123 km # 6 m -> 277 km # 8 m -> 493 km # 10 m -> 770 km # largest height from observed fetches up to 100 km: 3.6 m # fetch ratio for double the height: 4.0