airbase.summary.db module

class airbase.summary.db.Pollutant(notation, id)[source]

Bases: NamedTuple

Create new instance of Pollutant(notation, id)

Parameters:
  • notation (str) –

  • id (int) –

id: int

Alias for field number 1

notation: str

Alias for field number 0

class airbase.summary.db.SummaryDB[source]

Bases: object

In DB containing the available country and pollutants

cached data from https://eeadmz1-downloads-api-appservice.azurewebsites.net/City https://eeadmz1-downloads-api-appservice.azurewebsites.net/Country https://eeadmz1-downloads-api-appservice.azurewebsites.net/Property

property COUNTRY_CODES: frozenset[str]

All unique country codes

property POLLUTANTS: frozenset[str]

All unique pollutant names/notations

property POLLUTANT_IDS: frozenset[int]

All unique pollutant IDs

city_json()[source]

simulate a request to https://eeadmz1-downloads-api-appservice.azurewebsites.net/City

Return type:

CityJSON

countries()[source]

Unique country codes.

Returns:

list of available country codes

Return type:

list[str]

country_json()[source]

simulate a request to https://eeadmz1-downloads-api-appservice.azurewebsites.net/Country

Return type:

CountryJSON

classmethod cursor()[source]

db cursor as a “self closing” context manager

Return type:

Iterator[Cursor]

db = <sqlite3.Connection object>
pollutant_json()[source]

simulate a request to https://eeadmz1-downloads-api-appservice.azurewebsites.net/Pollutant

Return type:

PollutantJSON

pollutants()[source]

Pollutant notations and unique ids.

Returns:

The available pollutants, as a dictionary with

Return type:

dict[str, set[int]]

with notation as key and IDs as value, e.g. {“NO”: {38}, …}

properties(*pollutants)[source]

Pollutant description URLs

https://dd.eionet.europa.eu/vocabulary/aq/pollutant

Parameters:

pollutants (str) –

Return type:

list[str]

search_city(city)[source]

Search for a country code from city name

Parameters:

city (str) – City name.

Returns:

country code, e.g. “NO” for “Oslo”

Return type:

str | None

search_pollutant(query, *, limit=None)[source]

Search for a pollutant’s ID number based on its name.

Parameters:
  • query (str) – The pollutant to search for.

  • limit (int | None) – (optional) Max number of results.

Returns:

The best pollutant matches, as tuples of notation and ID, e.g. (“NO”, 38)

Return type:

Iterator[Pollutant]

search_pollutants(*pollutants)[source]

Search for a pollutant ID numbers based from exact matches to pollutant names.

Parameters:

pollutants (str) – The pollutant name(s)/notation(s) to search for.

Returns:

ID(s) corresponding to the name(s)/notation(s), e.g. “NO” –> 38

Return type:

Iterator[int]

airbase.summary.db.summary()[source]
Return type:

Path