-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsimple_model.py
68 lines (51 loc) · 1.68 KB
/
simple_model.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
# Try out some simpler models between parameter values (LHC) and CLM model
# output
# 6/29/18
#source /glade/work/kdagon/ncar_pylib_clone/bin/activate
from scipy import stats
from sklearn import linear_model
import numpy as np
#import matplotlib as mpl
#mpl.use('Agg')
import matplotlib.pyplot as plt
# Read in input array
inputdata = np.load(file="lhc_100.npy", allow_pickle=True)
print(inputdata.shape)
# List of input variables
in_vars = ['medlynslope','dleaf','kmax','fff','dint','baseflow_scalar']
# Read in output array
outputdata = np.loadtxt("outputdata/outputdata_GPP.csv")
print(outputdata.shape)
# Simple scatterplots and correlation coeffs
for x in range(6):
plt.scatter(inputdata[:,x],outputdata)
plt.ylabel('CLM Output')
plt.xlabel('LHC values')
plt.title(in_vars[x])
# plt.savefig("scatter_GPPvs%s.eps" % (in_vars[x], ))
plt.show()
rho, spval = stats.spearmanr(inputdata[:,x],outputdata)
print(rho, spval)
pcc, ppval = stats.pearsonr(inputdata[:,x],outputdata)
print(pcc, ppval)
# use eumerate to avoid range command
#for x, y in enumerate(in_vars):
# plt.scatter(inputdata[:,x], outputdata)
# etc...except for two changes:
# plt.title(y)
# plt.show()
# plt.savefig("scatter_GPPvs%s.eps" % (y, ))
# Multivariate linear regression
#regr = linear_model.LinearRegression()
#regr.fit(inputdata, outputdata)
#print('Coefficients: \n', regr.coef_)
#pred = regr.predict(inputdata)
#print(pred.shape)
#print(inputdata.shape, outputdata.shape)
#plt.scatter(inputdata[:,0], outputdata, color='black')
#plt.plot(inputdata[:,0], pred, color='blue', linewidth=3)
#plt.xticks(())
#plt.yticks(())
#plt.savefig('test.pdf')
#plt.close()
#plt.show()