Skip to content

Commit

Permalink
Merge pull request #489 from PCMDI/334_monsoon_wang_charles_review
Browse files Browse the repository at this point in the history
334 monsoon wang charles review [WIP]
  • Loading branch information
gleckler1 committed Jan 20, 2018
2 parents 5ee208b + 1215ca0 commit dddf781
Show file tree
Hide file tree
Showing 33 changed files with 5,308 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
os:
- linux
# - osx
# - osx
language: python
- "2.7"

Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@
'pcmdi_metrics.diurnal': 'src/python/diurnal',
'pcmdi_metrics.graphics': 'src/python/graphics',
'pcmdi_metrics.driver': 'src/python/pcmdi/scripts/driver',
'pcmdi_metrics.monsoon_wang': 'src/python/monsoon_wang/lib',
}
scripts = ['src/python/pcmdi/scripts/pcmdi_metrics_driver.py',
'src/python/pcmdi/scripts/pcmdi_metrics_driver_legacy.py',
'src/python/pcmdi/scripts/pcmdi_compute_climatologies.py',
'src/python/misc/scripts/install_metrics_from_branches.py',
'demo/pmp_demo_1.py',
'demo/pmp_demo.py',
'src/python/monsoon_wang/scripts/mpindex_compute.py',
]
scripts += glob.glob("src/python/diurnal/scripts/*.py")

Expand Down
1 change: 1 addition & 0 deletions share/default_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"PDO": {'domain': cdutil.region.domain(latitude=(20., 70), longitude=(110, 260))},
# Below is for monsoon domains
# All monsoon domains
'AllMW': {'domain': cdutil.region.domain(latitude=(-40., 45.), longitude=(0., 360.))},
'AllM': {'domain': cdutil.region.domain(latitude=(-45., 45.), longitude=(0., 360.))},
# North American Monsoon
'NAMM': {'domain': cdutil.region.domain(latitude=(0., 45.), longitude=(210., 310.))},
Expand Down
12 changes: 12 additions & 0 deletions src/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
# put here the impor calls to expose whatever we want to the user
import logging
LOG_LEVEL = logging.DEBUG
plog = logging.getLogger("pcmdi_metrics")
# create console handler
ch = logging.StreamHandler()
ch.setLevel(LOG_LEVEL)
# create formatter and add it to the handlers
formatter = logging.Formatter('%(levelname)s::%(asctime)s::%(name)s:: %(message)s', datefmt="%Y-%m-%d %H:%M")
ch.setFormatter(formatter)
# add the handler to the logger
plog.addHandler(ch)
plog.setLevel(LOG_LEVEL)
import io # noqa
import pcmdi # noqa
from version import __version__, __git_sha1__, __git_tag_describe__ # noqa
93 changes: 93 additions & 0 deletions src/python/devel/monsoon_wang/graphics/SeabarChart_mpl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import numpy as np
import matplotlib.pyplot as PLT
import sys
import pdb


class BarChart(object):

def __init__(self, mods, data, uni, fig=None, rect=111, **kwargs):

print 'IN FCN..... '

# Canvas setup
if fig is None:
fig = PLT.figure
ax = fig.add_subplot(rect)

# Enable to control ax options outside of this file
self._ax = ax

# Axis setup
unit_adjust = 1.
if 'yaxis_label' in kwargs:
unit = kwargs['label']
else:
unit = uni # 'Unit needed here ...'
print 'data above max '
ymax = max(data)
ymin = min(data)
# yint = float((ymax-ymin)/3.) # REPLACE INT WITH FLOAT
yint = .004

# Array setup
num_mods = len(mods)
x = np.linspace(0, num_mods - 1, num_mods)
y = np.array(data) * unit_adjust
labels = mods

# Plotting
ax.bar(x, y, bottom=0, align='center', color='b')
# JS: add the bars for each simulation
if 'highlights' in kwargs:
highlights = kwargs['highlights']
# -- Dealing with the colors
if 'colors' in kwargs:
colors = str.split(kwargs['colors'], ',')
if len(colors) != len(highlights):
if len(colors) == 1:
# -- if we provide only one color, we will use it for every highlighted simulation
colors = colors * len(highlights)
else:
# -- if we didn't provide enough colors (for the number of simulations),
# we will use green as a default
tmpcolors = ['g'] * len(highlights)
for i in xrange(len(colors)):
tmpcolors[i] = colors[i]
colors = tmpcolors
else:
colors = ['g'] * len(highlights)
print 'highlights = ', highlights
for highlight in highlights:
y_highlight = [0] * len(y)

y_highlight[mods.index(highlight)] = y[mods.index(highlight)]
ax.bar(x, y_highlight, bottom=0, align='center',
color=colors[highlights.index(highlight)])
ax.axhline(0, color='black')

# Title and axis
ax.set_title('Subtitle needed here..')
ax.set_xlabel('Models')
ax.set_ylabel(unit)
ax.set_xlim([-1., len(y) - 0.5])
ax.set_ylim([y.min() * 1.1, y.max() * 1.1])
ax.grid(True)

# Axis labels
# Label x-axis as model names
PLT.xticks(x, labels, rotation='vertical')
ax.yaxis.set_ticks(np.arange(int(ymin - yint), int(ymax + yint), yint))

# Multi model mean / std. dev. / min / max
yave = np.mean(y)
ystd = np.std(y)
ymin = np.amin(y)
ymax = np.amax(y)

ax.plot(-0.7, yave, 'x', c='red', markersize=12) # ave
ax.plot(-0.7, ymin, '+', c='red', markersize=12) # min
ax.plot(-0.7, ymax, '+', c='red', markersize=12) # max
# inter-model std. dev.
ax.errorbar(-0.7, yave, yerr=ystd, ls='solid',
color='red', linewidth=1)
2 changes: 2 additions & 0 deletions src/python/devel/monsoon_wang/graphics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from taylorDiagram import TaylorDiagram # noqa
from SeabarChart_mpl import BarChart # noqa
Loading

0 comments on commit dddf781

Please sign in to comment.