Skip to main content

Easy download and export EBAS data

Project description

pyebas

pyebas is created for an easy-access to open-source air pollutant data from EBAS database via their FTP 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.

  1. Import pyebas

    from pyebas import *
    
  2. Download EBAS data (.nc files)

    # set selection conditions
    # if you need the whole EBAS database, set conditions as None
    conditions = {
        "start_year": 1990,
        "end_year": 2021,
        "site": ['ES0010R', 'ES0011R'],
        "matrix": ['air'],
        "components": ['NOx'],
    }
    # set local stroage path
    db_dir = r'ebas_db'
    downloader = EbasDownloader(loc=db_dir)
    downloader.get_raw_files(conditions=conditions, download=True)
    
  3. 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')
    
  4. Create local database

    # set local stroage path, must be the same as previous path
    db_dir = r'ebas_db'
    # local database object
    db = EbasDB(dir=db_dir, dump='xz', detailed=True)
    # create/update database with new files
    db.update_db()
    
  5. Open local database

    # set local stroage path
    db_dir = r'ebas_db'
    # local database object
    db = EbasDB(dir=db_dir, dump='xz', detailed=True)
    # open database if it is created
    db.init_db()
    
  6. Query data from local database as pandas.DataFrame

    condition = {
        "id":["AM0001R", "EE0009R"],
        "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)
    
  7. Access detail information

    # access information for one site
    db.site_index["ES0011R"]
    db.site_index["ES0011R"]["components"].keys()
    db.site_index["ES0011R"]["files"]
    
  8. Use command line

    Possible arguments, use pyebas --help for details and options for matrix and components:

    pyebas 
    <starting year> 
    <ending year> 
    --mode <csv, db, query> 
    --site <site id, site id> 
    --matrix <matrix type> 
    --components <component name> 
    --output <output path>
    

    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.

    pyebas 2019 2021 --mode csv --site ES0010R ES0011R --matrix air --components NOx --output .\simple_csv
    

    Example 2: download all measurements from 2019 to 2021, and stored in local database.

    pyebas 2019 2021 --mode db --output .\ebas
    

    Start querying with the created local database (you need enter conditions through terminal later, and the results can be exported to .csv files).

    python main.py 2019 2021 --mode query --out .\ebas
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyebas-0.1.3.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyebas-0.1.3-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file pyebas-0.1.3.tar.gz.

File metadata

  • Download URL: pyebas-0.1.3.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for pyebas-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e99d451a40ae88d2009142a78f594395671832155f9e323c55c9765945a3e8c6
MD5 57f79d69db2bb18f50a842fd992b754f
BLAKE2b-256 aef37cfe3c35a953a9b59de10f2dc647b9866454ed644a24f3c8e82d57f5169a

See more details on using hashes here.

File details

Details for the file pyebas-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pyebas-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for pyebas-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c7c89a794f1c9c2146efb1f0c4cc4c2d660942727a2bc2b3c7fc341acecfa8b6
MD5 935ab7eb05afb99cea210d604f93a62e
BLAKE2b-256 ffbe1fe45eae9f6b0b101edef164975021787928565ab6bce81ec6fa6474cd33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page