Skip to content

Commit

Permalink
csv template, congo stations, aws-template test
Browse files Browse the repository at this point in the history
  • Loading branch information
maaikelimper committed Sep 14, 2023
1 parent 1ce5629 commit 5548168
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
17 changes: 17 additions & 0 deletions tests/data/metadata/station/station_list.csv
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,20 @@ CRAIOVA,0-20000-0-15450,15450,Land (fixed),44.3101404313,23.8669847441,192,,Roma
CALARASI,0-20000-0-15460,15460,Land (fixed),44.2057385289,27.3383080718,18.72,,Romania,VI
ROSIORII DE VEDE,0-20000-0-15470,15470,Land (fixed),44.1072133362,24.9787400713,102.15,102.15,Romania,VI
CONSTANTA,0-20000-0-15480,15480,Land (fixed),44.2138143888,28.6455646839,12.8,14.0,Romania,VI
POINTE-NOIRE,0-20000-0-64400,,Land (fixed),-4.8045,11.8817,18.00,Congo,I,
DOLISIE,0-20000-0-64401,,Land (fixed),-4.2119,12.6680,330.00,Congo,I,
MOUYONDZI,0-20000-0-64402,,Land (fixed),-4.0000,13.9500,509.00,Congo,I,
MAKABANA,0-20000-0-64403,,Land (fixed),-3.4833,12.6166,160.00,Congo,I,
SIBITI,0-20000-0-64405,,Land (fixed),-3.6845,13.3698,530.00,Congo,I,
BRAZZAVILLE /MAYA-MAYA,0-20000-0-64450,,Land (fixed),-4.2636,15.2429,314.27,Congo,I,
M'POUYA,0-20000-0-64452,,Land (fixed),-2.6166,16.2166,311.00,Congo,I,
DJAMBALA,0-20000-0-64453,,Land (fixed),-2.5333,14.7666,789.00,Congo,I,
GAMBOMA,0-20000-0-64454,,Land (fixed),-1.9000,15.8500,476.00,Congo,I,
MAKOUA,0-20000-0-64456,,Land (fixed),-0.0166,15.6500,394.00,Congo,I,
OUESSO,0-20000-0-64458,,Land (fixed),1.6125,16.0402,352.00,Congo,I,
IMPFONDO,0-20000-0-64459,,Land (fixed),1.5928,18.0540,324.00,Congo,I,
SOUANKE,0-20000-0-64460,,Land (fixed),2.0666,14.0333,549.00,Congo,I,
KELLE,0-20000-0-64462,,Land (fixed),0.0829,14.5329,408.00,Congo,I,
EWO,0-20000-0-64463,,Land (fixed),-0.8541,14.8034,479.00,Congo,I,
N'KAYI,0-20000-0-64406,,Land (fixed),-4.2218,13.2856,165.00,Congo,I,
OLLOMBO,0-20000-0-64461,,Land (fixed),-1.2257,15.9166,327.05,Congo,I,
4 changes: 4 additions & 0 deletions tests/data/observations/romania/aws_example.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wsi_series,wsi_issuer,wsi_issue_number,wsi_local,wmo_block_number,wmo_station_number,station_type,year,month,day,hour,minute,latitude,longitude,station_height_above_msl,barometer_height_above_msl,station_pressure,msl_pressure,geopotential_height,thermometer_height,air_temperature,dewpoint_temperature,relative_humidity,method_of_ground_state_measurement,ground_state,method_of_snow_depth_measurement,snow_depth,precipitation_intensity,anemometer_height,time_period_of_wind,wind_direction,wind_speed,maximum_wind_gust_direction_10_minutes,maximum_wind_gust_speed_10_minutes,maximum_wind_gust_direction_1_hour,maximum_wind_gust_speed_1_hour,maximum_wind_gust_direction_3_hours,maximum_wind_gust_speed_3_hours,rain_sensor_height,total_precipitation_1_hour,total_precipitation_3_hours,total_precipitation_6_hours,total_precipitation_12_hours,total_precipitation_24_hours
0,20000,0,15015,15,15,1,2022,3,31,1,0,47.77706163,23.94046026,503,,100940,101040,1448,5,298.15,294.55,80,3,1,1,0,0.004,10,-10,30,3,30,5,40,9,20,11,2,4.7,5.3,7.9,9.5,11.4
0,20000,0,15015,15,15,1,2022,3,31,2,0,47.77706163,23.94046026,503,504.43,100940,101040,1448,5,298.15,294.55,80,3,1,1,0,0.004,10,-10,30,3,30,5,40,9,20,11,2,4.7,5.3,7.9,9.5,11.4
0,20000,0,15015,15,15,1,2022,3,31,3,0,47.77706163,23.94046026,503,504.43,100940,101040,1448,5,298.15,294.55,80,3,1,1,0,0.004,10,-10,30,3,30,5,40,9,20,11,2,4.7,5.3,7.9,9.5,11.4
13 changes: 8 additions & 5 deletions wis2box-management/wis2box/data/csv2bufr.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@

import json
import logging
import csv2bufr.templates as c2bt

from pathlib import Path
from typing import Union

from csv2bufr import MAPPINGS, transform as transform_csv
from csv2bufr import transform as transform_csv

from wis2box.data.base import BaseAbstractData
from wis2box.metadata.station import get_valid_wsi
Expand All @@ -50,11 +52,12 @@ def __init__(self, defs: dict) -> None:
LOGGER.debug(f'Loading template {self.template}')
if self.template.startswith('/'):
mapping_bufr4 = Path(self.template)
with mapping_bufr4.open() as fh1:
self.mappings['bufr4'] = json.load(fh1)
else:
mapping_bufr4 = Path(MAPPINGS) / self.template

with mapping_bufr4.open() as fh1:
self.mappings['bufr4'] = json.load(fh1)
if self.template not in c2bt.list_templates():
raise Exception(f'Unknown template: {self.template}, options are: {c2bt.list_templates()}') # noqa
self.mappings['bufr4'] = c2bt.load_template(self.template)

self.station_metadata = None

Expand Down

0 comments on commit 5548168

Please sign in to comment.