Commit 88f1ee1c authored by Kennedy, Joseph H's avatar Kennedy, Joseph H
Browse files

Update energy table

Full names for variables are now used, units have been added to the
variables, insignificant digits have been suppressed, and the CESM and
RACMO 2.3 tables have been combined.

Fixes #22, #24
parent fa641925
# coding=utf-8
import os
import numpy as np
import numpy.ma as ma
from collections import OrderedDict
from netCDF4 import Dataset
......@@ -96,16 +99,16 @@ def calculate_area_weighted_averages(config):
gris_mask = ma.masked_equal(gris_mask, 0)
area_maskice = ma.masked_array(areaices, mask=gris_mask.mask)
aavgs = {
'Sw_d': (ma.average(sw_d, weights=area_maskice)),
'Sw_net': (ma.average(sw_net, weights=area_maskice)),
'Lw_d': (ma.average(lw_d, weights=area_maskice)),
'Lw_net': (ma.average(lw_net, weights=area_maskice)),
'Rnet': (ma.average(r_net, weights=area_maskice)),
'shf': (ma.average(shf, weights=area_maskice)),
'lhf': (ma.average(lhf, weights=area_maskice)),
'smb': (ma.average(smb_gt, weights=area_maskice)),
't2c': (ma.average(t2m_c, weights=area_maskice)),
}
aavgs = OrderedDict([
('Downward shortwave radiation (W m^-2)', '{:.1f}'.format(ma.average(sw_d, weights=area_maskice))),
('Net shortwave radiation (W m^-2)', '{:.1f}'.format(ma.average(sw_net, weights=area_maskice))),
('Downward longwave radiation (W m^-2)', '{:.1f}'.format(ma.average(lw_d, weights=area_maskice))),
('Net longwave radiation (W m^-2)', '{:.1f}'.format(ma.average(lw_net, weights=area_maskice))),
('Net surface radiation (W m^-2)', '{:.1f}'.format(ma.average(r_net, weights=area_maskice))),
('Sensible heat flux (W m^-2)', '{:.1f}'.format(ma.average(shf, weights=area_maskice))),
('Latent heat flux (W m^-2)', '{:.1f}'.format(ma.average(lhf, weights=area_maskice))),
('Surface mass balance (Gt a^-1)', '{:.1f}'.format(ma.average(qice, weights=area_maskice))),
('2-meter air temperature (°C)', '{:.1f}'.format(ma.average(t2m_c, weights=area_maskice))),
])
return aavgs
# coding=utf-8
import os
import numpy as np
import numpy.ma as ma
from collections import OrderedDict
from netCDF4 import Dataset
......@@ -78,16 +81,16 @@ def calculate_area_weighted_averages(config):
gris_mask = ma.masked_equal(gris_mask, 0)
area_maskice = ma.masked_array(areaices, mask=gris_mask.mask)
aavgs = {
'Sw_d': (ma.average(sw_d, weights=area_maskice)),
'Sw_net': (ma.average(sw_net, weights=area_maskice)),
'Lw_d': (ma.average(lw_d, weights=area_maskice)),
'Lw_net': (ma.average(lw_net, weights=area_maskice)),
'Rnet': (ma.average(r_net, weights=area_maskice)),
'shf': (ma.average(shf, weights=area_maskice)),
'lhf': (ma.average(lhf, weights=area_maskice)),
'smb': (ma.average(smb, weights=area_maskice)),
't2c': (ma.average(t2m_c, weights=area_maskice)),
}
aavgs = OrderedDict([
('Downward shortwave radiation (W m^-2)', '{:.1f}'.format(ma.average(sw_d, weights=area_maskice))),
('Net shortwave radiation (W m^-2)', '{:.1f}'.format(ma.average(sw_net, weights=area_maskice))),
('Downward longwave radiation (W m^-2)', '{:.1f}'.format(ma.average(lw_d, weights=area_maskice))),
('Net longwave radiation (W m^-2)', '{:.1f}'.format(ma.average(lw_net, weights=area_maskice))),
('Net surface radiation (W m^-2)', '{:.1f}'.format(ma.average(r_net, weights=area_maskice))),
('Sensible heat flux (W m^-2)', '{:.1f}'.format(ma.average(shf, weights=area_maskice))),
('Latent heat flux (W m^-2)', '{:.1f}'.format(ma.average(lhf, weights=area_maskice))),
('Surface mass balance (Gt a^-1)', '{:.1f}'.format(ma.average(smb, weights=area_maskice))),
('2-meter air temperature (°C)', '{:.1f}'.format(ma.average(t2m_c, weights=area_maskice))),
])
return aavgs
......@@ -31,6 +31,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals
import os
from collections import OrderedDict
import livvkit
from livvkit.util import elements as el
......@@ -55,8 +56,6 @@ with fn.temp_sys_path(os.path.dirname(__file__)):
import energy.rad_aavg_racmo as racmo_rad
import energy.timeseries_trefht as ts_trefht
import energy.timeseries_qice_gt as ts_qice_gt
import energy.timeseries_qice as ts_qice
import energy.timeseries_acab as ts_acab
def run(name, config):
......@@ -78,13 +77,19 @@ def run(name, config):
cesm_aavg = cesm_rad.calculate_area_weighted_averages(config)
racmo_aavg = racmo_rad.calculate_area_weighted_averages(config)
cesm_aavg_title = """Area weighted averages of CESM's energy balance variables."""
racmo_aavg_title = """Area weighted averages of RACMO's energy balance variables."""
table_data = [(key, {'CESM': cesm_aavg[key], 'RACMO 2.3': racmo_aavg[key]}) for key in cesm_aavg.keys()]
table_dict = OrderedDict(table_data)
element_list.append(el.vtable(cesm_aavg_title, cesm_aavg.keys(), cesm_aavg))
element_list.append(el.vtable(racmo_aavg_title, racmo_aavg.keys(), racmo_aavg))
# FIXME this is using an undocumented LIVVkit table type, developed for EVE.
table_el = {'Type': 'V-H Table',
'Title': 'Validation',
'TableTitle': 'Area weighted averages of energy balance variables.',
'Headers': ['CESM', 'RACMO 2.3'],
'Data': {'': table_dict}
}
element_list.append(table_el)
# PLOTS
img_list = []
img_list.extend(cesm_albedo.make_plot(config, out_path=img_dir))
img_list.extend(cesm_latf.make_plot(config, out_path=img_dir))
......@@ -101,7 +106,6 @@ def run(name, config):
img_list.extend(ts_trefht.make_plot(config, out_path=img_dir))
img_list.extend(ts_qice_gt.make_plot(config, out_path=img_dir))
element_list.append(el.gallery('Figures', img_list))
ref_bib = utils.bib2html(config['references'])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment