Skip to content

Commit 46873e6

Browse files
committed
ENH: Add test for .pyproj_crs attribute
1 parent d4037dc commit 46873e6

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

tests/test_xarray.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from collections import OrderedDict
66

77
import numpy as np
8+
import pyproj
89
import pytest
910
import xarray as xr
1011

@@ -63,11 +64,19 @@ def test_var_multidim_no_xy(test_var_multidim_full):
6364
def test_projection(test_var, ccrs):
6465
"""Test getting the proper projection out of the variable."""
6566
crs = test_var.metpy.crs
66-
assert crs['grid_mapping_name'] == 'lambert_conformal_conic'
6767

68+
assert crs['grid_mapping_name'] == 'lambert_conformal_conic'
6869
assert isinstance(test_var.metpy.cartopy_crs, ccrs.LambertConformal)
6970

7071

72+
def test_pyproj_projection(test_var):
73+
"""Test getting the proper pyproj projection out of the variable."""
74+
proj = test_var.metpy.pyproj_crs
75+
76+
assert isinstance(proj, pyproj.CRS)
77+
assert proj.coordinate_operation.method_name == 'Lambert Conic Conformal (1SP)'
78+
79+
7180
def test_no_projection(test_ds):
7281
"""Test getting the crs attribute when not available produces a sensible error."""
7382
var = test_ds.lat
@@ -1309,9 +1318,8 @@ def test_grid_deltas_from_dataarray_xy(test_da_xy):
13091318
def test_grid_deltas_from_dataarray_actual_xy(test_da_xy, ccrs):
13101319
"""Test grid_deltas_from_dataarray with a xy grid and kind='actual'."""
13111320
# Construct lon/lat coordinates
1312-
from pyproj import Proj
13131321
y, x = xr.broadcast(*test_da_xy.metpy.coordinates('y', 'x'))
1314-
lon, lat = Proj(test_da_xy.metpy.pyproj_crs)(
1322+
lon, lat = pyproj.Proj(test_da_xy.metpy.pyproj_crs)(
13151323
x.values,
13161324
y.values,
13171325
inverse=True,

0 commit comments

Comments
 (0)