Skip to content

Commit

Permalink
Cleanup HTML repr proj warnings and extent floats
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Jul 30, 2024
1 parent f31cc52 commit 9bf142c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pyresample/_formatting_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import numpy as np

import pyresample.geometry as geom
from pyresample.utils.proj4 import ignore_pyproj_proj_warnings

try:
import cartopy
Expand Down Expand Up @@ -193,7 +194,8 @@ def proj_area_attrs_section(area: 'geom.AreaDefinition') -> str: # noqa F821
"""
resolution_str = "/".join([str(round(x, 1)) for x in area.resolution])
proj_dict = area.proj_dict
with ignore_pyproj_proj_warnings():
proj_dict = area.proj_dict
proj_str = "{{{}}}".format(", ".join(["'%s': '%s'" % (str(k), str(proj_dict[k])) for k in
sorted(proj_dict.keys())]))
area_units = proj_dict.get("units", "")
Expand All @@ -207,7 +209,7 @@ def proj_area_attrs_section(area: 'geom.AreaDefinition') -> str: # noqa F821
f"<dt>Width/Height</dt><dd>{area.width}/{area.height} Pixel</dd>"
f"<dt>Resolution x/y (SSP)</dt><dd>{resolution_str} {area_units}</dd>"
f"<dt>Extent (ll_x, ll_y, ur_x, ur_y)</dt>"
f"<dd>{tuple(round(x, 4) for x in area.area_extent)}</dd>"
f"<dd>{tuple(round(float(x), 4) for x in area.area_extent)}</dd>"
"</dl>"
)

Expand Down Expand Up @@ -299,14 +301,15 @@ def swath_area_attrs_section(area: 'geom.SwathDefinition') -> str: # noqa F821
return f"{coll}"


def area_repr(area: Union['geom.AreaDefinition', 'geom.SwathDefinition'], include_header: Optional[bool] = True, # noqa F821
include_static_files: Optional[bool] = True):
def area_repr(area: Union['geom.AreaDefinition', 'geom.SwathDefinition'],
include_header: bool = True,
include_static_files: bool = True):
"""Return html repr of an AreaDefinition.
Args:
area : Area definition.
include_header : If true a header with object type will be included in
the html. This is mainly intented for display in Jupyter Notebooks. For the
the html. This is mainly intended for display in Jupyter Notebooks. For the
display in the overview of area definitions for the Satpy documentation this
should be set to false.
include_static_files : Load and include css and html needed for representation.
Expand Down

0 comments on commit 9bf142c

Please sign in to comment.