-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathrun_experiment.py
executable file
·92 lines (70 loc) · 2.7 KB
/
run_experiment.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
""" run GDAY, plot LAI, NPP, transpiration """
import os
import sys
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import datetime as dt
import example
__author__ = "Martin De Kauwe"
__version__ = "1.0 (11.02.2014)"
__email__ = "[email protected]"
def main(experiment_id, site, treatment):
# run new simulations
example.ambient_sim(experiment_id, site, treatment)
# load data
amb = read_data("outputs/D1GDAY%s%s.csv" % (site, treatment.upper()))
plt.rcParams['figure.subplot.hspace'] = 0.15
plt.rcParams['figure.subplot.wspace'] = 0.15
plt.rcParams['font.size'] = 10
plt.rcParams['legend.fontsize'] = 10
plt.rcParams['xtick.labelsize'] = 10.0
plt.rcParams['ytick.labelsize'] = 10.0
plt.rcParams['axes.labelsize'] = 10.0
plt.rcParams['font.family'] = "sans-serif"
plt.rcParams['font.style'] = "normal"
plt.rcParams['font.serif'] = "Helvetica"
fig = plt.figure()
#years = np.unique(amb.YEAR).values
years = np.unique(amb.YEAR)
years = [int(float(i)) for i in years]
ax1 = fig.add_subplot(311)
ax1.plot(years, amb.groupby("YEAR").NPP.sum(), "b-", label="Amb")
obs_npp = np.array([1010.363435,1052.484494,930.9501267,1132.113908,\
1204.210228,1020.08473,662.2080009,953.6588582,\
1038.468081,909.183305,1220.6568,965.8984])
ax1.plot(years, obs_npp, "ro", label="Obs")
ax1.legend(numpoints=1, loc="best")
ax1.set_ylabel("NPP (g m$^{2}$ yr$^{-1}$)")
plt.setp(ax1.get_xticklabels(), visible=False)
ax1.set_ylim(0., 1800)
ax1.set_xlim(1995, 2008)
ax2 = fig.add_subplot(312)
ax2.plot(years, amb.groupby("YEAR").LAI.max(), "b-", label="Amb")
#ax2.legend(numpoints=1, loc="best")
ax2.set_ylabel("LAI (m$^{2}$ m$^{-2}$)")
#ax2.set_xlabel("Year")
ax2.set_ylim(0., 5)
plt.setp(ax2.get_xticklabels(), visible=False)
ax3 = fig.add_subplot(313)
ax3.plot(years, amb.groupby("YEAR").T.sum(), "b-", label="Amb")
ax3.set_ylabel("Transpiration (mm yr$^{-1}$)")
ax3.set_xlabel("Year")
ax3.set_ylim(0., 800)
plt.show()
#fig.savefig("example_plot.png", dpi=100)
def date_converter(*args):
return dt.datetime.strptime(str(int(float(args[0]))) + " " +\
str(int(float(args[1]))), '%Y %j')
def read_data(fname):
df = pd.read_csv(fname, parse_dates=[[0,1]], index_col=0, sep=",",
keep_date_col=True, date_parser=date_converter,
na_values=["-999.9"], skiprows=3)
return df
if __name__ == "__main__":
# Ambient
experiment_id = "NCEAS"
site = "DUKE"
treatment="amb"
main(experiment_id, site, treatment)