Skip to content

Commit

Permalink
Version of code as of submission of revised JAMES paper.
Browse files Browse the repository at this point in the history
  • Loading branch information
quantheory committed Feb 24, 2021
1 parent b289705 commit 633b8c0
Show file tree
Hide file tree
Showing 4 changed files with 492 additions and 56 deletions.
43 changes: 38 additions & 5 deletions plot_dynamics_attribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,37 @@
REF_CASE = E3SMCaseOutput("timestep_presaer_ctrl", "CTRLPA", MONTHLY_FILE_LOC, START_MONTH, END_MONTH)
TEST_CASES = [
]
STYLES = {
"CLUBBMICRO10PA": ('indigo', '-'),
"ALL10PA": ('dimgrey', '-'),
"ZM10PA": ('g', '-'),
"CLUBBMICRO10ZM10PA": ('saddlebrown', '-'),
"CLD10PA": ('slateblue', '-'),
"ALL10LTPA": ('dimgrey', '-.'),
"ZM10LTPA": ('g', '-.'),
"CLUBBMICRO10ZM10LTPA": ('saddlebrown', '-.'),
"CLD10LTPA": ('slateblue', '-.'),
"CLD10LT2PA": ('slateblue', ':'),
}
else:
REF_CASE = E3SMCaseOutput("timestep_ctrl", "CTRL", MONTHLY_FILE_LOC, START_MONTH, END_MONTH)
TEST_CASES = [
E3SMCaseOutput("timestep_all_10s", "ALL10", MONTHLY_FILE_LOC, START_MONTH, END_MONTH),
]
STYLES = {
"DYN10": ('y', '-'),
"CLUBB10": ('b', '-'),
"MICRO10": ('r', '-'),
"CLUBB10MICRO10": ('maroon', '-'),
"CLUBBMICROSTR": ('m', '-'),
"CLUBBMICROSTR60": ('m', '--'),
"CLUBBMICRO60": ('indigo', '--'),
"CLUBBMICRO10": ('indigo', '-'),
"ALL10": ('r', '-'),
"ALL60": ('dimgrey', '--'),
"ALL300": ('dimgrey', ':'),
"ALLRAD10": ('orange', '-'),
}

case_num = len(TEST_CASES)

Expand Down Expand Up @@ -208,9 +234,13 @@ def plot_dyn_attr(names, units, scales, log_plot_names):
test_total_dists[i][name] += test_var_dists[i][name]*scales[name] / nmonths

omegas = 864.*np.linspace(omega_span[0] + 0.5*bin_size, omega_span[1] - 0.5*bin_size, nbins)
plt.plot(omegas, ref_total_pdf / bin_size, label=REF_CASE.short_name)
plt.semilogy(omegas, ref_total_pdf / bin_size, label=REF_CASE.short_name,
color='k')
for i in range(case_num):
plt.plot(omegas, test_total_pdfs[i] / bin_size, label=TEST_CASES[i].short_name)
plt.semilogy(omegas, test_total_pdfs[i] / bin_size,
label=TEST_CASES[i].short_name,
color=STYLES[TEST_CASES[i].short_name][0],
linestyle=STYLES[TEST_CASES[i].short_name][1])
plt.axis('tight')
plt.xlabel(r'$\omega_{500}$')
plt.ylabel(r'$p(\omega_{500})$')
Expand All @@ -231,12 +261,14 @@ def plot_dyn_attr(names, units, scales, log_plot_names):
else:
plot_var = plt.plot
ref_plot_var = get_2D(ref_total_dists[name]) * ref_total_pdf
plot_var(omegas, ref_plot_var, label=REF_CASE.short_name)
plot_var(omegas, ref_plot_var, label=REF_CASE.short_name, color='k')
for i in range(case_num):
test_plot_var = get_2D(test_total_dists[i][name]) * test_total_pdfs[i]
plot_var(omegas,
test_plot_var,
label=TEST_CASES[i].short_name)
label=TEST_CASES[i].short_name,
color=STYLES[TEST_CASES[i].short_name][0],
linestyle=STYLES[TEST_CASES[i].short_name][1])
print(name, " for case ", TEST_CASES[i].short_name, " has total diff ",
(test_plot_var - ref_plot_var).sum(),
file=log_file, flush=True)
Expand Down Expand Up @@ -360,7 +392,8 @@ def plot_dyn_attr(names, units, scales, log_plot_names):
'TMQ': r'$kg/m^2$',
'T': r'$K$',
}
names = list(units.keys())
#names = list(units.keys())
names = ['PRECC', 'PRECL', 'PRECT', 'OMEGA500']
scales = dict()
for name in names:
scales[name] = 1.
Expand Down
Loading

0 comments on commit 633b8c0

Please sign in to comment.