本文整理汇总了Python中pycmbs.data.Data.mulc方法的典型用法代码示例。如果您正苦于以下问题:Python Data.mulc方法的具体用法?Python Data.mulc怎么用?Python Data.mulc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycmbs.data.Data
的用法示例。
在下文中一共展示了Data.mulc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mean_model
# 需要导入模块: from pycmbs.data import Data [as 别名]
# 或者: from pycmbs.data.Data import mulc [as 别名]
def test_mean_model():
#The following code provides a routine that allows to validate the MeanModel() class
print ('Jetzt gehts los')
# generate some sample data ---
x = Data(None, None)
x.data = np.random.random((10,20,30))
x.label='nothing'
y = x.mulc(0.3)
z = x.mulc(0.5)
m = x.add(y).add(z).divc(3.)
r = m.div(x) # gives 0.6 as reference solution
# generate Model instances and store Data objects as 'variables' ---
dic_variables = ['var1', 'var2']
X = Model(None, dic_variables, name='x', intervals='season')
X.variables = {'var1': x, 'var2': x}
Y = Model(None, dic_variables, name='y', intervals='season')
Y.variables = {'var1': y, 'var2': y}
Z = Model(None, dic_variables, name='z', intervals='season')
Z.variables={'var1': z, 'var2': z}
#... now try multimodel ensemble
M=MeanModel(dic_variables,intervals='season')
M.add_member(X)
M.add_member(Y)
M.add_member(Z)
M.ensmean() # calculate ensemble mean
# print M.variables['var2'].div(x).data #should give 0.6
npt.assert_equal(np.all(np.abs(1. - M.variables['var2'].div(x).data/0.6) < 0.00000001), True)