Skip to content
Snippets Groups Projects
Commit e532578e authored by lukas leufen's avatar lukas leufen
Browse files

post processing can plot station_map(), but countries are not filled with e.g....

post processing can plot station_map(), but countries are not filled with e.g. elevation data (just blank fill)
parent 4cd8fe3c
Branches
Tags
2 merge requests!37include new development,!27Lukas issue032 feat plotting postprocessing
Pipeline #28079 passed
......@@ -6,4 +6,10 @@ This is a collection of all relevant functions used for ML stuff in the ESDE gro
See a description [here](https://towardsdatascience.com/a-simple-guide-to-the-versions-of-the-inception-network-7fc52b863202)
or take a look on the papers [Going Deeper with Convolutions (Szegedy et al., 2014)](https://arxiv.org/abs/1409.4842)
and [Network In Network (Lin et al., 2014)](https://arxiv.org/abs/1312.4400).
\ No newline at end of file
and [Network In Network (Lin et al., 2014)](https://arxiv.org/abs/1312.4400).
# Installation
* Install __proj__ on your machine using the console. E.g. for opensuse / leap `zypper install proj`
* c++ compiler required for cartopy installation
\ No newline at end of file
......@@ -14,4 +14,12 @@ statsmodels
seaborn
dask==0.20.2
toolz # for dask
cloudpickle # for dask
\ No newline at end of file
cloudpickle # for dask
cython
pyshp
six
pyproj
shapely
cartopy==0.16.0
matplotlib
pillow
\ No newline at end of file
......@@ -8,10 +8,9 @@ import xarray as xr
import matplotlib
import seaborn as sns
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import dask.array as da
import dask
import dask.dataframe as ddf
logging.getLogger('matplotlib').setLevel(logging.WARNING)
......@@ -53,3 +52,30 @@ def plot_monthly_summary(stations, data_path, name: str, window_lead_time, targe
plt.close('all')
def plot_climsum_boxplot():
return
def station_map(generators, plot_folder="."):
logging.debug("run station_map()")
fig = plt.figure(figsize=(10, 5))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
ax.set_extent([0, 20, 42, 58], crs=ccrs.PlateCarree())
ax.add_feature(cfeature.COASTLINE.with_scale("10m"), edgecolor='black')
ax.add_feature(cfeature.LAKES.with_scale("50m"))
ax.add_feature(cfeature.OCEAN.with_scale("50m"))
ax.add_feature(cfeature.RIVERS.with_scale("10m"))
ax.add_feature(cfeature.BORDERS.with_scale("10m"), facecolor='none', edgecolor='black')
if generators is not None:
for color, gen in generators.items():
for k, v in enumerate(gen):
station_coords = gen.get_data_generator(k).meta.loc[['station_lon', 'station_lat']]
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)
ax.plot(IDx, IDy, mfc=color, mec='k', marker='s', markersize=6, transform=ccrs.PlateCarree())
plot_path = os.path.join(os.path.abspath(plot_folder), 'test_map_plot.pdf')
plt.savefig(plot_path)
plt.close('all')
......@@ -17,7 +17,7 @@ from src.model_modules.linear_model import OrdinaryLeastSquaredModel
from src import statistics
from src import helpers
from src.helpers import TimeTracking
from src.plotting.postprocessing_plotting import plot_monthly_summary
from src.plotting.postprocessing_plotting import plot_monthly_summary, plot_climsum_boxplot, station_map
class PostProcessing(RunEnvironment):
......@@ -39,11 +39,14 @@ class PostProcessing(RunEnvironment):
self.plot()
def plot(self):
logging.debug("Run plotting routines...")
path = self.data_store.get("forecast_path", "general")
window_lead_time = self.data_store.get("window_lead_time", "general")
target_var = self.data_store.get("target_var", "general")
station_map(generators={'b': self.test_data}, plot_folder=self.plot_path)
plot_monthly_summary(self.test_data.stations, path, r"forecasts_%s_test.nc", window_lead_time, target_var,
plot_folder=self.plot_path)
# plot_climsum_boxplot()
def calculate_test_score(self):
test_score = self.model.evaluate(generator=self.test_data_distributed.distribute_on_batches(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment