Skip to content

FIX: Require plausible dtype for coordinate regex fallback - #4174

Open
thaliamontreux wants to merge 1 commit into
Unidata:mainfrom
thaliamontreux:fix-coord-regex-dtype
Open

thaliamontreux wants to merge 1 commit into
Unidata:mainfrom
thaliamontreux:fix-coord-regex-dtype

Conversation

@thaliamontreux

Copy link
Copy Markdown
Contributor

Description

Fixes #3860, following the direction suggested by the reporter. The non-CF name-based regex fallback in check_axis matched any variable whose name fit, so a string-valued auxiliary coordinate like longseason=('isobaric', ['DJF', 'MAM']) was misidentified as a longitude candidate and .metpy.longitude access failed.

Now the regex fallback only applies when the variable's dtype is plausible for a coordinate: numeric for spatial/vertical axes, or numeric/datetimelike for time. CF-standard attributes and unit checks are unaffected and still take precedence.

Checklist

@thaliamontreux
thaliamontreux requested a review from a team as a code owner October 20, 2026 09:29
@thaliamontreux
thaliamontreux requested review from dcamron and removed request for a team October 20, 2026 09:29
The non-CF name-based fallback in check_axis matched any variable whose
name fit the coordinate regexes, so a string-valued auxiliary coordinate
like 'longseason' was misidentified as a longitude candidate and made
da.metpy.longitude fail (Unidata#3860).

Now only apply the regex fallback when the variable has a plausible
dtype: numeric for spatial/vertical axes, or numeric/datetimelike for
time.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coordinate identification for 2d latitude/longitude fails in presence of similarly named auxilliary variables

1 participant