An open API service indexing awesome lists of open source software.

https://github.com/atsyplenkov/rp5pik

Download And Preprocess Russian Meteorological Data
https://github.com/atsyplenkov/rp5pik

Last synced: 3 months ago
JSON representation

Download And Preprocess Russian Meteorological Data

Awesome Lists containing this project

README

        

---
output: github_document
editor_options:
chunk_output_type: inline
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)

Sys.setlocale(category = "LC_TIME", locale = "en_us")
```

# rp5pik

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8090329.svg)](https://doi.org/10.5281/zenodo.8090329)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![pkgcheck](https://github.com/atsyplenkov/rp5pik/workflows/pkgcheck/badge.svg)](https://github.com/atsyplenkov/rp5pik/actions?query=workflow%3Apkgcheck)
[![CRAN status](https://www.r-pkg.org/badges/version/rp5pik)](https://CRAN.R-project.org/package=rp5pik)
![GitHub R package version](https://img.shields.io/github/r-package/v/atsyplenkov/rp5pik?label=github)
![GitHub last commit](https://img.shields.io/github/last-commit/atsyplenkov/rp5pik)

The `rp5pik` package provides a set of functions to download and preprocess meteorological data from http://www.pogodaiklimat.ru/

## Installation

You can install the development version of rp5pik from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("atsyplenkov/rp5pik")

# OR

# install.packages("remotes")
remotes::install_github("atsyplenkov/rp5pik")
```

## Examples
### 1. Data download

Below is an example for `rp_parse_pik` functions. It allows you to download meteo data at **3-hour** temporal resolution for various stations using their WMO ID from [http://www.pogodaiklimat.ru/](http://www.pogodaiklimat.ru/):

```{r example}
library(rp5pik)

example <-
rp_parse_pik(
wmo_id = c("20069", "27524"),
start_date = "2022-05-01",
end_date = "2022-05-31"
)

example
```

List of available variables:

- `wmo`
character. WMO index of the meteostation

- `datetime_utc`
POSIXct. Date and Time of the measurement at UTC

- `ta`
numeric. Air temperature at 2m above the surface, °C

- `td`
numeric. Dew point, °C

- `rh`
numeric. Relative humidity at 2m above the surface, %

- `ps`
numeric. Atmosphere pressure at meteostation, hPa

- `psl`
numeric. Atmosphere pressure adjusted to the height of mean sea level, hPa

- `prec`
numeric. Cumulative precipitation for the last 12 hours, mm

- `windd`
integer. Wind direction, deg

- `winds_mean`
numeric. Average 10-min wind speed, m/s

- `winds_max`
numeric. Maximum wind speed, m/s

We can visualize the `example` dataset using `ggplot2` as follows:
```{r plot, fig.align='center', dpi=1000, fig.width=7, fig.height=5, out.width='80%'}
library(ggplot2)

example |>
ggplot(
aes(
x = datetime_utc,
y = ta,
group = wmo
)
) +
geom_line(aes(color = wmo)) +
labs(
x = "",
y = "Average Temperature, °C"
) +
theme_minimal()

```

### 2. Data preprocessing
Since the downloaded with `rp_parse_pik` data contains raw data, it requires additional checking and cleaning. We suggest to explore the raw dataset by yourselves before any further manipulations.

However, the `rp5pik` package has a function to aggregate raw data on daily (`24h`) or semi-daily (`12h`) periods. The `rp_aggregate_pik` function removes known error codes from precipitation data (`699` values). Additionally, it calculates daily precipitation sums based on measured precipitation at 06 UTC and 18 UTC in European part of Russia (see [meteostation manuals for more info](https://method.meteorf.ru/ansambl/pojasnenijaansambl.html)).

⚠ As of `r Sys.Date()` this function works only with Moscow timezone.

This is how you can aggregate data daily:
```{r aggregate, message=FALSE, warning=FALSE}
library(dplyr)

example_daily <-
example |>
rp_aggregate_pik(.period = "24h") |>
group_split(wmo)

example_daily

```

Or semi-daily:

```{r aggregate_12, message=FALSE, warning=FALSE}
library(dplyr)

example_12h <-
example |>
rp_aggregate_pik(.period = "12h", .tz = "Europe/Moscow") |>
group_split(wmo)

example_12h

```

## Roadmap
```
rp5pik 📦
├── Parser functions for
│ ├── pogodaiklimat
│ │ ├── rp5pik::rp_parse_pik ✅
│ │ └── rp5pik::rp_aggregate_pik ✅
│ ├── rp5 🔲
│ └── gmvo.skniivh 🔲
├── WMO stations coordinates 🔲
└── Rain/Snow guessing
└── rp5pik::rp_get_temp50 ✅
```