Skip to content

Commit

Permalink
Per #1293, define DataPlane::convert() member function and call it bo…
Browse files Browse the repository at this point in the history
…th from data_class.cc and vx_regrid.cc.
  • Loading branch information
JohnHalleyGotway committed Apr 10, 2020
1 parent 2aad8e5 commit 0382ad6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
15 changes: 15 additions & 0 deletions met/src/basic/vx_util/data_plane.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,21 @@ void DataPlane::threshold(const SingleThresh &st) {

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

void DataPlane::convert(const UserFunc_1Arg &convert_fx) {

if(!convert_fx.is_set()) return;

mlog << Debug(3) << "Applying conversion function.\n";

for(int i=0; i<Nxy; i++) {
if(!is_bad_data(buf()[i])) buf()[i] = convert_fx(buf()[i]);
}

return;
}

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

void DataPlane::censor(const ThreshArray &censor_thresh,
const NumArray &censor_val) {
int i, j, count;
Expand Down
2 changes: 2 additions & 0 deletions met/src/basic/vx_util/data_plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "thresh_array.h"
#include "num_array.h"
#include "two_d_array.h"
#include "config_funcs.h"

#include "vx_cal.h"

Expand Down Expand Up @@ -100,6 +101,7 @@ class DataPlane {
//

void threshold(const SingleThresh &);
void convert (const UserFunc_1Arg &);
void censor (const ThreshArray &, const NumArray &);

void replace_bad_data(const double value);
Expand Down
13 changes: 1 addition & 12 deletions met/src/libcode/vx_data2d/data_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,18 +285,7 @@ if ( ShiftRight != 0 ) dp.shift_right(ShiftRight);
// Apply conversion logic.
//

if ( vinfo->ConvertFx.is_set() ) {

mlog << Debug(3) << "Applying conversion function.\n";

int Nxy = dp.nx()*dp.ny();

for (int j=0; j<Nxy; ++j) {
if ( ! is_bad_data(dp.buf()[j]) ) {
dp.buf()[j] = vinfo->ConvertFx(dp.buf()[j]);
}
}
}
dp.convert(vinfo->ConvertFx);

//
// Apply censor logic.
Expand Down
13 changes: 1 addition & 12 deletions met/src/libcode/vx_regrid/vx_regrid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,7 @@ switch ( info.method ) {
// apply convert logic
//

if ( info.convert_fx.is_set() ) {

mlog << Debug(3) << "Applying conversion function.\n";

int Nxy = out.nx()*out.ny();

for (int j=0; j<Nxy; ++j) {
if ( ! is_bad_data(out.buf()[j]) ) {
out.buf()[j] = info.convert_fx(out.buf()[j]);
}
}
}
out.convert(info.convert_fx);

//
// apply censor logic
Expand Down

0 comments on commit 0382ad6

Please sign in to comment.