Chat history cleared. Start a new conversation!
Chat history cleared. Start a new conversation!
Welcome to the world of sea level and tidal research! The University of Hawaii Sea Level Center (UHSLC) provides a comprehensive set of data related to sea levels and tides, which can be accessed and analyzed through this application. Here's an overview of the types of data available and how you can interact with them:
Water Levels Data (Fast Delivery Data)
Tide Gauge Data (Tide Prediction Data)
Datum Data
Climatological Data
Near-real Time Data (Rapid Data)
Feel free to ask for specific data samples, analyses, or visualizations. You can also request to download data files or ask for guidance on how to interpret the data. Let me know what aspect of sea level or tidal information you would like to explore next!
To get started with the daily water level data, I'll first load the data from the pickle file and then create a plot to visualize it. After that, I'll provide you with a link to download the data.
Let's begin by loading the daily water level data and preparing it for visualization.
import pandas as pd
import numpy as np
import pickle
import matplotlib.pyplot as plt
from datetime import timedelta
# Load the daily water level data
file_path = './data/sea_level_data/daily_sea_level_data_fast_delivery.pkl'
with open(file_path, 'rb') as f:
daily_data = pickle.load(f)
# Process the data for a specific station (e.g., station '057')
station_id = '057'
station_data = daily_data['daily'].get(station_id, {})
# Extract start date and sea level data
start_date_str = station_data.get('start_date')
sea_level_data = station_data.get('sea_level_data', [])
# Convert start date to datetime object
start_date = pd.to_datetime(start_date_str, format='%Y%m%d')
# Replace missing data (-32767) with NaN
sea_level_data = [np.nan if x == -32767 else x for x in sea_level_data]
# Create a date range for the time series
dates = pd.date_range(start=start_date, periods=len(sea_level_data), freq='D')
# Create a DataFrame
df = pd.DataFrame({'Date': dates, 'Sea Level (mm)': sea_level_data})
# Plot the data
plt.figure(figsize=(12, 6))
plt.plot(df['Date'], df['Sea Level (mm)'], label='Sea Level (Station Zero Datum)')
plt.title('Daily Sea Level Data for Station 057')
plt.xlabel('Date')
plt.ylabel('Sea Level (mm)')
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()
# Save the DataFrame to a CSV file for download
download_path = './static/msg-iz2n425im/daily_sea_level_data_station_057.csv'
df.to_csv(download_path, index=False)
download_path
It seems there was an issue saving the file because the directory doesn't exist. Let me create the directory and save the file again.
import os
# Create the directory if it doesn't exist
output_dir = './static/msg-iz2n425im'
os.makedirs(output_dir, exist_ok=True)
# Save the DataFrame to a CSV file for download
download_path = os.path.join(output_dir, 'daily_sea_level_data_station_057.csv')
df.to_csv(download_path, index=False)
download_path
The daily sea level data for Station 057 has been successfully saved. You can download it using the link below:
Download Daily Sea Level Data (Station 057)
Feel free to explore the data further or let me know if there's anything else you'd like to do!