Skip to content

Commit

Permalink
Bugfix 1798 develop py_grid_string (#1800)
Browse files Browse the repository at this point in the history
* Per #1798, fix up the read_tmpe_dataplane.py script to handle a grid string or dictionary.

* Per #1798, add a test to unit_python.xml to exercise this bugfix.
  • Loading branch information
JohnHalleyGotway authored May 20, 2021
1 parent a0dcfd9 commit 754889b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
9 changes: 7 additions & 2 deletions met/data/wrappers/read_tmp_dataplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@
ds = nc.Dataset(netcdf_filename, 'r')
met_data = ds['met_data'][:]
met_attrs = {}

# grid is defined as a dictionary or string
grid = {}
for attr, attr_val in ds.__dict__.items():
if 'grid' in attr:
if 'grid.' in attr:
grid_attr = attr.split('.')[1]
grid[grid_attr] = attr_val
else:
met_attrs[attr] = attr_val
met_attrs['grid'] = grid

if grid:
met_attrs['grid'] = grid

met_attrs['name'] = met_attrs['name_str']
del met_attrs['name_str']
met_info['met_data'] = met_data
Expand Down
20 changes: 20 additions & 0 deletions test/xml/unit_python.xml
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,26 @@
</output>
</test>

<!-- Invokes user-python logic to read a grid string -->
<test name="python_numpy_grid_name_user_python">
<exec>&MET_BIN;/plot_data_plane</exec>
<env>
<pair><name>MET_PYTHON_EXE</name> <value>&MET_PYTHON_EXE;</value></pair>
<pair><name>PYTHON_GRID</name> <value>G212</value></pair>
</env>
<param> \
PYTHON_NUMPY \
&OUTPUT_DIR;/python/letter_numpy_grid_name_user_python.ps \
'name = "&MET_BASE;/python/read_ascii_numpy_grid.py &DATA_DIR_PYTHON;/letter.txt LETTER";' \
-plot_range 0.0 255.0 \
-title "Grid Name: 'G212'" \
-v 1
</param>
<output>
<ps>&OUTPUT_DIR;/python/letter_numpy_grid_name_user_python.ps</ps>
</output>
</test>

<!-- Invokes user-python logic to read point data -->
<test name="python_ascii2nc_user_python">
<exec>&MET_BIN;/ascii2nc</exec>
Expand Down

0 comments on commit 754889b

Please sign in to comment.