-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinteractive_demo.txt
More file actions
93 lines (66 loc) · 2.68 KB
/
interactive_demo.txt
File metadata and controls
93 lines (66 loc) · 2.68 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
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
93
# import dedicated interactive shell
import opec.benchmarking as benchmarking
# print a lot of useful information about the possible functions (only possible in IPython)
#help(benchmarking)
# load the source data file
data = benchmarking.load('resources/test.nc')
# show the reference variables
data.ref_vars()
# show the model variables
data.model_vars()
# calculate the statistics for some model variable with some reference variable
stats = benchmarking.calculate_statistics('chl', 'chl_ref', data)
# inspect statistics
stats['rmse']
stats['unbiased_rmse']
stats['p90']
stats['ref_p90']
# get all matchups in the data file
m = benchmarking.get_matchups(data)
# show number of matchups
len(m)
# inspect matchups
print(m[0])
print(m[1])
print(m[2])
# define valid matchups considered valid
valid_matchups = [m[0], m[1]]
# calculate the statistics only from matchups considered valid
stats2 = benchmarking.calculate_statistics_from_matchups(valid_matchups, 'chl', 'chl_ref', data)
# inspect statistics
stats2['rmse']
stats2['unbiased_rmse']
stats2['p90']
stats2['ref_p90']
# get data arrays from matchups
reference_data, model_data = benchmarking.extract_values_from_matchups(valid_matchups, data, 'chl', 'chl_ref')
# inspect reference data
reference_data
# inspect model data
model_data
# manipulate model data
model_data[0] = 0.5
stats3 = benchmarking.calculate_statistics_from_values(model_data, reference_data)
# inspect statistics
stats3['rmse']
stats3['unbiased_rmse']
stats3['p90']
stats3['ref_p90']
# write the benchmarking results to CSV, target diagram, and taylor diagram(s)
benchmarking.write_csv(stats3, 'chl', 'chl_ref', valid_matchups, data, './chl_stats.csv')
taylor_files = benchmarking.taylor_diagrams(stats3, './chl_stats_taylor.png')
target_file = benchmarking.target_diagram(stats3, './chl_stats_target.png')
# write a density plot of the matchups
density_file = benchmarking.density_plot('chl', 'chl_ref', model_data, reference_data, target_file='./chl_density.png', unit='mg/m^3')
# write an XHTML-report from stats3
benchmarking.write_xhtml_report([stats3], valid_matchups, data, './chl_report.xml', ['./chl_stats_taylor.png'], './chl_stats_target.png', ['./chl_density.png'])
# Following: examples using custom configurations
from opec.configuration import Configuration
config = Configuration(time_delta=86400, depth_delta=2.0, alpha=0.4, beta=0.4)
m = benchmarking.get_matchups(data, config)
stats4 = benchmarking.calculate_statistics_from_matchups(m, 'chl', 'chl_ref', data, config)
stats4['rmse']
stats4['unbiased_rmse']
stats4['p90']
benchmarking.write_csv(stats4, 'chl', 'chl_ref', m, data, './chl_stats_2.csv', config)
benchmarking.taylor_diagrams(stats4, './chl_stats.png', config)