From 3a551012d15f1aee2f3ccf08a637aca511979282 Mon Sep 17 00:00:00 2001 From: Gratien Date: Mon, 16 Dec 2024 16:47:20 +0100 Subject: [PATCH] Remove raster.py --- pyproject.toml | 5 ---- src/meteole/raster.py | 66 ------------------------------------------- 2 files changed, 71 deletions(-) delete mode 100644 src/meteole/raster.py diff --git a/pyproject.toml b/pyproject.toml index 54526d4..a1d4542 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,14 +24,9 @@ dependencies = [ "pandas>=2.0.0", "ecmwflibs>=0.6.3", "cfgrib>=0.0.11.0", - "numpy>=1.26.4", - "rasterio>=1.3.10", "requests>=2.31.0", - "tqdm>=4.66.4", "xarray>=2024.5.0", "xmltodict>=0.13.0", - "cartopy>=0.23.0", - "matplotlib>=3.8.4", ] [project.optional-dependencies] diff --git a/src/meteole/raster.py b/src/meteole/raster.py deleted file mode 100644 index 2111e94..0000000 --- a/src/meteole/raster.py +++ /dev/null @@ -1,66 +0,0 @@ -"""Functionnalities to deal with the raster data""" - -import cartopy.crs as ccrs -import matplotlib.pyplot as plt -import rasterio -from cartopy import feature - - -def open_tiff_file(filename): - """Ope, a tiff file.""" - with rasterio.open(filename) as source: - field = source.read(1, masked=True) - transform = source.transform - return field, transform - - -def plot_tiff_file( - filename, - data_type: str, - unit: str, - title: str | None = None, -): - """ - Plot a tiff file. - - Parameters - ---------- - filename : file - filename from a get coverage - data_type: str - datatype of the coverage : temperature,wind,humidity ... - unit: str - Unit of the coverage (°C, Kmh) - title: str, optional - Plot title - - .. note:: - This Function is more an "How-To" rather than a tool to use as is. - - """ - data_field, transform = open_tiff_file(filename=filename) - fig = plt.figure(figsize=(10, 10)) - ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree()) - im = ax.imshow( - data_field, - cmap="jet", - extent=[ - transform[2], - transform[2] + transform[0] * data_field.shape[1], - transform[5] + transform[4] * data_field.shape[0], - transform[5], - ], - ) - ax.add_feature(feature.BORDERS.with_scale("10m"), color="black", linewidth=1) - ax.add_feature(feature.COASTLINE.with_scale("10m"), color="black", linewidth=1) - cbar = plt.colorbar(im, ax=ax, shrink=0.5) - height = filename.stem.split("_")[0] - computed_at = filename.parent.stem.split("_")[-1] - - cbar.set_label(f"{data_type}_{unit}") - - if title is None: - ax.set_title(f"{data_type} at {height} above ground \n computed at {computed_at} ") - else: - ax.set_title(f"{title}_{computed_at}") - return ax