feature/port-to-py3 #11
							
								
								
									
										30
									
								
								PyLoT.py
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								PyLoT.py
									
									
									
									
									
								
							| @ -96,10 +96,9 @@ from pylot.styles import style_settings | ||||
| 
 | ||||
| if sys.version_info.major == 3: | ||||
|     import icons_rc_3 as icons_rc | ||||
| elif sys.version_info.major == 2: | ||||
|     import icons_rc_2 as icons_rc | ||||
| else: | ||||
|     raise ImportError('Could not determine python version.') | ||||
|     raise ImportError(f'Python version {sys.version_info.major} of current interpreter not supported.' | ||||
|                       f'\nPlease use Python 3+.') | ||||
| 
 | ||||
| # workaround to prevent PyCharm from deleting icons_rc import when optimizing imports | ||||
| icons_rc = icons_rc | ||||
| @ -189,6 +188,7 @@ class MainWindow(QMainWindow): | ||||
|         self.table_headers = ['', 'Event', 'Time', 'Lat', 'Lon', 'Depth', 'Ml', 'Mw', '[N] MP', '[N] AP', 'Tuning Set', | ||||
|                               'Test Set', 'Notes'] | ||||
| 
 | ||||
|         # TODO: refactor rootpath to datapath | ||||
|         while True: | ||||
|             try: | ||||
|                 if settings.value("user/FullName", None) is None: | ||||
| @ -496,11 +496,6 @@ class MainWindow(QMainWindow): | ||||
|                                        homepage (internet connection available), | ||||
|                                        or shipped documentation files.""") | ||||
| 
 | ||||
|         # phaseToolBar = self.addToolBar("PhaseTools") | ||||
|         # phaseToolActions = (self.selectPAction, self.selectSAction) | ||||
|         # phaseToolBar.setObjectName("PhaseTools") | ||||
|         # self.addActions(phaseToolBar, phaseToolActions) | ||||
| 
 | ||||
|         # create button group for component selection | ||||
| 
 | ||||
|         componentGroup = QActionGroup(self) | ||||
| @ -728,7 +723,6 @@ class MainWindow(QMainWindow): | ||||
| 
 | ||||
|         self.setCentralWidget(_widget) | ||||
| 
 | ||||
| 
 | ||||
|     def init_wfWidget(self): | ||||
|         xlab = self.startTime.strftime('seconds since %Y/%m/%d %H:%M:%S (%Z)') | ||||
|         plottitle = None  # "Overview: {0} components ".format(self.getComponent()) | ||||
| @ -1195,13 +1189,14 @@ class MainWindow(QMainWindow): | ||||
|             if system_name in ["Linux", "Darwin"]: | ||||
|                 dirs = { | ||||
|                     'database': path.split('/')[-2], | ||||
|                     'datapath': path.split('/')[-3], | ||||
|                     'datapath': os.path.split(path)[0],  # path.split('/')[-3], | ||||
|                     'rootpath': '/' + os.path.join(*path.split('/')[:-3]) | ||||
|                 } | ||||
|             elif system_name == "Windows": | ||||
|                 rootpath = path.split('/')[:-3] | ||||
|                 rootpath[0] += '/' | ||||
|                 dirs = { | ||||
|                     # TODO: Arrange path to meet Win standards | ||||
|                     'database': path.split('/')[-2], | ||||
|                     'datapath': path.split('/')[-3], | ||||
|                     'rootpath': os.path.join(*rootpath) | ||||
| @ -1215,7 +1210,7 @@ class MainWindow(QMainWindow): | ||||
|             print('Warning: Could not automatically init folder structure. ({})'.format(e)) | ||||
| 
 | ||||
|         settings = QSettings() | ||||
|         settings.setValue("data/dataRoot", dirs['rootpath']) | ||||
|         settings.setValue("data/dataRoot", dirs['datapath'])  #d irs['rootpath']) | ||||
|         settings.sync() | ||||
| 
 | ||||
|         if not self.project.eventlist: | ||||
| @ -1233,14 +1228,16 @@ class MainWindow(QMainWindow): | ||||
|             if not dirs_box.exec_(): | ||||
|                 return | ||||
|             self.project.rootpath = dirs['rootpath'] | ||||
|             self.project.datapath = dirs['datapath'] | ||||
|         else: | ||||
|             if hasattr(self.project, 'rootpath'): | ||||
|                 if not self.project.rootpath == dirs['rootpath']: | ||||
|             if hasattr(self.project, 'datapath'): | ||||
|                 if not self.project.datapath == dirs['datapath']: | ||||
|                     QMessageBox.warning(self, "PyLoT Warning", | ||||
|                                         'Rootpath missmatch to current project!') | ||||
|                                         'Datapath missmatch to current project!') | ||||
|                     return | ||||
|             else: | ||||
|                 self.project.rootpath = dirs['rootpath'] | ||||
|                 self.project.datapath = dirs['datapath'] | ||||
| 
 | ||||
|         self.project.add_eventlist(eventlist) | ||||
|         self.init_events() | ||||
| @ -3758,11 +3755,12 @@ class Project(object): | ||||
|     ''' | ||||
|     Pickable class containing information of a PyLoT project, like event lists and file locations. | ||||
|     ''' | ||||
| 
 | ||||
|     # TODO: remove rootpath | ||||
|     def __init__(self): | ||||
|         self.eventlist = [] | ||||
|         self.location = None | ||||
|         self.rootpath = None | ||||
|         self.datapath = None | ||||
|         self.dirty = False | ||||
|         self.parameter = None | ||||
|         self._table = None | ||||
| @ -3851,7 +3849,7 @@ class Project(object): | ||||
|             if not event.datapath in datapaths: | ||||
|                 datapaths.append(event.datapath) | ||||
|         for datapath in datapaths: | ||||
|             datapath = os.path.join(self.rootpath, datapath) | ||||
|             # datapath = os.path.join(self.rootpath, datapath) | ||||
|             if os.path.isdir(datapath): | ||||
|                 for filename in os.listdir(datapath): | ||||
|                     filename = os.path.join(datapath, filename) | ||||
|  | ||||
| @ -172,9 +172,9 @@ class Array_map(QtWidgets.QWidget): | ||||
|         self.canvas.fig.tight_layout() | ||||
| 
 | ||||
|     def add_merid_paral(self): | ||||
|         self.gridlines = self.canvas.axes.gridlines(draw_labels=False, alpha=0.8, color='gray', linewidth=self.linewidth/2, zorder=7) | ||||
|         self.gridlines = self.canvas.axes.gridlines(draw_labels=False, alpha=0.6, color='gray', linewidth=self.linewidth/2, zorder=7) | ||||
|         # TODO: current cartopy version does not support label removal. Devs are working on it. | ||||
|         #  Should be fixed with next cartopy version | ||||
|         #  Should be fixed in coming cartopy versions | ||||
|         # self.gridlines.xformatter = LONGITUDE_FORMATTER | ||||
|         # self.gridlines.yformatter = LATITUDE_FORMATTER | ||||
| 
 | ||||
| @ -511,7 +511,7 @@ class Array_map(QtWidgets.QWidget): | ||||
|         levels = np.linspace(self.get_min_from_picks(), self.get_max_from_picks(), nlevel) | ||||
| 
 | ||||
|         self.contourf = self.canvas.axes.contourf(self.longrid, self.latgrid, self.picksgrid_active, levels, | ||||
|                                                   linewidths=self.linewidth*4, transform=ccrs.PlateCarree(), | ||||
|                                                   linewidths=self.linewidth*5, transform=ccrs.PlateCarree(), | ||||
|                                                   alpha=0.4, zorder=8, cmap=self.get_colormap()) | ||||
| 
 | ||||
|     def get_colormap(self): | ||||
|  | ||||
| @ -21,12 +21,13 @@ class Event(ObsPyEvent): | ||||
|         :param path: path to event directory | ||||
|         :type path: str | ||||
|         """ | ||||
|         # TODO: remove rootpath and database | ||||
|         self.pylot_id = path.split('/')[-1] | ||||
|         # initialize super class | ||||
|         super(Event, self).__init__(resource_id=ResourceIdentifier('smi:local/' + self.pylot_id)) | ||||
|         self.path = path | ||||
|         self.database = path.split('/')[-2] | ||||
|         self.datapath = path.split('/')[-3] | ||||
|         self.datapath = os.path.split(path)[0]  # path.split('/')[-3] | ||||
|         self.rootpath = '/' + os.path.join(*path.split('/')[:-3]) | ||||
|         self.pylot_autopicks = {} | ||||
|         self.pylot_picks = {} | ||||
|  | ||||
| @ -3,6 +3,14 @@ | ||||
| # small script that creates array maps for each event within a previously generated PyLoT project | ||||
| 
 | ||||
| import os | ||||
| num_thread = "16" | ||||
| os.environ["OMP_NUM_THREADS"] = num_thread | ||||
| os.environ["OPENBLAS_NUM_THREADS"] = num_thread | ||||
| os.environ["MKL_NUM_THREADS"] = num_thread | ||||
| os.environ["VECLIB_MAXIMUM_THREADS"] = num_thread | ||||
| os.environ["NUMEXPR_NUM_THREADS"] = num_thread | ||||
| os.environ["NUMEXPR_MAX_THREADS"] = num_thread | ||||
| 
 | ||||
| import multiprocessing | ||||
| import sys | ||||
| import glob | ||||
| @ -61,7 +69,7 @@ def array_map_worker(input_dict): | ||||
|             metadata = Metadata(inventory=metadata_path, verbosity=0) | ||||
| 
 | ||||
|         # create figure to plot on | ||||
|         fig, ax = plt.subplots(figsize=(16, 9)) | ||||
|         fig, ax = plt.subplots(figsize=(15, 9)) | ||||
|         # create array map object | ||||
|         map = Array_map(None, metadata, parameter=input_dict['project'].parameter, axes=ax, | ||||
|                         width=2.13e6, height=1.2e6, pointsize=25., linewidth=1.0) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user