-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcatchment-analysis.py
More file actions
39 lines (31 loc) · 1.18 KB
/
catchment-analysis.py
File metadata and controls
39 lines (31 loc) · 1.18 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
#!/usr/bin/env python3
"""Software for managing and tracking environmental data
from our field project."""
import argparse
from catchment import models, views
def main(args):
"""The MVC Controller of the environmental data system.
The Controller is responsible for:
- selecting the necessary models and views for the current task
- passing data between models and views
"""
in_files = args.infiles
if not isinstance(in_files, list):
in_files = [args.infiles]
for filename in in_files:
measurement_data = models.read_variable_from_csv(filename)
view_data = {
'daily sum': models.daily_total(measurement_data),
'daily average': models.daily_mean(measurement_data),
'daily max': models.daily_max(measurement_data),
'daily min': models.daily_min(measurement_data)}
views.visualize(view_data)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description='A basic environmental data management system')
parser.add_argument(
'infiles',
nargs='+',
help='Input CSV(s) containing measurement data')
args = parser.parse_args()
main(args)