Skip to content

Commit 15c9227

Browse files
aligned with S1
1 parent e406b46 commit 15c9227

2 files changed

Lines changed: 48 additions & 17 deletions

File tree

src/eopf_geozarr/conversion/geozarr.py

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import os
1919
import shutil
2020
import time
21-
from collections.abc import Hashable, Iterable, Mapping, Sequence
21+
from collections.abc import Hashable, Iterable, Mapping
2222
from typing import Any, Dict, List, Tuple
2323

2424
import numpy as np
@@ -33,6 +33,8 @@
3333

3434
from eopf_geozarr.types import (
3535
OverviewLevelJSON,
36+
StandardLatCoordAttrsJSON,
37+
StandardLonCoordAttrsJSON,
3638
StandardXCoordAttrsJSON,
3739
StandardYCoordAttrsJSON,
3840
TileMatrixJSON,
@@ -924,26 +926,21 @@ def create_overview_dataset_all_vars(
924926

925927
# Check if we're dealing with geographic coordinates (EPSG:4326)
926928
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),
938934
}
935+
939936
else:
940937
x_attrs = _get_x_coord_attrs()
941938
y_attrs = _get_y_coord_attrs()
942939

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+
}
947944

948945
# Determine standard name based on whether this is Sentinel-1 data
949946
# TODO: use a better way to determine this than just checking for ds_gcp
@@ -1535,7 +1532,27 @@ def _get_y_coord_attrs() -> StandardYCoordAttrsJSON:
15351532
}
15361533

15371534

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:
15391556
"""Find the grid_mapping variable name from the dataset."""
15401557
grid_mapping_var_name = ds.attrs.get("grid_mapping", None)
15411558
if not grid_mapping_var_name and data_vars:

src/eopf_geozarr/types.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ class StandardYCoordAttrsJSON(TypedDict):
3232
_ARRAY_DIMENSIONS: list[Literal["y"]]
3333

3434

35+
class StandardLonCoordAttrsJSON(TypedDict):
36+
units: Literal["degrees_east"]
37+
long_name: Literal["longitude"]
38+
standard_name: Literal["longitude"]
39+
_ARRAY_DIMENSIONS: list[Literal["x"]]
40+
41+
42+
class StandardLatCoordAttrsJSON(TypedDict):
43+
units: Literal["degrees_north"]
44+
long_name: Literal["latitude"]
45+
standard_name: Literal["latitude"]
46+
_ARRAY_DIMENSIONS: list[Literal["y"]]
47+
48+
3549
class OverviewLevelJSON(TypedDict):
3650
level: int
3751
zoom: int

0 commit comments

Comments
 (0)