-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
607 review request to integrate universal pipeline (#611)
* grib2-pipeline-plugin-demo-from-CMA This is grib2 pipeline plugin from CMA which named universal.py, it is recommended to put it in /wis2box/wis2box-management/wis2box/data directory. * Update data-mappings.yml reference grib2-pipeline-plugin in CMA demo TH in data-mapping to deal with grib2 files, which is recomended to append it in /wis2box/tests/data/data-mappings.yml * add china-NWP-grib2 testing data these testing dataset provide some sample to support users to test grib2-data-pipeline-plugin * update universal pipeline and center-id,add discovery-metadata * Update GRAPES-GEPS-GLB.yml * add test and documentation * uncommit local port * flake8, remove md, fix expected numbers * align numbers * 5 + 11 = 16 (to validate congo msg 5, skip 11 china msg) * Update tests-docker.yml * Update data-pipeline-plugins.rst * Update GRAPES-GEPS-GLB.yml * update metadata, topic, identifier, filename * update metadata, topic, identifier, filename * Update cn-grapes-geps-global.yml * Update tests-docker.yml * Update data-mappings.yml --------- Co-authored-by: Maaike <[email protected]> Co-authored-by: Tom Kralidis <[email protected]>
- Loading branch information
1 parent
a28d7e2
commit dafcecc
Showing
16 changed files
with
201 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
wis2box: | ||
retention: P30D | ||
topic_hierarchy: cn-cma-babj.data.core.weather.prediction.forecast.medium-range.probabilistic.global | ||
country: chn | ||
centre_id: cn-cma-babj | ||
|
||
mcf: | ||
version: 1.0 | ||
|
||
metadata: | ||
identifier: urn:x-wmo:md:cn-cma-babj:grapes-geps-global | ||
hierarchylevel: dataset | ||
|
||
identification: | ||
title: CMA GRAPES GEPS v1.3 | ||
abstract: GRAPES GEPS is the main technical means to solve the uncertainty of CMA-GFS medium-term forecast and the difficulties of extreme weather forecast. | ||
dates: | ||
creation: 2024-01-17 | ||
keywords: | ||
default: | ||
keywords: | ||
- mean sea level Pressure | ||
- 2 m above ground Temperature | ||
- 10 m above ground U-Component of Wind | ||
- 10 m above ground V-Component of Wind | ||
- Total Precipitation | ||
- Geopotential Height | ||
- Temperature | ||
- U-Component of Wind | ||
- V-Component of Wind | ||
wmo: | ||
keywords: | ||
- weather | ||
keywords_type: theme | ||
vocabulary: | ||
name: Earth system disciplines as defined by the WMO Unified Data Policy, Resolution 1 (Cg-Ext(2021), Annex 1. | ||
url: https://github.com/wmo-im/wis2-topic-hierarchy/blob/main/topic-hierarchy/earth-system-discipline/index.csv | ||
extents: | ||
spatial: | ||
- bbox: [73.66000, 4.00000, 135.08000, 53.52000] | ||
crs: 259200 | ||
temporal: | ||
- begin: 2021-11-29 | ||
end: null | ||
resolution: P12H | ||
url: http://gisc.wis.cma.cn/wis/portal.pub?M_PID=urn:x-wmo:md:int.wmo.wis::CMA_GEPS | ||
wmo_data_policy: core | ||
|
||
contact: | ||
pointOfContact: &contact_poc | ||
organization: China Meteorological Administration (CMA) | ||
url: https://www.cma.gov.cn/ | ||
individualname: National Meteorological Information Center (NMIC) | ||
positionname: National Meteorological Information Center (NMIC) | ||
phone: 86-10-68409329 | ||
fax: null | ||
address: 46 Zhongguancun Nandajie | ||
city: Beijing | ||
administrativearea: Beijing | ||
postalcode: 100 081 | ||
country: China | ||
email: [email protected] | ||
hoursofservice: 0000h - 0900h UTC | ||
contactinstructions: email | ||
|
||
distributor: *contact_poc |
Binary file added
BIN
+2.46 MB
tests/data/observations/china/Z_NAFP_C_BABJ_20231207000000_P_CMA-GEPS-GLB-024.grib2
Binary file not shown.
Binary file added
BIN
+3.21 MB
tests/data/observations/china/Z_NAFP_C_BABJ_20231207000000_P_CMA-GEPS-GLB-036.grib2
Binary file not shown.
Binary file added
BIN
+3.52 MB
tests/data/observations/china/Z_NAFP_C_BABJ_20231207000000_P_CMA-GEPS-GLB-048.grib2
Binary file not shown.
Binary file added
BIN
+3.7 MB
tests/data/observations/china/Z_NAFP_C_BABJ_20231207000000_P_CMA-GEPS-GLB-060.grib2
Binary file not shown.
Binary file added
BIN
+3.86 MB
tests/data/observations/china/Z_NAFP_C_BABJ_20231207000000_P_CMA-GEPS-GLB-072.grib2
Binary file not shown.
Binary file added
BIN
+3.96 MB
tests/data/observations/china/Z_NAFP_C_BABJ_20231207000000_P_CMA-GEPS-GLB-084.grib2
Binary file not shown.
Binary file added
BIN
+3.95 MB
tests/data/observations/china/Z_NAFP_C_BABJ_20231207000000_P_CMA-GEPS-GLB-096.grib2
Binary file not shown.
Binary file added
BIN
+4.01 MB
tests/data/observations/china/Z_NAFP_C_BABJ_20231207000000_P_CMA-GEPS-GLB-108.grib2
Binary file not shown.
Binary file added
BIN
+4.12 MB
tests/data/observations/china/Z_NAFP_C_BABJ_20231207000000_P_CMA-GEPS-GLB-120.grib2
Binary file not shown.
Binary file added
BIN
+4.15 MB
tests/data/observations/china/Z_NAFP_C_BABJ_20231207000000_P_CMA-GEPS-GLB-132.grib2
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
############################################################################### | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
############################################################################### | ||
|
||
import logging | ||
from pathlib import Path | ||
from typing import Union | ||
|
||
from dateutil.parser import parse | ||
|
||
from wis2box.data.base import BaseAbstractData | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class UniversalData(BaseAbstractData): | ||
"""Universal data""" | ||
|
||
def __init__(self, defs: dict) -> None: | ||
super().__init__(defs) | ||
|
||
def transform(self, input_data: Union[Path, bytes], | ||
filename: str = '') -> bool: | ||
|
||
filename = Path(filename) | ||
LOGGER.debug('Procesing data') | ||
input_bytes = self.as_bytes(input_data) | ||
|
||
LOGGER.debug('Deriving datetime') | ||
match = self.validate_filename_pattern(filename.name) | ||
|
||
if match is None: | ||
msg = f'Invalid filename format: {filename} ({self.file_filter})' | ||
LOGGER.error(msg) | ||
raise ValueError(msg) | ||
try: | ||
date_time = match.group(1) | ||
except IndexError: | ||
msg = 'Missing date/time in filename pattern' | ||
LOGGER.error(msg) | ||
raise ValueError(msg) | ||
|
||
try: | ||
date_time = parse(date_time) | ||
except Exception: | ||
msg = f'Invalid date/time format: {date_time}' | ||
LOGGER.error(msg) | ||
raise ValueError(msg) | ||
|
||
rmk = filename.stem | ||
suffix = filename.suffix.replace('.', '') | ||
|
||
self.output_data[rmk] = { | ||
suffix: input_bytes, | ||
'_meta': { | ||
'identifier': rmk, | ||
'relative_filepath': self.get_local_filepath(date_time), | ||
'data_date': date_time | ||
} | ||
} | ||
|
||
return True | ||
|
||
def get_local_filepath(self, date_): | ||
yyyymmdd = date_.strftime('%Y-%m-%d') | ||
return Path(yyyymmdd) / 'wis' / self.topic_hierarchy.dirpath |