Skip to content

Commit 810c603

Browse files
committed
Cleanup HDF5 test warnings
1 parent 74fd933 commit 810c603

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ concurrency:
55
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.type }}
66
cancel-in-progress: true
77

8-
on: [push, pull_request]
8+
on: [push, pull_request, workflow_dispatch]
99

1010
env:
1111
CACHE_NUMBER: 1

build_environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies:
3737
- requests
3838
- setuptools
3939
- six
40-
- trollimage>=1.21.0
40+
- trollimage>=1.22.2
4141
- trollsift>=0.5.0
4242
- scipy
4343
- zarr

polar2grid/utils/legacy_compat.py

+21
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424

2525
from __future__ import annotations
2626

27+
import contextlib
2728
import logging
29+
import warnings
2830
from typing import Generator, Iterable, Optional, Union
2931

3032
from satpy import DataID, DataQuery, Scene
@@ -257,3 +259,22 @@ def get_sensor_alias(satpy_sensor):
257259
if len(new_sensor) == 1:
258260
return new_sensor.pop()
259261
return new_sensor
262+
263+
264+
@contextlib.contextmanager
265+
def ignore_pyproj_proj_warnings():
266+
"""Wrap operations that we know will produce a PROJ.4 precision warning.
267+
268+
Only to be used internally to Pyresample when we have no other choice but
269+
to use PROJ.4 strings/dicts. For example, serialization to YAML or other
270+
human-readable formats or testing the methods that produce the PROJ.4
271+
versions of the CRS.
272+
273+
"""
274+
with warnings.catch_warnings():
275+
warnings.filterwarnings(
276+
"ignore",
277+
"You will likely lose important projection information",
278+
UserWarning,
279+
)
280+
yield

polar2grid/writers/hdf5.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from pyresample.geometry import SwathDefinition
5353
from satpy.writers import Writer, compute_writer_results, split_results
5454

55-
from polar2grid.utils.legacy_compat import convert_p2g_pattern_to_satpy
55+
from polar2grid.utils.legacy_compat import convert_p2g_pattern_to_satpy, ignore_pyproj_proj_warnings
5656
from polar2grid.writers.geotiff import NUMPY_DTYPE_STRS, NumpyDtypeList, str_to_dtype
5757

5858
LOG = logging.getLogger(__name__)
@@ -163,7 +163,8 @@ def create_proj_group(filename: str, parent: TextIO, area_def):
163163
group.attrs["height"], group.attrs["width"] = area_def.shape
164164
group.attrs["description"] = "No projection: native format"
165165
else:
166-
group.attrs["proj4_definition"] = area_def.proj4_string
166+
with ignore_pyproj_proj_warnings():
167+
group.attrs["proj4_definition"] = area_def.crs.to_string()
167168
for a in ["height", "width"]:
168169
ds_attr = getattr(area_def, a, None)
169170
if ds_attr is None:

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ include-package-data = true
5656
[tool.setuptools.packages]
5757
find = {}
5858

59+
[tool.pytest.ini_options]
60+
minversion = 7.0
61+
5962
[tool.coverage.run]
6063
relative_files = true
6164

0 commit comments

Comments
 (0)