Package: pyebas
pyebaspyebas is created for an easy-access to open-source air pollutant data fromEBAS databasevia theirFTP server. EBAS database collects mainly from EU air pollutant monitoring programs.pyebas provides can both download files from EBAS database and created local database for further usage. The downloaded raw EBAS files (.nc file) can be exported to .csv files. The local pyebas database converts ~25GB EBAS raw data to ~800MB local files. Users can access and query data through local database.Import pyebaspip3installpyebasfrompyebasimport*Download EBAS data (.nc files)# set selection conditions# if you need the whole EBAS database, set conditions as Noneconditions={"start_year":1990,"end_year":2021,"site":['ES0010R','ES0011R'],"matrix":['air'],"components":['NOx'],}# set local stroage pathdb_dir=r'ebas_db'downloader=EbasDownloader(loc=db_dir)# download requires multiprocessing, error may occurs because of multiprocessing# use command line or Jupyter Notebook to prevent errorsdownloader.get_raw_files(conditions=conditions,download=True)Export to .csv file# export all the downloaded .nc files in the output path to .csv# important: .csv file might be very large.csv_exporter=csvExporter(loc=db_dir)csv_exporter.export_csv('export.csv')Create local database# set local stroage path, must be the same as previous pathdb_dir=r'ebas_db'# local database objectdb=EbasDB(dir=db_dir,dump='xz',detailed=True)# create/update database with new filesdb.update_db()Open local database# set local stroage pathdb_dir=r'ebas_db'# local database objectdb=EbasDB(dir=db_dir,dump='xz',detailed=True)# open database if it is createddb.init_db()Query data from local database as pandas.DataFramecondition={"id":["AM0001R","EE0009R",'ES0010R','ES0011R'],"component":["NOx","nitrate","nitric_acid"],"matrix":["air","aerosol"],"stat":['arithmetic mean',"median"],"st":np.datetime64("1970-01-01"),"ed":np.datetime64("2021-10-01"),# if you want to include all, just remove the condition#"country":["Denmark","France"],}df=db.query(condition,use_number_indexing=False)df.head(20)Access detail information# access information for one sitedb.site_index["ES0011R"]db.site_index["ES0011R"]["components"].keys()db.site_index["ES0011R"]["files"]Get summary# get summary informationdb.list_sites()# possible keys are: "id","name","country","station_setting", "lat", "lon","alt","land_use", "file_num","components"db.list_sites(keys=["name","lat","lon"])# if components are selected, set list_time=True to see the starting and ending timedb.list_sites(keys=["name","components"],list_time=True)Use command linePossible arguments, usepyebas --helpfor details and options formatrixandcomponents:pyebas<startingyear><endingyear>--mode<csv,db,query>--site<siteid,siteid>--matrix<matrixtype>--components<componentname>--output<outputpath>Example 1: download NOx measurements in air of two sites (ES0010R and ES0011R) from 2019 to 2021, the results will be exported as .csv file.pyebas20192021--modecsv--siteES0010RES0011R--matrixair--componentsNOx--output.\simple_csvExample 2: download all measurements from 2019 to 2021, and stored in local database.pyebas20192021--modedb--output.\ebasStart querying with the created local database (you need enter conditions through terminal later, and the results can be exported to .csv files).pythonmain.py20192021--modequery--out.\ebas