forked from meteomatics/R-connector-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.R
More file actions
executable file
·161 lines (108 loc) · 4.83 KB
/
Copy pathexample.R
File metadata and controls
executable file
·161 lines (108 loc) · 4.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#Meteomatics Weather API Connector - Examples
#Required packages: httr, data.table, lubridate, ggplot2, stringr.
#install.packages("")
source('R_query_api.R')
#Account data
username <- "r-community"
password <- "Utotugode673"
#Find out what the current account can do
limits <- query_user_features(username, password)
limits
#Set initial time data####
time_zone <- "Europe/Berlin"
startdate <- ISOdatetime(year = as.integer(strftime(today(),'%Y')),
month = as.integer(strftime(today(),'%m')),
day = as.integer(strftime(today(),'%d')),
hour = 00, min = 00, sec = 00, tz = "UTC")
enddate <- ISOdatetime(year = as.integer(strftime(today(),'%Y')),
month = as.integer(strftime(today(),'%m')),
day = as.integer(strftime(today(),'%d'))+1,
hour = 00, min = 00, sec = 00, tz = "UTC")
interval <- "PT1H"
#Query a Timeseries####
parameters <- "t_2m:C,relative_humidity_1000hPa:p"
coordinate <- "47.11,11.47"
#coordinate <- "47.11,11.47+50,10"
ts_output <- timeseries(startdate, enddate, interval, parameters, coordinate)
head(ts_output)
#Grid####
parameter <- "t_2m:C"
coordinate <- "48.5,5.5_45.5,11.5:800x600"
grid_output <- grid(startdate, parameter, coordinate)
head(grid_output)
#Pivot Grid####
parameter <- "t_2m:C" #only one parameter
coordinate <- "48.5,5.5_45.5,11.5:5x5" #Rectangle
pivot_grid <- grid_pivot(startdate, parameter, coordinate)
head(pivot_grid)
#Timeseries grid####
parameter <- "t_2m:C"
coordinate <- "50,0_40,20:500x300"
interval <- "PT12H"
timeseries_grid_output <- timeseries_grid(startdate, enddate, interval, parameter, coordinate)
head(timeseries_grid_output)
#Get a list of lightning strikes####
time_range="2019-07-07T12:00:00ZPT2S"
bounding_box="50,10_40,20"
ls <- lightning_strikes(time_range, bounding_box)
head(ls)
#save timeseries grid as .netcdf####
parameters = "t_2m:C"
coordinate = "90,-180_-90,180:600x400"
startdate <- ISOdatetime(year = as.integer(strftime(today(),'%Y')),
month = as.integer(strftime(today(),'%m')),
day = as.integer(strftime(today(),'%d')),
hour = 00, min = 00, sec = 00, tz = "UTC")
duration = "PT3H"
interval = "PT1H"
save_netcdf(startdate, duration, interval, parameters, coordinate)
#safe grads plot####
parameters <- "t_500hPa:C,gh_500hPa:m"
coordinate <- "70,-15_35,30:0.1,0.1"
save_grads_plot(startdate, parameters, coordinate)
#Find stations####
location <- "location=47.3,9.3"
#parameters=<comma separated parameter list>
parameters <- "parameters=t_2m:C"
stations <- find_station(location, parameters)
head(stations)
#Query a timeseries for a weather station with certain coordinates if possible####
startdate <- ISOdatetime(year = as.integer(strftime(today(),'%Y')),
month = as.integer(strftime(today(),'%m')),
day = as.integer(strftime(today(),'%d'))-1,
hour = 00, min = 00, sec = 00, tz = "UTC")
enddate <- ISOdatetime(year = as.integer(strftime(today(),'%Y')),
month = as.integer(strftime(today(),'%m')),
day = as.integer(strftime(today(),'%d')),
hour = 00, min = 00, sec = 00, tz = "UTC")
interval <- "PT1H"
parameters <- "t_2m:C,relative_humidity_2m:p"
coordinate <- "47.43,9.4"
stations_timeseries <- station_timeseries(startdate, enddate, interval, parameters, coordinate)
head(stations_timeseries)
#Query a timeseries for a weather station with certain IDs####
startdate = ISOdatetime(year = as.integer(strftime(today(),'%Y')),
month = as.integer(strftime(today(),'%m')),
day = as.integer(strftime(today(),'%d'))-1,
hour = 00, min = 00, sec = 00, tz = "UTC")
enddate = ISOdatetime(year = as.integer(strftime(today(),'%Y')),
month = as.integer(strftime(today(),'%m')),
day = as.integer(strftime(today(),'%d')),
hour = 00, min = 00, sec = 00, tz = "UTC")
interval <- "PT3H"
parameters = "t_2m:C,relative_humidity_2m:p"
station <- "wmo_037720"
timeseries_station_id(startdate, enddate, interval, parameters, station)
#Get latest initial times####
parameters <- "t_2m:C,relative_humidity_2m:p"
model <- "ecmwf-ifs"
startdate = ISOdatetime(year = as.integer(strftime(today(),'%Y')),
month = as.integer(strftime(today(),'%m')),
day = as.integer(strftime(today(),'%d')),
hour = 00, min = 00, sec = 00, tz = "UTC")
date <- strftime(startdate,format='%Y-%m-%dT%H:%M:%OSZ', tz='UTC')
init_dates(model, date, parameters)
#Get available time range####
model <- "ecmwf-ifs"
paramters <- "global_rad:W,t_2m:C"
available_time_range(model,parameters)