Skip to content

Commit

Permalink
modify compression methods
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienWehrle committed Dec 12, 2024
1 parent 3f242d8 commit b6bc469
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions earthspy/earthspy.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,21 +203,18 @@ def get_raster_compression(self, raster_compression: Union[None, str]) -> str:
:rtype: Union[None, str]
"""

if raster_compression in [
"DEFLATE",
"LZW",
"PACKBITS",
"JPEG",
"WEBP",
"LZMA",
"ZSTD",
]:
# list rasterio compression algorithm and exclude dunders
rasterio_compression_algorithms = [
m for m in dir(rasterio.enums.Compression) if not m.startswith("__")
]

# use rasterio compression method as is
if raster_compression.lower() in rasterio_compression_algorithms:
self.raster_compression = raster_compression
elif raster_compression is None:
self.raster_compression = None
else:
raise KeyError("Compression mode not found")
raise KeyError("Compression algorithm not found")

return self.raster_compression

Expand Down

0 comments on commit b6bc469

Please sign in to comment.