Skip to content

Commit

Permalink
Add grib to geotiff test
Browse files Browse the repository at this point in the history
  • Loading branch information
sandorkertesz committed Feb 21, 2025
1 parent 5f591e9 commit adfbe31
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/earthkit/data/encoders/geotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


class GeoTIFFEncodedData(EncodedData):

_GDAL_DRIVER = "GTiff"

def __init__(self, ds):
Expand All @@ -42,7 +41,6 @@ def metadata(self, key):


class GeoTIFFEncoder(Encoder):

def __init__(self, **kwargs):
super().__init__(**kwargs)

Expand Down
17 changes: 17 additions & 0 deletions tests/targets/test_target_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,23 @@ def test_target_file_grib_to_netcdf():
# assert np.allclose(ds1.values[:, :4], vals_ref)


@pytest.mark.skipif(NO_RIOXARRAY, reason="rioxarray not available")
@pytest.mark.with_proj
def test_target_file_grib_to_geotiff():
ds = from_source("file", earthkit_examples_file("test.grib"))
vals_ref = ds.values[:, :4]

with temp_file() as path:
ds.to_target("file", path, encoder="geotiff")

ds1 = from_source("file", path)
assert len(ds1) == len(ds)
from earthkit.data.readers.geotiff import GeoTIFFField

assert isinstance(ds1[0], GeoTIFFField)
assert np.allclose(ds1.values[:, :4], vals_ref)


@pytest.mark.skipif(NO_RIOXARRAY, reason="rioxarray not available")
@pytest.mark.with_proj
def test_target_file_geotiff():
Expand Down

0 comments on commit adfbe31

Please sign in to comment.