Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
while t < 6:
if t > 3:
if worker == 'CPython':
t0 = now
n = 0
a = step_numba(dt, size, a)
worker = 'Numba'
else:
a = step(dt, size, a)
gr.clearws()
gr.setmarkercolorind(75)
gr.polymarker(a[0, :, 0], a[0, :, 1])
if n > 0:
gr.text(0.01, 0.95, '%10s: %4d fps' % (worker, int(n / (now - t0))))
gr.updatews()
now = time.time()
n += 1
t = now - start
start = time.time()
while time.time() - start < 10:
try:
power = get_spectrum()
peakind = signal.find_peaks_cwt(power, np.array([5]))
except (IOError):
continue
gr.clearws()
gr.setlinewidth(1)
gr.setlinecolorind(1)
gr.grid(1, 5, 50, 0, 1, 2)
gr.axes(1, 5, 50, 0, 1, 2, -0.008)
gr.setcharheight(0.020)
gr.text(0.15, 0.965, '100Hz')
gr.text(0.47, 0.965, '1kHz')
gr.text(0.79, 0.965, '10kHz')
gr.setlinecolorind(4)
gr.polyline(f[1:], power[1:])
for p in peakind:
if power[p] > 10:
gr.setlinewidth(2)
gr.setlinecolorind(2)
xe, ye = parabolic(f[p], power, p)
print(xe, ye)
gr.polyline([xe] * 2, [0, ye])
gr.updatews()
while t < 6:
if t > 3:
if worker == 'CPython':
t0 = now
n = 0
a = step_numba(dt, size, a)
worker = 'Numba'
else:
a = step(dt, size, a)
gr.clearws()
gr.setmarkercolorind(75)
gr.polymarker(a[0, :, 0], a[0, :, 1])
if n > 0:
gr.text(0.01, 0.95, '%10s: %4d fps' % (worker, int(n / (now - t0))))
gr.updatews()
now = time.time()
n += 1
t = now - start
self._draw_mathtext(gc, x, y, s, prop, angle)
else:
x, y = gr.wctondc(x, y)
fontsize = prop.get_size_in_points()
rgba = gc.get_rgb()[:4]
color = gr.inqcolorfromrgb(rgba[0], rgba[1], rgba[2])
gr.settransparency(rgba[3])
gr.setcolorrep(color, rgba[0], rgba[1], rgba[2])
gr.setcharheight(fontsize * self.nominal_fontsize)
gr.settextcolorind(color)
if angle != 0:
gr.setcharup(-np.sin(angle * np.pi/180),
np.cos(angle * np.pi/180))
else:
gr.setcharup(0, 1)
gr.text(x, y, s)
while time.time() - start < 10:
try:
power = get_spectrum()
peakind = signal.find_peaks_cwt(power, np.array([5]))
except (IOError):
continue
gr.clearws()
gr.setlinewidth(1)
gr.setlinecolorind(1)
gr.grid(1, 5, 50, 0, 1, 2)
gr.axes(1, 5, 50, 0, 1, 2, -0.008)
gr.setcharheight(0.020)
gr.text(0.15, 0.965, '100Hz')
gr.text(0.47, 0.965, '1kHz')
gr.text(0.79, 0.965, '10kHz')
gr.setlinecolorind(4)
gr.polyline(f[1:], power[1:])
for p in peakind:
if power[p] > 10:
gr.setlinewidth(2)
gr.setlinecolorind(2)
xe, ye = parabolic(f[p], power, p)
print(xe, ye)
gr.polyline([xe] * 2, [0, ye])
gr.updatews()
gr.polymarker([x + lineWidth / 2.], [ys])
ybase = (y - charHeightUnscaled / 2) * self.sizey
ytop = (y + charHeightUnscaled / 2) * self.sizey
roi = RegionOfInterest(Point(x, ybase),
Point(x, ytop),
reference=curve,
regionType=RegionOfInterest.LEGEND)
x += lineWidth + .01
if curve.visible:
gr.settextcolorind(1)
else:
gr.settextcolorind(83)
gr.settextalign(gr.TEXT_HALIGN_LEFT,
gr.TEXT_VALIGN_HALF)
gr.text(x, ys, curve.legend)
gr.settextcolorind(1)
x += textWidth
roi.append(Point(x, ytop), Point(x, ybase))
self._legendROI.append(roi)
# gr.polyline(roi.x, roi.y)
tbx = gr.inqtext(0, 0, "X")[0]
charWidth = max(tbx) - min(tbx)
x += charWidth
# restore old values
gr.setlinecolorind(lcolor)
gr.setmarkercolorind(mcolor)
gr.setlinetype(ltype)
gr.setmarkertype(mtype)
gr.setlinewidth(lwidth)
# restore viewport and window
gr.setviewport(*self.viewportscaled)
"""
Example for drawing a molecule using mogli and GR
"""
import gr
import mogli
molecules = mogli.read('examples/dna.xyz')
gr.clearws()
gr.setviewport(0, 1, 0, 1)
mogli.draw(molecules[0], bonds_param=1.15, camera=((60, 0, 0),
(0, 0, 0),
(0, 1, 0)))
gr.settextalign(gr.TEXT_HALIGN_CENTER, gr.TEXT_VALIGN_TOP)
gr.text(0.5, 1.0, 'DNA example')
gr.updatews()
r = (r_min + i * tick) / r_max
gr.setlinecolorind(88)
r = np.clip(r, 0, 1)
if i % 2 == 1 and r <= 1:
gr.setlinecolorind(90)
gr.drawarc(-r, r, -r, r, phi_min, phi_max)
if i % 2 == 0 and not r > 1:
gr.settextalign(gr.TEXT_HALIGN_CENTER, gr.TEXT_VALIGN_HALF)
sinf = np.sin(np.radians(phi_min))
cosf = np.cos(np.radians(phi_min))
x, y = gr.wctondc(r * cosf + sinf * 0.05, r * sinf - cosf * 0.05)
if _plt.kwargs.get('rflip', False):
r_label = r_max - i * tick
else:
r_label = r_min + i * tick
gr.text(x, y, "%g" % r_label)
gr.restorestate()
if self.title or self.subTitle:
dyTitle = 0
dySubTitle = 0
gr.settextalign(gr.TEXT_HALIGN_CENTER, gr.TEXT_VALIGN_BOTTOM)
gr.setcharup(0., 1.)
gr.setcharheight(charHeight)
x = xmin + (xmax - xmin) / 2
if self.title:
dyTitle = charHeightUnscaled
if self.title and self.subTitle:
dySubTitle = charHeightUnscaled
y = (self.viewport[3] + dyTitle + dySubTitle + charHeightUnscaled
+ 0.01)
if self.title:
gr.text(x, y * self.sizey, self.title)
y -= dyTitle + 0.01
if self.subTitle:
gr.text(x, y * self.sizey, self.subTitle)
# -- draw axes and curves --------------------------------------------
if self._lstAxes:
for axes in self._lstAxes:
axes.drawGR()
dyXLabel = 0
dxYLabel = 0
# -- draw x- and y label ---------------------------------------------
y = self.offsetXLabel + self.viewport[2]
if self.xlabel:
gr.settextalign(gr.TEXT_HALIGN_CENTER, gr.TEXT_VALIGN_TOP)
gr.setcharup(0., 1.)
# tby = gr.inqtext(0, 0, self.xlabel)[1]
# tby = map(lambda y: gr.wctondc(0, y)[1], tby)
nominalWindowHeight = 500.0
pointSize = ( 8, 9, 10, 11, 12, 14, 18, 24, 36 )
s = "i\\hbar\\frac{\\partial\\psi}{\\partial t} = \\frac{\\hbar^2}{2m}\\nabla^2\\psi + V(\\mathbf{r})\\psi"
x = 0.9
y = 0.9;
gr.settextalign(3, 3)
for i in range(8):
gr.setcharheight(pointSize[i] / nominalWindowHeight)
gr.mathtex(x, y, s)
y -= 4 * pointSize[i] / nominalWindowHeight
gr.setcharheight(0.1)
gr.mathtex(0.9, 0.05, "Hello World!")
gr.settextcolorind(8)
gr.text(0.9, 0.05, "Hello World!")
gr.updatews()
gr3.setcameraprojectionparameters(45, 1, 200)
gr3.cameralookat(10*math.cos(-rx*math.pi/2), 10*math.sin(-rx*math.pi/2), 0, 0, 0, 0, 0, 0, 1)