-
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
29 changed files
with
467 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ Testing/ | |
CMakeFiles/ | ||
CMakeCache.txt | ||
*.bak | ||
.vim | ||
*.egg-info |
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 |
---|---|---|
@@ -1 +1 @@ | ||
0.6.1 | ||
0.6.2 |
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,29 @@ | ||
# Finding python modules | ||
# ====================== | ||
# This function tries to import the specified python module and print its version. | ||
# This function will abort the configure priocess if the module cannot be imported. | ||
# This code depends on that the python interpreter has been found with | ||
# find_package(Python) | ||
# | ||
# Arguments | ||
# --------- | ||
# python_module: The module to search for | ||
# | ||
# Example Usage | ||
# ------------- | ||
# find_python_module(numpy) | ||
function(find_python_module python_module) | ||
execute_process( | ||
COMMAND | ||
${Python_EXECUTABLE} "-c" "import ${python_module}; print(${python_module}.__version__)" | ||
RESULT_VARIABLE status | ||
OUTPUT_VARIABLE python_module_version | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
if(NOT status) | ||
message("Found Python module ${python_module} ${python_module_version}") | ||
else() | ||
message(FATAL_ERROR "Did not find package ${python_module}") | ||
endif() | ||
endfunction() |
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 @@ | ||
#! /usr/bin/env bash | ||
set -ex | ||
export GRIBJUMP_HOME="@CMAKE_BINARY_DIR@" | ||
export FDB5_DIR="@FDB5_DIR@" | ||
export PYTHONPATH="${PYTHONPATH}:@CMAKE_CURRENT_SOURCE_DIR@/pygribjump/src" | ||
|
||
eccodes_definition_path="@REDEFINED_ECCODES_DEFINITION_PATH@" | ||
if [ -n "${eccodes_definition_path}" ]; then | ||
export ECCODES_DEFINITION_PATH=${eccodes_definition_path} | ||
fi | ||
|
||
@Python_EXECUTABLE@ -m pytest @CMAKE_CURRENT_SOURCE_DIR@ --basetemp="@CMAKE_CURRENT_BINARY_DIR@/test-results" "$@" | ||
|
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,5 @@ | ||
cffi~=1.17 | ||
numpy~=2.1 | ||
pytest~=8.3 | ||
setuptools~=75.1 | ||
findlibs~=0.0.5 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,22 @@ | ||
import os | ||
import pathlib | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def gribjump_env() -> None: | ||
""" | ||
Sets default environment variables that are not dependent on individual testsetup. | ||
""" | ||
os.environ["GRIBJUMP_IGNORE_GRID"] = "1" | ||
|
||
|
||
@pytest.fixture | ||
def data_path(request) -> pathlib.Path: | ||
""" | ||
Provides path to test data at '<src-root>/pygribjump/tests/data' | ||
""" | ||
path = request.config.rootpath / "pygribjump" / "tests" / "data" | ||
assert path.exists() | ||
return path |
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,30 @@ | ||
# Default types | ||
|
||
param: Param; | ||
step: Step; | ||
date: Date; | ||
levelist: Double; | ||
grid: Grid; | ||
expver: Expver; | ||
time: Time; | ||
number: Integer; | ||
|
||
######################################################## | ||
# The are the rules matching most of the fields | ||
# oper/dcda | ||
[ class, expver, stream=oper/dcda/scda, date, time, domain? | ||
[ type, levtype | ||
[ step, levelist?, param ]] | ||
] | ||
# enfo | ||
[ class, expver, stream=enfo/efov/eefo, date, time, domain | ||
[ type, levtype | ||
[ step, quantile?, number?, levelist?, param ]] | ||
] | ||
|
||
# waef/weov | ||
[ class, expver, stream=waef/weov/weef, date, time, domain | ||
[ type, levtype | ||
[ step, number?, param, frequency?, direction? ]] | ||
] | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
""" | ||
NOTE: | ||
To be able to run the tests pyfdb and pygribjump need to find the native libraries. | ||
If not installed into a default location export the following environent | ||
variables in the shell running pytest: | ||
GRIBJUMP_HOME = <cmake-build-root-for-gribjump> or <custom-install-location> | ||
FDB5_DIR = <cmake-build-root-for-fdb> or <custom-install-location> | ||
""" | ||
|
||
import os | ||
import pathlib | ||
import shutil | ||
|
||
import numpy | ||
import pytest | ||
import yaml | ||
|
||
# Do not reorder the imports otherwise this will trigger an assertion in eckits | ||
# library registration handling. | ||
import pygribjump as pygj | ||
import pyfdb | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def read_only_fdb_setup(data_path, tmp_path) -> pathlib.Path: | ||
""" | ||
Creates a FDB setup in this tests temp directory. | ||
Test FDB currently reads all grib files in `tests/data` | ||
""" | ||
db_store_path = tmp_path / "db_store" | ||
db_store_path.mkdir(exist_ok=True) | ||
schema_path = tmp_path / "schema" | ||
config = dict( | ||
type="local", | ||
engine="toc", | ||
schema=str(schema_path), | ||
spaces=[ | ||
dict( | ||
handler="Default", | ||
roots=[ | ||
{"path": str(db_store_path)}, | ||
], | ||
) | ||
], | ||
) | ||
config_path = tmp_path / "config.yaml" | ||
config_path.write_text(yaml.dump(config)) | ||
shutil.copy(data_path / "schema", schema_path) | ||
os.environ["FDB5_CONFIG_FILE"] = str(config_path) | ||
|
||
# grib_files = data_path.glob("*.grib") | ||
grib_files = [data_path / "synth11.grib"] | ||
fdb = pyfdb.FDB() | ||
for f in grib_files: | ||
fdb.archive(f.read_bytes()) | ||
return tmp_path | ||
|
||
|
||
def test_extract_simple_sunshine_case(read_only_fdb_setup) -> None: | ||
grib_jump = pygj.GribJump() | ||
reqstrs = [ | ||
{ | ||
"domain": "g", | ||
"levtype": "sfc", | ||
"date": "20230508", | ||
"time": "1200", | ||
"step": "1", | ||
"param": "151130", | ||
"class": "od", | ||
"type": "fc", | ||
"stream": "oper", | ||
"expver": "0001", | ||
}, | ||
] | ||
ranges = [ | ||
[(0, 6)], | ||
] | ||
|
||
polyrequest = [(a, b) for a, b in zip(reqstrs, ranges)] | ||
|
||
expected = numpy.array([0.0, numpy.nan, numpy.nan, 3.0, 4.0, numpy.nan]) | ||
|
||
actual = grib_jump.extract(polyrequest) | ||
assert numpy.array_equal(expected, actual[0][0][0][0], equal_nan=True) |
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
[tool.pytest.ini_options] | ||
minversion = "6.0" | ||
addopts = "-vv -s" | ||
testpaths = [ | ||
"pygribjump/tests" | ||
] |
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
Oops, something went wrong.