def test_GlecklerPlot(self): G = GlecklerPlot() G.add_model('echam5') G.add_model('mpi-esm') G.add_variable('ta') G.add_variable('P') G.add_data('ta', 'echam5', 0.5, pos=1) G.add_data('P', 'echam5', 0.25, pos=1) G.add_data('P', 'echam5', -0.25, pos=2) G.add_data('P', 'mpi-esm', -0.25, pos=1) G.plot() G.plot_model_error('ta') G.plot_model_ranking('ta') G.write_ranking_table('ta', self._tmpdir + os.sep + 'nix.tex', fmt='latex') self.assertTrue(os.path.exists(self._tmpdir + os.sep + 'nix.tex')) if os.path.exists(self._tmpdir + os.sep + 'nix.tex'): os.remove(self._tmpdir + os.sep + 'nix.tex') G.write_ranking_table('ta', self._tmpdir + os.sep + 'nix1', fmt='latex') self.assertTrue(os.path.exists(self._tmpdir + os.sep + 'nix1.tex')) if os.path.exists(self._tmpdir + os.sep + 'nix1.tex'): os.remove(self._tmpdir + os.sep + 'nix1.tex')
def test_GlecklerPlot_4obs(self): G = GlecklerPlot() G.add_model('echam5') G.add_model('mpi-esm') G.add_variable('ta') G.add_variable('P') G.add_data('P', 'echam5', 0.5, pos=1) G.add_data('P', 'echam5', 0.25, pos=2) G.add_data('P', 'echam5', -0.25, pos=3) G.add_data('P', 'mpi-esm', -0.25, pos=4) G.plot()
def test_GlecklerPlot_4obs(self): G = GlecklerPlot() G.add_model('echam5') G.add_model('mpi-esm') G.add_variable('ta') G.add_variable('P') G.add_data('P', 'echam5', 0.5,pos=1) G.add_data('P', 'echam5',0.25,pos=2) G.add_data('P', 'echam5',-0.25,pos=3) G.add_data('P', 'mpi-esm',-0.25,pos=4) G.plot()
def test_GlecklerPlot_InvalidNumberOfObservations(self): G = GlecklerPlot() G.add_model('echam5') G.add_model('mpi-esm') G.add_variable('ta') G.add_data('ta', 'echam5', 0.5, pos=1) G.add_data('ta', 'echam5', 0.25, pos=2) G.add_data('ta', 'echam5', -0.25, pos=3) G.add_data('ta', 'mpi-esm', -0.25, pos=4) G.add_data('ta', 'mpi-esm', -0.25, pos=5) with self.assertRaises(ValueError): G.plot()
def test_GlecklerPlot_InvalidNumberOfObservations(self): G = GlecklerPlot() G.add_model('echam5') G.add_model('mpi-esm') G.add_variable('ta') G.add_data('ta', 'echam5', 0.5,pos=1) G.add_data('ta', 'echam5',0.25,pos=2) G.add_data('ta', 'echam5',-0.25,pos=3) G.add_data('ta', 'mpi-esm',-0.25,pos=4) G.add_data('ta', 'mpi-esm',-0.25,pos=5) with self.assertRaises(ValueError): G.plot()
def test_GlecklerPlot(self): G = GlecklerPlot() G.add_model('echam5') G.add_model('mpi-esm') G.add_variable('ta') G.add_variable('P') G.add_data('ta', 'echam5', 0.5,pos=1) G.add_data('P', 'echam5',0.25,pos=1) G.add_data('P', 'echam5',-0.25,pos=2) G.add_data('P', 'mpi-esm',-0.25,pos=1) G.plot() G.plot_model_error('ta') G.plot_model_ranking('ta') G.write_ranking_table('ta', self._tmpdir + os.sep + 'nix.tex', fmt='latex') self.assertTrue(os.path.exists(self._tmpdir + os.sep + 'nix.tex')) if os.path.exists(self._tmpdir + os.sep + 'nix.tex'): os.remove(self._tmpdir + os.sep + 'nix.tex') G.write_ranking_table('ta', self._tmpdir + os.sep + 'nix1', fmt='latex') self.assertTrue(os.path.exists(self._tmpdir + os.sep + 'nix1.tex')) if os.path.exists(self._tmpdir + os.sep + 'nix1.tex'): os.remove(self._tmpdir + os.sep + 'nix1.tex')
# -*- coding: utf-8 -*- from pycmbs.plots import GlecklerPlot import matplotlib.pyplot as plt # this is just an artificial example illustrating principle usage of the # Portraet diagram fig = plt.figure(figsize=(8, 6)) G = GlecklerPlot(fig=fig) # register models G.add_model('MPI-ESM-MR') G.add_model('MPI-ESM-LR') G.add_model('MPI-ESM-P') # then register variables G.add_variable('Ta') G.add_variable('P') # after that you can add values to be plotted # pos=1 top triangle, pos2= lower triangle # different positions are for different observations G.add_data('Ta', 'MPI-ESM-MR', 0.5, pos=1) G.add_data('Ta', 'MPI-ESM-MR', -0.2, pos=2) G.add_data('Ta', 'MPI-ESM-LR', 0.3, pos=1) G.add_data('Ta', 'MPI-ESM-LR', 0.2, pos=2) G.add_data('Ta', 'MPI-ESM-P', 0.05, pos=1) G.add_data('Ta', 'MPI-ESM-P', -0.1, pos=2)
This file is part of pyCMBS. (c) 2012- Alexander Loew For COPYING and LICENSE details, please refer to the LICENSE file """ from pycmbs.plots import GlecklerPlot import matplotlib.pyplot as plt # this is just an artificial example illustrating principle usage of the # Portraet diagram fig = plt.figure(figsize=(8,6)) G = GlecklerPlot(fig=fig) # register models G.add_model('MPI-ESM-MR') G.add_model('MPI-ESM-LR') G.add_model('MPI-ESM-P') # then register variables G.add_variable('Ta') G.add_variable('P') # after that you can add values to be plotted # pos=1 top triangle, pos2= lower triangle # different positions are for different observations G.add_data('Ta','MPI-ESM-MR',0.5,pos=1) G.add_data('Ta','MPI-ESM-MR',-0.2,pos=2) G.add_data('Ta','MPI-ESM-LR',0.3,pos=1) G.add_data('Ta','MPI-ESM-LR',0.2,pos=2)