Chat history cleared. Start a new conversation!
Chat history cleared. Start a new conversation!
Tidal datums are standard elevations defined by a certain phase of the tide. They are used as reference points for measuring local water levels and are crucial for understanding coastal impacts, such as flooding risks and navigation safety. Here are some common tidal datums:
Mean Lower Low Water (MLLW): The average of the lower low water height of each tidal day observed over the National Tidal Datum Epoch (NTDE).
Mean Higher High Water (MHHW): The average of the higher high water height of each tidal day observed over the NTDE.
Mean Sea Level (MSL): The average height of the sea's surface, taken over all stages of the tide and over a long period.
Station Zero Datum: A local reference point used by tide gauges, often specific to a particular station.
To convert water levels from one datum to another, you add or subtract the difference between the datums. For example, to convert a water level from MLLW to MHHW, you would use the equation:
$$ \text{Water Level}{\text{MHHW}} = \text{Water Level}{\text{MLLW}} + (\text{MHHW} - \text{MLLW}) $$
Let's load the tidal datums for station 261 and plot them relative to both the Station Zero and MHHW datums.
Let's start by loading and parsing the tidal datum data.
import requests
from bs4 import BeautifulSoup
# Define the URL for the tidal datum data
station_id = '261'
unit = 'm'
url = f'https://uhslc.soest.hawaii.edu/stations/TIDES_DATUMS/fd/LST/fd{station_id}/datumTable_{station_id}_{unit}.html'
# Fetch the HTML content
response = requests.get(url)
# Parse the HTML content
soup = BeautifulSoup(response.content, 'html.parser')
# Extract datum information from the table
table = soup.find('table')
datum_info = []
# Iterate over the rows in the table
for row in table.find_all('tr')[2:]: # Skip the first two rows (header and possibly non-standard row)
columns = row.find_all('td')
if len(columns) == 3: # Ensure there are exactly 3 columns
datum_name = columns[0].text.strip()
datum_value = float(columns[1].text.strip())
datum_description = columns[2].text.strip()
datum_info.append((datum_name, datum_value, datum_description))
# Display the extracted datum information
datum_info
It seems there was an issue with converting one of the datum values to a float. This might be due to unexpected data in the table, such as a date or other non-numeric value. Let's inspect the table data more closely to identify the issue. I'll print out the raw data from the table to see what's causing the problem.
# Print the raw data from the table to identify the issue
raw_data = []
for row in table.find_all('tr'):
columns = [col.text.strip() for col in row.find_all('td')]
raw_data.append(columns)
raw_data
The issue was caused by the presence of non-numeric data in the table, such as dates and status information. Now that we have identified the relevant datum values, let's extract only the numeric datum values for plotting.
Here are the relevant tidal datums extracted from the table:
Let's proceed to plot these datums relative to both the Station Zero and MHHW datums.
import matplotlib.pyplot as plt
# Extract the relevant datum values
mhhw = 2.593
mhw = 2.482
mtl = 1.697
msl = 1.733
mlw = 0.911
mllw = 0.853
stnd = 0.000
# Datum names and values
datum_names = ['MHHW', 'MHW', 'MTL', 'MSL', 'MLW', 'MLLW', 'STND']
datum_values_station_zero = [mhhw, mhw, mtl, msl, mlw, mllw, stnd]
datum_values_mhhw = [value - mhhw for value in datum_values_station_zero]
# Plotting
plt.figure(figsize=(10, 6))
# Plot relative to Station Zero
plt.subplot(1, 2, 1)
plt.barh(datum_names, datum_values_station_zero, color='skyblue')
plt.title('Datums Relative to Station Zero')
plt.xlabel('Meters')
plt.grid(True, linestyle='--', alpha=0.6)
# Plot relative to MHHW
plt.subplot(1, 2, 2)
plt.barh(datum_names, datum_values_mhhw, color='lightcoral')
plt.title('Datums Relative to MHHW')
plt.xlabel('Meters')
plt.grid(True, linestyle='--', alpha=0.6)
plt.tight_layout()
plt.show()
The plots show the tidal datums for Station 261:
Left Plot (Relative to Station Zero):
Right Plot (Relative to MHHW):
These visualizations help understand how different tidal datums relate to each other and can be used to assess potential coastal impacts, such as flooding risks.
Would you like to explore more about tidal datums, or is there another aspect of sea level data you're interested in?
# Re-plot with flipped axes for easier interpretation
plt.figure(figsize=(10, 6))
# Plot relative to Station Zero
plt.subplot(1, 2, 1)
plt.bar(datum_names, datum_values_station_zero, color='skyblue')
plt.title('Datums Relative to Station Zero')
plt.ylabel('Meters')
plt.xticks(rotation=45)
plt.grid(True, linestyle='--', alpha=0.6)
# Plot relative to MHHW
plt.subplot(1, 2, 2)
plt.bar(datum_names, datum_values_mhhw, color='lightcoral')
plt.title('Datums Relative to MHHW')
plt.ylabel('Meters')
plt.xticks(rotation=45)
plt.grid(True, linestyle='--', alpha=0.6)
plt.tight_layout()
plt.show()
The updated plots now have the axes flipped for easier interpretation:
Left Plot (Relative to Station Zero):
Right Plot (Relative to MHHW):
These plots provide a clear visual representation of the tidal datums, helping to assess potential coastal impacts.