Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for PET BMI module (replaces PR#401) #429

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/module_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ jobs:
mod-dir: "extern/cfe/"
targets: "cfebmi"

- name: Build PET
id: submod_build_5
uses: ./.github/actions/ngen-submod-build
with:
mod-dir: "extern/evapotranspiration/evapotranspiration"
targets: "petbmi"

- name: Build Ngen
uses: ./.github/actions/ngen-build
with:
Expand All @@ -65,6 +72,11 @@ jobs:
inputfile='data/example_bmi_multi_realization_config.json'
./cmake_build/ngen data/catchment_data.geojson "cat-27" data/nexus_data.geojson "nex-26" $inputfile

- name: Run surfacebmi, cfebmi and petbmi
run: |
inputfile='data/example_bmi_multi_realization_config_w_noah_pet_cfe.json'
./cmake_build/ngen data/catchment_data.geojson "cat-27" data/nexus_data.geojson "nex-26" $inputfile

# Run t-route/pybind integration test
test_troute_integration:
# The type of runner that the job will run on
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/test_and_validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,40 @@ jobs:
- name: Clean Up
uses: ./.github/actions/clean-build

# Test PET
test_pet:
# The type of runner that the job will run on
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Build PET Submodule
id: submod_build_5
uses: ./.github/actions/ngen-submod-build
with:
mod-dir: "extern/evapotranspiration/evapotranspiration"
targets: "petbmi"

- name: Build PET Tests
uses: ./.github/actions/ngen-build
with:
targets: "compare_pet"
build-cores: ${{ env.LINUX_NUM_PROC_CORES }}

- name: Run Tests
run: ./cmake_build/test/compare_pet
timeout-minutes: 15

- name: Clean Up
uses: ./.github/actions/clean-build

# Test MPI remote nexus behavior in linux
test_mpi_remote_nexus:
# The type of runner that the job will run on
Expand Down
21 changes: 21 additions & 0 deletions data/bmi/c/pet/cat-27_bmi_config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
verbose=0
pet_method=5
forcing_file=BMI
run_unit_tests=0
yes_aorc=1
yes_wrf=0
wind_speed_measurement_height_m=10.0
humidity_measurement_height_m=2.0
vegetation_height_m=0.12
zero_plane_displacement_height_m=0.0003
momentum_transfer_roughness_length=0.0
heat_transfer_roughness_length_m=0.0
surface_longwave_emissivity=1.0
surface_shortwave_albedo=0.22
cloud_base_height_known=FALSE
latitude_degrees=37.25
longitude_degrees=-97.5554
site_elevation_m=303.33
time_step_size_s=3600
num_timesteps=720
shortwave_radiation_provided=0
21 changes: 21 additions & 0 deletions data/bmi/c/pet/cat-67_bmi_config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
verbose=0
pet_method=1
forcing_file=BMI
run_unit_tests=0
yes_aorc=1
yes_wrf=0
wind_speed_measurement_height_m=10.0
humidity_measurement_height_m=2.0
vegetation_height_m=0.12
zero_plane_displacement_height_m=0.0003
momentum_transfer_roughness_length=0.0
heat_transfer_roughness_length_m=0.0
surface_longwave_emissivity=1.0
surface_shortwave_albedo=0.22
cloud_base_height_known=FALSE
latitude_degrees=37.865211
longitude_degrees=-98.12345
site_elevation_m=303.333
time_step_size_s=3600
num_timesteps=720
shortwave_radiation_provided=0
90 changes: 90 additions & 0 deletions data/example_bmi_multi_realization_config_w_noah_pet_cfe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"global": {
"formulations": [
{
"name": "bmi_multi",
"params": {
"model_type_name": "bmi_multi_noahowp_cfe",
"forcing_file": "",
"init_config": "",
"allow_exceed_end_time": true,
"main_output_variable": "Q_OUT",
"modules": [
{
"name": "bmi_fortran",
"params": {
"model_type_name": "bmi_fortran_noahowp",
"library_file": "./extern/noah-owp-modular/cmake_build/libsurfacebmi",
"forcing_file": "",
"init_config": "./data/bmi/fortran/noah-owp-modular-init-{{id}}.namelist.input",
"allow_exceed_end_time": true,
"main_output_variable": "QINSUR",
"variables_names_map": {
"PRCPNONC": "atmosphere_water__liquid_equivalent_precipitation_rate",
"Q2": "atmosphere_air_water~vapor__relative_saturation",
"SFCTMP": "land_surface_air__temperature",
"UU": "land_surface_wind__x_component_of_velocity",
"VV": "land_surface_wind__y_component_of_velocity",
"LWDN": "land_surface_radiation~incoming~longwave__energy_flux",
"SOLDN": "land_surface_radiation~incoming~shortwave__energy_flux",
"SFCPRS": "land_surface_air__pressure"
},
"uses_forcing_file": false
}
},
{
"name": "bmi_c",
"params": {
"model_type_name": "bmi_c_pet",
"library_file": "./extern/evapotranspiration/evapotranspiration/cmake_build/libpetbmi",
"forcing_file": "",
"init_config": "./data/bmi/c/pet/{{id}}_bmi_config.ini",
"allow_exceed_end_time": true,
"main_output_variable": "water_potential_evaporation_flux",
"registration_function": "register_bmi_pet",
"variables_names_map": {
"water_potential_evaporation_flux": "potential_evapotranspiration"
},
"uses_forcing_file": false
}
},
{
"name": "bmi_c",
"params": {
"model_type_name": "bmi_c_cfe",
"library_file": "./extern/cfe/cmake_build/libcfebmi",
"forcing_file": "",
"init_config": "./data/bmi/c/cfe/{{id}}_bmi_config.ini",
"allow_exceed_end_time": true,
"main_output_variable": "Q_OUT",
"registration_function": "register_bmi_cfe",
"variables_names_map": {
"water_potential_evaporation_flux": "potential_evapotranspiration",
"atmosphere_air_water~vapor__relative_saturation": "SPFH_2maboveground",
"land_surface_air__temperature": "TMP_2maboveground",
"land_surface_wind__x_component_of_velocity": "UGRD_10maboveground",
"land_surface_wind__y_component_of_velocity": "VGRD_10maboveground",
"land_surface_radiation~incoming~longwave__energy_flux": "DLWRF_surface",
"land_surface_radiation~incoming~shortwave__energy_flux": "DSWRF_surface",
"land_surface_air__pressure": "PRES_surface"
},
"uses_forcing_file": false
}
}
],
"uses_forcing_file": false
}
}
],
"forcing": {
"file_pattern": ".*{{id}}.*..csv",
"path": "./data/forcing/",
"provider": "CsvPerFeature"
}
},
"time": {
"start_time": "2015-12-01 00:00:00",
"end_time": "2015-12-30 23:00:00",
"output_interval": 3600
}
}
1 change: 1 addition & 0 deletions include/realizations/catchment/Bmi_C_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ namespace realization {
friend class ::Bmi_Formulation_Test;
friend class ::Bmi_C_Formulation_Test;
friend class ::Bmi_C_Cfe_IT;
friend class ::Bmi_C_Pet_IT;

private:

Expand Down
1 change: 1 addition & 0 deletions include/realizations/catchment/Bmi_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
class Bmi_Formulation_Test;
class Bmi_C_Formulation_Test;
class Bmi_C_Cfe_IT;
class Bmi_C_Pet_IT;

using namespace std;

Expand Down
1 change: 1 addition & 0 deletions include/realizations/catchment/Bmi_Module_Formulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Bmi_Multi_Formulation_Test;
class Bmi_C_Formulation_Test;
class Bmi_Cpp_Formulation_Test;
class Bmi_C_Cfe_IT;
class Bmi_C_Pet_IT;
class Bmi_Cpp_Multi_Array_Test;

namespace realization {
Expand Down
14 changes: 14 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,20 @@ add_test(
${NETCDF_LIBRARIES}
)

########################## Comparison tests for the BMI PET implementation
# TODO: this probably needs to be added to integration testing also
add_test(
compare_pet
1
realizations/catchments/Bmi_C_Pet_IT.cpp
NGen::core
NGen::realizations_catchment
NGen::core_mediator
NGen::forcing
libudunits2
${NETCDF_LIBRARIES}
)

########################## Internal Torchlib LSTM Tests
if(LSTM_TORCH_LIB_ACTIVE)
add_test(
Expand Down
Loading