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

Bugfix #2173 develop shift_data_plane #2175

Merged
merged 5 commits into from
Jun 7, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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