Skip to content

Commit

Permalink
Current public local
Browse files Browse the repository at this point in the history
My public dir as it currently looks locally
  • Loading branch information
NkululekoMemela authored Feb 12, 2025
1 parent 0725445 commit f3a2e47
Show file tree
Hide file tree
Showing 25 changed files with 1,212 additions and 0 deletions.
Binary file added public/clippedsimulation.mp4
Binary file not shown.
Binary file modified public/croco_avg_temp_100m.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/croco_avg_temp_bot _Algoa.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/croco_avg_temp_bot.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/croco_avg_temp_surf.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added public/cron_log.txt
Empty file.
14 changes: 14 additions & 0 deletions public/default-img.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions public/download_gifs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import os
import requests
from datetime import datetime, timedelta

# Define constants
BASE_URL = "https://somisana.ocean.gov.za/sa-west/v1.0/forecasts"
LOCAL_DIR = "/home/nc.memela/Projects/somisana-current_running_file/public"
LOG_FILE = os.path.join(LOCAL_DIR, "download_log.txt")

GIF_FILES = ["croco_avg_temp_100m.gif", "croco_avg_temp_surf.gif", "croco_avg_temp_bot.gif"]

def get_today_date_path():
"""Return today's date path in the required format YYYYMM/YYYYMMDD."""
today = datetime.utcnow()
return f"{today.strftime('%Y%m')}/{today.strftime('%Y%m%d')}_00"

def get_latest_available_url():
"""Check for the latest available data, going back if today's is missing."""
today = datetime.utcnow()

for days_back in range(7): # Look back up to a week
date_path = (today - timedelta(days=days_back)).strftime('%Y%m/%Y%m%d_00')
url = f"{BASE_URL}/{date_path}/MERCATOR-GFS"
if check_url_exists(url):
return url
return None

def check_url_exists(url):
"""Check if the URL is reachable (test with HEAD request)."""
try:
response = requests.head(url, timeout=10)
return response.status_code == 200
except requests.RequestException:
return False

def download_gif(url, filename):
"""Download the GIF from the given URL and save it locally."""
gif_url = f"{url}/{filename}"
local_path = os.path.join(LOCAL_DIR, filename)

try:
response = requests.get(gif_url, timeout=15)
if response.status_code == 200:
with open(local_path, 'wb') as f:
f.write(response.content)
return True
else:
return False
except requests.RequestException:
return False

def log_download_attempt(success, date):
"""Log the attempt in a text file."""
with open(LOG_FILE, "a") as log:
status = "Success" if success else "Failure"
log.write(f"{date}: {status}\n")

def main():
"""Main function to check and download the latest GIFs."""
os.makedirs(LOCAL_DIR, exist_ok=True)

latest_url = get_latest_available_url()
if not latest_url:
print("No recent valid forecast found. Keeping existing files.")
log_download_attempt(False, datetime.utcnow().strftime('%Y-%m-%d'))
return

success = False
for gif in GIF_FILES:
if download_gif(latest_url, gif):
success = True

log_download_attempt(success, datetime.utcnow().strftime('%Y-%m-%d'))

if __name__ == "__main__":
main()

4 changes: 4 additions & 0 deletions public/download_log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2025-02-11: Success
2025-02-11: Success
2025-02-12: Success
2025-02-12: Success
Binary file added public/egagsiniadress1-1500w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/giles-200w.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
523 changes: 523 additions & 0 deletions public/index.html

Large diffs are not rendered by default.

Binary file added public/jenny-200h.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/laura1-300h.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions public/newpage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Models and Products</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
</head>
<body>

<!-- Page Header with Back Navigation -->
<div class="page-header">
<a href="index.html" class="back-nav">
<img src="left-arrow.png" alt="Back">
</a>
<h1 class="page-title">Models and Products</h1>
</div>

<!-- Content Container -->
<div class="content-container">

<!-- Top Section: Our Models -->
<div class="section models-section">
<h1>Our Models</h1>
<a href="sa-west-model.html" class="data-card-button button">
<span><span class="Anchor">SA West Model</span><br /></span>
</a>
<a href="sa-southeast-model.html" class="data-card-button button">
<span><span class="Anchor">SA S-East Model</span><br /></span>
</a>
</div>

