{ "cells": [ { "cell_type": "markdown", "id": "16473b52-64fd-425b-bab4-356708192bab", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "# QC protocol for Private Weather Stations" ] }, { "cell_type": "markdown", "id": "957fd8e7-df3f-47d8-b57c-e60e26513338", "metadata": {}, "source": [ "This notebook presents how to use the Python package `pypwsqc`, a quality assurance protocol developed for automated private weather stations (PWS). The protocol consists of three filters; the Faulty Zero filter, the High Influx filter and the Station Outlier filter.\n", "\n", "The package is based on the original R code available at https://github.com/LottedeVos/PWSQC/.\n", "\n", "Publication: de Vos, L. W., Leijnse, H., Overeem, A., & Uijlenhoet, R. (2019). Quality control for crowdsourced personal weather stations to enable operational rainfall monitoring. Geophysical Research Letters, 46(15), 8820-8829\n", "\n", "`pypwsqc` depends on the `poligrain`, `xarray`, `pandas` and `numpy` packages. Make sure to install and import the required packages first." ] }, { "cell_type": "code", "execution_count": 1, "id": "78857b63-6c25-4391-be95-119a6e906aeb", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import poligrain as plg\n", "import xarray as xr\n", "\n", "import pypwsqc" ] }, { "cell_type": "markdown", "id": "d852ea47-40ab-4956-ac7c-f9aaa1dee996", "metadata": {}, "source": [ "## Download example data\n", "\n", "In this example, we use an open PWS dataset from Amsterdam, called the \"AMS PWS\" dataset. By running the cell below, an example NetCDF-file will be downloaded to your current repository (if your machine is connected to the internet)." ] }, { "cell_type": "code", "execution_count": 2, "id": "25b78fd5-c92b-4854-9a56-cefe8450f734", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " % Total % Received % Xferd Average Speed Time Time Time Current\n", " Dload Upload Total Spent Left Speed\n", " 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\n", "100 5687k 100 5687k 0 0 3800k 0 0:00:01 0:00:01 --:--:-- 6267k\n" ] } ], "source": [ "!curl -OL https://github.com/OpenSenseAction/OS_data_format_conventions/raw/main/notebooks/data/OpenSense_PWS_example_format_data.nc" ] }, { "cell_type": "markdown", "id": "e420966c-eba1-4a40-aa4b-e1f10e7bbe26", "metadata": {}, "source": [ "## Data preparations" ] }, { "cell_type": "markdown", "id": "fa7460be-a65e-4549-831d-f11fa418a21c", "metadata": {}, "source": [ "This package handles rainfall data as `xarray` Datasets. The data set must have `time` and `id` dimensions, `latitude` and `longitude` as coordinates, and `rainfall` as data variable.\n", "\n", "An example of how to convert .csv data to a `xarray` dataset is found [here](https://github.com/OpenSenseAction/OS_data_format_conventions/blob/main/notebooks/PWS_example_dataset.ipynb).\n", "\n", "We now load the data set under the name `ds_pws`." ] }, { "cell_type": "code", "execution_count": 3, "id": "9a8f4054-4282-42a0-bfff-c12a55241672", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n",
"Dimensions: (time: 219168, id: 134)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 2016-05-01T00:05:00 ... 2018-06-01\n",
" * id (id) <U6 'ams1' 'ams2' 'ams3' ... 'ams132' 'ams133' 'ams134'\n",
" elevation (id) <U3 ...\n",
" latitude (id) float64 ...\n",
" longitude (id) float64 ...\n",
"Data variables:\n",
" rainfall (id, time) float64 ...\n",
"Attributes:\n",
" title: PWS data from Amsterdam\n",
" file author: Maximilian Graf\n",
" institution: Wageningen University and Research, Department of ...\n",
" date: 2022-10-18 10:32:00\n",
" source: Netamo PWS\n",
" history: Data derived and reformated from the originally pu...\n",
" naming convention: OpenSense-0.1\n",
" license restrictions: CC-BY 4.0 https://creativecommons.org/licenses/by/...\n",
" reference: https://doi.org/10.1029/2019GL083731\n",
" comment: