-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
39 lines (27 loc) · 934 Bytes
/
demo.py
File metadata and controls
39 lines (27 loc) · 934 Bytes
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
import os
from pathlib import Path
from opencdms import MidasOpen
from opencdms.process.climatol import windrose
# Instead of using a database connection string, the MIDAS Open
# provider requires the root directory for the MIDAS Open data.
CONNECTION = os.path.join(
Path.home(), 'opencdms-dev', 'git', 'opencdms-test-data')
def main(connection=None, write_csv=False):
if connection is None:
connection = CONNECTION
# All instances of CDMS Providers act as an active session
session = MidasOpen(connection)
filters = {
'src_id': 838,
'period': 'hourly',
'year': 1991,
'elements': ['wind_speed', 'wind_direction'],
}
# Get observations DataFrame using filters
obs = session.obs(**filters)
if write_csv:
# Save observations to CSV file
obs.to_csv('example_observations.csv')
windrose(obs)
if __name__ == '__main__':
main()