Skip to content

Commit

Permalink
Feature 1747 pylonglong (#1748)
Browse files Browse the repository at this point in the history
* Per #1747, update MET to interpret longlong values as integers. NetCDF file attributes that have an LL suffix are read into python as numpy.int64 objects. Right now MET fails when trying to read those as integers. Update the parsing logic to interpret those as ints.

* Per #1747, since MET can now interpret both long and longlong's as ints, there's no need to cast nx and ny to ints in the read_tmp_dataplane.py script anymore.

* Per #1747, this is slightly unrelated. But after installing the netCDF4 module on kiowa for /usr/local/met-python3/bin/python3, we should no longer need a custom PATH setting to get unit_python.xml to work. Reverting the change I made to it a couple of days ago to get it working.
  • Loading branch information
JohnHalleyGotway authored Apr 6, 2021
1 parent 9a9bbc7 commit 1757cb1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion met/data/wrappers/read_tmp_dataplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
grid[grid_attr] = attr_val
else:
met_attrs[attr] = attr_val
grid['nx'], grid['ny'] = int(grid['nx']), int(grid['ny'])
met_attrs['grid'] = grid
met_attrs['name'] = met_attrs['name_str']
del met_attrs['name_str']
Expand Down
8 changes: 8 additions & 0 deletions met/src/libcode/vx_python3_utils/python3_dict.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ if ( ! a ) {

}

// If not a Long, try interpreting as LongLong for numpy.int64 values

if ( ! PyLong_Check(a) ) {

a = PyLong_FromLongLong(PyLong_AsLongLong(a));

}

if ( ! PyLong_Check(a) ) {

mlog << Error << "\nPython3_Dict::lookup_int(const char *) -> "
Expand Down
4 changes: 1 addition & 3 deletions test/xml/unit_python.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<!ENTITY INPUT_DIR "${MET_TEST_INPUT}">
<!ENTITY OUTPUT_DIR "${MET_TEST_OUTPUT}">
<!ENTITY MET_PYTHON_EXE "/usr/local/python3/bin/python3">
<!ENTITY ANACONDA_BIN "/usr/local/anaconda3-20190923/bin">

<!ENTITY CONFIG_DIR "&TEST_DIR;/config">
<!ENTITY DATA_DIR_PYTHON "&INPUT_DIR;/python">
Expand Down Expand Up @@ -392,8 +391,7 @@

<!-- Invokes Python pickle logic to read NUMPY text data -->
<test name="python_numpy_plot_data_plane_pickle">
<exec>export PATH='&ANACONDA_BIN;:${PATH}'; \
&MET_BIN;/plot_data_plane</exec>
<exec>&MET_BIN;/plot_data_plane</exec>
<env>
<pair><name>MET_PYTHON_EXE</name> <value>&MET_PYTHON_EXE;</value></pair>
</env>
Expand Down

0 comments on commit 1757cb1

Please sign in to comment.