File indexing completed on 2024-12-22 04:17:10

0001 #!/usr/bin/python2.7
0002 import pykst as kst
0003 import numpy as np
0004 
0005 client=kst.Client("NumpyVector")
0006 
0007 # create a pair of numpy arrays
0008 x = np.linspace( -10, 10, 1000)
0009 y = np.sin(x)
0010 
0011 # copy the numpy arrays into kst and plot them
0012 V1 = client.new_editable_vector(x, name="X")
0013 V2 = client.new_editable_vector(y, name="sin(X)")
0014 c1 = client.new_curve(V1, V2)
0015 p1 = client.new_plot()
0016 p1.add(c1)
0017 
0018 V3 = client.new_generated_vector(-10*180/3.1415926, 10*180/3.1415926, 100)
0019 c2 = client.new_curve(V3, V2)
0020 p2 = client.new_plot()
0021 p2.add(c2)
0022 
0023 
0024 # print out the name of every vector.
0025 vectors = client.get_vector_list()
0026 print "----- Vectors: ----------"
0027 for vector in vectors:
0028   print vector.name()
0029 
0030 # print out the name of ediable vectors.
0031 vectors = client.get_editable_vector_list()
0032 print "----- Editable Vectors: ----------"
0033 for vector in vectors:
0034   print vector.name()
0035 
0036 # print out the name of generated vectors.
0037 vectors = client.get_generated_vector_list()
0038 print "----- Generated Vectors: ----------"
0039 for vector in vectors:
0040   print vector.name()
0041   
0042 # print out every scalar name and value
0043 scalars = client.get_scalar_list()
0044 print "----- Scalars: ----------"
0045 for scalar in scalars:
0046   print scalar.name(), scalar.value()
0047   
0048 
0049