[task] rewriting some functions to make them more flexible
This commit is contained in:
parent
2a798a554b
commit
87f87ffb95
@ -345,13 +345,13 @@ class PDFstatistics(object):
|
|||||||
'''
|
'''
|
||||||
def __init__(self, directory):
|
def __init__(self, directory):
|
||||||
self.directory = directory
|
self.directory = directory
|
||||||
self.arraylen = 0
|
#self.arraylen = 0
|
||||||
self.stations = {}
|
# self.stations = {}
|
||||||
self.p_std = {}
|
# self.p_std = {}
|
||||||
self.s_std = {}
|
#self.s_std = {}
|
||||||
self.theta0 = []
|
# self.theta0 = []
|
||||||
self.theta1 = []
|
# self.theta1 = []
|
||||||
self.theta2 = []
|
# self.theta2 = []
|
||||||
|
|
||||||
|
|
||||||
def readTheta(self, arname, dir, fnpattern):
|
def readTheta(self, arname, dir, fnpattern):
|
||||||
@ -375,6 +375,31 @@ class PDFstatistics(object):
|
|||||||
def makeFileList(self, fn_pattern='*'):
|
def makeFileList(self, fn_pattern='*'):
|
||||||
self.evtlist = glob.glob1((os.path.join(self.directory)), '*.xml')
|
self.evtlist = glob.glob1((os.path.join(self.directory)), '*.xml')
|
||||||
|
|
||||||
|
def nextPDF(self):
|
||||||
|
|
||||||
|
for evt in self.evtlist:
|
||||||
|
self.getPDFDict(self.directory, evt)
|
||||||
|
for station, pdfs in self.pdfdict.pdf_data.items():
|
||||||
|
try:
|
||||||
|
yield pdfs['P']
|
||||||
|
except KeyError:
|
||||||
|
yield np.nan
|
||||||
|
try:
|
||||||
|
yield pdfs['S']
|
||||||
|
except KeyError:
|
||||||
|
yield np.nan
|
||||||
|
|
||||||
|
def getQD(self,value):
|
||||||
|
pdfgen = self.nextPDF()
|
||||||
|
QDlist = []
|
||||||
|
for pdf in pdfgen:
|
||||||
|
if pdf == np.nan:
|
||||||
|
continue
|
||||||
|
QD = pdf.quantile_distance(value)
|
||||||
|
QDlist.append(QD)
|
||||||
|
return QDlist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getData(self):
|
def getData(self):
|
||||||
for evt in self.evtlist:
|
for evt in self.evtlist:
|
||||||
@ -470,6 +495,12 @@ class PDFstatistics(object):
|
|||||||
fid.write(str(val)+'\n')
|
fid.write(str(val)+'\n')
|
||||||
fid.close()
|
fid.close()
|
||||||
|
|
||||||
|
def main():
|
||||||
|
root_dir ='/home/sebastianp/Codetesting/xmls/'
|
||||||
|
Insheim = PDFstatistics(root_dir)
|
||||||
|
Insheim.makeFileList()
|
||||||
|
qdlist = Insheim.getQD(0.3)
|
||||||
|
print qdlist
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
#if __name__ == "__main__":
|
main()
|
Loading…
Reference in New Issue
Block a user