Compare commits
2 Commits
cf4e506523
...
ddc7446d8c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddc7446d8c | ||
|
|
c2b3f9650b |
166
chom.json
Normal file
166
chom.json
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
{
|
||||||
|
"shom_id": "386",
|
||||||
|
"name": "BALISE_A",
|
||||||
|
"longitude": 0.110667,
|
||||||
|
"latitude": 49.431833,
|
||||||
|
"state": "OK",
|
||||||
|
"reseau": "REFMAR",
|
||||||
|
"alertCustom": false,
|
||||||
|
"delai_alerte": "06:00",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"individual_name": "HAROPA PORT | Rouen",
|
||||||
|
"organization_name": "HAROPA PORT | Rouen",
|
||||||
|
"voice": "",
|
||||||
|
"delivery_point": "",
|
||||||
|
"city": "",
|
||||||
|
"postal_code": "",
|
||||||
|
"electronic_mail_address": "scan@rouen.port.fr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"events": [
|
||||||
|
{
|
||||||
|
"id": "1855",
|
||||||
|
"tide_gauge_id": "386",
|
||||||
|
"content": "P\u00e9riode d'\u00e9chantillonnage = 1 seconde\nDur\u00e9e d'int\u00e9gration = 61 secondes\nP\u00e9riode d'archivage = 5 minutes\n\nLa p\u00e9riode d'archivage n'est pas centr\u00e9e sur la dur\u00e9e d'int\u00e9gration mais uniquement sur la derni\u00e8re observation.",
|
||||||
|
"creation_date": "2023-08-30T12:21:06.000Z",
|
||||||
|
"due_date": "2015-01-01T01:00:00.000Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"organismes": [
|
||||||
|
{
|
||||||
|
"nom": "HAROPA PORT | Rouen",
|
||||||
|
"logo": "https://services.data.shom.fr/static/logo/DDM/logo_GPM_le_havre.png",
|
||||||
|
"url": "https://www.haropaport.com/fr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"verticalRef": {
|
||||||
|
"nom_ref": "IGN69",
|
||||||
|
"zero_hydro": "zero_hydrographique",
|
||||||
|
"zh_ref": "-4.38"
|
||||||
|
},
|
||||||
|
"date_prem_obs": "1985-03-31",
|
||||||
|
"fuseau_horaire": "0",
|
||||||
|
"gestionnaire": "Grand Port Maritime Rouen",
|
||||||
|
"id_ram": "PK 364,775 : Balise A",
|
||||||
|
"info_maregraphe": "https://refmar.shom.fr/donnees/386",
|
||||||
|
"journal_de_bord": "https://refmar.shom.fr/donnees/386",
|
||||||
|
"niveau_moyen": "4.91",
|
||||||
|
"npbma": "0.21",
|
||||||
|
"nphma": "8.64",
|
||||||
|
"sect_geographique": "FH",
|
||||||
|
"spm": "BALISE_A",
|
||||||
|
"ville_d_hebergement": "Le Havre"
|
||||||
|
}
|
||||||
|
2025-04-24 16:11:23,976 - INFO - Hauteur de la marée : -4.38 mètres
|
||||||
|
print: -4.38
|
||||||
|
2025-04-24 16:11:34,227 - INFO - {
|
||||||
|
"shom_id": "386",
|
||||||
|
"name": "BALISE_A",
|
||||||
|
"longitude": 0.110667,
|
||||||
|
"latitude": 49.431833,
|
||||||
|
"state": "OK",
|
||||||
|
"reseau": "REFMAR",
|
||||||
|
"alertCustom": false,
|
||||||
|
"delai_alerte": "06:00",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"individual_name": "HAROPA PORT | Rouen",
|
||||||
|
"organization_name": "HAROPA PORT | Rouen",
|
||||||
|
"voice": "",
|
||||||
|
"delivery_point": "",
|
||||||
|
"city": "",
|
||||||
|
"postal_code": "",
|
||||||
|
"electronic_mail_address": "scan@rouen.port.fr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"events": [
|
||||||
|
{
|
||||||
|
"id": "1855",
|
||||||
|
"tide_gauge_id": "386",
|
||||||
|
"content": "P\u00e9riode d'\u00e9chantillonnage = 1 seconde\nDur\u00e9e d'int\u00e9gration = 61 secondes\nP\u00e9riode d'archivage = 5 minutes\n\nLa p\u00e9riode d'archivage n'est pas centr\u00e9e sur la dur\u00e9e d'int\u00e9gration mais uniquement sur la derni\u00e8re observation.",
|
||||||
|
"creation_date": "2023-08-30T12:21:06.000Z",
|
||||||
|
"due_date": "2015-01-01T01:00:00.000Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"organismes": [
|
||||||
|
{
|
||||||
|
"nom": "HAROPA PORT | Rouen",
|
||||||
|
"logo": "https://services.data.shom.fr/static/logo/DDM/logo_GPM_le_havre.png",
|
||||||
|
"url": "https://www.haropaport.com/fr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"verticalRef": {
|
||||||
|
"nom_ref": "IGN69",
|
||||||
|
"zero_hydro": "zero_hydrographique",
|
||||||
|
"zh_ref": "-4.38"
|
||||||
|
},
|
||||||
|
"date_prem_obs": "1985-03-31",
|
||||||
|
"fuseau_horaire": "0",
|
||||||
|
"gestionnaire": "Grand Port Maritime Rouen",
|
||||||
|
"id_ram": "PK 364,775 : Balise A",
|
||||||
|
"info_maregraphe": "https://refmar.shom.fr/donnees/386",
|
||||||
|
"journal_de_bord": "https://refmar.shom.fr/donnees/386",
|
||||||
|
"niveau_moyen": "4.91",
|
||||||
|
"npbma": "0.21",
|
||||||
|
"nphma": "8.64",
|
||||||
|
"sect_geographique": "FH",
|
||||||
|
"spm": "BALISE_A",
|
||||||
|
"ville_d_hebergement": "Le Havre"
|
||||||
|
}
|
||||||
|
2025-04-24 16:11:34,227 - INFO - Hauteur de la marée : -4.38 mètres
|
||||||
|
print: -4.38
|
||||||
|
2025-04-24 16:11:44,339 - INFO - {
|
||||||
|
"shom_id": "386",
|
||||||
|
"name": "BALISE_A",
|
||||||
|
"longitude": 0.110667,
|
||||||
|
"latitude": 49.431833,
|
||||||
|
"state": "OK",
|
||||||
|
"reseau": "REFMAR",
|
||||||
|
"alertCustom": false,
|
||||||
|
"delai_alerte": "06:00",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"individual_name": "HAROPA PORT | Rouen",
|
||||||
|
"organization_name": "HAROPA PORT | Rouen",
|
||||||
|
"voice": "",
|
||||||
|
"delivery_point": "",
|
||||||
|
"city": "",
|
||||||
|
"postal_code": "",
|
||||||
|
"electronic_mail_address": "scan@rouen.port.fr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"events": [
|
||||||
|
{
|
||||||
|
"id": "1855",
|
||||||
|
"tide_gauge_id": "386",
|
||||||
|
"content": "P\u00e9riode d'\u00e9chantillonnage = 1 seconde\nDur\u00e9e d'int\u00e9gration = 61 secondes\nP\u00e9riode d'archivage = 5 minutes\n\nLa p\u00e9riode d'archivage n'est pas centr\u00e9e sur la dur\u00e9e d'int\u00e9gration mais uniquement sur la derni\u00e8re observation.",
|
||||||
|
"creation_date": "2023-08-30T12:21:06.000Z",
|
||||||
|
"due_date": "2015-01-01T01:00:00.000Z"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"organismes": [
|
||||||
|
{
|
||||||
|
"nom": "HAROPA PORT | Rouen",
|
||||||
|
"logo": "https://services.data.shom.fr/static/logo/DDM/logo_GPM_le_havre.png",
|
||||||
|
"url": "https://www.haropaport.com/fr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"verticalRef": {
|
||||||
|
"nom_ref": "IGN69",
|
||||||
|
"zero_hydro": "zero_hydrographique",
|
||||||
|
"zh_ref": "-4.38"
|
||||||
|
},
|
||||||
|
"date_prem_obs": "1985-03-31",
|
||||||
|
"fuseau_horaire": "0",
|
||||||
|
"gestionnaire": "Grand Port Maritime Rouen",
|
||||||
|
"id_ram": "PK 364,775 : Balise A",
|
||||||
|
"info_maregraphe": "https://refmar.shom.fr/donnees/386",
|
||||||
|
"journal_de_bord": "https://refmar.shom.fr/donnees/386",
|
||||||
|
"niveau_moyen": "4.91",
|
||||||
|
"npbma": "0.21",
|
||||||
|
"nphma": "8.64",
|
||||||
|
"sect_geographique": "FH",
|
||||||
|
"spm": "BALISE_A",
|
||||||
|
"ville_d_hebergement": "Le Havre"
|
||||||
|
}
|
||||||
37
main.py
37
main.py
@ -8,9 +8,13 @@ import json
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
# Configuration de l'API REFMAR
|
# Configuration de l'API REFMAR
|
||||||
API_URL = "https://services.data.shom.fr/maregraphie/service/completetidegauge"
|
# API_URL = "https://services.data.shom.fr/maregraphie/service/completetidegauge"
|
||||||
|
# API_URL = "https://services.data.shom.fr/maregraphie/observation/json"
|
||||||
|
# curl -X GET "https://services.data.shom.fr/maregraphie/observation/json/386?sources=1&dtStart=2025-05-22T15%3A56%3A00Z&dtEnd=2025-05-22T15%3A57%3A00Z&interval=1" -H "accept: application/json"
|
||||||
# API_KEY = "votre_cle_api" # Remplacez par votre clé API
|
# API_KEY = "votre_cle_api" # Remplacez par votre clé API
|
||||||
STATION = '386' # Identifiant de la station du Havre
|
# STATION = '386' # Identifiant de la station du Havre
|
||||||
|
|
||||||
|
API_URL = "https://data.haropaport.com/sig/capteur/hauteur"
|
||||||
|
|
||||||
UDP_IP = "127.0.0.1"
|
UDP_IP = "127.0.0.1"
|
||||||
UDP_PORT = 8765
|
UDP_PORT = 8765
|
||||||
@ -26,11 +30,13 @@ def fetch_data():
|
|||||||
# "Ocp-Apim-Subscription-Key": API_KEY,
|
# "Ocp-Apim-Subscription-Key": API_KEY,
|
||||||
}
|
}
|
||||||
params = {
|
params = {
|
||||||
# "station": STATION,
|
# "sources": 1,
|
||||||
# "time": "current", # Vous pouvez ajuster ce paramètre selon vos besoins
|
# "dtStart": "2025-05-22T10:00:00Z",
|
||||||
|
# "dtEnd": "2025-05-22T17:00:00Z",
|
||||||
|
# # "interval": 1
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
response = requests.get(API_URL+"/"+STATION, headers=headers, params=params)
|
response = requests.get(API_URL, headers=headers, params=params)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response.json()
|
return response.json()
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
@ -40,12 +46,11 @@ def fetch_data():
|
|||||||
def process_data(data):
|
def process_data(data):
|
||||||
"""Traite les données récupérées."""
|
"""Traite les données récupérées."""
|
||||||
try:
|
try:
|
||||||
zh_ref = data.get("verticalRef", {}).get("zh_ref", 0)
|
for item in data['items']:
|
||||||
logging.info(f"Hauteur de la marée : {zh_ref} mètres")
|
if item['id'] == "hauteur_shom":
|
||||||
zh_ref_bytes = f"{zh_ref};".encode('utf-8')
|
logging.info(f"{item["capteur"]} Hauteur d'eau : {item["valeur"]} mètres")
|
||||||
sock.sendto(zh_ref_bytes, (UDP_IP, UDP_PORT))
|
hauteurdeau_bytes = f"{item["valeur"]};".encode('utf-8')
|
||||||
# sock.sendto(float(zh_ref).to_bytes(8, byteorder='big'), (UDP_IP, UDP_PORT))
|
sock.sendto(hauteurdeau_bytes, (UDP_IP, UDP_PORT))
|
||||||
# sock.sendto(float(zh_ref), (UDP_IP, UDP_PORT))
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Erreur lors du traitement des données : {e}")
|
logging.error(f"Erreur lors du traitement des données : {e}")
|
||||||
|
|
||||||
@ -54,21 +59,21 @@ def main():
|
|||||||
logging.info("Démarrage de l'application de traitement des données du marégraphe.")
|
logging.info("Démarrage de l'application de traitement des données du marégraphe.")
|
||||||
# lancement du patch pd
|
# lancement du patch pd
|
||||||
pd_patch = "./maregraphe.pd" # Remplace par le chemin de ton patch
|
pd_patch = "./maregraphe.pd" # Remplace par le chemin de ton patch
|
||||||
pd_process = subprocess.Popen(["pd", "-nogui", "-open", pd_patch])
|
# pd_process = subprocess.Popen(["pd", "-nogui", "-open", pd_patch])
|
||||||
|
pd_process = subprocess.Popen(["pd", "-open", pd_patch])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
print('/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / /')
|
||||||
data = fetch_data()
|
data = fetch_data()
|
||||||
logging.info(json.dumps(data, indent=2))
|
# logging.info(json.dumps(data, indent=2))
|
||||||
# print(data)
|
|
||||||
if data:
|
if data:
|
||||||
process_data(data)
|
process_data(data)
|
||||||
time.sleep(10) # 300 Attendre 5 minutes
|
time.sleep(10) # 300 Attendre 5 minutes
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Arrêt du script, fermeture de Pure Data...")
|
print("Arrêt du script, fermeture de Pure Data...")
|
||||||
pd_process.terminate()
|
pd_process.terminate()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user