当前位置: 首页>>代码示例>>Python>>正文


Python Data._get_days_per_month方法代码示例

本文整理汇总了Python中pycmbs.data.Data._get_days_per_month方法的典型用法代码示例。如果您正苦于以下问题:Python Data._get_days_per_month方法的具体用法?Python Data._get_days_per_month怎么用?Python Data._get_days_per_month使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pycmbs.data.Data的用法示例。


在下文中一共展示了Data._get_days_per_month方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sum

# 需要导入模块: from pycmbs.data import Data [as 别名]
# 或者: from pycmbs.data.Data import _get_days_per_month [as 别名]
print air.date

# obviously the different months have different numbers of days.
# Let's say you want now to perform a proper averaging of the data
# taking into account the different lengths of the months
#
# the way how you would do it is like
# y = sum(w[i] * x[i])
# whereas w is a weighting factor for each timestep and 'x' is the input data

# 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)
开发者ID:jian-peng,项目名称:pycmbs,代码行数:33,代码来源:scale_by_month_length.py


注:本文中的pycmbs.data.Data._get_days_per_month方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。