""" This file is part of pyCMBS. (c) 2012-2014 For COPYING and LICENSE details, please refer to the file COPYRIGHT.md """ from pycmbs.data import Data import numpy as np fname = '../pycmbs/examples/example_data/air.mon.mean.nc' d = Data(fname, 'air', read=True) c = d.get_climatology(return_object=True) print 'c raw: ', c.fldmean() print c.date print '' # create some invalid data d1 = d.copy() t = d1.time * 1. d1.time[20:] = t[0:-20] d1.time[0:20] = t[-20:] tmp = d1.data * 1. d1.data[20:, :, :] = tmp[0:-20, :, :] d1.data[0:20, :, :] = tmp[-20:, :, :] c1 = d1.get_climatology(return_object=True, ensure_start_first=True) print ''
# -*- coding: utf-8 -*- """ This file is part of pyCMBS. (c) 2012- Alexander Loew For COPYING and LICENSE details, please refer to the LICENSE files """ from pycmbs.data import Data from pycmbs.plots import map_difference import matplotlib.pyplot as plt file_name = '../../../pycmbs/examples/example_data/air.mon.mean.nc' A = Data(file_name, 'air', lat_name='lat', lon_name='lon', read=True, label='air temperature') B = A.copy() B.mulc(2.3, copy=False) a = A.get_climatology(return_object=True) b = B.get_climatology(return_object=True) # a quick plot as well as a projection plot f1 = map_difference(a, b, show_stat=False, vmin=-30., vmax=30., dmin=-60., dmax=60.) # unprojected plt.show()
f=plt.figure() ax1=f.add_subplot(221) ax2=f.add_subplot(222) ax3=f.add_subplot(223) ax4=f.add_subplot(224) R,S,I,P = D.temporal_trend(return_object=True) map_plot(R, use_basemap=True, ax=ax1) map_plot(S, use_basemap=True, ax=ax2) map_plot(I, use_basemap=True, ax=ax3) map_plot(P, use_basemap=True, ax=ax4) f.suptitle('Example of temporal correlation analysis results', size=20) print 'Calculate climatology and plot ...' # get_climatology() returns 12 values which are then used for plotting map_season(D.get_climatology(return_object=True), use_basemap=True, vmin=-20., vmax=30.) print 'Map difference between datasets ...' map_difference(D,P) print 'ZonalPlot ...' Z=ZonalPlot() Z.plot(D) print 'Some LinePlot' L=LinePlot(regress=True, title='This is a LinePlot with regression') L.plot(D, label='2m air temperature') L.plot(P, label='Precipitable water', ax=L.ax.twinx(), color='green') # use secondary axis for plotting here L.legend() print 'Scatterplot between different variables ...'