Package: pyaemet
pyAEMETA python library developed to download daily climatological values from the Spanish National
Meteorological Agency (AEMET) through its OpenData API. The library contains several methods
to facilitate downloading and filtering the climatological data.The information that this library collects and uses is property of the Spanish State
Meteorological Agency, available through its AEMET OpenData REST API.Installation$pipinstallpyaemetTo use the pyAEMET module, you need to get an API key from the AEMET (Spanish State Meteorological
Agency) OpenData platform. You can apply for a keyhere.UsageOnce the module is installed and you have your API key, you can start using the module by
importing it in your Python script. To use the module's functions, you need to initialize
the client with your API key:importpyaemetaemet=pyaemet.AemetClima(api_key)TheAemetClimaclass takes an API key as a parameter in its constructor and allows you to get
information about the available monitoring sites, filter sites based on different parameters
(e.g., city, province, autonomous community), and get nearby sites to a specific location.Here is a summary of some of the methods provided by theAemetClimaclass:sites_info: Retrieves information about all the available monitoring sites. The method
returns an instance of theSitesDataFrameclass, which is a subclass of the pandasDataFrame.aemet.sites_info(update=True)sites_in: Filters the available monitoring sites based on specified parameters
(e.g., city, province, autonomous community). The method returns an instance of theSitesDataFrameclass.aemet.sites_in(subregion="Cantabria")near_sites: Retrieves then_nearmonitoring sites closest to a specified latitude and longitude,
within a maximum distance ofmax_distancekilometers. The method returns an instance of theNearSitesDataFrameclass.aemet.near_sites(latitude=43.47,longitude=-3.798,n_near=5,max_distance=50)sites_curation: Retrieves the amount of available data of certainvariablesin the monitoringsitesin a period of time defined bystart_dtandend_dt. The function returns aSitesDataFrameorNearSitesDataFrame(depends of the type of thesitesparameter given)
with a column with the averageamountbetween allvariablesandhas_enoughboolean if the amount is greater or equal to athreshold.daily_clima: Retrieves daily climate data for a givensiteor a list of sites over a
specified date range defined bystart_dtandend_dt. The function returns aObservationsDataFrameobject, which is a data structure that holds the retrieved climate data
along with any associated metadata.importdatetimeaemet.daily_clima(site=aemet.sites_in(city="Santander"),start_dt=datetime.date(2022,6,3),end_dt=datetime.date.today())The module also provides three deprecated methodsestaciones_info,estaciones_locandclima_diariathat perform similar functionality as thesites_info,sites_inanddaily_climamethods, respectively.You can find the complete documentation of the module's functions in the GitHub repository,
under the docs directory.FAQContributingReferences"Estimating changes in air pollutant levels due to COVID-19 lockdown measures based on a business-as-usual prediction scenario using data mining models: A case-study for urban traffic sites in Spain", submitted to Environmental Software & Modelling byJ. González-Pardoet al. (2021)