Skip to content

Commit

Permalink
Bugfix #2173 develop shift_data_plane (#2175)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway authored Jun 7, 2022
1 parent f90b73e commit 76d12c4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
28 changes: 28 additions & 0 deletions internal/test_unit/xml/unit_python.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,34 @@
</output>
</test>

<test name="python_numpy_shift_data_plane">
<exec>&MET_BIN;/shift_data_plane</exec>
<param> \
PYTHON_NUMPY \
&OUTPUT_DIR;/python/shift_data_plane.nc \
'name="&MET_BASE;/python/read_ascii_numpy.py &DATA_DIR_PYTHON;/fcst.txt FCST";' \
-from 30 -110 -to 35 -115 \
-v 1
</param>
<output>
<grid_nc>&OUTPUT_DIR;/python/shift_data_plane.nc</grid_nc>
</output>
</test>

<test name="python_numpy_shift_data_plane_input_arg">
<exec>&MET_BIN;/shift_data_plane</exec>
<param> \
&DATA_DIR_PYTHON;/fcst.txt \
&OUTPUT_DIR;/python/shift_data_plane_input_arg.nc \
'name="&MET_BASE;/python/read_ascii_numpy.py MET_PYTHON_INPUT_ARG FCST"; file_type=PYTHON_NUMPY;' \
-from 30 -110 -to 35 -115 \
-v 1
</param>
<output>
<grid_nc>&OUTPUT_DIR;/python/shift_data_plane_input_arg.nc</grid_nc>
</output>
</test>

<test name="python_numpy_series_analysis">
<exec>&MET_BIN;/series_analysis</exec>
<env>
Expand Down
22 changes: 12 additions & 10 deletions src/tools/other/shift_data_plane/shift_data_plane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// Mod# Date Name Description
// ---- ---- ---- -----------
// 000 11-12-14 Halley Gotway New
// 001 06-07-22 Halley Gotway MET #2173 Fix python embedding
//
////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -50,6 +51,10 @@ using namespace std;
#include "vx_cal.h"
#include "vx_math.h"

#ifdef WITH_PYTHON
#include "data2d_python.h"
#endif

////////////////////////////////////////////////////////////////////////

static ConcatString program_name;
Expand Down Expand Up @@ -200,17 +205,11 @@ void process_data_file() {
// Populate the VarInfo object using config
vinfo->set_dict(config);

// Open the input file
if(!mtddf->open(InputFilename.c_str())) {
mlog << Error << "\nprocess_data_file() -> can't open file \""
<< InputFilename << "\"\n\n";
exit(1);
}

// Get the data plane from the file for this VarInfo object
if(!mtddf->data_plane(*vinfo, dp_in)) {
mlog << Error << "\nprocess_data_file() -> trouble getting field \""
<< FieldString << "\" from file \"" << InputFilename << "\"\n\n";
mlog << Error << "\nprocess_data_file() -> "
<< "trouble getting field \"" << FieldString
<< "\" from file \"" << InputFilename << "\"\n\n";
exit(1);
}

Expand Down Expand Up @@ -253,7 +252,6 @@ void process_data_file() {
mlog << Debug(2) << shift_cs << "\n";

// Shift the data

dp_shift = dp_in;
for(x=0; x<dp_shift.nx(); x++) {
for(y=0; y<dp_shift.ny(); y++) {
Expand All @@ -270,6 +268,10 @@ void process_data_file() {
if(mtddf) { delete mtddf; mtddf = (Met2dDataFile *) 0; }
if(vinfo) { delete vinfo; vinfo = (VarInfo *) 0; }

#ifdef WITH_PYTHON
GP.finalize();
#endif

return;
}

Expand Down

0 comments on commit 76d12c4

Please sign in to comment.