diff --git a/hub/management/commands/import_air_quality_data.py b/hub/management/commands/import_air_quality_data.py index febbdcb9b..f42701c4e 100644 --- a/hub/management/commands/import_air_quality_data.py +++ b/hub/management/commands/import_air_quality_data.py @@ -34,34 +34,34 @@ class Command(BaseCommand): } in_files = { - "pm__10": { - "pollutant": "PM_{10}", + "pm_10": { + "pollutant": "PM10", "metric": "Annual mean", "header_label": "pm102021g", "comments": "Gravimetric units", "csv_link": "https://uk-air.defra.gov.uk/datastore/pcm/mappm102021g.csv", }, - "pm__2_5": { - "pollutant": "PM_{2.5}", + "pm_2_5": { + "pollutant": "PM2.5", "metric": "Annual mean", "header_label": "pm252021g", "csv_link": "https://uk-air.defra.gov.uk/datastore/pcm/mappm252021g.csv", }, - "no__2": { - "pollutant": "NO_2", + "no_2": { + "pollutant": "NO2", "metric": "Annual mean", "header_label": "no22021", "csv_link": "https://uk-air.defra.gov.uk/datastore/pcm/mapno22021.csv", }, - "no__x": { - "pollutant": "NO_X", + "no_x": { + "pollutant": "NOx", "metric": "Annual mean", "header_label": "nox2021", "comments": "µg m\u207B\u00B3 (NO\u2093 as NO\u2082)", "csv_link": "https://uk-air.defra.gov.uk/datastore/pcm/mapnox2021.csv", }, - "so__2": { - "pollutant": "SO_2", + "so_2": { + "pollutant": "SO2", "metric": "Annual mean", "header_label": "so22021", "csv_link": "https://uk-air.defra.gov.uk/datastore/pcm/mapso22021.csv", @@ -70,7 +70,7 @@ class Command(BaseCommand): "pollutant": "Ozone", "metric": "DGT120", "header_label": "dgt12021", - "comments": "metric is number of days on which the daily max 8-hr concentration is greater than 120 µg m\u207B\u00B3", + "comments": "number of days on which the daily max 8-hr concentration is greater than 120 µg m\u207B\u00B3", "csv_link": "https://uk-air.defra.gov.uk/datastore/pcm/mapdgt12021.csv", }, "benzene": { diff --git a/hub/templates/hub/area/_place_data.html b/hub/templates/hub/area/_place_data.html index 88f38a6bf..0428ecafa 100644 --- a/hub/templates/hub/area/_place_data.html +++ b/hub/templates/hub/area/_place_data.html @@ -82,6 +82,30 @@
{{ category.name }}
{% endfor %} + {% elif category.name == 'Air pollution' %} + + + + + + + + + + {% for range in category.data %} + + + + + + {% endfor %} + +
PollutantThis areaUK average
+ {{ range.label|html_format_dataset_name|safe }} + {% if range.data_type.description %} + {{ range.data_type.description|escape }} + {% endif %} + {{ range.value|floatformat }}%{{ range.average|floatformat }}%
{% else %} {% if category.data.is_number %}

{{ category.data.value|floatformat }}{% if category.data.is_percentage %}%{% endif %}

diff --git a/hub/templatetags/hub_filters.py b/hub/templatetags/hub_filters.py index 2d7e6637a..20f2857d1 100644 --- a/hub/templatetags/hub_filters.py +++ b/hub/templatetags/hub_filters.py @@ -56,3 +56,16 @@ def pending_account_requests(**kwargs): userproperties__email_confirmed=True, userproperties__account_confirmed=False, ).count() + + +@register.filter +@stringfilter +def html_format_dataset_name(value): + pollutants = { + "PM10": "PM10", + "PM2.5": "PM2.5", + "NO2": "NO2", + "NOx": "NOX", + "SO2": "SO2", + } + return pollutants.get(value, value)