diff --git a/src/plotting/postprocessing_plotting.py b/src/plotting/postprocessing_plotting.py index 3338ce4c0d6f14aa8c0173779329a2fd81f0f57e..f469131343bc1ba4bcf5e86c1d98b95752afb275 100644 --- a/src/plotting/postprocessing_plotting.py +++ b/src/plotting/postprocessing_plotting.py @@ -7,8 +7,7 @@ import os import warnings from typing import Dict, List, Tuple -import cartopy.crs as ccrs -import cartopy.feature as cfeature + import matplotlib import matplotlib.pyplot as plt import numpy as np @@ -126,6 +125,9 @@ class PlotStationMap(RunEnvironment): background, but this can be adjusted by loading locally stored topography data (not implemented yet). The plot is saved under plot_path with the name station_map.pdf """ + import cartopy.crs as ccrs + import cartopy.feature as cfeature + def __init__(self, generators: Dict, plot_folder: str = "."): """ Sets attributes and create plot @@ -141,11 +143,11 @@ class PlotStationMap(RunEnvironment): """ Draw coastline, lakes, ocean, rivers and country borders as background on the map. """ - self._ax.add_feature(cfeature.COASTLINE.with_scale("50m"), edgecolor='black') - self._ax.add_feature(cfeature.LAKES.with_scale("50m")) - self._ax.add_feature(cfeature.OCEAN.with_scale("50m")) - self._ax.add_feature(cfeature.RIVERS.with_scale("50m")) - self._ax.add_feature(cfeature.BORDERS.with_scale("50m"), facecolor='none', edgecolor='black') + self._ax.add_feature(self.cfeature.COASTLINE.with_scale("50m"), edgecolor='black') + self._ax.add_feature(self.cfeature.LAKES.with_scale("50m")) + self._ax.add_feature(self.cfeature.OCEAN.with_scale("50m")) + self._ax.add_feature(self.cfeature.RIVERS.with_scale("50m")) + self._ax.add_feature(self.cfeature.BORDERS.with_scale("50m"), facecolor='none', edgecolor='black') def _plot_stations(self, generators): """ @@ -161,7 +163,7 @@ class PlotStationMap(RunEnvironment): # station_names = gen.get_data_generator(k).meta.loc[['station_id']] IDx, IDy = float(station_coords.loc['station_lon'].values), float( station_coords.loc['station_lat'].values) - self._ax.plot(IDx, IDy, mfc=color, mec='k', marker='s', markersize=6, transform=ccrs.PlateCarree()) + self._ax.plot(IDx, IDy, mfc=color, mec='k', marker='s', markersize=6, transform=self.ccrs.PlateCarree()) def _plot(self, generators: Dict, plot_folder: str): """ @@ -171,8 +173,8 @@ class PlotStationMap(RunEnvironment): :param plot_folder: path to save the plot """ fig = plt.figure(figsize=(10, 5)) - self._ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree()) - self._ax.set_extent([0, 20, 42, 58], crs=ccrs.PlateCarree()) + self._ax = fig.add_subplot(1, 1, 1, projection=self.ccrs.PlateCarree()) + self._ax.set_extent([0, 20, 42, 58], crs=self.ccrs.PlateCarree()) self._draw_background() self._plot_stations(generators) self._save(plot_folder)