本文整理汇总了Python中pycmbs.data.Data.mul_tvec方法的典型用法代码示例。如果您正苦于以下问题:Python Data.mul_tvec方法的具体用法?Python Data.mul_tvec怎么用?Python Data.mul_tvec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycmbs.data.Data
的用法示例。
在下文中一共展示了Data.mul_tvec方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: float
# 需要导入模块: from pycmbs.data import Data [as 别名]
# 或者: from pycmbs.data.Data import mul_tvec [as 别名]
# how can you easily do that with the Data object?
# 1) calculate the weights ...
# these are dependent on the number of days which you get as ...
ml = air._get_days_per_month()
print ml
w = ml / float(sum(ml)) # relative weights
print w
print 'The sum of the weights should be 1.: ', sum(w)
# 2) now we need to multiply the data with the weights and then
# sum up over time
new = air.mul_tvec(w, copy=True) # check also the other options of this routine!
res = new.timsum(return_object=True) # gives a 2D array with weighted results
print res.shape
map_plot(air, title='classical unweighted temporal mean', show_stat=True)
map_plot(res, title='weighted temporal mean', show_stat=True)
map_plot(air.sub(res), title='difference', show_stat=True, cmap_data='RdBu_r', vmin=-0.1, vmax=0.1)
# you will see that the differences are marginal, but they are nevertheless there
# for this example.
plt.show()