我正在使用Python Scipy我有下一个代码:
<!DOCTYPE html>
<head>
<link rel="stylesheet" style="text/css" href="annie.css">
<script src="js/visible.js"></script>
<script src="js/jquery-3.1.1.js"></script>
<script src="js/jquery.visible.min.js"></script>
<script src="js/checkVisible.js"></script>
</head>
<body>
<div id="nav">
<div id="logo"><img id="logo_img" src="images/annie2.gif"></div>
<div id="navbar">
<p class="hdr">SHOP</p>
<p class="hdr">JOBS</p>
<p class="hdr">ABOUT US</p>
<p class="hdr">BOOKINGS</p>
<p class="hdr">PAYMENTS</p>
</div>
</div>
<div class="holder">
<div id="lh_top_bar">
<div id="lh_top_bar_text">ANNIE</div>
</div>
<div id="rh_top_bar"></div>
<div id="lh_bar">
<div id="line"></div>
<div id="lh_bar_text">Collection 2016/2017</div>
</div>
<div class="image1">
<img class="cs--img1" src="images/shoe_black_pair_small.jpg" alt="black shoe">
</div>
<div id="rh_bar">
<div id="rh_bar_text">We will be at White Show January 20, 2017</div>
</div>
<div id="bottom_bar">
<div id="discover">DISCOVER COLLECTION</div>
<div id="lh_bottom_bar"></div>
<div id="rh_bottom_bar"></div>
</div>
</div>
<div class="holder2">
<div id="lh_top_bar">
<div id="lh_top_bar_text">ANNIE</div>
</div>
<div id="rh_top_bar"></div>
<div id="lh_bar">
<div id="line"></div>
<div id="lh_bar_text">Collection 2016/2017</div>
</div>
<div class="image1">
<img class="cs--img1" src="images/canstockphoto28075264.jpg" alt="gucci">
<!-- ID="COVER" -->
<div id="cover"></div>
</div>
<div id="rh_bar">
<div id="rh_bar_text">Instagram</div>
</div>
<div id="bottom_bar">
<div id="discover">INFO@DANNIECOLLECTIONS.COM</div>
<div id="lh_bottom_bar"></div>
<div id="rh_bottom_bar"></div>
<div id="copyright">© 2016 ALL RIGHTS RESERVED ANNIE COLLECTIONS</div>
</div>
</div>
</body>
</html>
我的最后一个函数...
t = np.linspace(0, simtime, points)
def Vbooster90(t):
return np.sin(t * 2 * np.pi*F_booster + 0.5 * np.pi)
def beam(t):
return np.sign(Vrfq(t) - Vrfq(bunchwidth)) * 0.5 + 0.5
def criteria(t):
return np.sign(Vbooster90(t))
def kicker(t):
if criteria(t) > 0:
k(t)=beam(t)
else:
k(t)=0
return k(t)
有问题。我想在t的每个值中将函数kicker(t)
与零进行比较,如果criteria(t)
大于零,我想将criteria(t)
赋给函数{{1}的值在相同的t值。我是Python新手,不熟悉语法。
答案 0 :(得分:0)
修改kicker
函数,如下所示。
def kicker(t):
k = 0
if criteria(t) > 0:
k = beam(t)
return k
答案 1 :(得分:0)
感谢您的回答,而不是定义一个函数,我接下来解决了它:
kicker = np.empty(points)
i = np.arange(points)
time = np.empty(points)
time[i] = i*simtime/points
for i in range(points):
if criteria(time[i]) > 0:
kicker[i] = beam(time[i])
else:
kicker[i] = 0