meteociel.forecasts.forecast
- meteociel.forecasts.forecast(*, city_name: str = '', city_id: str = '', mode: str = 'forecasts', model: str = 'gfs')
Get the data of the forecasts or trends from the city name or id and given model. You can give the name or the id, but at least one of the both. If you give both, the id will have an higher priority.
Warning
Some cities across the world have the same name, so be careful when dumping data. To be sure, you can search by city id. Moreover, all the models aren’t available everywhere.
Available models Model name
Coverage
Resolution
GFS
Global
25km
WRF
Western Europe [1]
5km
AROME
France
1km
ARPEGE
Europe
10km
ICON-EU
Europe
7km
ICON-D2
Central Europe
2.2km
Parameters
- city_name
str, keyword-only, optionnal By default:
"". The name of the requested city.- city_id
str, keyword-only, optionnal By default, this feature is disabled. By passing directly the city id, the API will search by id rather than by name. The city id can be manually found by accessing: https://www.meteociel.fr/prevville.php, then search for the city you want, you will have an url of the form:
https://www.meteociel.fr/previsions/CityId/CityName.htmwhereCityIdshould be a number.Important
Search by identifier takes precedence over search by name.
- mode
str, keyword_only, optionnal By default:
"forecasts". There is two available modes:"forecasts"that provides data for the three days ahead;"trends"that provides data for the ten days ahead but with lower confidence.
- model
str, keyword_only, optionnal By default:
"gfs". The model from which the data are obtained. The available models are:"gfs": an american global model (25km);"wrf","wrf-1h": an american non-hydrostatic limited area model (5km) you can pass"wrf-1h"to have hourly data;"arome","arome-1h": a french limited area model (1km), hourly data are also available;"arpege-1h": a french global area (10km), only hourly data available;"iconeu": a german limited-area model (7km);"icond2": a german limited-area model (2.2km).
Note
The
modelparameter is only available in"forecasts"mode, otherwise it will ignored.
Returns
- out
tuple(str, pd.DataFrame) A tuple that contains two elements:
the name of the city;
the requested forecast data in a
DataFrame.
Raises
- UnknownModeError
This exception is raised if the given
modeis unknown.- UnknownModelError
This exception is raised if the given
modelis unknown.
Exemples
Extraction of Paris (France) weather forecasts data with the hourly arome model:
>>> from meteociel.forecasts import forecast >>> city_name, data = forecast(city_name="Paris (75000)", model="arome-1h") >>> data date temperature windchill ... rain humidity pressure 0 2024-06-23 03:00:00 15.0 15.0 ... 0 80.0 1019.0 1 2024-06-23 04:00:00 14.0 14.0 ... 0 79.0 1020.0 2 2024-06-23 05:00:00 14.0 14.0 ... 0 78.0 1020.0 3 2024-06-23 06:00:00 14.0 14.0 ... 0 78.0 1020.0 4 2024-06-23 07:00:00 14.0 14.0 ... 0 77.0 1020.0 5 2024-06-23 08:00:00 15.0 15.0 ... 0 73.0 1021.0 ... ... ... ... ... ... ... ... 41 2024-06-24 20:00:00 27.0 30.0 ... 0 41.0 1014.0
Extraction of weather trends by id (here for Berlin, Germany):
>>> from meteociel.forecasts import forecast >>> city_name, data = forecast(city_id=49679, mode="trends") >>> city_name berlin >>> data date temperature windchill ... rain humidity pressure 0 2024-06-26 20:00:00 27.0 32.0 ... 0.0 53.0 1009.0 1 2024-06-27 02:00:00 20.0 26.0 ... 1.6 82.0 1010.0 2 2024-06-27 08:00:00 22.0 27.0 ... 0.0 72.0 1009.0 3 2024-06-27 14:00:00 32.0 36.0 ... 0.0 39.0 1008.0 4 2024-06-27 20:00:00 23.0 31.0 ... 1.7 82.0 1009.0 5 2024-06-28 02:00:00 21.0 28.0 ... 1.5 91.0 1008.0 ... ... ... ... ... ... ... ... 25 2024-07-03 02:00:00 14.0 12.0 ... 2.6 94.0 1007.0
- city_name