<commit_before># Air Quality Observed

This folder contains scripts that give support to expose air quality observed data as NGSI version 2.

The data provided comes from the [air quality stations](../PointOfInterest/AirQualityStation) owned by Madrid City Council.

Please check the original data source before making use of this data in an application. 

The following scripts are present:

* `madrid_air_quality.py` .- Offers both an NGSIv2 end point and NGSI10 to provide ambient observed data
* `ngsi_helper.py` .- Contains helper functions to support the NGSI protocol

## Examples of Use

What was the ambient observed today at 11:00 AM at the "Plaza de España" air quality station?

```
curl http://130.206.83.68:1029/v2/entities?type=AmbientObserved&q=stationCode:28079004;hour:11
```

```json

{
    "address": {
      "addressCountry": "ES",
      "addressLocality": "Madrid",
      "streetAddress": "Plaza de España"
    },
    "dateCreated": "2016-03-15T13:29:30.894942",
    "id": "Madrid-AmbientObserved-28079004-2016-03-15T11:00:00",
    "location": {
      "type": "geo:point",
      "value": "40.423852777777775,-3.712247222222222"
    },
    "pollutants": {
      "CO": {
        "concentration": 500,
        "description": "Carbon Monoxide"
      },
      "NO": {
        "concentration": 45,
        "description": "Nitrogen Monoxide"
      },
      "NO2": {
        "concentration": 69,
        "description": "Nitrogen Dioxide"
      },
      "NOx": {
        "concentration": 139,
        "description": "Nitrogen oxides"
      },
      "SO2": {
        "concentration": 11,
        "description": "Sulfur Dioxide"
      }
    },
    "precipitation": 0,
    "relativeHumidity": 54,
    "source": "http://datos.madrid.es",
    "stationCode": "28079004",
    "stationName": "Pza. de España",
    "temperature": 12.2,
    "type": "AmbientObserved",
    "validity": {
      "from": "2016-03-15T11:00:00",
      "to": "2016-03-15T12:00:00"
    },
    "windDirection": 186,
    "windSpeed": 0.64
}

```
<commit_msg>Align README.md with latest services used<commit_after># Air Quality Observed

This folder contains scripts that give support to expose air quality observed data as NGSI version 2.

The data provided comes from [air quality stations](../PointOfInterest/AirQualityStation) located in different cities in Spain.

Please check the original data source before making use of this data in an application. 

The following scripts are present:

* `madrid_air_quality_harvest.py`.- A data harvest and harmonization program for official Madrid's Air Quality Data provided
by Madrid's City Council.
* `barcelona_air_quality_harvest.py`.- A data harvest and harmonization program for official Barcelona's Air Quality Data 
provided by Catalonia's Government.
* `madrid_air_quality.py` .- Offers both an NGSIv2 end point and NGSI10 to provide ambient observed data (outdated)
* `ngsi_helper.py` .- Contains helper functions to support the NGSI protocol (outdated)

## Examples of Use

What was the air quality observed today at the "Plaza de España" air quality station?

```
curl -S --header 'fiware-service:airquality' --header 'fiware-servicepath:/Spain_Madrid' --header 'x-auth-token:4bc89e757d1841f6a33b02748376edc9' "http://172.16.31.10:1027/v2/entities?type=AirQualityObserved&attrs=measurand,address&q=dateObserved>2016-11-24;stationCode:'28079004'&orderBy=dateObserved&options=keyValues" | python -mjson.tool
```

```json

[{
        "address": {
            "addressCountry": "ES",
            "addressLocality": "Madrid",
            "streetAddress": "Plaza de Espa\u00f1a"
        },
        "id": "Madrid-AmbientObserved-28079004-2016-11-24T01:00:00",
        "measurand": [
            "SO2,2.0,GQ,Sulfur Dioxide",
            "CO,0.3,GP,Carbon Monoxide",
            "NO,20.0,GQ,Nitrogen Monoxide",
            "NO2,57.0,GQ,Nitrogen Dioxide",
            "NOx,88.0,GQ,Nitrogen oxides"
        ],
        "type": "AirQualityObserved"
    }
...
```

{'fraction_non_alphanumeric': 0.1250313833793623, 'fraction_numerical': 0.06678383128295255, 'mean_word_length': 3.2977346278317152, 'pattern_counts': {'":': 44, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5437132', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1277, 'n_words': 349}