<!-- Bottom Section: Satellite Derived Products -->
<div class="section satellite-section">
<h1>Satellite Derived Products</h1>
<a href="products.html" class="data-card-button button">
<span><span class="Anchor">Products</span><br /></span>
</a>
</div>

</div>

</body>
</html>



Binary file added public/nkululekohr-pic-200w.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/pyramid_diagram4-1300w.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/pyramid_diagram4-1500w.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/pyramid_diagram4-1600h.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/pyramid_diagram4-2000w.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/pyramid_diagram4-600h.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions public/run_downloads.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Ensure Conda is available in non-interactive shells
source /home/nc.memela/anaconda3/etc/profile.d/conda.sh

# Activate your Conda environment
conda activate somisana_croco

# Run the Python script
python /home/nc.memela/Projects/somisana-current_running_file/public/download_gifs.py

# Deactivate the environment (optional)
conda deactivate

58 changes: 58 additions & 0 deletions public/sa-southeast-model.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>SA West Model</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
</head>
<body>

<!-- Page Header with Back Navigation -->
<div class="page-header">
<a href="newpage.html" class="back-nav">
<img src="left-arrow.png" alt="Back">
</a>
<h1 class="page-title">SA South East Model</h1>
</div>

<!-- Content Section -->
<div class="content-container model-content">

<!-- GIF Section -->
<div class="model-images">
<div class="gif-container">
<h3>SST</h3>
<img src="croco_avg_temp_surf_Algoa.gif" alt="Sea Surface Temperature Animation">
</div>
<div class="gif-container">
<h3>Temp at 100m</h3>
<img src="croco_avg_temp_100m_Algoa.gif" alt="Temperature at 100m Animation">
</div>
</div>

<!-- Right Section: Blurb -->
<div class="model-description">
<h2>SA S.East Model</h2>
<p>
Past, present and future ocean state at the water surface from a Coastal and Regional Ocean
Community (CROCO) numerical model configuration of the Algoa Bay region. The model is
initialized once a day, and produces output at an hourly temporal resolution for a period
of 5 days into the past to 5 days into the future.
</p>
<p>
The provided variables are sea surface temperature (SST), sea surface height (SSH), salinity,
and surface currents. Boundary conditions for the model are obtained from the ~9km resolution
Mercator global ocean analysis and forecast product, while surface forcing is obtained from
the Global Forecast System (GFS).
</p>
<p>
Our configuration represents a 'downscaling' of the Mercator global ocean product to high
resolution (~500 m) over Algoa Bay, allowing for the simulation of local bay-scale processes.
</p>
</div>

</div>

</body>
</html>
61 changes: 61 additions & 0 deletions public/sa-west-model.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>SA West Model</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
</head>
<body>

<!-- Page Header with Back Navigation -->
<div class="page-header">
<a href="newpage.html" class="back-nav">
<img src="left-arrow.png" alt="Back">
</a>
<h1 class="page-title">SA West Model</h1>
</div>

<!-- Content Section -->
<div class="content-container model-content">

<!-- GIF Section -->
<div class="model-images">
<div class="gif-container">
<h3>SST</h3>
<img src="croco_avg_temp_surf.gif" alt="Sea Surface Temperature Animation">
</div>
<div class="gif-container">
<h3>Temp at 100m</h3>
<img src="croco_avg_temp_100m.gif" alt="Temperature at 100m Animation">
</div>
</div>

<!-- Right Section: Blurb -->
<div class="model-description">
<h2>Algoa Bay Model</h2>
<p>
Past, present and future ocean state at the water surface from a Coastal and Regional Ocean
Community (CROCO) numerical model configuration of the Algoa Bay region. The model is
initialized once a day, and produces output at an hourly temporal resolution for a period
of 5 days into the past to 5 days into the future.
</p>
<p>
The provided variables are sea surface temperature (SST), sea surface height (SSH), salinity,
and surface currents. Boundary conditions for the model are obtained from the ~9km resolution
Mercator global ocean analysis and forecast product, while surface forcing is obtained from
the Global Forecast System (GFS).
</p>
<p>
Our configuration represents a 'downscaling' of the Mercator global ocean product to high
resolution (~500 m) over Algoa Bay, allowing for the simulation of local bay-scale processes.
</p>
</div>

</div>

</body>
</html>



Loading

0 comments on commit f3a2e47

Please sign in to comment.