|
18 | 18 | import os |
19 | 19 | import shutil |
20 | 20 | import time |
21 | | -from collections.abc import Hashable, Iterable, Mapping, Sequence |
| 21 | +from collections.abc import Hashable, Iterable, Mapping |
22 | 22 | from typing import Any, Dict, List, Tuple |
23 | 23 |
|
24 | 24 | import numpy as np |
|
33 | 33 |
|
34 | 34 | from eopf_geozarr.types import ( |
35 | 35 | OverviewLevelJSON, |
| 36 | + StandardLatCoordAttrsJSON, |
| 37 | + StandardLonCoordAttrsJSON, |
36 | 38 | StandardXCoordAttrsJSON, |
37 | 39 | StandardYCoordAttrsJSON, |
38 | 40 | TileMatrixJSON, |
@@ -924,26 +926,21 @@ def create_overview_dataset_all_vars( |
924 | 926 |
|
925 | 927 | # Check if we're dealing with geographic coordinates (EPSG:4326) |
926 | 928 | if native_crs and native_crs.to_epsg() == 4326: |
927 | | - x_attrs = { |
928 | | - "_ARRAY_DIMENSIONS": ["x"], |
929 | | - "standard_name": "longitude", |
930 | | - "units": "degrees_east", |
931 | | - "long_name": "longitude", |
932 | | - } |
933 | | - y_attrs = { |
934 | | - "_ARRAY_DIMENSIONS": ["y"], |
935 | | - "standard_name": "latitude", |
936 | | - "units": "degrees_north", |
937 | | - "long_name": "latitude", |
| 929 | + lon_attrs = _get_lon_coord_attrs() |
| 930 | + lat_attrs = _get_lat_coord_attrs() |
| 931 | + overview_coords = { |
| 932 | + "x": (["x"], x_coords, lon_attrs), |
| 933 | + "y": (["y"], y_coords, lat_attrs), |
938 | 934 | } |
| 935 | + |
939 | 936 | else: |
940 | 937 | x_attrs = _get_x_coord_attrs() |
941 | 938 | y_attrs = _get_y_coord_attrs() |
942 | 939 |
|
943 | | - overview_coords = { |
944 | | - "x": (["x"], x_coords, x_attrs), |
945 | | - "y": (["y"], y_coords, y_attrs), |
946 | | - } |
| 940 | + overview_coords = { |
| 941 | + "x": (["x"], x_coords, x_attrs), |
| 942 | + "y": (["y"], y_coords, y_attrs), |
| 943 | + } |
947 | 944 |
|
948 | 945 | # Determine standard name based on whether this is Sentinel-1 data |
949 | 946 | # TODO: use a better way to determine this than just checking for ds_gcp |
@@ -1535,7 +1532,27 @@ def _get_y_coord_attrs() -> StandardYCoordAttrsJSON: |
1535 | 1532 | } |
1536 | 1533 |
|
1537 | 1534 |
|
1538 | | -def _find_grid_mapping_var_name(ds: xr.Dataset, data_vars: Sequence[str]) -> str: |
| 1535 | +def _get_lon_coord_attrs() -> StandardLonCoordAttrsJSON: |
| 1536 | + """Get standard attributes for longitude coordinate.""" |
| 1537 | + return { |
| 1538 | + "units": "degrees_east", |
| 1539 | + "long_name": "longitude", |
| 1540 | + "standard_name": "longitude", |
| 1541 | + "_ARRAY_DIMENSIONS": ["x"], |
| 1542 | + } |
| 1543 | + |
| 1544 | + |
| 1545 | +def _get_lat_coord_attrs() -> StandardLatCoordAttrsJSON: |
| 1546 | + """Get standard attributes for latitude coordinate.""" |
| 1547 | + return { |
| 1548 | + "units": "degrees_north", |
| 1549 | + "long_name": "latitude", |
| 1550 | + "standard_name": "latitude", |
| 1551 | + "_ARRAY_DIMENSIONS": ["y"], |
| 1552 | + } |
| 1553 | + |
| 1554 | + |
| 1555 | +def _find_grid_mapping_var_name(ds: xr.Dataset, data_vars: list[Hashable]) -> str: |
1539 | 1556 | """Find the grid_mapping variable name from the dataset.""" |
1540 | 1557 | grid_mapping_var_name = ds.attrs.get("grid_mapping", None) |
1541 | 1558 | if not grid_mapping_var_name and data_vars: |
|
0 commit comments