implementen some new functions to PDFStatistics
This commit is contained in:
		
							parent
							
								
									8433767b22
								
							
						
					
					
						commit
						1ed83d786d
					
				| @ -342,41 +342,33 @@ class PDFstatistics(object): | |||||||
|     ''' |     ''' | ||||||
|     To do: |     To do: | ||||||
|     plots for std, quantiles, |     plots for std, quantiles, | ||||||
|     calc: quantiles |  | ||||||
|     encountering error when trying to get quantile... float.. utcdatetime error |  | ||||||
|     ''' |     ''' | ||||||
|     def __init__(self, directory): |     def __init__(self, directory): | ||||||
|         self.directory = directory |         self.directory = directory | ||||||
|  |         self.arraylen = 0 | ||||||
|         self.stations = {} |         self.stations = {} | ||||||
|         self.p_std = {} |         self.p_std = {} | ||||||
|         self.s_std = {} |         self.s_std = {} | ||||||
|         self.theta015 = [] |         self.theta015 = [] | ||||||
|         self.theta1 = [] |         self.theta1 = [] | ||||||
|         self.theta2 = [] |         self.theta2 = [] | ||||||
|         self.dirlist = list() |         self.makefilelist() | ||||||
|         self.evtdict = {} |         self.getData() | ||||||
|         #self.makeDirlist() |         self.getStatistics() | ||||||
|         #self.getData() |  | ||||||
|         #self.getStatistics() |  | ||||||
| 
 | 
 | ||||||
|         #self.showData() |         #self.showData() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     def makeDirlist(self, fn_pattern='*'): |     def makefilelist(self, fn_pattern='*'): | ||||||
|         self.dirlist = glob.glob1(self.directory, fn_pattern) |         self.evtlist = glob.glob1((os.path.join(self.directory)), '*.xml') | ||||||
|         self.evtdict = {} |  | ||||||
|         for rd in self.dirlist: |  | ||||||
|             self.evtdict[rd] = glob.glob1((os.path.join(self.directory, rd)), '*.xml') |  | ||||||
| 
 | 
 | ||||||
|     def getData(self): |     def getData(self): | ||||||
|         arraylen = 0 |         for evt in self.evtlist: | ||||||
|         for dir in self.dirlist: |  | ||||||
|             for evt in self.evtdict[dir]: |  | ||||||
|             print evt |             print evt | ||||||
|             self.stations[evt] = [] |             self.stations[evt] = [] | ||||||
|             self.p_std[evt] = [] |             self.p_std[evt] = [] | ||||||
|             self.s_std[evt] = [] |             self.s_std[evt] = [] | ||||||
|                 self.getPDFDict(dir, evt) |             self.getPDFDict(self.directory, evt) | ||||||
|             for station, pdfs in self.pdfdict.pdf_data.items(): |             for station, pdfs in self.pdfdict.pdf_data.items(): | ||||||
|                 # print station, pdfs |                 # print station, pdfs | ||||||
|                 try: |                 try: | ||||||
| @ -396,8 +388,7 @@ class PDFstatistics(object): | |||||||
|                 self.stations[evt].append(station) |                 self.stations[evt].append(station) | ||||||
|                 self.p_std[evt].append(p_std) |                 self.p_std[evt].append(p_std) | ||||||
|                 self.s_std[evt].append(s_std) |                 self.s_std[evt].append(s_std) | ||||||
|                     arraylen += 1 |                 self.arraylen += 1 | ||||||
|         self.arraylen = arraylen |  | ||||||
|         self.makeArray() |         self.makeArray() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -414,14 +405,23 @@ class PDFstatistics(object): | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     def showData(self): |     def histplot(self ,array , bins = 100, label=None): | ||||||
|         #figure(p, s) = plt.pyplot.subplots(2) |         # baustelle | ||||||
|         #p.hist(self.p_stdarray, Bins=100, range=[min(self.p_stdarray),max(self.p_stdarray)/256]) |         import matplotlib.pyplot as plt | ||||||
|         #s.hist(self.s_stdarray, Bins=100, range=[min(self.s_stdarray),max(self.s_stdarray)/256]) | 
 | ||||||
|         #p.set_title('Histogramm der P-Wellen-Standartabweichung') |         plt.hist(self.axis, self.data()) | ||||||
|         #s.set_title('Histogramm der S-Wellen-Standartabweichung') |         plt.xlabel('x') | ||||||
|         # plt.show() |         plt.ylabel('f(x)') | ||||||
|         pass |         plt.autoscale(axis='x', tight=True) | ||||||
|  |         if self: | ||||||
|  |             title_str = 'Probability density function ' | ||||||
|  |             if label: | ||||||
|  |                 title_str += label | ||||||
|  |             title_str.strip() | ||||||
|  |         else: | ||||||
|  |             title_str = 'Function not suitable as probability density function' | ||||||
|  |         plt.title(title_str) | ||||||
|  |         plt.show() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     def getPDFDict(self, month, evt): |     def getPDFDict(self, month, evt): | ||||||
| @ -440,9 +440,6 @@ class PDFstatistics(object): | |||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|     rootdir = '/home/sebastianp/Data/Reassessment/Insheim/2012.10/' |     rootdir = '/home/sebastianp/Data/Reassessment/Insheim/2012.10/' | ||||||
|     Insheim = PDFstatistics(rootdir) |     Insheim = PDFstatistics(rootdir) | ||||||
|     Insheim.dirlist = [rootdir] |     Insheim.makefilelist() | ||||||
|     Insheim.evtdict[rootdir] = ['e0002.294.12.xml'] |  | ||||||
|     Insheim.getData() |     Insheim.getData() | ||||||
|     print Insheim.theta015 | 
 | ||||||
|     print Insheim.theta1 |  | ||||||
|     print Insheim.theta2 |  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user