From 562b50c92a549cc3eaf01678a480cc63e5c70b4e Mon Sep 17 00:00:00 2001 From: RoryPTB <47696929+RoryPTB@users.noreply.github.com> Date: Tue, 26 Sep 2023 10:10:49 +0200 Subject: [PATCH] Corrected encoding of station name --- synop2bufr/__init__.py | 2 ++ synop2bufr/resources/synop-mappings-307080.json | 2 +- synop2bufr/resources/synop-mappings-307096.json | 2 +- tests/test_synop2bufr.py | 12 ++++++------ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/synop2bufr/__init__.py b/synop2bufr/__init__.py index 40860fc..3b19d19 100644 --- a/synop2bufr/__init__.py +++ b/synop2bufr/__init__.py @@ -1471,6 +1471,7 @@ def transform(data: str, metadata: str, year: int, wsi_series, wsi_issuer, wsi_issue_number, wsi_local = wsi.split("-") # noqa # get other required metadata + station_name = metadata_dict[wsi]["station_name"] latitude = metadata_dict[wsi]["latitude"] longitude = metadata_dict[wsi]["longitude"] station_height = metadata_dict[wsi]["elevation"] @@ -1481,6 +1482,7 @@ def transform(data: str, metadata: str, year: int, msg['_wsi_issuer'] = wsi_issuer msg['_wsi_issue_number'] = wsi_issue_number msg['_wsi_local'] = wsi_local + msg['_station_name'] = station_name msg['_latitude'] = latitude msg['_longitude'] = longitude msg['_station_height'] = station_height diff --git a/synop2bufr/resources/synop-mappings-307080.json b/synop2bufr/resources/synop-mappings-307080.json index c498366..58a8fb5 100644 --- a/synop2bufr/resources/synop-mappings-307080.json +++ b/synop2bufr/resources/synop-mappings-307080.json @@ -35,7 +35,7 @@ {"eccodes_key": "#1#heightOfBarometerAboveMeanSeaLevel", "value":"data:_barometer_height", "valid_min": "const:-400.0", "valid_max": "const:12707.1"}, {"eccodes_key": "#1#blockNumber", "value": "data:block_no", "valid_min": "const:0", "valid_max": "const:127"}, {"eccodes_key": "#1#stationNumber", "value": "data:station_no", "valid_min": "const:0", "valid_max": "const:1023"}, - {"eccodes_key": "#1#stationOrSiteName", "value": "data:station_id"}, + {"eccodes_key": "#1#stationOrSiteName", "value": "data:_station_name"}, {"eccodes_key": "#1#stationType", "value": "data:WMO_station_type", "valid_min": "const:0", "valid_max": "const:3"}, {"eccodes_key": "#1#year", "value": "data:year", "valid_min": "const:0", "valid_max": "const:4095"}, {"eccodes_key": "#1#month", "value": "data:month", "valid_min": "const:0", "valid_max": "const:15"}, diff --git a/synop2bufr/resources/synop-mappings-307096.json b/synop2bufr/resources/synop-mappings-307096.json index 33b6c1b..575fd5e 100644 --- a/synop2bufr/resources/synop-mappings-307096.json +++ b/synop2bufr/resources/synop-mappings-307096.json @@ -35,7 +35,7 @@ {"eccodes_key": "#1#heightOfBarometerAboveMeanSeaLevel", "value":"data:_barometer_height", "valid_min": "const:-400.0", "valid_max": "const:12707.1"}, {"eccodes_key": "#1#blockNumber", "value": "data:block_no", "valid_min": "const:0", "valid_max": "const:127"}, {"eccodes_key": "#1#stationNumber", "value": "data:station_no", "valid_min": "const:0", "valid_max": "const:1023"}, - {"eccodes_key": "#1#stationOrSiteName", "value": "data:station_id"}, + {"eccodes_key": "#1#stationOrSiteName", "value": "data:_station_name"}, {"eccodes_key": "#1#stationType", "value": "data:WMO_station_type", "valid_min": "const:0", "valid_max": "const:3"}, {"eccodes_key": "#1#year", "value": "data:year", "valid_min": "const:0", "valid_max": "const:4095"}, {"eccodes_key": "#1#month", "value": "data:month", "valid_min": "const:0", "valid_max": "const:15"}, diff --git a/tests/test_synop2bufr.py b/tests/test_synop2bufr.py index 64cf34f..b28d47d 100644 --- a/tests/test_synop2bufr.py +++ b/tests/test_synop2bufr.py @@ -149,9 +149,9 @@ def test_bufr_307080(multiple_reports_307080, metadata_string): for item in result: msgs[item['_meta']['id']] = item # Test the md5 keys - assert msgs['WIGOS_0-20000-0-15015_20220321T120000']['_meta']['properties']['md5'] == 'f1595e9f82880b650de227fa007eb770' # noqa - assert msgs['WIGOS_0-20000-0-15020_20220321T120000']['_meta']['properties']['md5'] == '21cd8741f8615cc7b0df70060c3a98ff' # noqa - assert msgs['WIGOS_0-20000-0-15090_20220321T120000']['_meta']['properties']['md5'] == 'f0b736dba245b34985f757b0597e3d54' # noqa + assert msgs['WIGOS_0-20000-0-15015_20220321T120000']['_meta']['properties']['md5'] == 'f5874a7e7da9f6132018690f73017a10' # noqa + assert msgs['WIGOS_0-20000-0-15020_20220321T120000']['_meta']['properties']['md5'] == '230d74d29fba410e38cbb6fae1d6fb3f' # noqa + assert msgs['WIGOS_0-20000-0-15090_20220321T120000']['_meta']['properties']['md5'] == '15cefdcd27eded01db05cd5acf7abe02' # noqa # Test the bufr template used for all the reports # (they should be the same for every report) @@ -168,9 +168,9 @@ def test_bufr_307096(multiple_reports_307096, metadata_string): for item in result: msgs[item['_meta']['id']] = item # Test the md5 keys - assert msgs['WIGOS_0-20000-0-15015_20220321T120000']['_meta']['properties']['md5'] == '27c990045879acc2eedddb7fdc70db4d' # noqa - assert msgs['WIGOS_0-20000-0-15020_20220321T120000']['_meta']['properties']['md5'] == '9db622c40d53aae4ce4f38a658f36d86' # noqa - assert msgs['WIGOS_0-20000-0-15090_20220321T120000']['_meta']['properties']['md5'] == '89f424b9fc38a6db69c7b195bd71d92f' # noqa + assert msgs['WIGOS_0-20000-0-15015_20220321T120000']['_meta']['properties']['md5'] == '3611e3fd99a441f6b80bfa5bea607fee' # noqa + assert msgs['WIGOS_0-20000-0-15020_20220321T120000']['_meta']['properties']['md5'] == '1948789be15abd74b9312d0be1e179d6' # noqa + assert msgs['WIGOS_0-20000-0-15090_20220321T120000']['_meta']['properties']['md5'] == '19fa379ecf284c6b17f51baa36cfc473' # noqa # Test the bufr template used for all the reports # (they should be the same for every report)