Skip to content

Fix user python embedding for lat/lon grids for met-10.0.0. #1747

@JohnHalleyGotway

Description

@JohnHalleyGotway

Describe the Problem

Merging MET #1319 to read/write temporary gridded NetCDF files instead of pickle files has introduced a small problem. @georgemccabe found that METplus use cases calling user python embedding are now failing. The problem is in the "read_tmp_dataplane.py" script. It converts the 'nx' and 'ny' attributes to integers so that the MET code can parse their values properly.

The problem is the 'nx' and 'ny' grid attributes are not defined for all projection types, specifically they are not defined for LatLon grids. This makes the "read_tmp_dataplane.py" script fail when processing LatLon grids.

I recommend two changes. First, remove that line from the read_tmp_dataplane.py script. Second, enhance the MET library code to handle long long python objects directly and just interpret them as integers. The second change will remove the need for casting the variable type in the first place.

Expected Behavior

User python embedding should work for all projection types, not just the ones that include nx and ny as grid attribute names.

Environment

Describe your runtime environment:
1. Machine: seen in Docker by @georgemccabe and reproduced on my Mac laptop

To Reproduce

Describe the steps to reproduce the behavior:
1. Ran the following commands on my laptop:

mv read_ascii_numpy_latlon.py.txt read_ascii_numpy_latlon.py
export MET_PYTHON_EXE=/opt/local/bin/python3
plot_data_plane PYTHON_NUMPY letter_pickle.ps \
'name = "./read_ascii_numpy_latlon.py letter.txt LETTER";'

Using these files:
read_ascii_numpy_latlon.py.txt
letter.txt
2: Observe error:

ERROR  : Python3_Dict::lookup_int(const char *) -> value for key "Nlat" not an integer

Relevant Deadlines

Fix ASAP

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 to fix and @georgemccabe to review.
  • 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

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions