Skip to content

Commit

Permalink
Closes #239 Adding diffs to tests
Browse files Browse the repository at this point in the history
test diff has beed added to all mentioned alg tests. cf_reader cxx & python tests are failing (cam5 test in cxx)
  • Loading branch information
elbashandy committed Dec 12, 2019
1 parent f2fb77a commit b7bc6f4
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 59 deletions.
2 changes: 2 additions & 0 deletions io/teca_cartesian_mesh_writer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ const_p_teca_dataset teca_cartesian_mesh_writer::execute(
= std::dynamic_pointer_cast<const teca_cartesian_mesh>(
input_data[0]);

std::cerr << "teca_cartesian_mesh_writer::execute -- mesh: " << mesh << std::endl;

// only rank 0 is required to have data
int rank = 0;
#if defined(TECA_HAS_MPI)
Expand Down
12 changes: 6 additions & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,29 @@ teca_add_test(test_cf_reader_cam5
LIBS teca_core teca_data teca_io teca_alg ${teca_test_link}
COMMAND test_cf_reader
-i "${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-[0-9][0-9]-10800\\.nc"
-o "test_cf_reader_%t%.%e%" -s 1,2 -x lon -y lat -t time U850 V850
-o "${TECA_DATA_ROOT}/test_cf_reader_cam5.bin" -s 1,2 -x lon -y lat -t time U850 V850
FEATURES ${TECA_HAS_NETCDF}
REQ_TECA_DATA)

teca_add_test(test_cf_reader_cfsr
COMMAND test_cf_reader
-i "${TECA_DATA_ROOT}/NCEP_CFSR_0\\.5_1979\\.nc"
-o "test_cf_reader_%t%.%e%" -s 1,2 -x longitude -y latitude
-o "${TECA_DATA_ROOT}/test_cf_reader_cfsr.bin" -s 1,2 -x longitude -y latitude
-b 65,110,10,55,0,0 elevation
FEATURES ${TECA_HAS_NETCDF}
REQ_TECA_DATA)

teca_add_test(test_cf_reader_era5
COMMAND test_cf_reader
-i "${TECA_DATA_ROOT}/e5\.oper\.an\.vinteg\.162_072_viwvn.*\.nc"
-o "test_cf_reader_era5_%t%.%e%" -s 0,-1 -x longitude -y latitude -t time VIWVN
-o "${TECA_DATA_ROOT}/test_cf_reader_era5.bin" -s 0,-1 -x longitude -y latitude -t time VIWVN
FEATURES ${TECA_HAS_NETCDF}
REQ_TECA_DATA)

teca_add_test(test_cf_reader_file_time
COMMAND test_cf_reader
-i "${TECA_DATA_ROOT}/ARTMIP_MERRA_2D_20170210_06\.nc"
-o "test_cf_reader_file_time_%t%.%e%" -s 0,-1 -x lon -y lat
-o "test_cf_reader_file_time.bin" -s 0,-1 -x lon -y lat
-n "ARTMIP_MERRA_2D_%Y%m%d_%H.nc" IVT
FEATURES ${TECA_HAS_NETCDF}
REQ_TECA_DATA)
Expand Down Expand Up @@ -235,7 +235,7 @@ teca_add_test(test_temporal_average
LIBS teca_core teca_data teca_io teca_alg ${teca_test_link}
COMMAND test_temporal_average
"${TECA_DATA_ROOT}/cam5_1_amip_run2.cam2.h2.1991-10-01-10800.nc"
test_temporal_average_%t%.%e% 0 -1 3 U850
${TECA_DATA_ROOT}/test_temporal_average.bin 0 -1 3 U850
FEATURES ${TECA_HAS_NETCDF}
REQ_TECA_DATA)

Expand Down Expand Up @@ -500,7 +500,7 @@ teca_add_test(test_binary_segmentation
SOURCES test_binary_segmentation.cpp
LIBS teca_core teca_data teca_io teca_alg ${teca_test_link}
COMMAND test_binary_segmentation "${TECA_DATA_ROOT}/prw_hus_day_MRI.*\\.nc$"
prw 50 75 "prw_segmentation_50-75_%t%.%e%"
prw 50 75 "${TECA_DATA_ROOT}/prw_segmentation_50-75.bin"
REQ_TECA_DATA)

teca_add_test(test_bayesian_ar_detect_serial
Expand Down
10 changes: 5 additions & 5 deletions test/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
teca_add_test(py_test_cf_reader
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_cf_reader.py
"${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-0[12]-10800\\.nc"
1 2 "py_test_cf_reader_%t%.vtk" U850 V850
1 2 "${TECA_DATA_ROOT}/py_test_cf_reader.bin" U850 V850
FEATURES ${TECA_HAS_NETCDF}
REQ_TECA_DATA)

Expand Down Expand Up @@ -40,7 +40,7 @@ if (TECA_DATA_ROOT AND TECA_HAS_NETCDF)
add_test(NAME py_test_connected_components
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_connected_components.py
"${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-01-10800\\.nc"
"" U850 V850 15 0 0 "py_test_connected_components_%t%.vtk"
"" U850 V850 15 0 0 "${TECA_DATA_ROOT}/py_test_connected_components.bin"
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()

Expand All @@ -51,7 +51,7 @@ teca_add_test(py_test_component_area_filter
teca_add_test(py_test_derived_quantity
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_derived_quantity.py
"${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-0[12]-10800\\.nc"
U850 V850 0 0 "py_test_derived_quantity_%t%.vtk"
U850 V850 0 0 "${TECA_DATA_ROOT}/py_test_derived_quantity.bin"
FEATURES ${TECA_HAS_NETCDF}
REQ_TECA_DATA)

Expand All @@ -62,14 +62,14 @@ teca_add_test(py_test_latitude_damper
teca_add_test(py_test_programmable_algorithm
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_programmable_algorithm.py
"${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-0[12]-10800\\.nc"
U850 V850 0 0 "py_test_programmable_algorithm_%t%.vtk"
U850 V850 0 0 "${TECA_DATA_ROOT}/py_test_programmable_algorithm.bin"
FEATURES ${TECA_HAS_NETCDF}
REQ_TECA_DATA)

teca_add_test(py_test_vector_ops
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_vector_ops.py
"${TECA_DATA_ROOT}/cam5_1_amip_run2\\.cam2\\.h2\\.1991-10-01-10800\\.nc"
0 0 py_test_vector_ops_%t%.vtk U850 V850
0 0 ${TECA_DATA_ROOT}/py_test_vector_ops.bin U850 V850
FEATURES ${TECA_HAS_NETCDF}
REQ_TECA_DATA)

Expand Down
25 changes: 19 additions & 6 deletions test/python/test_cf_reader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from teca import *
import os
import sys

set_stack_trace_on_error()
Expand Down Expand Up @@ -34,9 +35,21 @@
exe.set_end_index(end_index)
exe.set_arrays(arrays)

wri = teca_cartesian_mesh_writer.New()
wri.set_input_connection(coords.get_output_port())
wri.set_executive(exe)
wri.set_file_name(out_file)

wri.update()
if os.path.exists(out_file):
rea = teca_cartesian_mesh_reader.New()
rea.set_file_name(out_file)

diff = teca_dataset_diff.New()
diff.set_input_connection(0, rea.get_output_port())
diff.set_input_connection(1, coords.get_output_port())
diff.set_executive(exe)

diff.update()
else:
sys.stderr.write('generating baseline\n')
wri = teca_cartesian_mesh_writer.New()
wri.set_input_connection(coords.get_output_port())
wri.set_executive(exe)
wri.set_file_name(out_file)

wri.update()
23 changes: 18 additions & 5 deletions test/python/test_connected_components.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from teca import *
import os
import sys

set_stack_trace_on_error()
Expand Down Expand Up @@ -58,9 +59,21 @@
exe.set_start_index(first_step)
exe.set_end_index(end_index)

wri = teca_cartesian_mesh_writer.New()
wri.set_input_connection(cc.get_output_port())
wri.set_executive(exe)
wri.set_file_name(out_file)
if os.path.exists(out_file):
rea = teca_cartesian_mesh_reader.New()
rea.set_file_name(out_file)

diff = teca_dataset_diff.New()
diff.set_input_connection(0, rea.get_output_port())
diff.set_input_connection(1, cc.get_output_port())
diff.set_executive(exe)

wri.update()
diff.update()
else:
sys.stderr.write('generating baseline\n')
wri = teca_cartesian_mesh_writer.New()
wri.set_input_connection(cc.get_output_port())
wri.set_executive(exe)
wri.set_file_name(out_file)

wri.update()
23 changes: 18 additions & 5 deletions test/python/test_derived_quantity.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from teca import *
import numpy as np
import os
import sys

set_stack_trace_on_error()
Expand Down Expand Up @@ -50,9 +51,21 @@ def execute(port, data_in, req):
exe.set_start_index(first_step)
exe.set_end_index(end_index)

wri = teca_cartesian_mesh_writer.New()
wri.set_input_connection(alg.get_output_port())
wri.set_executive(exe)
wri.set_file_name(out_file)
if os.path.exists(out_file):
rea = teca_cartesian_mesh_reader.New()
rea.set_file_name(out_file)

diff = teca_dataset_diff.New()
diff.set_input_connection(0, rea.get_output_port())
diff.set_input_connection(1, alg.get_output_port())
diff.set_executive(exe)

wri.update()
diff.update()
else:
sys.stderr.write('generating baseline\n')
wri = teca_cartesian_mesh_writer.New()
wri.set_input_connection(alg.get_output_port())
wri.set_executive(exe)
wri.set_file_name(out_file)

wri.update()
23 changes: 18 additions & 5 deletions test/python/test_programmable_algorithm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from teca import *
import numpy as np
import sys
import os

set_stack_trace_on_error()

Expand Down Expand Up @@ -65,9 +66,21 @@ def execute(port, data_in, req):
exe.set_start_index(first_step)
exe.set_end_index(end_index)

wri = teca_cartesian_mesh_writer.New()
wri.set_input_connection(alg.get_output_port())
wri.set_executive(exe)
wri.set_file_name(out_file)
if os.path.exists(out_file):
rea = teca_cartesian_mesh_reader.New()
rea.set_file_name(out_file)

diff = teca_dataset_diff.New()
diff.set_input_connection(0, rea.get_output_port())
diff.set_input_connection(1, alg.get_output_port())
diff.set_executive(exe)

wri.update()
diff.update()
else:
sys.stderr.write('generating baseline\n')
wri = teca_cartesian_mesh_writer.New()
wri.set_input_connection(alg.get_output_port())
wri.set_file_name(out_file)
wri.set_executive(exe)

wri.update()
23 changes: 18 additions & 5 deletions test/python/test_vector_ops.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from teca import *
import os
import sys

set_stack_trace_on_error()
Expand Down Expand Up @@ -46,9 +47,21 @@
exe.set_start_index(first_step)
exe.set_end_index(end_index)

wri = teca_cartesian_mesh_writer.New()
wri.set_input_connection(vort.get_output_port())
wri.set_executive(exe)
wri.set_file_name(out_file)
if os.path.exists(out_file):
rea = teca_cartesian_mesh_reader.New()
rea.set_file_name(out_file)

diff = teca_dataset_diff.New()
diff.set_input_connection(0, rea.get_output_port())
diff.set_input_connection(1, vort.get_output_port())
diff.set_executive(exe)

wri.update()
diff.update()
else:
sys.stderr.write('generating baseline\n')
wri = teca_cartesian_mesh_writer.New()
wri.set_input_connection(vort.get_output_port())
wri.set_executive(exe)
wri.set_file_name(out_file)

wri.update()
35 changes: 30 additions & 5 deletions test/test_binary_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
#include "teca_binary_segmentation.h"
#include "teca_cartesian_mesh_writer.h"
#include "teca_file_util.h"
#include "teca_cartesian_mesh_reader.h"
#include "teca_cartesian_mesh_writer.h"
#include "teca_dataset_diff.h"
#include "teca_mpi_manager.h"
#include "teca_system_interface.h"
#include "teca_mpi.h"

#include <vector>
#include <string>
Expand All @@ -12,6 +17,9 @@ using namespace std;

int main(int argc, char **argv)
{
teca_mpi_manager mpi_man(argc, argv);
int rank = mpi_man.get_comm_rank();

teca_system_interface::set_stack_trace_on_error();

if (argc != 6)
Expand All @@ -26,7 +34,7 @@ int main(int argc, char **argv)
std::string var = argv[2];
double low = atof(argv[3]);
double high = atof(argv[4]);
std::string out_file = argv[5];
std::string baseline = argv[5];

// build the pipeline
p_teca_cf_reader cfr = teca_cf_reader::New();
Expand All @@ -39,11 +47,28 @@ int main(int argc, char **argv)
seg->set_threshold_by_percentile();
seg->set_input_connection(cfr->get_output_port());

p_teca_cartesian_mesh_writer wri = teca_cartesian_mesh_writer::New();
wri->set_input_connection(seg->get_output_port());
wri->set_file_name(out_file);
// regression test
if (teca_file_util::file_exists(baseline.c_str()))
{
// run the test
p_teca_cartesian_mesh_reader rea = teca_cartesian_mesh_reader::New();
rea->set_file_name(baseline);

wri->update();
p_teca_dataset_diff diff = teca_dataset_diff::New();
diff->set_input_connection(0, rea->get_output_port());
diff->set_input_connection(1, seg->get_output_port());
diff->update();
}
else
{
// make a baseline
if (rank == 0)
cerr << "generating baseline image " << baseline << endl;
p_teca_cartesian_mesh_writer wri = teca_cartesian_mesh_writer::New();
wri->set_input_connection(seg->get_output_port());
wri->set_file_name(baseline.c_str());
wri->update();
}

return 0;
}
Loading

0 comments on commit b7bc6f4

Please sign in to comment.