Skip to content

Fix python embedding when using a named grid with MET_PYTHON_EXE set. #1798

@JohnHalleyGotway

Description

@JohnHalleyGotway

Describe the Problem

While working on the DTC Air Force GSWR evaluation project, I ran into a wrinkle with python embedding in MET version 10.0.0 that needs to be fixed.

GitHub issue #1471 enhanced MET version 10.0.0 to enable the python grid to be defined as a named grid or grid specification string. This works well with straight python but causes a runtime error when the MET_PYTHON_EXE environment variable is set. The problem exists in the read_tmp_dataplane.py wrapper. It assumes that the grid is defined as a dictionary.

Expected Behavior

Specifying the grid as a string should work via python embedding whether or not MET_PYTHON_EXE is set.

Environment

Describe your runtime environment:
1. Machine: Mac Laptop
2. OS: MacOS
3. Software version number(s): MET version 10.0.0

To Reproduce

Describe the steps to reproduce the behavior:

  1. Download this sample python embedding script:
    read_ascii_numpy_named_grid.py.txt
  2. Rename it and run it with straight python:
mv read_ascii_numpy_named_grid.py.txt read_ascii_numpy_named_grid.py
bin/plot_data_plane PYTHON_NUMPY plot.ps 'name="read_ascii_numpy_named_grid.py data/python/fcst.txt FCST";'
  1. Set MET_PYTHON_EXE and rerun:
export MET_PYTHON_EXE=`which python3`
bin/plot_data_plane PYTHON_NUMPY plot.ps 'name="read_ascii_numpy_named_grid.py data/python/fcst.txt FCST";'
  1. Note the runtime error:
Traceback (most recent call last):
  File "/Volumes/d1/projects/MET/MET_development/MET-develop/met/share/met/wrappers/read_tmp_dataplane.py", line 23, in <module>
    grid_attr = attr.split('.')[1]
IndexError: list index out of range
WARNING: 
WARNING: tmp_nc_dataplane() -> an error occurred importing module "read_tmp_dataplane"
WARNING: 
ERROR  : 
ERROR  : plot_data_plane -> trouble getting field "name="read_ascii_numpy_named_grid.py data/python/fcst.txt FCST";" from file "PYTHON_NUMPY"
ERROR  : 

Post relevant sample data following these instructions:
https://dtcenter.org/community-code/model-evaluation-tools-met/met-help-desk#ftp

Relevant Deadlines

For met-10.0.1

Funding Source

Define the source of funding and account keys here or state NONE.

Define the Metadata

Assignee

  • Select engineer(s) or no engineer required: John HG
  • Select scientist(s) or no scientist required: No scientist required

Labels

  • Select component(s)
  • Select priority
  • Select requestor(s)

Projects and Milestone

  • Review projects and select relevant Repository and Organization ones or add "alert:NEED PROJECT ASSIGNMENT" label
  • Select milestone to relevant bugfix version

Define Related Issue(s)

Consider the impact to the other METplus components.

Bugfix Checklist

See the METplus Workflow for details.

  • Complete the issue definition above, including the Time Estimate and Funding Source.
  • Fork this repository or create a branch of main_<Version>.
    Branch name: bugfix_<Issue Number>_main_<Version>_<Description>
  • Fix the bug and test your changes.
  • Add/update log messages for easier debugging.
  • Add/update unit tests.
  • Add/update documentation.
  • Push local changes to GitHub.
  • Submit a pull request to merge into main_<Version>.
    Pull request: bugfix <Issue Number> main_<Version> <Description>
  • Define the pull request metadata, as permissions allow.
    Select: Reviewer(s), Project(s), Milestone, and Linked issues
  • Iterate until the reviewer(s) accept and merge your changes.
  • Delete your fork or branch.
  • Complete the steps above to fix the bug on the develop branch.
    Branch name: bugfix_<Issue Number>_develop_<Description>
    Pull request: bugfix <Issue Number> develop <Description>
  • Close this issue.

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions