Skip to content

Commit 61a28a3

Browse files
authored
Make seeds for Juno Bfield lines
It reads Mathematica created lat-lon grids of different densities and uses it to generate a single non-uniform grid file that can be used to seed field lines in Paraview for generating 3D field line plot.
1 parent 65d12db commit 61a28a3

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

Make_seed_points_for_Juno_field.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import random
2+
import numpy as np
3+
import matplotlib.pyplot as plt
4+
from scipy.interpolate import griddata
5+
6+
#print test_data.shape
7+
#juno_data = np.loadtxt('Juno_field.txt').T
8+
#field_mag = np.absolute(juno_data)
9+
10+
# grid for juno field
11+
juno_data = np.loadtxt('Juno_field.txt').T
12+
field_mag = np.absolute(juno_data)
13+
pphi, ttheta = np.mgrid[0:2.*np.pi:1024*1j, 0:np.pi:512*1j]
14+
pphi = pphi.flatten(); ttheta = ttheta.flatten()
15+
16+
17+
def chose_grid(grid,minB,maxB):
18+
if grid==250:
19+
data = np.loadtxt('mathematica_1.5k_to_0.25k/0.25k.dat')
20+
elif grid==500:
21+
data = np.loadtxt('mathematica_1.5k_to_0.25k/0.5k.dat')
22+
elif grid==750:
23+
data = np.loadtxt('mathematica_1.5k_to_0.25k/0.75k.dat')
24+
elif grid==1000:
25+
data = np.loadtxt('mathematica_1.5k_to_0.25k/1k.dat')
26+
elif grid==1250:
27+
data = np.loadtxt('mathematica_1.5k_to_0.25k/1.25k.dat')
28+
elif grid==1500:
29+
data = np.loadtxt('mathematica_1.5k_to_0.25k/1.5k.dat')
30+
x = data[:,0]
31+
y = data[:,1]
32+
z = data[:,2]
33+
34+
#convert to lat, lon
35+
r = np.sqrt(x**2 + y**2 + z**2)
36+
ttheta1 = np.arccos(z/r)
37+
pphi1 = np.arctan2(y,x)+np.pi
38+
#pphi1, ttheta1 = np.meshgrid(phi1,theta1)
39+
#print phi1.min(), phi1.max(), theta1.min(), theta1.max()
40+
41+
interp_data = griddata((pphi, ttheta), field_mag.flatten(), (pphi1, ttheta1), method='nearest')
42+
print interp_data.shape
43+
#plt.hist(interp_data)
44+
#plt.show()
45+
46+
#new x,y,z with smaller radius
47+
x = 1.6*np.sin(ttheta1)*np.cos(pphi1)
48+
y = 1.6*np.sin(ttheta1)*np.sin(pphi1)
49+
z = 1.6*np.cos(ttheta1)
50+
51+
trunc_x = x[np.where( ((minB < interp_data) & (interp_data < maxB)) )]
52+
trunc_y = y[np.where( ((minB < interp_data) & (interp_data < maxB)) )]
53+
trunc_z = z[np.where( ((minB < interp_data) & (interp_data < maxB)) )]
54+
55+
return trunc_x,trunc_y,trunc_z
56+
57+
#------------------------
58+
f=open("seeds.csv","w+")
59+
f.write('x coord, y coord, z coord\n')
60+
61+
x1,y1,z1 = chose_grid(1500,50,65)
62+
63+
for i in range(len(x1)):
64+
to_write = "%f, %f, %f" %(x1[i], y1[i], z1[i])
65+
f.write(to_write+'\n')
66+
67+
x1,y1,z1 = chose_grid(1250,40,50)
68+
for i in range(len(x1)):
69+
to_write = "%f, %f, %f" %(x1[i], y1[i], z1[i])
70+
f.write(to_write+'\n')
71+
72+
x1,y1,z1 = chose_grid(1000,30,40)
73+
for i in range(len(x1)):
74+
to_write = "%f, %f, %f" %(x1[i], y1[i], z1[i])
75+
f.write(to_write+'\n')
76+
77+
x1,y1,z1 = chose_grid(750,20,30)
78+
for i in range(len(x1)):
79+
to_write = "%f, %f, %f" %(x1[i], y1[i], z1[i])
80+
f.write(to_write+'\n')
81+
82+
x1,y1,z1 = chose_grid(500,10,20)
83+
for i in range(len(x1)):
84+
to_write = "%f, %f, %f" %(x1[i], y1[i], z1[i])
85+
f.write(to_write+'\n')
86+
87+
x1,y1,z1 = chose_grid(250,0,10)
88+
for i in range(len(x1)):
89+
to_write = "%f, %f, %f" %(x1[i], y1[i], z1[i])
90+
f.write(to_write+'\n')
91+
92+
f.close()

0 commit comments

Comments
 (0)