forked from dbratcher/MediaKhan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkhan.py
executable file
·106 lines (76 loc) · 2.06 KB
/
khan.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/python
from optparse import OptionParser
import sys
sys.path.append('./libim7/libim7')
import numpy as np
import libim7.libim7 as im7
import matplotlib.pyplot as plt
from pylab import *
import glob
y_frame0 = []
y_frame1 = []
parser = OptionParser()
parser.add_option("-t", type="int", dest="attr_num")
(option, args) = parser.parse_args()
#print option
#print args[0]
#s = "ihpcae/marshall_andrew/PIV/LSB/reacting/S = 0.58/1 atm/300 K/30 mps/100 H2/phi = 0.46/24 deg/Cam_Date=121103_Time=114443/B00004.im7"
#a = s.split("/")
s = "/net/hu21/agangil3/data/PIV/LSB/reacting/S = 0.58/1 atm/300 K/30 mps/100 H2/phi = 0.46/0 deg/Cam_Date=121103_Time=112726/B00001.im7"
#s = args[0]
#print 'Path is ', s
a = s.split("/")
#print "Split ", a
buf, att = ('', '')
def S():
for i in a:
if 'S = ' in i:
return i.split(" ")[2]
def Pressure():
for i in a:
if 'atm' in i:
return i.split(" ")[0]
def Kelvin():
for i in a:
if 'K' in i:
return i.split(" ")[0]
def Velocity():
for i in a:
if 'mps' in i:
return i.split(" ")[0]
def Composition():
for i in a:
if 'H2' in i:
return i
elif 'CH4' in i:
return i
def Phi():
for i in a:
if 'phi' in i:
return i.split(" ")[2]
def Temperature():
for i in a:
if 'deg' in i:
return i.split(" ")[0]
def Date():
for i in a:
if 'Cam_Date' in i:
return i.split("=")[1].split("_")[0]
def Time():
for i in a:
if 'Cam_Date' in i:
return i.split("=")[2]
def Intensity_Frame1():
buf, att = im7.readim7(s)
return mean(buf.get_frame(0))
def Intensity_Frame2():
buf, att = im7.readim7(s)
return mean(buf.get_frame(1))
def mean(img):
sum_intensity = 0
for row in range (len(img)):
sum_intensity += sum(img[row])
total_pixels = len(img) * len(img[0])
return sum_intensity / total_pixels
attr = {1:S, 2:Pressure, 3:Kelvin, 4:Velocity, 5:Composition, 6:Phi, 7:Temperature, 8:Date, 9:Time, 10:Intensity_Frame1, 11:Intensity_Frame2}
print attr[option.attr_num]()