[edit] fixing bugs (in progress)
This commit is contained in:
		
							parent
							
								
									618dd10c23
								
							
						
					
					
						commit
						36b0aea86c
					
				
							
								
								
									
										13
									
								
								QtPyLoT.py
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								QtPyLoT.py
									
									
									
									
									
								
							| @ -203,7 +203,7 @@ class MainWindow(QMainWindow): | |||||||
|                                                "Load location information on " |                                                "Load location information on " | ||||||
|                                                "the actual event.") |                                                "the actual event.") | ||||||
|         loadpilotevent = self.createAction(self, "Load PILOT &event ...", |         loadpilotevent = self.createAction(self, "Load PILOT &event ...", | ||||||
|                                            self.load_pilot, "Ctrl+E", |                                            self.load_pilotevent, "Ctrl+E", | ||||||
|                                            loadpiloticon, |                                            loadpiloticon, | ||||||
|                                            "Load PILOT event from information " |                                            "Load PILOT event from information " | ||||||
|                                            "Matlab binary collections.") |                                            "Matlab binary collections.") | ||||||
| @ -397,17 +397,22 @@ class MainWindow(QMainWindow): | |||||||
|         filt = "PILOT location files (*.mat)" |         filt = "PILOT location files (*.mat)" | ||||||
|         caption = "Select PILOT loaction file" |         caption = "Select PILOT loaction file" | ||||||
|         fn_loc = QFileDialog().getOpenFileName(self, caption=caption, |         fn_loc = QFileDialog().getOpenFileName(self, caption=caption, | ||||||
|                                               filter=filt) |                                               filter=filt, dir=self.getRoot()) | ||||||
|  |         fn_loc = fn_loc[0] | ||||||
|  |         loc_dir = os.path.split(fn_loc)[0] | ||||||
|         filt = "PILOT phases files (*.mat)" |         filt = "PILOT phases files (*.mat)" | ||||||
|         caption = "Select PILOT phases file" |         caption = "Select PILOT phases file" | ||||||
|         fn_phases = QFileDialog().getOpenFileName(self, caption=caption, |         fn_phases = QFileDialog().getOpenFileName(self, caption=caption, | ||||||
|                                               filter=filt) |                                               filter=filt, dir=loc_dir) | ||||||
|  |         fn_phases = fn_phases[0] | ||||||
|         type = QInputDialog().getItem(self, self.tr("Select phases type"), |         type = QInputDialog().getItem(self, self.tr("Select phases type"), | ||||||
|                                      self.tr("Type:"), [self.tr("manual"), |                                      self.tr("Type:"), [self.tr("manual"), | ||||||
|                                                         self.tr("automatic")]) |                                                         self.tr("automatic")]) | ||||||
| 
 | 
 | ||||||
|         if type.startswith('auto'): |         if type[0].startswith('auto'): | ||||||
|             type = 'auto' |             type = 'auto' | ||||||
|  |         else: | ||||||
|  |             type = type[0] | ||||||
| 
 | 
 | ||||||
|         fname_dict = dict(phasfn=fn_phases, locfn=fn_loc) |         fname_dict = dict(phasfn=fn_phases, locfn=fn_loc) | ||||||
|         self.load_data(fname_dict, type=type) |         self.load_data(fname_dict, type=type) | ||||||
|  | |||||||
| @ -68,8 +68,8 @@ def create_creation_info(agency_id=None, creation_time=None, author=None): | |||||||
|                             creation_time=creation_time) |                             creation_time=creation_time) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def create_event(origintime, cinfo, originloc=None, etype=None, resID=None, | def create_event(origintime, cinfo, originloc=None, etype='earthquake', | ||||||
|                  authority_id=None): |                  resID=None, authority_id=None): | ||||||
|     ''' |     ''' | ||||||
|     create_event - funtion to create an ObsPy Event |     create_event - funtion to create an ObsPy Event | ||||||
| 
 | 
 | ||||||
