Skip to content

Commit

Permalink
Per #2550, update tc_diag to import the atcf_tools, diag_lib, and tc_…
Browse files Browse the repository at this point in the history
…diag_driver code
  • Loading branch information
JohnHalleyGotway committed Sep 29, 2023
1 parent f61fba9 commit dc879a0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions scripts/python/tc_diag/compute_tc_diag.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import os
import sys
import atcf_tools
import diag_lib
import tc_diag_driver

###########################################

Expand Down
18 changes: 16 additions & 2 deletions src/tools/tc_utils/tc_diag/python_tc_diag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern GlobalPython GP; // this needs external linkage
static const char * user_ppath = nullptr;
static const char write_tmp_diag [] = "MET_BASE/python/pyembed/write_tmp_tc_diag.py";
static const char read_tmp_diag [] = "pyembed.read_tmp_tc_diag"; // NO ".py" suffix
static const char python_tc_diag_dir[] = "MET_BASE/python/tc_diag";
static const char tc_diag_dict_name [] = "tc_diag";

////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -98,13 +99,26 @@ bool straight_python_tc_diag(const ConcatString &script_name,
run_python_string("import sys");

ConcatString command;

// Add the tc_diag python directory to the path
ConcatString tc_diag_dir(replace_path(python_tc_diag_dir));

command << cs_erase
<< "sys.path.append(\""
<< script_name.dirname()
<< tc_diag_dir
<< "\")";

run_python_string(command.text());

// Add the directory of the script to the path, if needed
if(tc_diag_dir != script_name.dirname()) {

command << cs_erase
<< "sys.path.append(\""
<< script_name.dirname()
<< "\");";
run_python_string(command.text());
}

if(arg_sa.n() > 0) {
PySys_SetArgv(wa.wargc(), wa.wargv());
}
Expand Down
3 changes: 0 additions & 3 deletions src/tools/tc_utils/tc_diag/tc_diag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ static void compute_lat_lon(TcrmwGrid&, double *, double *);

int met_main(int argc, char *argv[]) {

// Print beta status warning
print_beta_warning("The TC-Diag tool");

// Process command line arguments
process_command_line(argc, argv);

Expand Down

0 comments on commit dc879a0

Please sign in to comment.