|
1 | 1 | import numpy as np
|
2 | 2 | import xarray as xr
|
3 |
| -from pyproj import CRS |
4 | 3 |
|
5 | 4 | airds = xr.tutorial.open_dataset("air_temperature").isel(time=slice(4), lon=slice(50))
|
6 | 5 | airds.air.attrs["cell_measures"] = "area: cell_area"
|
@@ -751,37 +750,42 @@ def _create_inexact_bounds():
|
751 | 750 | )
|
752 | 751 |
|
753 | 752 |
|
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 |
785 | 789 |
|
786 | 790 |
|
787 | 791 | def point_dataset():
|
|
0 commit comments