-
Notifications
You must be signed in to change notification settings - Fork 1
/
inverabel.py
executable file
·63 lines (54 loc) · 1.91 KB
/
inverabel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
#Take an azimuth average data perform inverse abel transformation to get density
import abel_scikit
import abel_local as abel
import numpy as np
import matplotlib.pyplot as plt
import math
import argparse
def inverAbelDat(x,y):
# First one uses the direct integral
invx,invy = abel.inverAbel(x,y)
invx = np.array(invx)
invy = np.array(invy)
# Second one uses the radon transform
x2 = np.append(x[:0:-1],x)
y2 = np.append(y[:0:-1],y)
invx2,invy2 = abel_scikit.inverAbel(x2,y2)
skipn = len(invx2)/2+1
invx2 = np.array( invx2[skipn:] )
invy2 = np.array( invy2[skipn:] )
return (invx, invy),(invx2,invy2)
def inverAbel(path,show=1):
try:
data = np.loadtxt(path)
except:
print "File does not exist"
return
x = data[:,0]
y = data[:,1]
invx,invy = abel.inverAbel(x,y)
x2 = np.append(x[:0:-1],x)
y2 = np.append(y[:0:-1],y)
invx2,invy2 = abel_scikit.inverAbel(x2,y2)
fig = plt.figure()
ax = fig.add_subplot(111)
ax2 = ax.twinx()
lns1 = ax.plot(x,y,label="Original Azimuthal Data")
ax.set_xlabel("Pixels")
ax.set_ylabel("Azimuthal Ave")
lns2 = ax2.plot(invx,invy,"r--",label="Inv Abel Trans by direct Integral")
lns3 = ax2.plot(invx2[len(invx2)/2+1:],invy2[len(invx2)/2+1:],"g--",label="Inv Abel Trans by Radon Trans")
ax2.set_ylabel("Azimuthal Ave Inverse Abel Transfrom")
lns = lns1+lns2+lns3
labs = [l.get_label() for l in lns]
ax.legend(lns, labs, loc=1)
plt.savefig(path.replace(".AZASCII","_invAbel.png"))
if (show):
plt.show()
if __name__ == "__main__":
parser = argparse.ArgumentParser('inverabel.py')
parser.add_argument('shot', action="store", type=int, help='The shot number to perform inver abel tranfromation')
parser.add_argument('--show', action = "store_true", dest='show', help="Show the plot.")
path= "./%04d"%parser.parse_args().shot + "_datAzimuth.AZASCII"
inverAbel(path, parser.parse_args().show)