-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
88 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
pymorize: | ||
version: "unreleased" | ||
use_xarray_backend: true | ||
warn_on_no_rule: False | ||
minimum_jobs: 8 | ||
maximum_jobs: 10 | ||
general: | ||
name: "pi_uxarray" | ||
description: "This is a test configuration using the UXArray test data on PI Mesh" | ||
maintainer: "pgierz" | ||
email: "[email protected]" | ||
cmor_version: "CMIP6" | ||
mip: "CMIP" | ||
frequency: "mon" | ||
CMIP_Tables_Dir: "./cmip6-cmor-tables/Tables" | ||
rules: | ||
- name: "temp" | ||
inputs: | ||
- path: "REPLACE_ME" | ||
pattern: "temp.fesom.????.nc" | ||
cmor_variable: "thetao" |
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
Empty file.
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,38 @@ | ||
"""Example data for the FESOM model.""" | ||
|
||
import tarfile | ||
from pathlib import Path | ||
|
||
import pytest | ||
import requests | ||
|
||
URL = "https://nextcloud.awi.de/s/swqyFgbL2jjgjRo/download/pi_uxarray.tar" | ||
"""str : URL to download the example data from.""" | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def download_data(tmp_path_factory): | ||
cache_dir = tmp_path_factory.getbasetemp() / "cached_data" | ||
cache_dir.mkdir(exist_ok=True) | ||
data_path = cache_dir / "pi_uxarray.tar" | ||
|
||
if not data_path.exists(): | ||
response = requests.get(URL) | ||
response.raise_for_status() | ||
with open(data_path, "wb") as f: | ||
f.write(response.content) | ||
print("Data downloaded.") | ||
else: | ||
print("Using cached data.") | ||
|
||
return data_path | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def pi_uxarray_data(download_data): | ||
|
||
data_dir = Path(download_data).parent | ||
with tarfile.open(download_data, "r") as tar: | ||
tar.extractall(data_dir) | ||
|
||
return data_dir / "pi_uxarray" |
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,13 @@ | ||
def test_process(test_uxarray_config, pi_uxarray_data): | ||
from pymorize.cmorizer import CMORizer | ||
from pymorize.logging import logger | ||
|
||
logger.info(f"Processing {test_uxarray_config}") | ||
with open(test_uxarray_config, "r") as f: | ||
cfg = yaml.safe_load(f) | ||
for rule in cfg.rules: | ||
for input in rule["inputs"]: | ||
input["path"] = input["path"].replace("REPLACE_ME", pi_uxarray_data) | ||
|
||
cmorizer = CMORizer.from_dict(test_uxarray_config) | ||
cmorizer.process() |