-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_plots.py
76 lines (68 loc) · 2.89 KB
/
make_plots.py
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
import os
from cr2 import *
def make_folders():
root = 'plots'
folders = ['prec', 'caud', 'temp', 'tmin', 'tmax']
subfolders = ['annual', 'simple', 'month']
if not os.path.exists(root):
os.mkdir(root)
for folder in folders:
fold = os.path.join(root, folder)
if not os.path.exists(fold):
os.mkdir(fold)
for subfolder in subfolders:
subfold = os.path.join(fold, subfolder)
if not os.path.exists(subfold):
os.mkdir(subfold)
def plots_prec(prec):
for istation in prec.df.columns:
filename = 'plots/prec/annual/%s_annual.png'%(istation)
prec.plot_annual(istation, filename=filename)
filename = 'plots/prec/simple/%s_simple.png'%(istation)
prec.plot_simple(istation, filename=filename)
filename = 'plots/prec/month/%s_month.png'%(istation)
prec.plot_month(istation, filename=filename)
def plots_caud(caud):
for istation in caud.df.columns:
filename = 'plots/caud/annual/%s_annual.png'%(istation)
caud.plot_annual(istation, filename=filename)
filename = 'plots/caud/simple/%s_simple.png'%(istation)
caud.plot_simple(istation, filename=filename)
filename = 'plots/caud/month/%s_month.png'%(istation)
caud.plot_month(istation, filename=filename)
def plots_temp(temp):
for istation in temp.df.columns:
filename = 'plots/temp/annual/%s_annual.png'%(istation)
temp.plot_annual(istation, filename=filename)
filename = 'plots/temp/simple/%s_simple.png'%(istation)
temp.plot_simple(istation, filename=filename)
filename = 'plots/temp/month/%s_month.png'%(istation)
temp.plot_month(istation, filename=filename)
def plots_tmin(tmin):
for istation in tmin.df.columns:
filename = 'plots/tmin/annual/%s_annual.png'%(istation)
tmin.plot_annual(istation, filename=filename)
filename = 'plots/tmin/simple/%s_simple.png'%(istation)
tmin.plot_simple(istation, filename=filename)
filename = 'plots/tmin/month/%s_month.png'%(istation)
tmin.plot_month(istation, filename=filename)
def plots_tmax(tmax):
for istation in tmax.df.columns:
filename = 'plots/tmax/annual/%s_annual.png'%(istation)
tmax.plot_annual(istation, filename=filename)
filename = 'plots/tmax/simple/%s_simple.png'%(istation)
tmax.plot_simple(istation, filename=filename)
filename = 'plots/tmax/month/%s_month.png'%(istation)
tmax.plot_month(istation, filename=filename)
if __name__ == '__main__':
make_folders()
prec = Cr2('monthly', 'p', 'data.json')
plots_prec(prec)
caud = Cr2('monthly', 'q', 'data.json')
plots_caud(caud)
temp = Cr2('monthly', 't', 'data.json')
plots_temp(temp)
tmin = Cr2('monthly', 'tmin', 'data.json')
plots_tmin(tmin)
tmax = Cr2('monthly', 'tmax', 'data.json')
plots_tmax(tmax)