 Sharedsupport / 2016-09-21-111819-parametric.sagewsOpen in CoCalc
Author: William A. Stein
Description: Examples for support purposes.
cmsel = [colormaps.autumn(_) for _ in sxrange(0,1,0.05)]
var('r,t')
S=parametric_plot3d([2*r*cos(t), sqrt(2)*r*sin(t), 4 + (2*r*cos(t))^2 - 2*(sqrt(2)*r*sin(t))^2],
(r,0,1),(t,0,pi/2), adaptive=True, color=cmsel, plot_points=10, opacity=0.9)
S

(r, t)
3D rendering not yet implemented


var("x y z")
T(x,y,z) = sin(2*y + 3*z)^2
cm = colormaps.gist_rainbow
g = implicit_plot3d(x^2 + y^2 + z^2, (x,-2, 2), (y,-2, 2), (z,-2, 2), contour=2, color=(T, cm), plot_points=4)
show(g, viewer='tachyon')

(x, y, z) g

3D rendering not yet implemented
sh??

   File: /projects/sage/sage-7.3/local/lib/python2.7/site-packages/smc_sagews/sage_salvus.py
Source:
def sh(code):
"""
Run a bash script in Salvus. Uses jupyter bash kernel
which allows keeping state between cells.

EXAMPLES:

Use as a block decorator on a single line::

%sh pwd

and multiline

%sh
echo "hi"
pwd
ls -l

You can also just directly call it::

sh('pwd')

The output is printed. To capture it, use capture

%capture(stdout='output')
%sh pwd

After that, the variable output contains the current directory

Remember shell state between cells

%sh
FOO='xyz'
cd /tmp
... new cell will show settings from previous cell ...
%sh
echo \$FOO
pwd

Display image file (this is a feature of jupyter bash kernel)

%sh
display < sage_logo.png

.. WARNING::

The jupyter bash kernel does not separate stdout and stderr as cell is running.
It only returns ok or error depending on exit status of last command in the cell.
So all cell output captured goes to either stdout or stderr variable, depending
on exit status of the last command in the %sh cell.
"""
if sh.jupyter_kernel is None:
sh.jupyter_kernel = jupyter("bash")
return sh.jupyter_kernel(code)