Compare commits
	
		
			4 Commits
		
	
	
		
			0b50a91f57
			...
			7c926327dd
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 7c926327dd | ||
|  | e9d3caafd3 | ||
|  | 0dc5aff3fc | ||
|  | 7c5e16ecc6 | 
							
								
								
									
										31
									
								
								PyLoT.py
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								PyLoT.py
									
									
									
									
									
								
							| @ -98,10 +98,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 | ||||
| @ -191,6 +190,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: | ||||
| @ -506,11 +506,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) | ||||
| @ -738,7 +733,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()) | ||||
| @ -1205,13 +1199,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) | ||||
| @ -1225,7 +1220,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: | ||||
| @ -1243,14 +1238,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() | ||||
| @ -1337,6 +1334,7 @@ class MainWindow(QMainWindow): | ||||
|             return True | ||||
| 
 | ||||
|     def modify_project_path(self, new_rootpath): | ||||
|         # TODO: change root to datapath | ||||
|         self.project.rootpath = new_rootpath | ||||
|         for event in self.project.eventlist: | ||||
|             event.rootpath = new_rootpath | ||||
| @ -3784,11 +3782,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 | ||||
| @ -3877,7 +3876,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) | ||||
|  | ||||
| @ -189,7 +189,7 @@ def autoPyLoT(input_dict=None, parameter=None, inputfile=None, fnames=None, even | ||||
|         if not input_dict: | ||||
|             # started in production mode | ||||
|             datapath = datastructure.expandDataPath() | ||||
|             if fnames == 'None' and parameter['eventID'] != '*': | ||||
|             if fnames == 'None' and parameter['eventID'] == '*': | ||||
|                 # multiple event processing | ||||
|                 # read each event in database | ||||
|                 events = [event for event in glob.glob(os.path.join(datapath, '*')) if | ||||
|  | ||||
| @ -794,8 +794,8 @@ class PilotDataStructure(GenericDataStructure): | ||||
| 
 | ||||
|     def __init__(self, **fields): | ||||
|         if not fields: | ||||
|             fields = {'database': '2006.01', | ||||
|                       'root': '/data/Egelados/EVENT_DATA/LOCAL'} | ||||
|             fields = {'database': '', | ||||
|                       'root': ''} | ||||
| 
 | ||||
|         GenericDataStructure.__init__(self, **fields) | ||||
| 
 | ||||
|  | ||||
| @ -376,7 +376,7 @@ def picks_from_picksdict(picks, creation_info=None): | ||||
| 
 | ||||
| def reassess_pilot_db(root_dir, db_dir, out_dir=None, fn_param=None, verbosity=0): | ||||
|     import glob | ||||
| 
 | ||||
|     # TODO: change root to datapath | ||||
|     db_root = os.path.join(root_dir, db_dir) | ||||
|     evt_list = glob.glob1(db_root, 'e????.???.??') | ||||
| 
 | ||||
| @ -391,6 +391,7 @@ def reassess_pilot_event(root_dir, db_dir, event_id, out_dir=None, fn_param=None | ||||
| 
 | ||||
|     from pylot.core.io.inputs import PylotParameter | ||||
|     from pylot.core.pick.utils import earllatepicker | ||||
|     # TODO: change root to datapath | ||||
| 
 | ||||
|     if fn_param is None: | ||||
|         fn_param = defaults.AUTOMATIC_DEFAULTS | ||||
| @ -483,7 +484,6 @@ def reassess_pilot_event(root_dir, db_dir, event_id, out_dir=None, fn_param=None | ||||
|             os.makedirs(out_dir) | ||||
|         fnout_prefix = os.path.join(out_dir, 'PyLoT_{0}.'.format(event_id)) | ||||
|     evt.write(fnout_prefix + 'xml', format='QUAKEML') | ||||
|     # evt.write(fnout_prefix + 'cnv', format='VELEST') | ||||
| 
 | ||||
| 
 | ||||
| def writephases(arrivals, fformat, filename, parameter=None, eventinfo=None): | ||||
|  | ||||
| @ -400,6 +400,7 @@ class PDFstatistics(object): | ||||
|     This object can be used to get various statistic values from probability density functions. | ||||
|     Takes a path as argument. | ||||
|     """ | ||||
|     # TODO: change root to datapath | ||||
| 
 | ||||
|     def __init__(self, directory): | ||||
|         """Initiates some values needed when dealing with pdfs later""" | ||||
|  | ||||
| @ -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): | ||||
|  | ||||
| @ -380,7 +380,7 @@ def check_time(datetime): | ||||
|     except ValueError: | ||||
|         return False | ||||
| 
 | ||||
| 
 | ||||
| # TODO: change root to datapath | ||||
| def get_file_list(root_dir): | ||||
|     """ | ||||
|     Function uses a directorie to get all the *.gse files from it. | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -61,10 +61,9 @@ from pylot.core.util.dataprocessing import Metadata | ||||
| 
 | ||||
| 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 | ||||
| @ -4601,7 +4600,7 @@ class InputsTab(PropTab): | ||||
|             self.fullNameEdit.setText(fulluser) | ||||
|         except TypeError as e: | ||||
|             self.fullNameEdit.setText(fulluser[0]) | ||||
| 
 | ||||
|         # TODO: check settings and substitute datapath for root | ||||
|         # information about data structure | ||||
|         dataroot = settings.value("data/dataRoot") | ||||
|         curstructure = settings.value("data/Structure") | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user