Cette page fournit une interface de navigation pour trouver toutes les valeurs d’une propriété et une page donnée. D’autres interfaces de recherche disponibles incluent la recherche de propriété et le constructeur de requête « ask » .
Liste de résultats <nowiki>import requests<br />& … <nowiki>import requests<br /><br />from bs4 import BeautifulSoup<br /><br />class AQIRepository:<br /><br />URL = "https://www.atmo-nouvelleaquitaine.org/air-commune/Bordeaux/33063/indice-atmo?date=2025-10-14"<br /><br />def __init__(self):<br /><br />self.cat_to_conc = {<br /><br />'Bon': {'PM2.5': 5.0, 'PM10': 15.0, 'O3': 0.040, 'NO2': 20.0, 'SO2': 5.0},<br /><br />'Moyen': {'PM2.5': 20.0, 'PM10': 40.0, 'O3': 0.060, 'NO2': 60.0, 'SO2': 20.0},<br /><br />'Mauvais':{'PM2.5': 40.0, 'PM10': 100.0,'O3': 0.100, 'NO2': 150.0,'SO2': 100.0},<br /><br />'Très mauvais':{'PM2.5':120.0,'PM10':300.0,'O3':0.180,'NO2':800.0,'SO2':500.0}<br /><br />}<br /><br />self.breakpoints = {<br /><br />'PM2.5': [(0.0,12.0,0,50),(12.1,35.4,51,100),(35.5,55.4,101,150),(55.5,150.4,151,200)],<br /><br />'PM10': [(0,54,0,50),(55,154,51,100),(155,254,101,150),(255,354,151,200)],<br /><br />'O3': [(0.000,0.054,0,50),(0.055,0.070,51,100),(0.071,0.085,101,150)],<br /><br />'NO2': [(0,53,0,50),(54,100,51,100),(101,360,101,150),(361,649,151,200)],<br /><br />'SO2': [(0,35,0,50),(36,75,51,100),(76,185,101,150),(186,304,151,200)],<br /><br />}<br /><br />def linear_scale(self, C, C_low, C_high, I_low, I_high):<br /><br />return round((I_high - I_low) / (C_high - C_low) * (C - C_low) + I_low)<br /><br />def find_aqi_subindex(self, C, pollutant):<br /><br />for (C_low, C_high, I_low, I_high) in self.breakpoints[pollutant]:<br /><br />if C_low <= C <= C_high:<br /><br />return self.linear_scale(C, C_low, C_high, I_low, I_high)<br /><br />return None<br /><br />def scrape_categories(self):<br /><br />response = requests.get(self.URL, timeout=10)<br /><br />soup = BeautifulSoup(response.text, "html.parser")<br /><br />categories = {}<br /><br />blocks = soup.select(".c-indice-polluant")<br /><br />for block in blocks:<br /><br />title_tag = block.select_one(".c-indice-polluant-title span")<br /><br />cat_tag = block.select_one(".home-map-legend-item span")<br /><br />if title_tag and cat_tag:<br /><br />name = title_tag.get_text(strip=True).replace("₂", "2").replace("₃", "3")<br /><br />cat = cat_tag.get_text(strip=True)<br /><br />categories[name] = cat<br /><br />return categories<br /><br />def compute_aqi(self, categories):<br /><br />concentrations = {k: self.cat_to_conc[v][k] for k, v in categories.items() if k in self.cat_to_conc[v]}<br /><br />subindices = {k: self.find_aqi_subindex(concentrations[k], k) for k in concentrations}<br /><br />aqi_global = max(v for v in subindices.values() if v is not None)<br /><br />return aqi_global, subindices <br /><br />import requests<br /><br />class MeteoRepository:<br /><br />def __init__(self, latitude=44.8378, longitude=-0.5792):<br /><br />self.latitude = latitude<br /><br />self.longitude = longitude<br /><br />self.api_url = (<br /><br />"https://api.open-meteo.com/v1/forecast?"<br /><br />f"latitude={self.latitude}&longitude={self.longitude}"<br /><br />"&hourly=temperature_2m,precipitation,weathercode"<br /><br />"¤t_weather=true&timezone=Europe%2FParis"<br /><br />)<br /><br />def get_weather(self):<br /><br />response = requests.get(self.api_url, timeout=10)<br /><br />data = response.json()<br /><br />return data.get("current_weather", {})<br /><br />def compute_weather_score(self, weather):<br /><br />wmo_scores = {<br /><br />0: 100, 1: 90, 2: 80, 3: 70, 45: 60, 48: 55,<br /><br />51: 50, 53: 45, 55: 40, 61: 35, 63: 25, 65: 15,<br /><br />71: 25, 73: 15, 75: 5, 95: 10, 99: 0,<br /><br />}<br /><br />temp = weather.get("temperature", 20)<br /><br />wind = weather.get("windspeed", 10)<br /><br />code = weather.get("weathercode", 0)<br /><br />base_score = wmo_scores.get(code, 60)<br /><br />if temp < 0:<br /><br />temp_penalty = 30<br /><br />elif temp < 10:<br /><br />temp_penalty = 15<br /><br />elif temp > 30:<br /><br />temp_penalty = 20<br /><br />else:<br /><br />temp_penalty = 0<br /><br />wind_penalty = 0<br /><br />if wind > 40:<br /><br />wind_penalty = 20<br /><br />elif wind > 25:<br /><br />wind_penalty = 10<br /><br />score = base_score - temp_penalty - wind_penalty<br /><br />return round(max(0, min(100, score)))<br /><br />import requests<br /><br />import json<br /><br />class TrafficRepository:<br /><br />BASE_URL = "https://data.bordeaux-metropole.fr/geojson"<br /><br />def __init__(self, api_key="2HH8S7FKPP", typename="ci_trafi_l"):<br /><br />self.api_key = api_key<br /><br />self.typename = typename<br /><br />def get_traffic_by_gid(self, gid=2215):<br /><br />params = {<br /><br />"key": self.api_key,<br /><br />"typename": self.typename,<br /><br />"filter": json.dumps({"gid": gid}),<br /><br />}<br /><br />response = requests.get(self.BASE_URL, params=params, timeout=10)<br /><br />if response.status_code != 200:<br /><br />raise Exception(f"Erreur API {response.status_code} : {response.text}")<br /><br />return response.json()<br /><br />def compute_traffic_score(self, traffic_data):<br /><br />features = traffic_data.get("features", [])<br /><br />if not features:<br /><br />return 50<br /><br />props = features[0].get("properties", {})<br /><br />etat = props.get("etat_trafic") or props.get("etat") or "INCONNU"<br /><br />mapping = {"FLUIDE": 100, "RALENTI": 70, "EMBOUTEILLE": 30, "INCONNU": 50}<br /><br />return mapping.get(etat.upper(), 50)<br /><br />import requests<br /><br />import json<br /><br />from datetime import datetime, timezone<br /><br />class TbmRepository:<br /><br />BASE_URL = "https://data.bordeaux-metropole.fr/geojson"<br /><br />def __init__(self, api_key="2HH8S7FKPP", arret_id=4037):<br /><br />self.api_key = api_key<br /><br />self.arret_id = arret_id<br /><br />def get_next_tram(self, max_results=100):<br /><br />params = {<br /><br />"key": self.api_key,<br /><br />"typename": "sv_horai_a",<br /><br />"filter": json.dumps({"rs_sv_arret_p": self.arret_id}),<br /><br />"orderby": json.dumps(["hor_theo"]),<br /><br />"maxfeatures": max_results<br /><br />}<br /><br />response = requests.get(self.BASE_URL, params=params)<br /><br />response.raise_for_status()<br /><br />data = response.json()<br /><br />now = datetime.now(timezone.utc)<br /><br />for feature in data.get("features", []):<br /><br />props = feature.get("properties", {})<br /><br />hor_theo = props.get("hor_theo")<br /><br />if not hor_theo:<br /><br />continue<br /><br />try:<br /><br />tram_time = datetime.fromisoformat(hor_theo)<br /><br />except ValueError:<br /><br />continue<br /><br />if tram_time > now:<br /><br />diff_sec = int((tram_time - now).total_seconds())<br /><br />return {"heure": tram_time, "seconds": diff_sec, "etat": props.get("etat"), "type": props.get("type")}<br /><br />return None<br /><br />from AQIRepository import AQIRepository<br /><br />from MeteoRepository import MeteoRepository<br /><br />from TrafficRepository import TrafficRepository<br /><br />from TramRepository import TbmRepository<br /><br />from fastapi import FastAPI<br /><br />app = FastAPI()<br /><br />@app.get("/")<br /><br />def read_root():<br /><br />longitude = -0.5935101<br /><br />latitude = 44.8538665<br /><br />borneTraficGID = 2215<br /><br />Aqirepo = AQIRepository()<br /><br />categories = Aqirepo.scrape_categories()<br /><br />aqi, details = Aqirepo.compute_aqi(categories)<br /><br />meteo = MeteoRepository(latitude=latitude, longitude=longitude)<br /><br />weather = meteo.get_weather()<br /><br />score_M = meteo.compute_weather_score(weather)<br /><br />traffic = TrafficRepository()<br /><br />data = traffic.get_traffic_by_gid(borneTraficGID)<br /><br />score_T = traffic.compute_traffic_score(data)<br /><br />tbm = TbmRepository(arret_id=4037)<br /><br />prochain = tbm.get_next_tram()<br /><br />if prochain and 'seconds' in prochain:<br /><br />TP_seconds = prochain['seconds']<br /><br />else:<br /><br />TP_seconds = 3600<br /><br />max_tp_seconds = 3600<br /><br />TP_score = max(0, min(100, 100 - (TP_seconds / max_tp_seconds) * 100))<br /><br />IMR = (<br /><br />0.4 * (100 - aqi) +<br /><br />0.3 * (100 - score_T) +<br /><br />0.2 * TP_score +<br /><br />0.1 * score_M<br /><br />)<br /><br />return {"IMR": round(IMR, 1)}<br /><br /><br /><br /><br /><br /><br/></nowiki> e(data)<br /><br />tbm = TbmRepository(arret_id=4037)<br /><br />prochain = tbm.get_next_tram()<br /><br />if prochain and 'seconds' in prochain:<br /><br />TP_seconds = prochain['seconds']<br /><br />else:<br /><br />TP_seconds = 3600<br /><br />max_tp_seconds = 3600<br /><br />TP_score = max(0, min(100, 100 - (TP_seconds / max_tp_seconds) * 100))<br /><br />IMR = (<br /><br />0.4 * (100 - aqi) +<br /><br />0.3 * (100 - score_T) +<br /><br />0.2 * TP_score +<br /><br />0.1 * score_M<br /><br />)<br /><br />return {"IMR": round(IMR, 1)}<br /><br /><br /><br /><br /><br /><br/></nowiki> Analyse des sources disponibles sur les sites de TBM et de Bordeaux Métropole pour identifier les bénéfices environnementaux du tramway et du réseau de bus. + Bois, LED, papier transparent, éléments imprimés en 3D, ainsi que des cartes électroniques(Arduino ) pour la rotation et l’éclairage des LED. + Chaque participant partage sa compréhension du thème. Toutes les idées et les mots-clés sont ensuite notés et organisés sous forme de schéma. + Conception d’une machine capable d’analyser la qualité de l’air et le trafic, afin de proposer le meilleur moyen de transport entre bus, tram, voiture ou taxi. +
Vous avez entré un nom de page invalide, avec un ou plusieurs caractères suivants :
< > @ ~ : * € £ ` + = / \ | [ ] { } ; ? #
Pas encore enregistré ? Créez un compte pour profiter de toutes les fonctionnalités du service !
Copiez-collez le code ci-dessous à intégrer sur votre page