mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-05-04 20:42:16 +02:00
refactor
This commit is contained in:
@@ -211,7 +211,7 @@ NOAAalertCount = 2
|
||||
# use Open-Meteo API for weather data not NOAA useful for non US locations
|
||||
UseMeteoWxAPI = False
|
||||
|
||||
# Global Tide Prediction using tidepredict (for non-US locations)
|
||||
# Global Tide Prediction using tidepredict (for non-US locations or offline use)
|
||||
# When enabled, uses tidepredict library for global tide predictions instead of NOAA API
|
||||
# tidepredict uses University of Hawaii's Research Quality Dataset for worldwide coverage
|
||||
useTidePredict = False
|
||||
|
||||
19
mesh_bot.py
19
mesh_bot.py
@@ -1428,10 +1428,21 @@ def handle_repeaterQuery(message_from_id, deviceID, channel_number):
|
||||
return "Repeater lookup not enabled"
|
||||
|
||||
def handle_tide(message_from_id, deviceID, channel_number, vox=False):
|
||||
if vox:
|
||||
return get_NOAAtide(str(my_settings.latitudeValue), str(my_settings.longitudeValue))
|
||||
# Check if tidepredict (xtide) is enabled
|
||||
location = get_node_location(message_from_id, deviceID, channel_number)
|
||||
return get_NOAAtide(str(location[0]), str(location[1]))
|
||||
lat = str(location[0])
|
||||
lon = str(location[1])
|
||||
if lat == "0.0" or lon == "0.0":
|
||||
lat = str(my_settings.latitudeValue)
|
||||
lon = str(my_settings.longitudeValue)
|
||||
|
||||
if my_settings.useTidePredict:
|
||||
logger.debug("System: Location: Using tidepredict")
|
||||
return xtide.get_tide_predictions(lat, lon)
|
||||
else:
|
||||
# Fallback to NOAA tide data
|
||||
logger.debug("System: Location: Using NOAA")
|
||||
return get_NOAAtide(str(location[0]), str(location[1]))
|
||||
|
||||
def handle_moon(message_from_id, deviceID, channel_number, vox=False):
|
||||
if vox:
|
||||
@@ -1553,6 +1564,8 @@ def handle_boot(mesh=True):
|
||||
|
||||
if my_settings.coastalEnabled:
|
||||
logger.debug("System: Coastal Forecast and Tide Enabled!")
|
||||
if my_settings.useTidePredict:
|
||||
logger.debug("System: Using Local TidePredict for Tide Data")
|
||||
|
||||
if games_enabled:
|
||||
logger.debug("System: Games Enabled!")
|
||||
|
||||
@@ -175,17 +175,7 @@ def getArtSciRepeaters(lat=0, lon=0):
|
||||
return msg
|
||||
|
||||
def get_NOAAtide(lat=0, lon=0):
|
||||
# Check if tidepredict (xtide) is enabled
|
||||
if my_settings.useTidePredict:
|
||||
try:
|
||||
from modules import xtide
|
||||
if xtide.is_enabled():
|
||||
logger.debug("Location: Using tidepredict for global tide data")
|
||||
return xtide.get_tide_predictions(lat, lon)
|
||||
except Exception as e:
|
||||
logger.warning(f"Location: Failed to use tidepredict, falling back to NOAA: {e}")
|
||||
|
||||
# Original NOAA implementation
|
||||
# get tide data from NOAA for lat/lon
|
||||
station_id = ""
|
||||
location = lat,lon
|
||||
if float(lat) == 0 and float(lon) == 0:
|
||||
|
||||
@@ -125,6 +125,10 @@ if coastalEnabled:
|
||||
from modules.locationdata import * # from the spudgunman/meshing-around repo
|
||||
trap_list = trap_list + ("mwx","tide",)
|
||||
help_message = help_message + ", mwx, tide"
|
||||
if useTidePredict:
|
||||
from modules import xtide
|
||||
trap_list = trap_list + ("tide",)
|
||||
help_message = help_message + ", tide"
|
||||
|
||||
# BBS Configuration
|
||||
if bbs_enabled:
|
||||
|
||||
@@ -28,7 +28,7 @@ if os.path.isfile(checkall_path):
|
||||
|
||||
|
||||
# List of module names to exclude
|
||||
exclude = ['test_bot','udp', 'system', 'log', 'gpio', 'web',]
|
||||
exclude = ['test_bot','udp', 'system', 'log', 'gpio', 'web','test_xtide',]
|
||||
available_modules = [
|
||||
m.name for m in pkgutil.iter_modules([modules_path])
|
||||
if m.name not in exclude]
|
||||
|
||||
@@ -94,6 +94,18 @@ The module couldn't find a nearby station. This may happen if:
|
||||
- The station database hasn't been initialized
|
||||
- Network issues prevented loading the station list
|
||||
|
||||
Tide Station Map
|
||||
[https://uhslc.soest.hawaii.edu/network/](https://uhslc.soest.hawaii.edu/network/)
|
||||
- click on Tide Guages
|
||||
- Find yourself on the map
|
||||
- Locate the closest Gauge and its name (typically the city name)
|
||||
|
||||
To manually download data for the station first location the needed station id
|
||||
- `python -m tidepredict -l "Port Angeles"` finds a station
|
||||
- `python -m tidepredict -l "Port Angeles" -genharm` downloads that datafile
|
||||
|
||||
|
||||
|
||||
## Data Source
|
||||
|
||||
Tide predictions are based on harmonic analysis of historical tide data from:
|
||||
|
||||
@@ -13,7 +13,7 @@ try:
|
||||
TIDEPREDICT_AVAILABLE = True
|
||||
except ImportError:
|
||||
TIDEPREDICT_AVAILABLE = False
|
||||
logger.warning("xtide: tidepredict module not installed. Install with: pip install tidepredict")
|
||||
logger.error("xtide: tidepredict module not installed. Install with: pip install tidepredict")
|
||||
|
||||
def get_nearest_station(lat, lon):
|
||||
"""
|
||||
@@ -114,7 +114,7 @@ def get_tide_predictions(lat=0, lon=0, days=1):
|
||||
- Formatted string with tide predictions or error message
|
||||
"""
|
||||
if not TIDEPREDICT_AVAILABLE:
|
||||
return "tidepredict library not installed"
|
||||
return "module not installed, see logs for more ⚓️"
|
||||
|
||||
if float(lat) == 0 and float(lon) == 0:
|
||||
return "No GPS data for tide prediction"
|
||||
@@ -132,7 +132,7 @@ def get_tide_predictions(lat=0, lon=0, days=1):
|
||||
|
||||
# Check if harmonic data exists for this station
|
||||
if station_code not in station_dict:
|
||||
logger.warning(f"xtide: No harmonic data for {station_name}.")
|
||||
logger.warning(f"xtide: No harmonic data. python -m tidepredict -l \"{station_name}\" -genharm")
|
||||
return f"Tide data not available for {station_name}. Station database may need initialization."
|
||||
|
||||
# Reconstruct tide model
|
||||
|
||||
@@ -7,5 +7,4 @@ maidenhead
|
||||
beautifulsoup4
|
||||
dadjokes
|
||||
geopy
|
||||
schedule
|
||||
tidepredict
|
||||
schedule
|
||||
Reference in New Issue
Block a user