Skip to content

Commit 204f79f

Browse files
authored
Merge pull request #31 from terraref/clowder-met
updated met data tutorial
2 parents 5219cd9 + 2864da4 commit 204f79f

1 file changed

Lines changed: 54 additions & 11 deletions

File tree

sensors/01-meteorological-data.Rmd

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ Geodashboard:
2222

2323
[Sample raw meteorological (1/s) data on Clowder](https://terraref.ncsa.illinois.edu/clowder/files/588ba5474f0c06726acfcace?dataset=587fc7444f0cd67174e7a92d&space=57e42cd44f0cff4b58dd3eea)
2424

25-
26-
27-
2825
## Meteorological data formats
2926

3027
### Dimensions:
@@ -71,9 +68,46 @@ The key is to process each type of met data (site, reanalysis, forecast, climate
7168

7269
### The Geostreams Database
7370

74-
7571
!(schema)[https://cloud.githubusercontent.com/assets/9286213/16991300/b2f2b09a-4e60-11e6-96b7-8b63c3d1f995.jpg]
7672

73+
#### Querying the API
74+
75+
key query terms:
76+
77+
* /sensors
78+
* sensor_name=''
79+
* /streams
80+
*
81+
* /datapoints
82+
* &since=YYYY-MM-DD
83+
* &until=YYYY-MM-DD
84+
* stream_id=
85+
86+
How to find the stream_id from a particular station or sensor:
87+
88+
1. find streams on "UA-MAC AZMET Weather Station" https://terraref.ncsa.illinois.edu/clowder/api/geostreams/sensors?sensor_name=UA-MAC AZMET Weather Station
89+
2. take sensor id from that response and find the streams: https://terraref.ncsa.illinois.edu/clowder/api/geostreams/sensors/438/streams
90+
3. take stream id from that and use in the datapoints query: https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?stream_id=46431&since=2017-01-02&until=2017-01-31
91+
92+
93+
#### Locations with met data
94+
95+
These are some of the locations with met data:
96+
97+
| stream id | name |
98+
|------------|------------------------------------------|
99+
| 3211 | UA-MAC AZMET Weather Station - weather |
100+
| 3212 | UA-MAC AZMET Weather Station - irrigation |
101+
| 46431 | UA-MAC AZMET Weather Station - weather (5 min) |
102+
| 3208 | EnvironmentLogger sensor_weather_station |
103+
| 3207 | EnvironmentLogger sensor_par |
104+
| 748 | EnvironmentLogger sensor_spectrum |
105+
| 3210 | EnvironmentLogger sensor_co2 |
106+
| 4806 | UIUC Energy Farm SE |
107+
| 4807 | UIUC Energy Farm CEN |
108+
| 4805 | UIUC Energy Farm NE |
109+
110+
77111
Here is the json representation of a single five-minute observation:
78112

79113
```
@@ -108,18 +142,27 @@ Here is the json representation of a single five-minute observation:
108142

109143
The data represent 5 minute summaries aggregated from 1/s observations.
110144

111-
First, this is what the API looks like
145+
#### Using Curl
146+
147+
First, this is what the API looks like as a URL. Try pasting it into your browser
148+
149+
https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?stream_id=46431&since=2017-01-02&until=2017-01-31
150+
151+
This is how you can automatically download the met data to a local file:
152+
153+
```{sh eval=FALSE}
154+
curl -O spectra.json -X GET https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?stream_id=46431&since=2017-01-02&until=2017-01-31
155+
```
156+
157+
And this is how you can access the data in R:
112158

113-
https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?key=Pb3AUSqnUw&stream_id=4807&since=2017-01-02&until=2017-01-31
114159

115160
```{r met-geostream}
116161
library(dplyr)
117162
library(ggplot2)
118163
library(jsonlite)
119164
120-
url = ""
121-
mac_weather.list <- jsonlite::fromJSON('https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?key=Pb3AUSqnUw&stream_id=4807&since=2017-01-02&until=2017-01-31')
122-
#mac_weather.list <- jsonlite::fromJSON('https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?key=Pb3AUSqnUw&stream_id=3208&since=2017-01-02&until=2017-12-31', flatten = FALSE)
165+
mac_weather.list <- jsonlite::fromJSON('https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?stream_id=46431&since=2017-01-02&until=2017-01-31', flatten = FALSE)
123166
124167
# change time to human-readable
125168
mac_weather <- mac_weather.list$properties %>%
@@ -136,14 +179,14 @@ mac_weather <- mac_weather.list$properties %>%
136179
```{r weather}
137180
theme_set(ggthemes::theme_few())
138181
ggplot(data = mac_weather) +
139-
geom_line(aes(x = time, y = wind_speed), size = 0.1)
182+
geom_point(aes(x = time, y = wind_speed), size = 0.1)
140183
```
141184

142185
#### Rainfall
143186

144187
```{r precipitation}
145188
ggplot(data = mac_weather) +
146-
geom_line(aes(x = time, y = precipitation_rate), size = 0.1)
189+
geom_point(aes(x = time, y = precipitation_rate), size = 0.1)
147190
```
148191

149192
#### Your turn!

0 commit comments

Comments
 (0)