Skip to content

Bugfix: Invalid latitude values from a MPAS file #3381

Description

@hsoh-u

Replace italics below with details for this issue.

Describe the Problem

Provide a clear and concise description of the bug here.

MET reads latitude and longitude variables as double-precision values regardless of their original data type, converting float values to double precision during processing. Converting radian values as latitude values from float to double precision can introduce rounding errors, potentially resulting in values exceeding 90.0° or dropping below −90.0° when processing MPAS files.

Below is an example error message

DEBUG 6: get_nc_data(NcVar *, double *) lonCell data_size=41943042, is_unsigned_value: 0
DEBUG 6: UGridFile::read_netcdf_grid() -> convert  rad to degree for lat
DEBUG 6: UGridFile::read_netcdf_grid() ->   convert rad to degree for lon
DEBUG 9: UnstructuredData::set_points(int, double *, double *) first (-89.95510084, -58.29018675) and last (20.91506741, -0.01718597825) from (-89.95510084, -58.29018675) and (20.91506741, -0.01718597825)
PRE-MAIN-ERROR Exception: BadValue: Invalid latitude -90.000002504478161  (/glade/work/dtcrt/METplus/casper/components/MET/installations/12.2.0/external_libs/eckit/eckit-1.24.4/src/eckit/geometry/CoordinateHelpers.cc +49 assert_latitude_range)
terminate called after throwing an instance of 'eckit::BadValue'
  what():  BadValue: Invalid latitude -90.000002504478161
FATAL: Received Signal Abort. Exiting 6

The sample files and scripts are prepared at (/glade/u/home/johnhg/work/METplus/discussions/falko_20260422, casper or derecho) by @JohnHalleyGotway.

The coordinate NetCDF file ens_1/init.nc contains float data type radian values for lat and lon variables.

       float latCell(nCells) ;
                latCell:units = "rad" ;
                latCell:long_name = "Latitude of cells" ;
        float lonCell(nCells) ;
                lonCell:units = "rad" ;
                lonCell:long_name = "Longitude of cells" ;

Here are max and min radian values in the NetCDF file:

ncdump -v latCell ens_1/[init.nc](http://init.nc/) | grep "1\.57079" 
   -0.9446307, -1.570237, -1.570796, -1.570183, -1.569678, -1.569795,
    0.9437245, 0.944019, 0.9440414, 0.9443362, 0.9446307, 1.570237, 1.570796,

float data type minimum radian -1.570796 == -89.999981276
float data type maximum radian 1.570796 == 89.999981276
double data type minimum radian -1.570796371 == -90.000002532989
double data type maximum radian 1.570796371 == 90.000002532989

Expected Behavior

Provide a clear and concise description of what you expected to happen here.

The converted latitude values (from the radian unit) should be adjusted to remain within the −90.0° to 90.0° range.

Environment

Describe your runtime environment:

  1. casper or derecho
  2. OS: (e.g. RedHat Linux, MacOS)
  3. MET12.2.0 and MET13.0.0

To Reproduce

Describe the steps to reproduce the behavior:

  1. login to casper or derecho
  2. change directory to /glade/u/home/johnhg/work/METplus/discussions/falko_20260422
  3. ./run_ps.sh

Relevant Deadlines

List relevant project deadlines here or state NONE.

Funding Source

NCAR base 2702701

Define the Metadata

Assignee

  • Select engineer(s) or no engineer required
  • Select scientist(s) or no scientist required

Labels

  • Review default alert labels
  • Select component(s)
  • Select priority
  • Select requestor(s)

Milestone and Projects

  • Select Milestone as the next bugfix version
  • Select METplus-X.Y Support project for support of the current coordinated release
  • Select MET-X.Y Development project for development toward the next coordinated release

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) and Development issue
    Select: Milestone as the next bugfix version
    Select: METplus-X.Y Support project for support of the current coordinated release
  • 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>
    Select: Reviewer(s) and Development issue
    Select: Milestone as the next official version
    Select: MET-X.Y Development project for development toward the next coordinated release
  • Close this issue.

Metadata

Metadata

Assignees

Labels

MET: UGRIDIssues related to unstructured grid (UGRID) support in METcomponent: CI/CDContinuous integration and deployment issuesrequestor: NCARNational Center for Atmospheric Researchtype: bugFix something that is not working

Type

Fields

No fields configured for Bug.

Projects

Status
🏗 In progress
Status
🟢 Ready

Relationships

None yet

Development

No branches or pull requests

Issue actions