Skip to content

Commit a35ba2c

Browse files
committed
fix envs
1 parent b33698a commit a35ba2c

File tree

4 files changed

+39
-32
lines changed

4 files changed

+39
-32
lines changed

cf_xarray/datasets.py

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22
import xarray as xr
3-
from pyproj import CRS
43

54
airds = xr.tutorial.open_dataset("air_temperature").isel(time=slice(4), lon=slice(50))
65
airds.air.attrs["cell_measures"] = "area: cell_area"
@@ -751,37 +750,42 @@ def _create_inexact_bounds():
751750
)
752751

753752

754-
hrrrds = xr.Dataset()
755-
hrrrds["foo"] = (
756-
("x", "y"),
757-
np.arange(200).reshape((10, 20)),
758-
{
759-
"grid_mapping": "spatial_ref: crs_4326: latitude longitude crs_27700: x27700 y27700"
760-
},
761-
)
762-
hrrrds.coords["spatial_ref"] = ((), 0, CRS.from_epsg(3035).to_cf())
763-
hrrrds.coords["crs_4326"] = ((), 0, CRS.from_epsg(4326).to_cf())
764-
hrrrds.coords["crs_27700"] = ((), 0, CRS.from_epsg(27700).to_cf())
765-
hrrrds.coords["latitude"] = (
766-
("x", "y"),
767-
np.ones((10, 20)),
768-
{"standard_name": "latitude"},
769-
)
770-
hrrrds.coords["longitude"] = (
771-
("x", "y"),
772-
np.zeros((10, 20)),
773-
{"standard_name": "longitude"},
774-
)
775-
hrrrds.coords["y27700"] = (
776-
("x", "y"),
777-
np.ones((10, 20)),
778-
{"standard_name": "projected_x_coordinate"},
779-
)
780-
hrrrds.coords["x27700"] = (
781-
("x", "y"),
782-
np.zeros((10, 20)),
783-
{"standard_name": "projected_y_coordinate"},
784-
)
753+
try:
754+
from pyproj import CRS
755+
756+
hrrrds = xr.Dataset()
757+
hrrrds["foo"] = (
758+
("x", "y"),
759+
np.arange(200).reshape((10, 20)),
760+
{
761+
"grid_mapping": "spatial_ref: crs_4326: latitude longitude crs_27700: x27700 y27700"
762+
},
763+
)
764+
hrrrds.coords["spatial_ref"] = ((), 0, CRS.from_epsg(3035).to_cf())
765+
hrrrds.coords["crs_4326"] = ((), 0, CRS.from_epsg(4326).to_cf())
766+
hrrrds.coords["crs_27700"] = ((), 0, CRS.from_epsg(27700).to_cf())
767+
hrrrds.coords["latitude"] = (
768+
("x", "y"),
769+
np.ones((10, 20)),
770+
{"standard_name": "latitude"},
771+
)
772+
hrrrds.coords["longitude"] = (
773+
("x", "y"),
774+
np.zeros((10, 20)),
775+
{"standard_name": "longitude"},
776+
)
777+
hrrrds.coords["y27700"] = (
778+
("x", "y"),
779+
np.ones((10, 20)),
780+
{"standard_name": "projected_x_coordinate"},
781+
)
782+
hrrrds.coords["x27700"] = (
783+
("x", "y"),
784+
np.zeros((10, 20)),
785+
{"standard_name": "projected_y_coordinate"},
786+
)
787+
except ImportError:
788+
pass
785789

786790

787791
def point_dataset():

ci/environment-all-min-deps.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ dependencies:
2020
- shapely
2121
- xarray==2023.09.0
2222
- pip
23+
- pyproj
2324
- pip:
2425
- pytest-pretty

ci/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies:
1919
- scipy
2020
- shapely
2121
- xarray
22+
- pyproj
2223
- pip
2324
- pip:
2425
- pytest-pretty

ci/upstream-dev-env.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies:
1313
- pooch
1414
- rich
1515
- shapely
16+
- pyproj
1617
- pip
1718
- pip:
1819
- pytest-pretty

0 commit comments

Comments
 (0)