From e089768588cf72e3bad513af722a9c40b64476dc Mon Sep 17 00:00:00 2001
From: Carsten Hinz <c.hinz@fz-juelich.de>
Date: Fri, 26 Apr 2024 10:32:43 +0200
Subject: [PATCH] tests/quality_controll.ipynb - fixed bug in plotting of
 station positions

README.md
- started rework of documentation of examples

.gitignore added directory used for examples
---
 .gitignore                   |  1 +
 README.md                    | 12 +++++++++---
 tests/quality_controll.ipynb | 23 ++++++++++++-----------
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/.gitignore b/.gitignore
index db28b72..8922727 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@ tests/cache/
 */.ipynb_checkpoints/
 tests/data/
 data/
+tests/results
diff --git a/README.md b/README.md
index e5e61cc..ed29bbc 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ TOAR Gridding Tool
 # About 
 
 The TOARgridding projects data from the TOAD database (https://toar-data.fz-juelich.de/) onto a grid. 
-The stations within one cell of the grid are averaged. 
+The mean and standard deviation of all stations within a cell are computed. 
 
 The tool handels the request to the database over the REST API and the subsequent processing.
 The results are provided as xarray objects for subsequent processing by the user.
@@ -33,8 +33,14 @@ poetry install
 # Example
 
 There are at the moment three example provided as jupyter notebooks:
-tests/procude_data.ipynb provides an example on how the high level interface can be used.
+##  High level function
+```
+tests/procude_data.ipynb 
+```
+Provides an example on how to download data and save them as netCDF files.
+## Retrieving data
 get_sample_data.ipynb downloads already sampled data from the TOAR database. 
+## Retriving data and visualization
 quality_controll.ipynb processes the data of obtained with get_sample_data.ipynb. 
 
 # Supported Grids
@@ -43,6 +49,6 @@ The first supported grid is the Cartesian grid.
 
 # Supported Variables
 
-at the moment only a limited number of variables from the TOAR database is supported. 
+At the moment only a limited number of variables from the TOAR database is supported. 
 
 
diff --git a/tests/quality_controll.ipynb b/tests/quality_controll.ipynb
index 31c65a7..885d098 100644
--- a/tests/quality_controll.ipynb
+++ b/tests/quality_controll.ipynb
@@ -40,11 +40,7 @@
     "my_grid = RegularGrid(1.9, 2.5)\n",
     "\n",
     "time = TimeSample(dt(2016,1,1), dt(2016,12,31), \"daily\")\n",
-    "metadata = Metadata.construct(\"mole_fraction_of_ozone_in_air\", \"mean\", time)\n",
-    "\n",
-    "#not used in this notebook\n",
-    "#with open(\"data/daily_2010-01-01_2011-01-01.zip\", \"r+b\") as sample_file:\n",
-    "#    response_content = sample_file.read()"
+    "metadata = Metadata.construct(\"mole_fraction_of_ozone_in_air\", \"mean\", time)\n"
    ]
   },
   {
@@ -72,6 +68,7 @@
    "outputs": [],
    "source": [
     "#calculation of coordinates for plotting\n",
+    "#especially separation of coordinates with results and without results.\n",
     "\n",
     "import cartopy.crs as ccrs\n",
     "import matplotlib.pyplot as plt\n",
@@ -93,7 +90,7 @@
    "source": [
     "import matplotlib as mpl\n",
     "\n",
-    "#definition of plot function\n",
+    "#definition of plotting function\n",
     "\n",
     "def plot_cells(data, stations, na_stations, discrete=True, plot_stations=False):\n",
     "    fig = plt.figure(figsize=(9, 18))\n",
@@ -150,12 +147,12 @@
     "    \n",
     "\n",
     "    if plot_stations:\n",
-    "        plt.scatter(na_stations[STATION_LON], na_stations[STATION_LAT], s=1, c=\"k\")\n",
-    "        plt.scatter(stations[STATION_LON], stations[STATION_LAT], s=1, c=\"r\")\n",
+    "        plt.scatter(na_stations[\"longitude\"], na_stations[\"latitude\"], s=1, c=\"k\")\n",
+    "        plt.scatter(stations[\"longitude\"], stations[\"latitude\"], s=1, c=\"r\")\n",
     "\n",
     "    plt.tight_layout()\n",
     "\n",
-    "    plt.title(f\"global ozon at {data.time.values}\")"
+    "    plt.title(f\"global ozon at {data.time.values} {data.time.units}\")"
    ]
   },
   {
@@ -164,11 +161,13 @@
    "metadata": {},
    "outputs": [],
    "source": [
+    "#example visualization for two timepoints\n",
+    "print(not_na_coords)\n",
     "timestep = 2\n",
     "time = ds.time[timestep]\n",
     "data = ds.sel(time=time)\n",
     "\n",
-    "plot_cells(data[\"mean\"], not_na_coords, all_na_coords, discrete=False)\n",
+    "plot_cells(data[\"mean\"], not_na_coords, all_na_coords, discrete=False, plot_stations=True)\n",
     "plt.show()\n",
     "\n",
     "plot_cells(data[\"n\"], not_na_coords, all_na_coords, discrete=True)\n",
@@ -184,7 +183,9 @@
    "execution_count": null,
    "metadata": {},
    "outputs": [],
-   "source": []
+   "source": [
+    "print(data)"
+   ]
   }
  ],
  "metadata": {
-- 
GitLab