| @ -90,14 +90,12 @@ def create_event(origintime, cinfo, originloc=None, etype=None, resID=None, | |||||||
|     :type authority_id: str |     :type authority_id: str | ||||||
|     :return: An ObsPy :class: `~obspy.core.event.Event` object |     :return: An ObsPy :class: `~obspy.core.event.Event` object | ||||||
|     ''' |     ''' | ||||||
|     etype = ope.EventType(etype) | 
 | ||||||
|     if originloc is not None: |     if originloc is not None: | ||||||
|         o = create_origin(origintime, cinfo, |         o = create_origin(origintime, cinfo, | ||||||
|                           originloc[0], originloc[1], originloc[2]) |                           originloc[0], originloc[1], originloc[2]) | ||||||
|     else: |     else: | ||||||
|         o = None |         o = None | ||||||
|     if etype is None: |  | ||||||
|         etype = ope.EventType('earthquake')  # defaults to 'earthquake' |  | ||||||
|     if not resID: |     if not resID: | ||||||
|         resID = create_resourceID(origintime, etype, authority_id) |         resID = create_resourceID(origintime, etype, authority_id) | ||||||
|     elif isinstance(resID, str): |     elif isinstance(resID, str): | ||||||
| @ -216,7 +214,7 @@ def create_resourceID(timetohash, restype, authority_id=None, hrstr=None): | |||||||
|     if hrstr is None: |     if hrstr is None: | ||||||
|         resID = ope.ResourceIdentifier(restype + '/' + hid[0:6]) |         resID = ope.ResourceIdentifier(restype + '/' + hid[0:6]) | ||||||
|     else: |     else: | ||||||
|         resID = ope.ResourceIdentifier(restype + '/' + hrstr + '_' + hid[0:6]) |         resID = ope.ResourceIdentifier(restype + '/' + hrstr) | ||||||
|     if authority_id is not None: |     if authority_id is not None: | ||||||
|         resID.convertIDToQuakeMLURI(authority_id=authority_id) |         resID.convertIDToQuakeMLURI(authority_id=authority_id) | ||||||
|     return resID |     return resID | ||||||
| @ -54,8 +54,8 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id='RUB', **kwargs): | |||||||
|                                 author=locauthor, |                                 author=locauthor, | ||||||
|                                 creation_time=locctime) |                                 creation_time=locctime) | ||||||
|     np = 0 |     np = 0 | ||||||
|     try: |     #try: | ||||||
|         eventNum = loc['ID'][0] |     eventNum = str(loc['ID'][0]) | ||||||
| 
 | 
 | ||||||
|     # retrieve eventID for the actual database |     # retrieve eventID for the actual database | ||||||
|     idsplit = eventNum.split('.') |     idsplit = eventNum.split('.') | ||||||
| @ -74,14 +74,14 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id='RUB', **kwargs): | |||||||
| 
 | 
 | ||||||
|     stations = [stat for stat in phases['stat'][0:-1:3]] |     stations = [stat for stat in phases['stat'][0:-1:3]] | ||||||
| 
 | 
 | ||||||
|         event = create_event(eventDate, loccinfo, etype='earthquake', |  | ||||||
|                              resID=eventNum, authority_id=authority_id) |  | ||||||
| 
 |  | ||||||
|     lat = float(loc['LAT']) |     lat = float(loc['LAT']) | ||||||
|     lon = float(loc['LON']) |     lon = float(loc['LON']) | ||||||
|     dep = float(loc['DEP']) |     dep = float(loc['DEP']) | ||||||
| 
 | 
 | ||||||
|         origin = create_origin(eventDate, loccinfo, lat, lon, dep) |     event = create_event(eventDate, loccinfo, originloc=(lat, lon, dep), | ||||||
|  |                          etype='earthquake', resID=eventNum, | ||||||
|  |                          authority_id=authority_id) | ||||||
|  | 
 | ||||||
|     for n, pick in enumerate(phases['Ptime']): |     for n, pick in enumerate(phases['Ptime']): | ||||||
|         if pick[0] > 0: |         if pick[0] > 0: | ||||||
|             kwargs = {'year': int(pick[0]), |             kwargs = {'year': int(pick[0]), | ||||||
| @ -119,21 +119,21 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id='RUB', **kwargs): | |||||||
|             event.picks.append(pick) |             event.picks.append(pick) | ||||||
|             pickID = pick.get('id') |             pickID = pick.get('id') | ||||||
|             arrival = create_arrival(pickID, pickcinfo, phase) |             arrival = create_arrival(pickID, pickcinfo, phase) | ||||||
|                 origin.arrivals.append(arrival) |             if event.origins: | ||||||
|  |                 event.origins[0].arrivals.append(arrival) | ||||||
|             event.picks.append(pick) |             event.picks.append(pick) | ||||||
|                 np += 1 |  | ||||||
| 
 | 
 | ||||||
|  |     if event.origins: | ||||||
|  |         origin = event.origins[0] | ||||||
|         magnitude = create_magnitude(origin.get('id'), loccinfo) |         magnitude = create_magnitude(origin.get('id'), loccinfo) | ||||||
|         magnitude.mag = float(loc['Mnet']) |         magnitude.mag = float(loc['Mnet']) | ||||||
|         magnitude.magnitude_type = 'Ml' |         magnitude.magnitude_type = 'Ml' | ||||||
| 
 |  | ||||||
|         event.origins.append(origin) |  | ||||||
|         event.magnitudes.append(magnitude) |         event.magnitudes.append(magnitude) | ||||||
|     return event |     return event | ||||||
| 
 | 
 | ||||||
|     except AttributeError as e: |     #except AttributeError as e: | ||||||
|         raise AttributeError('{0} - Matlab LOC files {1} and {2} contains \ |     #    raise AttributeError('{0} - Matlab LOC files {1} and {2} contains \ | ||||||
|                               insufficient data!'.format(e, phasfn, locfn)) |     #                          insufficient data!'.format(e, phasfn, locfn)) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def picks_from_pilot(fn): | def picks_from_pilot(fn): | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user