get_DWDdata: get_DWDdata

View source: R/get_DWDdata.R

get_DWDdataR Documentation

get_DWDdata

Description

This is a function to download DWD data based on a buffer distance. The meteorological variables are provide in data.frame per station id.

Usage

get_DWDdata(
  lat_center,
  lon_center,
  radius_km,
  time_lag = "hourly",
  period,
  meteo_var,
  start_date,
  end_date,
  var_name,
  by_lag = "hour"
)

Arguments

lat_center

latitude central point for the buffer

lon_center

longitude central point for the buffer

radius_km

for the buffer

time_lag

default "hourly" , it can be change for daily or other timestamp available

period

default "historical", if change to "recent" you get one year lag up to "now".

meteo_var

type of meteorological data target in the DWD ftp (see option below)

start_date

select stations with date later than

end_date

select stations with date earlier than

var_name

variable name target in the the downloaded meteo_var file (see option below)

by_lag

to create a timestamp, default "hour",

Value

a list with: 1- a data.frame with the selected variable per station id for the set timestamp, and 2- a data.frame with metadata information, such as stations_id, start_date, end_date, station_height, latitude, longitude, stations_name, region, time_lag, variable, period, file, distance, url. data_dir where to save the downlaod data, default temporary. dir.create(file.path(tempdir(), "DWDdir"), showWarnings = FALSE)

Examples

##### meteo_var options
# "precipitation"       "air_temperature"     "extreme_temperature"   "extreme_wind"
# "solar"               "wind"                "wind_test"             "kl"
# "more_precip"         "weather_phenomena"   "soil_temperature"      "water_equiv"
# "cloud_type"          "cloudiness"          "dew_point"             "moisture"
# "pressure"            "sun"                 "visibility"            "wind_synop"
# "soil"                "standard_format"

##### var_name options
### meteo_var = air_temperature
# var_name = TT_TU, air temperature at 2m height (Ta)
# var_name = RF_TU, relative humidity at 2m height (RH)
# meteo_var = "precipitation"
# var_name = R1, mm of precipitation (prec_mm)
# var_name = RS_IND, occurrence of precipitation, 0 no precipitation / 1 precipitation fell (prec_h)
### meteo_var = "pressure"
# var_name = P0     # Pressure at station height (2m)
# var_name = P      # Pressure at see level
### meteo_var = "wind_synop"
# var_name = FF     # Average wind speed (ws)
# var_name = DD     # wind direction (wd)
### meteo_var = "moisture" (atm)
# var_name = P_STD	  Hourly air pressure	[hpa]
# var_name = RF_STD	Hourly values of relative humidity	[%]
# var_name = TD_STD	Dew point temperature at 2m height	[°C]
# var_name = TF_STD	Calculated hourly values of the wet temperature	[°C]
# var_name = TT_STD	Air temperature at 2m height	[°C]
# var_name = VP_STD	calculated hourly values of the vapour pressure [hpa]
### meteo_var = "sun"
# var_name = SD_SO   # sunshine duration - minutes
### "soil_temperature"
# soil.temp.2cm
# soil.temp.5cm
# soil.temp.10cm
# soil.temp.20cm
# soil.temp.50cm
# soil.temp.100cm
### "visibility"
# V_VV      # Visibility in meter
# V_VV_I    # from the observer
### "dew_point"
# TT   # dry bulb temperature at 2 meter above ground
# TD   # dew point temperature at 2 meter above ground
### "cloudiness"
# V_N    # Total coverage - eighth levels # same as cloudness

#########
Air_temp <- get_DWDdata(lat_center = 52.4537,
                        lon_center = 13.3017,
                        radius_km = 70,
                        time_lag = "hourly",
                        period = "historical",
                        meteo_var = "air_temperature",
                        start_date = "2019-01-01",
                        end_date = "2020-12-31",
                        var_name = "TT_TU");

Air_temp[[1]];
summary(Air_temp[[1]]);

#########
solar_radiation <- get_Solardata(lat_center = 52.4537,
                                 lon_center = 13.3017,
                                 radius_km = 70,
                                 time_lag = "hourly",
                                 meteo_var = "solar",
                                 start_date = "2018-12-31",
                                 end_date = "2021-01-01");

solar_radiation[[1]][[1]];
summary(solar_radiation[[1]][[1]]);

library(tidyverse)

solar_radiation[[1]][[1]] %>%
  mutate(Rli = zoo::na.approx(round((ATMO_LBERG*100*100)/(60*60),2)),
         diffuse_radiation = zoo::na.approx(round((FD_LBERG*100*100)/(60*60),2)),
         Rin = zoo::na.approx(round((FG_LBERG*100*100)/(60*60),2)),
         sun_duration = zoo::na.approx(SD_LBERG),
         sun_zenith_angle = zoo::na.approx(ZENIT),
         # timestamp = MESS_DATUM_WOZ,
         timestamp = with_tz(force_tz(MESS_DATUM_WOZ, "CEST"), tz = "UTC")
  ) %>%
  select(timestamp,  Rin, Rli, diffuse_radiation, sun_duration, sun_zenith_angle, MESS_DATUM) -> solar_radiation_3987

##########
SMC_daily <- get_SMCdata(lat_center = 52.4537,
                         lon_center = 13.3017,
                         radius_km = 70,
                         time_lag = "daily",
                         meteo_var = "soil",
                         start_date = "2019-01-01",
                         end_date = "2020-12-31");

SMC_daily[[1]][[1]];
summary(SMC_daily[[1]][[1]]);


AlbyDR/rSCOPE documentation built on Dec. 19, 2024, 7:29 p.m.