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

The clouds extension should now work on Rhea (only)

parent 4637d767
......@@ -4,8 +4,13 @@ import numpy as np
from netCDF4 import Dataset
from livvkit.util import elements as el
def make_plot(out_path='.',
describe = """CESM_cldhgh_ANN plot."""
def make_plot(config=None, out_path='.',
cloud_path='/lustre/atlas1/cli115/world-shared/4ue/obs_data/',
cism_path='/lustre/atlas1/cli115/world-shared/4ue/',
cesm_path='/lustre/atlas1/cli115/world-shared/4ue/b.e10.BG20TRCN.f09_g16.002/'):
......@@ -16,6 +21,8 @@ def make_plot(out_path='.',
f_cloudsat = os.path.join(cloud_path, 'CLOUDSAT_ANN_climo.nc')
# --------------------------------------------------------------
img_list = []
# read f_cism, the elevation data
cism = Dataset(f_cism)
cism_usrf = cism.variables['usrf'][0, :, :]
......@@ -56,7 +63,8 @@ def make_plot(out_path='.',
wkres.wkColorMap = "BlueWhiteOrangeRed"
wkres.wkOrientation = "portrait"
wks_type = "png"
wks = Ngl.open_wks(wks_type, os.path.join(out_path, 'CESM_cldhgh_ANN'), wkres)
wks_img = os.path.join(out_path, 'CESM_cldhgh_ANN')
wks = Ngl.open_wks(wks_type, wks_img, wkres)
# --- for the map -------
# Define plotting area, Greenland
......@@ -178,6 +186,17 @@ def make_plot(out_path='.',
Ngl.end()
img_link = os.path.join(os.path.basename(out_path),
os.path.basename(wks_img + '.' + wks_type))
img_elem = el.image('CESM_cldhgh_ANN',
' '.join(describe.split()),
img_link)
if config:
img_elem['Height'] = config['image_height']
img_list.append(img_elem)
return img_list
if __name__ == '__main__':
make_plot()
......@@ -4,8 +4,13 @@ import numpy as np
from netCDF4 import Dataset
from livvkit.util import elements as el
def make_plot(out_path='.',
describe = """CESM_cldlow_ANN plot."""
def make_plot(config=None, out_path='.',
cloud_path='/lustre/atlas1/cli115/world-shared/4ue/obs_data/',
cism_path='/lustre/atlas1/cli115/world-shared/4ue/',
cesm_path='/lustre/atlas1/cli115/world-shared/4ue/b.e10.BG20TRCN.f09_g16.002/'):
......@@ -16,6 +21,8 @@ def make_plot(out_path='.',
f_cloudsat = os.path.join(cloud_path, 'CLOUDSAT_ANN_climo.nc')
# --------------------------------------------------------------
img_list = []
# read f_cism, the elevation data
cism = Dataset(f_cism)
cism_usrf = cism.variables['usrf'][0, :, :]
......@@ -57,7 +64,8 @@ def make_plot(out_path='.',
wkres.wkColorMap = "BlueWhiteOrangeRed"
wkres.wkOrientation = "portrait" # "portrait" or "landscape"
wks_type = "png"
wks = Ngl.open_wks(wks_type, os.path.join(out_path, "CESM_cldlow_ANN"), wkres)
wks_img = os.path.join(out_path, "CESM_cldlow_ANN")
wks = Ngl.open_wks(wks_type, wks_img, wkres)
# --- for the map -------
# Define plotting area, Greenland
......@@ -179,6 +187,17 @@ def make_plot(out_path='.',
Ngl.end()
img_link = os.path.join(os.path.basename(out_path),
os.path.basename(wks_img + '.' + wks_type))
img_elem = el.image('CESM_cldlow_ANN',
' '.join(describe.split()),
img_link)
if config:
img_elem['Height'] = config['image_height']
img_list.append(img_elem)
return img_list
if __name__ == '__main__':
make_plot()
......@@ -4,8 +4,13 @@ import numpy as np
from netCDF4 import Dataset
from livvkit.util import elements as el
def make_plot(out_path='.',
describe = """CESM_cldtot_ANN plot."""
def make_plot(config=None, out_path='.',
cloud_path='/lustre/atlas1/cli115/world-shared/4ue/obs_data/',
cism_path='/lustre/atlas1/cli115/world-shared/4ue/',
cesm_path='/lustre/atlas1/cli115/world-shared/4ue/b.e10.BG20TRCN.f09_g16.002/'):
......@@ -15,7 +20,9 @@ def make_plot(out_path='.',
f_isccp = os.path.join(cloud_path, 'ISCCP_ANN_climo.nc')
f_cloudsat = os.path.join(cloud_path, 'CLOUDSAT_ANN_climo.nc')
# --------------------------------------------------------------
img_list = []
# read f_cism, the elevation data
cism = Dataset(f_cism)
cism_usrf = cism.variables['usrf'][0, :, :]
......@@ -57,7 +64,8 @@ def make_plot(out_path='.',
wkres.wkColorMap = "BlueWhiteOrangeRed"
wkres.wkOrientation = "portrait" # "portrait" or "landscape"
wks_type = "png"
wks = Ngl.open_wks(wks_type, os.path.join(out_path, "CESM_cldtot_ANN"), wkres)
wks_img = os.path.join(out_path, "CESM_cldtot_ANN")
wks = Ngl.open_wks(wks_type, wks_img, wkres)
# --- for the map -------
# Define plotting area, Greenland
......@@ -179,6 +187,17 @@ def make_plot(out_path='.',
Ngl.end()
img_link = os.path.join(os.path.basename(out_path),
os.path.basename(wks_img + '.' + wks_type))
img_elem = el.image('CESM_cldhgh_ANN',
' '.join(describe.split()),
img_link)
if config:
img_elem['Height'] = config['image_height']
img_list.append(img_elem)
return img_list
if __name__ == '__main__':
make_plot()
import pybtex.database
import pybtex.io
from pybtex.backends.html import Backend as BaseBackend
from pybtex.style.formatting.plain import Style as PlainStyle
class HTMLBackend(BaseBackend):
def __init__(self, *args, **kwargs):
super(HTMLBackend, self).__init__(*args, **kwargs)
self._html = ''
def output(self, html):
self._html += html
def format_protected(self, text):
if text[:4] == 'http':
return self.format_href(text, text)
else:
return r'<span class="bibtex-protected">{}</span>'.format(text)
def write_prologue(self):
self.output('<div class="bibliography"><dl>')
def write_epilogue(self):
self.output('</dl></div>')
def _repr_html(self, formatted_bibliography):
self.write_prologue()
for entry in formatted_bibliography:
self.write_entry(entry.key, entry.label, entry.text.render(self))
self.write_epilogue()
return self._html.replace('\n', ' ').replace('\\url <a', '<a')
def bib2html(bib_file):
style = PlainStyle()
backend = HTMLBackend()
bib = pybtex.database.parse_file(bib_file)
fbib = style.format_bibliography(bib)
return backend._repr_html(fbib)
......@@ -4,11 +4,18 @@ import matplotlib.pyplot as plt
from netCDF4 import Dataset
from livvkit.util import elements as el
def make_plot(out_path='.',
describe = """yearly_cycle_cldhgh plot."""
def make_plot(config=None, out_path='.',
cloud_path='/lustre/atlas1/cli115/world-shared/4ue/obs_data/',
cesm_path='/lustre/atlas1/cli115/world-shared/4ue/b.e10.BG20TRCN.f09_g16.002/'):
img_list = []
months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
percent_vals = []
model_vals = []
......@@ -51,9 +58,21 @@ def make_plot(out_path='.',
plt.plot(months, isccp_vals, 'c-.')
plt.xlabel('Months of climatology')
plt.ylabel('Percent total cloud')
plt.savefig(os.path.join(out_path, 'CESM_yearly_cycle_CLDHGH.png'), bbox_inches='tight')
img_path = os.path.join(out_path, 'CESM_yearly_cycle_CLDHGH.png')
plt.savefig(img_path, bbox_inches='tight')
plt.close()
img_link = os.path.join(os.path.basename(out_path),
os.path.basename(img_path))
img_elem = el.image('yearly_cycle_cldhgh',
' '.join(describe.split()),
img_link)
if config:
img_elem['Height'] = config['image_height']
img_list.append(img_elem)
return img_list
if __name__ == '__main__':
plt.switch_backend('agg')
......
......@@ -4,11 +4,18 @@ import matplotlib.pyplot as plt
from netCDF4 import Dataset
from livvkit.util import elements as el
def make_plot(out_path='.',
describe = """yearly_cycle_cldlow plot."""
def make_plot(config=None, out_path='.',
cloud_path='/lustre/atlas1/cli115/world-shared/4ue/obs_data/',
cesm_path='/lustre/atlas1/cli115/world-shared/4ue/b.e10.BG20TRCN.f09_g16.002/'):
img_list = []
months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
percent_vals = []
model_vals = []
......@@ -52,9 +59,21 @@ def make_plot(out_path='.',
plt.plot(months, isccp_vals, 'c-.')
plt.xlabel('Months of climatology')
plt.ylabel('Percent total cloud')
plt.savefig(os.path.join(out_path, 'CESM_yearly_cycle_CLDLOW.png'), bbox_inches='tight')
img_path = os.path.join(out_path, 'CESM_yearly_cycle_CLDLOW.png')
plt.savefig(img_path, bbox_inches='tight')
plt.close()
img_link = os.path.join(os.path.basename(out_path),
os.path.basename(img_path))
img_elem = el.image('yearly_cycle_cldlow',
' '.join(describe.split()),
img_link)
if config:
img_elem['Height'] = config['image_height']
img_list.append(img_elem)
return img_list
if __name__ == '__main__':
plt.switch_backend('agg')
......
......@@ -4,11 +4,18 @@ import matplotlib.pyplot as plt
from netCDF4 import Dataset
from livvkit.util import elements as el
def make_plot(out_path='.',
describe = """yearly_cycle_cldtot plot."""
def make_plot(config=None, out_path='.',
cloud_path='/lustre/atlas1/cli115/world-shared/4ue/obs_data/',
cesm_path='/lustre/atlas1/cli115/world-shared/4ue/b.e10.BG20TRCN.f09_g16.002/'):
img_list = []
months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']
percent_vals = []
model_vals = []
......@@ -52,9 +59,21 @@ def make_plot(out_path='.',
plt.plot(months, isccp_vals, 'c-.')
plt.xlabel('Months of climatology')
plt.ylabel('Percent total cloud')
plt.savefig(os.path.join(out_path, 'CESM_yearly_cycle_CLDTOT.png'), bbox_inches='tight')
img_path = os.path.join(out_path, 'CESM_yearly_cycle_CLDTOT.png')
plt.savefig(img_path, bbox_inches='tight')
plt.close()
img_link = os.path.join(os.path.basename(out_path),
os.path.basename(img_path))
img_elem = el.image('yearly_cycle_cldtot',
' '.join(describe.split()),
img_link)
if config:
img_elem['Height'] = config['image_height']
img_list.append(img_elem)
return img_list
if __name__ == '__main__':
plt.switch_backend('agg')
......
{
"clouds_cesm" : {
"module" : "clouds/clouds_cesm.py",
"description" : "An analysis of CESM's cloud cover over Greenland.",
"references" : "clouds/clouds_cesm.bib",
"directions" : "Put any declarations you need here."
"image_height" : 300
}
}
......@@ -26,10 +26,8 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""An analysis of CESM's cloud cover over Greenland."""
"""
This template provides an example of a minimal LIVVkit extension.
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import os
......@@ -39,12 +37,14 @@ from livvkit.util import elements as el
from livvkit.util import functions as fn
with fn.temp_sys_path(os.path.dirname(__file__)):
import clouds.CESM_cldhgh_ANN as clouds_high
import clouds.CESM_cldlow_ANN as clouds_low
import clouds.CESM_cldtot_ANN as clouds_total
import clouds.yearly_cycle_CLDHGH as yrly_high
import clouds.yearly_cycle_CLDLOW as yrly_low
import clouds.yearly_cycle_CLDTOT as yrly_total
import clouds.utils as utils
import clouds.cesm_cldhgh_ann as clouds_high
import clouds.cesm_cldlow_ann as clouds_low
import clouds.cesm_cldtot_ann as clouds_total
import clouds.yearly_cycle_cldhgh as yrly_high
import clouds.yearly_cycle_cldlow as yrly_low
import clouds.yearly_cycle_cldtot as yrly_total
def run(name, config):
......@@ -59,16 +59,28 @@ def run(name, config):
A LIVVkit page element containing the LIVVkit elements to display on a webpage
"""
print(livvkit.__file__)
print(clouds_high.__file__)
print(clouds_low.__file__)
print(clouds_total.__file__)
print(yrly_high.__file__)
print(yrly_low.__file__)
print(yrly_total.__file__)
img_dir = os.path.join(livvkit.output_dir, 'validation', 'imgs', name)
fn.mkdir_p(img_dir)
# PLOTS
img_list = []
img_list.extend(clouds_high.make_plot())
img_list.extend(clouds_low.make_plot())
img_list.extend(clouds_total.make_plot())
img_list.extend(yrly_high.make_plot())
img_list.extend(yrly_low.make_plot())
img_list.extend(yrly_total.make_plot())
element_list = [el.gallery('Figures', img_list)]
ref_bib = utils.bib2html(config['references'])
element_list.append(el.html(' '.join(['<div class="references"><h3>References</h3>',
'If you use this LIVVkit extension for any part of your',
'modeling or analyses, please cite:' + ref_bib + '</div>',
])
))
element_list = [el.error("Unimplemented test", "This test contains no analysis code!")]
return el.page(name, config['description'], element_list)
return el.page(name, __doc__, element_list)
def print_summary(summary):
......
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