From eff0f41d96c9f10c5a145543632d9844b304337b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20R=C3=B6sner?= Date: Thu, 25 Jul 2024 13:50:40 +0200 Subject: [PATCH 1/6] fix: SwathDefinition error when lons/lats 1D --- pyresample/_formatting_html.py | 37 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/pyresample/_formatting_html.py b/pyresample/_formatting_html.py index d1a087fe..bbf6f3ed 100644 --- a/pyresample/_formatting_html.py +++ b/pyresample/_formatting_html.py @@ -244,25 +244,30 @@ def swath_area_attrs_section(area: 'geom.SwathDefinition') -> str: # noqa F821 - Improve resolution estimation from lat/lon arrays. Maybe use CoordinateDefinition.geocentric_resolution? """ - if isinstance(area.lons, np.ndarray) & isinstance(area.lats, np.ndarray): - # Calculate and estimated resolution from lats/lons in meter - area_name = "Arbitrary Swath" - resolution_y = np.mean(area.lats[0:-1, :] - area.lats[1::, :]) - resolution_x = np.mean(area.lons[:, 1::] - area.lons[:, 0:-1]) - resolution = np.mean(np.array([resolution_x, resolution_y])) - resolution = np.round(40075000 * resolution / 360, 1) - resolution_str = f"{resolution}/{resolution}" - area_units = "m" + if np.ndim(area.lons) == 1: + area_name = "1D Swath" + resolution_str = "{resolution}/{resolution}".format(resolution="Na") + height, width = "Na", "Na" + area_units = "Na" else: - lon_attrs = area.lons.attrs - lat_attrs = area.lats.attrs + if isinstance(area.lons, np.ndarray) & isinstance(area.lats, np.ndarray): + # Calculate and estimated resolution from lats/lons in meter + area_name = "Arbitrary Swath" + resolution_y = np.mean(area.lats[0:-1, :] - area.lats[1::, :]) + resolution_x = np.mean(area.lons[:, 1::] - area.lons[:, 0:-1]) + resolution = np.mean(np.array([resolution_x, resolution_y])) + resolution = np.round(40075000 * resolution / 360, 1) + resolution_str = f"{resolution}/{resolution}" + else: + lon_attrs = area.lons.attrs + lat_attrs = area.lats.attrs + + # use resolution from lat/lons dataarray attributes -> are these always set? -> Maybe try/except? + area_name = f"{lon_attrs.get('sensor')} Swath" + resolution_str = "/".join([str(round(x.get("resolution"), 1)) for x in [lat_attrs, lon_attrs]]) - # use resolution from lat/lons dataarray attributes -> are these always set? -> Maybe try/except? - area_name = f"{lon_attrs.get('sensor')} swath" - resolution_str = "/".join([str(round(x.get("resolution"), 1)) for x in [lat_attrs, lon_attrs]]) area_units = "m" - - height, width = area.lons.shape + height, width = area.lons.shape attrs_icon = _icon("icon-file-text2") From 92fb36da8a9c40d88c2475e6005f0cc77ec461d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20R=C3=B6sner?= Date: Thu, 25 Jul 2024 13:51:06 +0200 Subject: [PATCH 2/6] fix: formatting of attributes --- pyresample/static/css/style.css | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/pyresample/static/css/style.css b/pyresample/static/css/style.css index a84a491c..39723b0d 100644 --- a/pyresample/static/css/style.css +++ b/pyresample/static/css/style.css @@ -90,19 +90,6 @@ body.vscode-dark { margin-right: 0.5em; } -/* und noch der Doppelpunkt */ -.pyresample-area-section-details dt:after { - content: ": "; -} - -/* ein Clearfix für Folge-dd-Elemente */ -.pyresample-area-section-details dd:after { - clear: left; - content: " "; - display: block; -} -/* end attribute list formatting */ - .pyresample-area-sections { display: grid; grid-template-columns: auto; From fd030a2ee03f3909649a5e93a7647d0d9341c728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20R=C3=B6sner?= Date: Thu, 25 Jul 2024 14:05:20 +0200 Subject: [PATCH 3/6] fix: wrapping of properties section --- pyresample/static/css/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyresample/static/css/style.css b/pyresample/static/css/style.css index 39723b0d..8cfef56b 100644 --- a/pyresample/static/css/style.css +++ b/pyresample/static/css/style.css @@ -29,7 +29,7 @@ body.vscode-dark { .pyresample-wrap { display: block !important; min-width: 700px; - max-width: 900px; + max-width: 1050px; } .pyresample-text-repr-fallback { From d53bb2f5ecd933855993cd4abe63aae8e06ea8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20R=C3=B6sner?= Date: Thu, 25 Jul 2024 14:06:16 +0200 Subject: [PATCH 4/6] refactor: resolution units --- pyresample/_formatting_html.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyresample/_formatting_html.py b/pyresample/_formatting_html.py index bbf6f3ed..f62b41a9 100644 --- a/pyresample/_formatting_html.py +++ b/pyresample/_formatting_html.py @@ -248,7 +248,7 @@ def swath_area_attrs_section(area: 'geom.SwathDefinition') -> str: # noqa F821 area_name = "1D Swath" resolution_str = "{resolution}/{resolution}".format(resolution="Na") height, width = "Na", "Na" - area_units = "Na" + area_units = "m" else: if isinstance(area.lons, np.ndarray) & isinstance(area.lats, np.ndarray): # Calculate and estimated resolution from lats/lons in meter From 9a19209c217731933aed3cf6472a1026ee8ed3b9 Mon Sep 17 00:00:00 2001 From: BENR0 Date: Fri, 26 Jul 2024 10:08:50 +0200 Subject: [PATCH 5/6] refactor: resolution string --- pyresample/_formatting_html.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pyresample/_formatting_html.py b/pyresample/_formatting_html.py index f62b41a9..bed6aecb 100644 --- a/pyresample/_formatting_html.py +++ b/pyresample/_formatting_html.py @@ -246,25 +246,25 @@ def swath_area_attrs_section(area: 'geom.SwathDefinition') -> str: # noqa F821 """ if np.ndim(area.lons) == 1: area_name = "1D Swath" - resolution_str = "{resolution}/{resolution}".format(resolution="Na") - height, width = "Na", "Na" + resolution_str = "NA/NA" + height, width = "NA", "NA" area_units = "m" else: - if isinstance(area.lons, np.ndarray) & isinstance(area.lats, np.ndarray): + if isinstance(area.lons, np.ndarray) and isinstance(area.lats, np.ndarray): # Calculate and estimated resolution from lats/lons in meter area_name = "Arbitrary Swath" resolution_y = np.mean(area.lats[0:-1, :] - area.lats[1::, :]) resolution_x = np.mean(area.lons[:, 1::] - area.lons[:, 0:-1]) resolution = np.mean(np.array([resolution_x, resolution_y])) resolution = np.round(40075000 * resolution / 360, 1) - resolution_str = f"{resolution}/{resolution}" + resolution_str = f"{resolution}x{resolution}" else: lon_attrs = area.lons.attrs lat_attrs = area.lats.attrs # use resolution from lat/lons dataarray attributes -> are these always set? -> Maybe try/except? area_name = f"{lon_attrs.get('sensor')} Swath" - resolution_str = "/".join([str(round(x.get("resolution"), 1)) for x in [lat_attrs, lon_attrs]]) + resolution_str = "x".join([str(round(x.get("resolution"), 1)) for x in [lat_attrs, lon_attrs]]) area_units = "m" height, width = area.lons.shape @@ -275,7 +275,7 @@ def swath_area_attrs_section(area: 'geom.SwathDefinition') -> str: # noqa F821 # f"
Area name
{area_name}
" f"
Description
{area_name}
" f"
Width/Height
{width}/{height} Pixel
" - f"
Resolution x/y (SSP)
{resolution_str} {area_units}
" + f"
Resolution XxY (SSP)
{resolution_str} {area_units}
" "" ) From 9c07da9b239b60c2df536c4fe9f7c207340977e7 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Sat, 27 Jul 2024 09:03:29 -0500 Subject: [PATCH 6/6] Update pyresample/_formatting_html.py --- pyresample/_formatting_html.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyresample/_formatting_html.py b/pyresample/_formatting_html.py index bed6aecb..3a131359 100644 --- a/pyresample/_formatting_html.py +++ b/pyresample/_formatting_html.py @@ -246,7 +246,7 @@ def swath_area_attrs_section(area: 'geom.SwathDefinition') -> str: # noqa F821 """ if np.ndim(area.lons) == 1: area_name = "1D Swath" - resolution_str = "NA/NA" + resolution_str = "NAxNA" height, width = "NA", "NA" area_units = "m" else: