Skip to content

Commit 2864da4

Browse files
committed
Updated streams and added some additional information on querying geostreams
1 parent 3df8442 commit 2864da4

1 file changed

Lines changed: 36 additions & 20 deletions

File tree

sensors/01-meteorological-data.Rmd

Lines changed: 36 additions & 20 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:
@@ -73,21 +70,42 @@ The key is to process each type of met data (site, reanalysis, forecast, climate
7370

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

76-
Locations with met data
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=
7785

78-
TODO (MAX ...) is there code / a curl statement that can be used to retrie this list?
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:
7996

8097
| stream id | name |
8198
|------------|------------------------------------------|
82-
| 300 | MAC weather |
83-
| 750 | MAC irrigation |
84-
| 746 | EnvironmentLogger sensor_weather_station |
85-
| 747 | EnvironmentLogger sensor_par |
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 |
86104
| 748 | EnvironmentLogger sensor_spectrum |
87-
| 749 | EnvironmentLogger sensor_co2 |
88-
| 1219 | UIUC Energy Farm SE |
89-
| 1222 | UIUC Energy Farm CEN |
90-
| 1223 | UIUC Energy Farm NE |
105+
| 3210 | EnvironmentLogger sensor_co2 |
106+
| 4806 | UIUC Energy Farm SE |
107+
| 4807 | UIUC Energy Farm CEN |
108+
| 4805 | UIUC Energy Farm NE |
91109

92110

93111
Here is the json representation of a single five-minute observation:
@@ -128,13 +146,12 @@ The data represent 5 minute summaries aggregated from 1/s observations.
128146

129147
First, this is what the API looks like as a URL. Try pasting it into your browser
130148

131-
132-
https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?user=USER&pass=PASSWORD&stream_id=746&since=2017-01-02&until=2017-01-31
149+
https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?stream_id=46431&since=2017-01-02&until=2017-01-31
133150

134151
This is how you can automatically download the met data to a local file:
135152

136153
```{sh eval=FALSE}
137-
curl -O spectra.json -X GET https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?user=USER&pass=PASSWORD&stream_id=746
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
138155
```
139156

140157
And this is how you can access the data in R:
@@ -145,8 +162,7 @@ library(dplyr)
145162
library(ggplot2)
146163
library(jsonlite)
147164
148-
url = ""
149-
mac_weather.list <- jsonlite::fromJSON('https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?user=USER&pass=PASSWORD&stream_id=746&since=2017-01-02&until=2017-01-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)
150166
151167
# change time to human-readable
152168
mac_weather <- mac_weather.list$properties %>%
@@ -163,14 +179,14 @@ mac_weather <- mac_weather.list$properties %>%
163179
```{r weather}
164180
theme_set(ggthemes::theme_few())
165181
ggplot(data = mac_weather) +
166-
geom_line(aes(x = time, y = wind_speed), size = 0.1)
182+
geom_point(aes(x = time, y = wind_speed), size = 0.1)
167183
```
168184

169185
#### Rainfall
170186

171187
```{r precipitation}
172188
ggplot(data = mac_weather) +
173-
geom_line(aes(x = time, y = precipitation_rate), size = 0.1)
189+
geom_point(aes(x = time, y = precipitation_rate), size = 0.1)
174190
```
175191

176192
#### Your turn!

0 commit comments

Comments
 (0)