Skip to content

Comments

Fix latlon_to_xy longitude scaling bug and update scaling tests (Fixes #2614)#2700

Open
muien5080 wants to merge 1 commit intopvlib:mainfrom
muien5080:fix-latlon-to-xy-scaling
Open

Fix latlon_to_xy longitude scaling bug and update scaling tests (Fixes #2614)#2700
muien5080 wants to merge 1 commit intopvlib:mainfrom
muien5080:fix-latlon-to-xy-scaling

Conversation

@muien5080
Copy link

@muien5080 muien5080 commented Feb 24, 2026

Fixes incorrect longitude scaling in latlon_to_xy where the NumPy array construction previously misapplied scaling factors, causing longitude to be multiplied by the latitude conversion factor.

This PR also updates the affected tests to reflect correct geodetic scaling.
Fixes #2614

Details
The previous implementation constructed the scaling vector incorrectly, which resulted in both latitude and longitude being scaled using the meters-per-degree latitude value.

This PR:
Corrects the scaling vector construction:
np.array([m_per_deg_lat, m_per_deg_lon])
Ensures longitude scaling properly depends on mean latitude.
Updates expected coordinate values in test_scaling.py.
Updates expected variability reduction (VR) values affected by corrected geometry.

Validation:
All test_scaling.py tests pass.
Full test suite passes locally:
1415 passed
111 skipped
2 xfailed
No new warnings introduced.

Notes:
latlon_to_xy is primarily a utility function for WVM-related workflows and is not used internally within pvlib, but correcting the geodetic scaling ensures accurate spatial modeling for users relying on this functionality.

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.

scaling.py Numpy function arg bug

1 participant