| | 17 | |
| | 18 | |
| | 19 | ---- |
| | 20 | |
| | 21 | In this tutorial in visualizing external data in Shape, we will be visualizing a sphere generated by the following script: |
| | 22 | |
| | 23 | [[CollapsibleStart(Pseudo-Data Generator (python))]] |
| | 24 | {{{ |
| | 25 | import random |
| | 26 | from math import pi,sin,cos |
| | 27 | |
| | 28 | #Creating Sphere Dataz |
| | 29 | def createSphere(r=5, N=100): |
| | 30 | lst = [] |
| | 31 | for phi in [(pi*i)/(N-1) for i in range(N)]: |
| | 32 | M = int(sin(phi)*(N-1))+1 |
| | 33 | for theta in [(2*pi*i)/M for i in range(M)]: |
| | 34 | x = r * sin(phi) * cos(theta) |
| | 35 | y = r * sin(phi) * sin(theta) |
| | 36 | z = r * cos(phi) |
| | 37 | lst.append((x, y, z)) |
| | 38 | return lst |
| | 39 | |
| | 40 | #Opens/creates new ascii file |
| | 41 | outfile = open("test_sphere_7col.dat", "w") |
| | 42 | |
| | 43 | #Writes the data to the file |
| | 44 | for x,y,z in createSphere(): |
| | 45 | rho = random.random()*1000000 |
| | 46 | vx = random.random()*10 |
| | 47 | vy = random.random()*100 |
| | 48 | vz = random.random() |
| | 49 | print("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}".format(x,y,z,vx,vy,vz,rho), file=outfile) |
| | 50 | |
| | 51 | #Closes the file |
| | 52 | outfile.close() |
| | 53 | }}} |
| | 54 | [[CollapsibleEnd]] |
| | 55 | |
| | 56 | a file generated by the script can be found in the attachments, titled ''test_sphere_7col.dat''. In the following sections you'll observe how we come to visualize its "emission map." We suggest downloading the attachment and following along with the tutorial. |