-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
My public dir as it currently looks locally
- Loading branch information
1 parent
0725445
commit f3a2e47
Showing
25 changed files
with
1,212 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
||
|
||
|
Oops, something went wrong.