本文整理匯總了Python中constants.Constants.power方法的典型用法代碼示例。如果您正苦於以下問題:Python Constants.power方法的具體用法?Python Constants.power怎麽用?Python Constants.power使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類constants.Constants
的用法示例。
在下文中一共展示了Constants.power方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Constants
# 需要導入模塊: from constants import Constants [as 別名]
# 或者: from constants.Constants import power [as 別名]
if __name__ == "__main__":
"""
Runs power dependance.
"""
constants = Constants()
hold_power = np.linspace(0.2, 0.8, num=60)
hold_x = []
hold_xx = []
for power in hold_power:
constants.power = power
experiment = Experiment(constants, Visualizer=False)
experiment.run('power_dep')
hold_x.append(experiment.spectrometer.x)
hold_xx.append(experiment.spectrometer.xx)
plt.plot(np.log10(hold_power), np.log10(hold_x), 'ro')
plt.plot(np.log10(hold_power), np.log10(hold_xx), 'bo')
idx = (np.abs(hold_power-1)).argmin()
A = np.vstack([np.log10(hold_power[0:idx]), np.ones(len(np.log10(hold_power[0:idx])))]).T
mx, cx = np.linalg.lstsq(A, np.log10(hold_x[0:idx]))[0]
mxx, cxx = np.linalg.lstsq(A, np.log10(hold_xx[0:idx]))[0]