[task] additional changes for phase separation
This commit is contained in:
parent
f4bdb38e16
commit
7c8a437dd8
@ -345,7 +345,7 @@ class PDFstatistics(object):
|
|||||||
'''
|
'''
|
||||||
def __init__(self, directory):
|
def __init__(self, directory):
|
||||||
self.directory = directory
|
self.directory = directory
|
||||||
|
self.return_phase = None
|
||||||
|
|
||||||
def readTheta(self, arname, dir, fnpattern):
|
def readTheta(self, arname, dir, fnpattern):
|
||||||
exec('self.' + arname +' = []')
|
exec('self.' + arname +' = []')
|
||||||
@ -363,24 +363,25 @@ class PDFstatistics(object):
|
|||||||
self.evtlist = glob.glob1((os.path.join(self.directory)), '*.xml')
|
self.evtlist = glob.glob1((os.path.join(self.directory)), '*.xml')
|
||||||
|
|
||||||
|
|
||||||
def nextPDF(self):
|
def __iter__(self):
|
||||||
|
assert isinstance(self.return_phase, str), 'phase has to be set before being able to iterate over items...'
|
||||||
for evt in self.evtlist:
|
for evt in self.evtlist:
|
||||||
self.getPDFDict(self.directory, evt)
|
self.getPDFDict(self.directory, evt)
|
||||||
for station, pdfs in self.pdfdict.pdf_data.items():
|
for station, pdfs in self.pdfdict.pdf_data.items():
|
||||||
try:
|
try:
|
||||||
yield pdfs['P']
|
yield pdfs[self.return_phase]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
yield np.nan
|
continue
|
||||||
try:
|
|
||||||
yield pdfs['S']
|
|
||||||
except KeyError:
|
|
||||||
yield np.nan
|
|
||||||
|
|
||||||
|
def set_return_phase(self, type):
|
||||||
|
if type.upper() not in 'PS':
|
||||||
|
raise ValueError("phase type must be either 'P' or 'S'!")
|
||||||
|
else:
|
||||||
|
self.return_phase = type.upper()
|
||||||
|
|
||||||
def getQD(self,value):
|
def getQD(self,value):
|
||||||
pdfgen = self.nextPDF()
|
|
||||||
QDlist = []
|
QDlist = []
|
||||||
for pdf in pdfgen:
|
for pdf in self:
|
||||||
try:
|
try:
|
||||||
QD = pdf.quantile_distance(value)
|
QD = pdf.quantile_distance(value)
|
||||||
QDlist.append(QD)
|
QDlist.append(QD)
|
||||||
@ -391,9 +392,8 @@ class PDFstatistics(object):
|
|||||||
|
|
||||||
|
|
||||||
def getQDQ(self,value):
|
def getQDQ(self,value):
|
||||||
pdfgen = self.nextPDF()
|
|
||||||
QDQlist = []
|
QDQlist = []
|
||||||
for pdf in pdfgen:
|
for pdf in self:
|
||||||
try:
|
try:
|
||||||
QDQ = pdf.qtile_dist_quot(value)
|
QDQ = pdf.qtile_dist_quot(value)
|
||||||
QDQlist.append(QDQ)
|
QDQlist.append(QDQ)
|
||||||
@ -404,24 +404,23 @@ class PDFstatistics(object):
|
|||||||
|
|
||||||
|
|
||||||
def getSTD(self):
|
def getSTD(self):
|
||||||
pdfgen = self.nextPDF()
|
std = []
|
||||||
self.p_std = []
|
for pdf in self:
|
||||||
self.s_std = []
|
|
||||||
for pdf in pdfgen:
|
|
||||||
try:
|
try:
|
||||||
self.p_std.append(pdf['P'].standard_deviation())
|
std.append(pdf.standard_deviation())
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
continue
|
||||||
try:
|
std = np.array(std)
|
||||||
self.s_std.append(pdf['S'].standard_deviation())
|
self.set_stdarray(std)
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
self.makeArray()
|
|
||||||
|
|
||||||
|
def set_stdarray(self, array):
|
||||||
def makeArray(self):
|
if self.return_phase == 'P':
|
||||||
self.p_stdarray = np.array(self.p_std)
|
self.p_stdarray = array
|
||||||
self.s_stdarray = np.array(self.s_std)
|
elif self.return_phase == 'S':
|
||||||
|
self.s_stdarray = array
|
||||||
|
else:
|
||||||
|
raise ValueError('phase type not set properly...\n'
|
||||||
|
'Actual phase type: {0}'.format(self.return_phase))
|
||||||
|
|
||||||
|
|
||||||
def getBinList(self,l_boundary,u_boundary,nbins = 100):
|
def getBinList(self,l_boundary,u_boundary,nbins = 100):
|
||||||
@ -468,9 +467,11 @@ def main():
|
|||||||
root_dir ='/home/sebastianp/Codetesting/xmls/'
|
root_dir ='/home/sebastianp/Codetesting/xmls/'
|
||||||
Insheim = PDFstatistics(root_dir)
|
Insheim = PDFstatistics(root_dir)
|
||||||
Insheim.makeFileList()
|
Insheim.makeFileList()
|
||||||
|
Insheim.set_return_phase('p')
|
||||||
Insheim.getSTD()
|
Insheim.getSTD()
|
||||||
Insheim.getStatistics()
|
|
||||||
qdlist = Insheim.getQDQ(0.3)
|
qdlist = Insheim.getQDQ(0.3)
|
||||||
|
binlist = Insheim.getBinList(0.,3.)
|
||||||
|
Insheim.histplot(qdlist,binlist)
|
||||||
print qdlist
|
print qdlist
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user