def __init__(self, parent: pw.QWidget, canvas, current_index=-1): super(EventInfoBox, self).__init__(parent) self.setupUi(self) self.__parent_name = parent.objectName( ) # used to save values in a group. self.__canvas = None self.__on_click_plot_arrivals_callback = None self.__arrivals_lines = [] if canvas: self.set_canvas(canvas) # set the parent properly ParentWidget.set_parent(parent, self, current_index) # force parent to have the same maximumSize and minimumSize of FileBox parent.setMaximumSize(self.maximumSize()) parent.setMinimumSize(self.minimumSize()) # bind widgets from EventInfo box. self.__latitude_bind = BindPyqtObject(self.latitudeDsb) self.__longitude_bind = BindPyqtObject(self.longitudeDsb) self.__depth_bind = BindPyqtObject(self.depthLineEdit) # button bind self.plotArrivalsBtn.clicked.connect(self.__on_click_plot_arrivals) self.clearArrivalsBtn.clicked.connect(self.__on_click_clear_arrivals)
def __init__(self, parent=None): super(PPSDsGeneratorDialog, self).__init__(parent) self.setupUi(self) self.inventory = {} self.ppsds = None self.progressbar = pw.QProgressDialog(self) self.progressbar.setWindowTitle('PPSD Running') self.progressbar.setLabelText(" Computing PPSDs ") self.progressbar.setWindowIcon(pqg.QIcon(':\icons\map-icon.png')) self.progressbar.close() # Binding self.root_path_bind = BindPyqtObject(self.rootPathForm) self.dataless_path_bind = BindPyqtObject(self.datalessPathForm, self.onChange_metadata_path) # Bind buttons self.selectDirBtn.clicked.connect( lambda: self.on_click_select_directory(self.root_path_bind)) self.datalessBtn.clicked.connect( lambda: self.on_click_select_metadata_file(self.dataless_path_bind )) # Action Buttons self.processBtn.clicked.connect( lambda: self._ppsd_thread(self.process_ppsds)) self.continueBtn.clicked.connect( lambda: self._ppsd_thread(self.ppsd_continue)) self.saveBtn.clicked.connect(lambda: self.saveDB()) self.loadBtn.clicked.connect(lambda: self.load_ppsd_db()) #self.load_metadataBtn.clicked.connect(lambda: self.load_metadata()) self.add_dataBtn.clicked.connect(lambda: self.add_data())
def __init__(self, parameters, settings): super(EGFFrame, self).__init__() self.setupUi(self) self.parameters = parameters self.settings_dialog = settings self.progressbar = pw.QProgressDialog(self) self.progressbar.setWindowTitle('Ambient Noise Tomography') self.progressbar.setLabelText(" Computing ") self.progressbar.setWindowIcon(pqg.QIcon(':\icons\map-icon.png')) self.progressbar.close() self.inventory = {} self.files = [] self.total_items = 0 self.items_per_page = 1 self.__dataless_manager = None self.__metadata_manager = None self.st = None self.output = None self.root_path_bind = BindPyqtObject(self.rootPathForm, self.onChange_root_path) self.root_path_bind2 = BindPyqtObject(self.rootPathForm2, self.onChange_root_path) self.metadata_path_bind = BindPyqtObject(self.datalessPathForm, self.onChange_metadata_path) self.updateBtn.clicked.connect(self.plot_egfs) self.output_bind = BindPyqtObject(self.outPathForm, self.onChange_root_path) self.pagination = Pagination(self.pagination_widget, self.total_items, self.items_per_page) self.pagination.set_total_items(0) self.canvas = MatplotlibCanvas(self.plotMatWidget, nrows=self.items_per_page, constrained_layout=False) self.canvas.set_xlabel(0, "Time (s)") self.canvas.figure.tight_layout() # Bind buttons self.readFilesBtn.clicked.connect(lambda: self.get_now_files()) self.selectDirBtn.clicked.connect( lambda: self.on_click_select_directory(self.root_path_bind)) self.selectDirBtn2.clicked.connect( lambda: self.on_click_select_directory(self.root_path_bind2)) self.metadata_path_bind = BindPyqtObject(self.datalessPathForm, self.onChange_metadata_path) self.selectDatalessDirBtn.clicked.connect( lambda: self.on_click_select_file(self.metadata_path_bind)) self.outputBtn.clicked.connect( lambda: self.on_click_select_directory(self.output_bind)) self.preprocessBtn.clicked.connect(self.run_preprocess) self.cross_stackBtn.clicked.connect(self.stack) self.mapBtn.clicked.connect(self.map)
def __init__(self): super(TimeFrequencyFrame, self).__init__() self.setupUi(self) self.__stations_dir = None self.__metadata_manager = None self.inventory = {} self._stations_info = {} self.tr1 = [] self.tr2 = [] self.canvas_plot1 = MatplotlibCanvas(self.widget_plot_up, nrows=2) # self.canvas_plot1.set_xlabel(1, "Time (s)") # self.canvas_plot1.set_ylabel(0, "Amplitude ") # self.canvas_plot1.set_ylabel(1, "Frequency (Hz)") self.canvas_plot2 = MatplotlibCanvas(self.widget_plot_down, nrows=2) # self.canvas_plot2.set_xlabel(1, "Time (s)") # self.canvas_plot2.set_ylabel(0, "Amplitude ") # self.canvas_plot2.set_ylabel(1, "Frequency (Hz)") # Binding self.canvas_plot1.mpl_connect('key_press_event', self.key_pressed) self.canvas_plot2.mpl_connect('key_press_event', self.key_pressed) self.root_path_bind = BindPyqtObject(self.rootPathForm, self.onChange_root_path) self.dataless_path_bind = BindPyqtObject(self.datalessPathForm) self.metadata_path_bind = BindPyqtObject(self.datalessPathForm, self.onChange_metadata_path) # Add file selector to the widget self.file_selector = FilesView( self.root_path_bind.value, parent=self.fileSelectorWidget, on_change_file_callback=lambda file_path: self.onChange_file( file_path)) # Binds self.selectDirBtn.clicked.connect( lambda: self.on_click_select_directory(self.root_path_bind)) self.datalessBtn.clicked.connect( lambda: self.on_click_select_file(self.dataless_path_bind)) # Action Buttons self.actionSettings.triggered.connect( lambda: self.open_parameters_settings()) self.actionOpen_Help.triggered.connect(lambda: self.open_help()) self.actionOpen_Spectral_Analysis.triggered.connect( self.time_frequency_advance) self.plotBtn.clicked.connect(self.plot_seismogram) self.stationsBtn.clicked.connect(self.stations_info) # help Documentation self.help = HelpDoc() # Parameters settings self.parameters = ParametersSettings()
def __init__(self): super(MTIFrame, self).__init__() self.setupUi(self) #super(MTIFrame, self).__init__() self.setupUi(self) self.__stations_dir = None self.__metadata_manager = None self.inventory = {} self._stations_info = {} self.stream = None # Binding self.root_path_bind = BindPyqtObject(self.rootPathForm) #self.dataless_path_bind = BindPyqtObject(self.datalessPathForm) self.metadata_path_bind = BindPyqtObject(self.datalessPathForm, self.onChange_metadata_path) self.earth_path_bind = BindPyqtObject(self.earth_modelPathForm) # Binds self.selectDirBtn.clicked.connect( lambda: self.on_click_select_directory(self.root_path_bind)) self.datalessBtn.clicked.connect( lambda: self.on_click_select_metadata_file(self.metadata_path_bind )) self.earthmodelBtn.clicked.connect( lambda: self.on_click_select_file(self.earth_path_bind)) # Action Buttons self.actionSettings.triggered.connect( lambda: self.open_parameters_settings()) self.plotBtn.clicked.connect(self.plot_seismograms) self.actionSettings.triggered.connect( lambda: self.open_parameters_settings()) self.actionWrite.triggered.connect(self.write) self.actionEarth_Model.triggered.connect( lambda: self.open_earth_model()) self.actionFrom_File.triggered.connect( lambda: self.load_event_from_isolapath()) self.actionOpen_Help.triggered.connect(lambda: self.open_help()) self.stationsBtn.clicked.connect(self.stationsInfo) self.run_inversionBtn.clicked.connect(lambda: self.run_inversion()) self.stations_mapBtn.clicked.connect(lambda: self.plot_map_stations()) self.plot_solutionBtn.clicked.connect(lambda: self.plot_solution()) #self.earthmodelBtn.clicked.connect(self.read_earth_model) # Parameters settings self.parameters = ParametersSettings() self.earth_model = CrustalModelParametersFrame() # help Documentation self.help = HelpDoc()
def on_click_select_file(self, bind: BindPyqtObject): file_path = pw.QFileDialog.getOpenFileName(self, 'Select Directory', bind.value) file_path = file_path[0] if file_path: bind.value = file_path
def __init__(self, parent: pw.QWidget = None): super(SyntheticsAnalisysFrame, self).__init__(parent) self.setupUi(self) ParentWidget.set_parent(parent, self) self.setWindowTitle('Synthetics Analysis Frame') self.setWindowIcon(pqg.QIcon(':\icons\pen-icon.png')) #Initialize parametrs for plot rotation self._z = {} self._r = {} self._t = {} self._st = {} self.inventory = {} parameters = {} self._generator = SyntheticsGeneratorDialog(self) # 3C_Component self.focmec_canvas = FocCanvas(self.widget_fp) self.canvas = MatplotlibCanvas(self.plotMatWidget_3C) self.canvas.set_new_subplot(3, ncols=1) # Map self.cartopy_canvas = CartopyCanvas(self.map_widget) # binds self.root_path_bind_3C = BindPyqtObject(self.rootPathForm_3C, self.onChange_root_path_3C) self.vertical_form_bind = BindPyqtObject(self.verticalQLineEdit) self.north_form_bind = BindPyqtObject(self.northQLineEdit) self.east_form_bind = BindPyqtObject(self.eastQLineEdit) self.generation_params_bind = BindPyqtObject(self.paramsPathLineEdit) # accept drops self.vertical_form_bind.accept_dragFile(drop_event_callback=self.drop_event) self.north_form_bind.accept_dragFile(drop_event_callback=self.drop_event) self.east_form_bind.accept_dragFile(drop_event_callback=self.drop_event) self.generation_params_bind.accept_dragFile(drop_event_callback=self.drop_event) self.paramsPathLineEdit.textChanged.connect(self._generationParamsChanged) # Add file selector to the widget self.file_selector = FilesView(self.root_path_bind_3C.value, parent=self.fileSelectorWidget) self.file_selector.setDragEnabled(True) self.selectDirBtn_3C.clicked.connect(self.on_click_select_directory_3C) self.plotBtn.clicked.connect(self.on_click_rotate) ### self.stationsBtn.clicked.connect(self.stationsInfo) ### self.actionGenerate_synthetics.triggered.connect(lambda : self._generator.show())
def on_click_select_directory(self, bind: BindPyqtObject): if "darwin" == platform: dir_path = pw.QFileDialog.getExistingDirectory(self, 'Select Directory', bind.value) else: dir_path = pw.QFileDialog.getExistingDirectory(self, 'Select Directory', bind.value, pw.QFileDialog.DontUseNativeDialog) if dir_path: bind.value = dir_path
def __init__(self, parent: pw.QWidget): super(Earthquake3CFrame, self).__init__(parent) self.setupUi(self) ParentWidget.set_parent(parent, self) #Initialize parametrs for plot rotation self._z = {} self._r = {} self._t = {} self._st = {} self.inventory = {} #self.filter_3ca = FilterBox(self.toolQFrame, 1) # add filter box component. self.parameters = ParametersSettings() # 3C_Component self.canvas = MatplotlibCanvas(self.plotMatWidget_3C) self.canvas.set_new_subplot(3, ncols=1) self.canvas_pol = MatplotlibCanvas(self.Widget_polarization) self.canvas.mpl_connect('key_press_event', self.key_pressed) # binds self.root_path_bind_3C = BindPyqtObject(self.rootPathForm_3C, self.onChange_root_path_3C) self.degreeSB_bind = BindPyqtObject(self.degreeSB) self.vertical_form_bind = BindPyqtObject(self.verticalQLineEdit) self.north_form_bind = BindPyqtObject(self.northQLineEdit) self.east_form_bind = BindPyqtObject(self.eastQLineEdit) # accept drops self.vertical_form_bind.accept_dragFile( drop_event_callback=self.drop_event) self.north_form_bind.accept_dragFile( drop_event_callback=self.drop_event) self.east_form_bind.accept_dragFile( drop_event_callback=self.drop_event) # Add file selector to the widget self.file_selector = FilesView(self.root_path_bind_3C.value, parent=self.fileSelectorWidget) self.file_selector.setDragEnabled(True) self.selectDirBtn_3C.clicked.connect(self.on_click_select_directory_3C) self.rotateplotBtn.clicked.connect( lambda: self.on_click_rotate(self.canvas)) self.rot_macroBtn.clicked.connect( lambda: self.open_parameters_settings()) self.polarizationBtn.clicked.connect(self.on_click_polarization) ### self.plotpolBtn.clicked.connect(self.plot_particle_motion) self.stationsBtn.clicked.connect(self.stationsInfo) self.save_rotatedBtn.clicked.connect(self.save_rotated)
def __init__(self, parent: pw.QWidget, current_index=-1): super(FilterBox, self).__init__(parent) self.setupUi(self) self.__parent_name = parent.objectName( ) # used to save values in a group. # set the parent properly ParentWidget.set_parent(parent, self, current_index) # force parent to have the same maximumSize and minimumSize of FileBox # parent.setMaximumSize(self.maximumSize()) # parent.setMinimumSize(self.minimumSize()) # Clean and add options to combo box. self.fiterComboBox.clear() self.fiterComboBox.addItems(Filters.get_filters()) # bind widgets from filter box. self.__filter_pick_bind = BindPyqtObject(self.fiterComboBox) self.__poles_bind = BindPyqtObject(self.nPolesSb) self.__min_freq_bind = BindPyqtObject(self.lowFreqDsb) self.__max_freq_bind = BindPyqtObject(self.upperFreqDsb)
def __init__(self, parent: pw.QWidget, current_index=-1): super(SpectrumBox, self).__init__(parent) self.setupUi(self) self.__parent_name = parent.objectName( ) # used to save values in a group. # set the parent properly ParentWidget.set_parent(parent, self, current_index) self.__mtp_click_callback = None self.__cwt_click_callback = None # button bind self.plotMTPBtn.clicked.connect(lambda: self.__on_click_plot_mtp()) self.plotCWTBtn.clicked.connect(lambda: self.__on_click_plot_cwt()) # binds self.win_bind = BindPyqtObject(self.winLenghtSpecSb) self.ntapers_bind = BindPyqtObject(self.ntapersSb) self.tw_bind = BindPyqtObject(self.twDsb) self.w1_bind = BindPyqtObject(self.win1Dsb) self.w2_bind = BindPyqtObject(self.win2Dsb)
def __init__(self, parent: pw.QWidget): super(EarthquakeLocationFrame, self).__init__(parent) self.setupUi(self) ParentWidget.set_parent(parent, self) self.__pick_output_path = PickerManager.get_default_output_path() self.__dataless_dir = None self.__nll_manager = None self.__first_polarity = None # Map self.cartopy_canvas = CartopyCanvas(self.widget_map) # Canvas for Earthquake Location Results self.residuals_canvas = MatplotlibCanvas(self.plotMatWidget_residuals) #self.residuals_canvas.figure.subplots_adjust(left = 0.03, bottom = 0.36, right=0.97, top=0.95, wspace=0.2, # hspace=0.0) # Canvas for FOCMEC Results self.focmec_canvas = FocCanvas(self.widget_focmec) self.grid_latitude_bind = BindPyqtObject(self.gridlatSB) self.grid_longitude_bind = BindPyqtObject(self.gridlonSB) self.grid_depth_bind = BindPyqtObject(self.griddepthSB) self.grid_xnode_bind = BindPyqtObject(self.xnodeSB) self.grid_ynode_bind = BindPyqtObject(self.ynodeSB) self.grid_znode_bind = BindPyqtObject(self.znodeSB) self.grid_dxsize_bind = BindPyqtObject(self.dxsizeSB) self.grid_dysize_bind = BindPyqtObject(self.dysizeSB) self.grid_dzsize_bind = BindPyqtObject(self.dzsizeSB) self.genvelBtn.clicked.connect(lambda: self.on_click_run_vel_to_grid()) self.grdtimeBtn.clicked.connect( lambda: self.on_click_run_grid_to_time()) self.runlocBtn.clicked.connect(lambda: self.on_click_run_loc()) self.plotmapBtn.clicked.connect(lambda: self.on_click_plot_map()) self.stationsBtn.clicked.connect( lambda: self.on_click_select_metadata_file()) self.firstpolarityBtn.clicked.connect(self.first_polarity) self.plotpdfBtn.clicked.connect(self.plot_pdf)
def __init__(self): super(FrequencyTimeFrame, self).__init__() self.setupUi(self) self.solutions = [] self.periods_now = [] self.colors = ["white", "green", "black"] self._stations_info = {} self.parameters = ParametersSettings() # Binds self.root_path_bind = BindPyqtObject(self.rootPathForm_2, self.onChange_root_path) self.canvas_plot1 = MatplotlibCanvas(self.widget_plot_up, ncols=2, sharey = True) top = 0.900 bottom = 0.180 left = 0.045 right = 0.720 wspace = 0.135 self.canvas_plot1.figure.subplots_adjust(left=left, bottom=bottom, right=right, top=top, wspace=wspace, hspace=0.0) ax = self.canvas_plot1.get_axe(0) left,width = 0.2, 0.55 bottom, height = 0.180, 0.72 spacing = 0.02 coords_ax = [left+width+spacing, bottom, 0.2, height] self.fig = ax.get_figure() #self.ax_seism1 = self.fig.add_axes(coords_ax, sharey = ax) self.ax_seism1 = self.fig.add_axes(coords_ax) self.ax_seism1.yaxis.tick_right() # Add file selector to the widget self.file_selector = FilesView(self.root_path_bind.value, parent=self.fileSelectorWidget_2, on_change_file_callback=lambda file_path: self.onChange_file(file_path)) # Binds self.selectDirBtn_2.clicked.connect(lambda: self.on_click_select_directory(self.root_path_bind)) # action self.plotBtn.clicked.connect(self.plot_seismogram) self.plot2Btn.clicked.connect(self.run_phase_vel) self.stationsBtn.clicked.connect(self.stations_info) self.macroBtn.clicked.connect(lambda: self.open_parameters_settings()) # clicks self.canvas_plot1.on_double_click(self.on_click_matplotlib) self.canvas_plot1.mpl_connect('key_press_event', self.key_pressed)
def __init__(self, ): super(TimeFrequencyFrame, self).__init__() self.setupUi(self) self.dayplot_frame = None # Bind buttons self.selectDirBtn.clicked.connect(self.on_click_select_directory) self.dayPlotBtn.clicked.connect(self.on_click_dayplot) # Bind qt objects self.root_path_bind = BindPyqtObject(self.rootPathForm, self.onChange_root_path) self.event_info = EventInfoBox(self.mainToolsWidget, None) self.event_info.set_buttons_visibility(False) # Add file selector to the widget self.file_selector = FilesView( self.root_path_bind.value, parent=self.fileSelectorWidget, on_change_file_callback=lambda file_path: self.onChange_file( file_path)) self.time_analysis_widget = TimeAnalysisWidget( self.canvasWidget, parent_name="time_analysis_0") self.time_analysis_widget2 = TimeAnalysisWidget( self.canvasWidget, parent_name="time_analysis_1") self.time_analysis_windows = [ self.time_analysis_widget, self.time_analysis_widget2 ] for taw in self.time_analysis_windows: taw.register_file_selector(self.file_selector) taw.set_event_info(self.event_info) self.actionPlotEnvelope.toggled.connect(self.on_envelop_toggle)
def __init__(self, parent, total_items: int, items_per_page: int = 1): super(Pagination, self).__init__(parent) self.setupUi(self) self.page_buttons = [ self.page1Btn, self.page2Btn, self.page3Btn, self.page4Btn, self.page5Btn ] self.__num_of_page_btn = len(self.page_buttons) # set the parent properly ParentWidget.set_parent(parent, self) self.__items_per_page = items_per_page self.__current_page = 1 self.__total_items = total_items self.__number_of_pages = self.number_of_pages self.firstPageBtn.clicked.connect(lambda: self.__onPage_changed(1)) self.lastPageBtn.clicked.connect( lambda: self.__onPage_changed(self.number_of_pages)) self.previousPageBtn.clicked.connect( lambda: self.__onPage_changed(max(self.__current_page - 1, 1))) self.nextPageBtn.clicked.connect(lambda: self.__onPage_changed( (min(self.__current_page + 1, self.number_of_pages)))) self.page_pick_bind = BindPyqtObject(self.itemsPerPagePicker, self.__onChange_items_per_page) self.__update_buttons() for btn in self.page_buttons: self.__bind_page_btn_click(btn) self.__onPageChange_callback = None self.__onItemPerPageChange_callback = None
def __init__(self, parent: pw.QWidget, current_index=-1): super(StationInfoBox, self).__init__(parent) self.setupUi(self) self.__parent_name = parent.objectName( ) # used to save values in a group. # set the parent properly ParentWidget.set_parent(parent, self, current_index) # binds self.latitude_bind = BindPyqtObject(self.latitudeDsb) self.longitude_bind = BindPyqtObject(self.longitudeDsb) self.network_station_bind = BindPyqtObject(self.networkStationQline) self.channel_bind = BindPyqtObject(self.channelQline) self.start_time_bind = BindPyqtObject(self.startTimeQline) self.end_time_bind = BindPyqtObject(self.endTimeQline) self.__basic_info_fields = [ self.network_station_bind, self.channel_bind, self.start_time_bind, self.end_time_bind ]
class SyntheticsAnalisysFrame(pw.QMainWindow, UiSyntheticsAnalisysFrame): def __init__(self, parent: pw.QWidget = None): super(SyntheticsAnalisysFrame, self).__init__(parent) self.setupUi(self) ParentWidget.set_parent(parent, self) self.setWindowTitle('Synthetics Analysis Frame') self.setWindowIcon(pqg.QIcon(':\icons\pen-icon.png')) #Initialize parametrs for plot rotation self._z = {} self._r = {} self._t = {} self._st = {} self.inventory = {} parameters = {} self._generator = SyntheticsGeneratorDialog(self) # 3C_Component self.focmec_canvas = FocCanvas(self.widget_fp) self.canvas = MatplotlibCanvas(self.plotMatWidget_3C) self.canvas.set_new_subplot(3, ncols=1) # Map self.cartopy_canvas = CartopyCanvas(self.map_widget) # binds self.root_path_bind_3C = BindPyqtObject(self.rootPathForm_3C, self.onChange_root_path_3C) self.vertical_form_bind = BindPyqtObject(self.verticalQLineEdit) self.north_form_bind = BindPyqtObject(self.northQLineEdit) self.east_form_bind = BindPyqtObject(self.eastQLineEdit) self.generation_params_bind = BindPyqtObject(self.paramsPathLineEdit) # accept drops self.vertical_form_bind.accept_dragFile(drop_event_callback=self.drop_event) self.north_form_bind.accept_dragFile(drop_event_callback=self.drop_event) self.east_form_bind.accept_dragFile(drop_event_callback=self.drop_event) self.generation_params_bind.accept_dragFile(drop_event_callback=self.drop_event) self.paramsPathLineEdit.textChanged.connect(self._generationParamsChanged) # Add file selector to the widget self.file_selector = FilesView(self.root_path_bind_3C.value, parent=self.fileSelectorWidget) self.file_selector.setDragEnabled(True) self.selectDirBtn_3C.clicked.connect(self.on_click_select_directory_3C) self.plotBtn.clicked.connect(self.on_click_rotate) ### self.stationsBtn.clicked.connect(self.stationsInfo) ### self.actionGenerate_synthetics.triggered.connect(lambda : self._generator.show()) def info_message(self, msg): md = MessageDialog(self) md.set_info_message(msg) def _generationParamsChanged(self): with open(self.generation_params_file, 'rb') as f: self.params = pickle.load(f) depth_est =self.params['sourcedepthinmeters'] depth_est =(float(depth_est))/1000 #self.paramsTextEdit.setPlainText(str(params)) self.paramsTextEdit.setPlainText("Earth Model: {model}".format(model=self.params['model'])) self.paramsTextEdit.appendPlainText("Event Coords: {lat} {lon} {depth}".format( lat=self.params['sourcelatitude'],lon=self.params['sourcelongitude'], depth=str(depth_est))) self.paramsTextEdit.appendPlainText("Time: {time}".format(time=self.params['origintime'])) self.paramsTextEdit.appendPlainText("Units: {units}".format(units=self.params['units'])) if 'sourcedoublecouple' in self.params: self.paramsTextEdit.appendPlainText("Source: {source}".format(source= self.params['sourcedoublecouple'])) if 'sourcemomenttensor' in self.params: self.paramsTextEdit.appendPlainText("Source: {source}".format(source= self.params['sourcemomenttensor'])) @staticmethod def drop_event(event: pqg.QDropEvent, bind_object: BindPyqtObject): data = event.mimeData() url = data.urls()[0] bind_object.value = url.fileName() @property def north_component_file(self): return os.path.join(self.root_path_bind_3C.value, self.north_form_bind.value) @property def vertical_component_file(self): return os.path.join(self.root_path_bind_3C.value, self.vertical_form_bind.value) @property def east_component_file(self): return os.path.join(self.root_path_bind_3C.value, self.east_form_bind.value) @property def generation_params_file(self): return os.path.join(self.root_path_bind_3C.value, self.generation_params_bind.value) def onChange_root_path_3C(self, value): """ Fired every time the root_path is changed :param value: The path of the new directory. :return: """ self.file_selector.set_new_rootPath(value) # Function added for 3C Components def on_click_select_directory_3C(self): if "darwin" == platform: dir_path = pw.QFileDialog.getExistingDirectory(self, 'Select Directory', self.root_path_bind_3C.value) else: dir_path = pw.QFileDialog.getExistingDirectory(self, 'Select Directory', self.root_path_bind_3C.value, pw.QFileDialog.DontUseNativeDialog) if dir_path: self.root_path_bind_3C.value = dir_path def on_click_rotate(self, canvas): time1 = convert_qdatetime_utcdatetime(self.dateTimeEdit_4) time2 = convert_qdatetime_utcdatetime(self.dateTimeEdit_5) try: sd = SeismogramData(self.vertical_component_file) z = sd.get_waveform() sd = SeismogramData(self.north_component_file) n = sd.get_waveform() sd = SeismogramData(self.east_component_file) e = sd.get_waveform() seismograms = [z, n, e] time = z.times("matplotlib") self._st = Stream(traces=seismograms) for index, data in enumerate(seismograms): self.canvas.plot(time, data, index, color="black", linewidth=0.5) info = "{}.{}.{}".format(self._st[index].stats.network, self._st[index].stats.station, self._st[index].stats.channel) ax = self.canvas.get_axe(0) ax.set_xlim(time1.matplotlib_date, time2.matplotlib_date) formatter = mdt.DateFormatter('%Y/%m/%d/%H:%M:%S') ax.xaxis.set_major_formatter(formatter) self.canvas.set_plot_label(index, info) self.canvas.set_xlabel(2, "Time (s)") if 'sourcedoublecouple' in self.params: self.focmec_canvas.drawSynthFocMec(0, first_polarity = self.params['sourcedoublecouple'], mti = []) if 'sourcemomenttensor' in self.params: self.focmec_canvas.drawSynthFocMec(0, first_polarity= [], mti=self.params['sourcemomenttensor']) except InvalidFile: self.info_message("Invalid mseed files. Please, make sure you have generated correctly the synthetics") self.__map_coords() def stationsInfo(self): files = [] try: if self.vertical_component_file and self.north_component_file and self.east_component_file: files = [self.vertical_component_file, self.north_component_file, self.east_component_file] except: pass sd = [] if len(files)==3: for file in files: try: st = SeismogramDataAdvanced(file) station = [st.stats.Network,st.stats.Station,st.stats.Location,st.stats.Channel,st.stats.StartTime, st.stats.EndTime, st.stats.Sampling_rate, st.stats.Npts] sd.append(station) except: pass self._stations_info = StationsInfo(sd) self._stations_info.show() def __map_coords(self): map_dict = {} sd = [] with open(self.generation_params_file, 'rb') as f: params = pickle.load(f) n = len(params["bulk"]) for j in range(n): for key in params["bulk"][j]: if key == "latitude": lat = params["bulk"][j][key] elif key == "longitude": lon = params["bulk"][j][key] #elif key == "networkcode": # net = params["bulk"][j][key] elif key == "stationcode": sta = params["bulk"][j][key] sd.append(sta) map_dict[sta] = [lon, lat] self.cartopy_canvas.plot_map(params['sourcelongitude'], params['sourcelatitude'], 0, 0, 0, 0, resolution='low', stations=map_dict)
def on_click_select_file(self, bind: BindPyqtObject): selected = pw.QFileDialog.getOpenFileName(self, "Select metadata file") if isinstance(selected[0], str) and os.path.isfile(selected[0]): bind.value = selected[0]
def drop_event(event: pqg.QDropEvent, bind_object: BindPyqtObject): data = event.mimeData() url = data.urls()[0] bind_object.value = url.fileName()
class Earthquake3CFrame(pw.QFrame, UiEarthquake3CFrame): def __init__(self, parent: pw.QWidget): super(Earthquake3CFrame, self).__init__(parent) self.setupUi(self) ParentWidget.set_parent(parent, self) #Initialize parametrs for plot rotation self._z = {} self._r = {} self._t = {} self._st = {} self.inventory = {} #self.filter_3ca = FilterBox(self.toolQFrame, 1) # add filter box component. self.parameters = ParametersSettings() # 3C_Component self.canvas = MatplotlibCanvas(self.plotMatWidget_3C) self.canvas.set_new_subplot(3, ncols=1) self.canvas_pol = MatplotlibCanvas(self.Widget_polarization) self.canvas.mpl_connect('key_press_event', self.key_pressed) # binds self.root_path_bind_3C = BindPyqtObject(self.rootPathForm_3C, self.onChange_root_path_3C) self.degreeSB_bind = BindPyqtObject(self.degreeSB) self.vertical_form_bind = BindPyqtObject(self.verticalQLineEdit) self.north_form_bind = BindPyqtObject(self.northQLineEdit) self.east_form_bind = BindPyqtObject(self.eastQLineEdit) # accept drops self.vertical_form_bind.accept_dragFile( drop_event_callback=self.drop_event) self.north_form_bind.accept_dragFile( drop_event_callback=self.drop_event) self.east_form_bind.accept_dragFile( drop_event_callback=self.drop_event) # Add file selector to the widget self.file_selector = FilesView(self.root_path_bind_3C.value, parent=self.fileSelectorWidget) self.file_selector.setDragEnabled(True) self.selectDirBtn_3C.clicked.connect(self.on_click_select_directory_3C) self.rotateplotBtn.clicked.connect( lambda: self.on_click_rotate(self.canvas)) self.rot_macroBtn.clicked.connect( lambda: self.open_parameters_settings()) self.polarizationBtn.clicked.connect(self.on_click_polarization) ### self.plotpolBtn.clicked.connect(self.plot_particle_motion) self.stationsBtn.clicked.connect(self.stationsInfo) self.save_rotatedBtn.clicked.connect(self.save_rotated) ### def open_parameters_settings(self): self.parameters.show() def info_message(self, msg): md = MessageDialog(self) md.set_info_message(msg) @staticmethod def drop_event(event: pqg.QDropEvent, bind_object: BindPyqtObject): data = event.mimeData() url = data.urls()[0] bind_object.value = url.fileName() @property def north_component_file(self): return os.path.join(self.root_path_bind_3C.value, self.north_form_bind.value) @property def vertical_component_file(self): return os.path.join(self.root_path_bind_3C.value, self.vertical_form_bind.value) @property def east_component_file(self): return os.path.join(self.root_path_bind_3C.value, self.east_form_bind.value) def onChange_root_path_3C(self, value): """ Fired every time the root_path is changed :param value: The path of the new directory. :return: """ self.file_selector.set_new_rootPath(value) # Function added for 3C Components def on_click_select_directory_3C(self): if "darwin" == platform: dir_path = pw.QFileDialog.getExistingDirectory( self, 'Select Directory', self.root_path_bind_3C.value) else: dir_path = pw.QFileDialog.getExistingDirectory( self, 'Select Directory', self.root_path_bind_3C.value, pw.QFileDialog.DontUseNativeDialog) if dir_path: self.root_path_bind_3C.value = dir_path def set_times(self, st): max_start = np.max([tr.stats.starttime for tr in st]) min_end = np.min([tr.stats.endtime for tr in st]) return min_end, max_start def on_click_rotate(self, canvas): time1 = convert_qdatetime_utcdatetime(self.dateTimeEdit_4) time2 = convert_qdatetime_utcdatetime(self.dateTimeEdit_5) angle = self.degreeSB.value() incidence_angle = self.incidenceSB.value() method = self.methodCB.currentText() parameters = self.parameters.getParameters() try: sd = PolarizationAnalyis(self.vertical_component_file, self.north_component_file, self.east_component_file) time, z, r, t, st = sd.rotate(self.inventory, time1, time2, angle, incidence_angle, method=method, parameters=parameters, trim=True) self._z = z self._r = r self._t = t self._st = st rotated_seismograms = [z, r, t] for index, data in enumerate(rotated_seismograms): self.canvas.plot(time, data, index, color="black", linewidth=0.5) info = "{}.{}.{}".format(self._st[index].stats.network, self._st[index].stats.station, self._st[index].stats.channel) ax = self.canvas.get_axe(0) ax.set_xlim(sd.t1.matplotlib_date, sd.t2.matplotlib_date) formatter = mdt.DateFormatter('%Y/%m/%d/%H:%M:%S') ax.xaxis.set_major_formatter(formatter) self.canvas.set_plot_label(index, info) canvas.set_xlabel(2, "Time (s)") except InvalidFile: self.info_message( "Invalid mseed files. Please, make sure to select all the three components (Z, N, E) " "for rotate.") except ValueError as error: self.info_message(str(error)) def on_click_polarization(self): time1 = convert_qdatetime_utcdatetime(self.dateTimeEdit_4) time2 = convert_qdatetime_utcdatetime(self.dateTimeEdit_5) sd = PolarizationAnalyis(self.vertical_component_file, self.north_component_file, self.east_component_file) try: var = sd.polarize(time1, time2, self.doubleSpinBox_winlen.value(), self.freq_minDB.value(), self.freq_maxDB.value()) artist = self.canvas_pol.plot( var['time'], var[self.comboBox_yaxis.currentText()], 0, clear_plot=True, linewidth=0.5) self.canvas_pol.set_xlabel(0, "Time [s]") self.canvas_pol.set_ylabel(0, self.comboBox_yaxis.currentText()) self.canvas_pol.set_yaxis_color(self.canvas_pol.get_axe(0), artist.get_color(), is_left=True) self.canvas_pol.plot(var['time'], var[self.comboBox_polarity.currentText()], 0, is_twinx=True, color="red", linewidth=0.5) self.canvas_pol.set_ylabel_twinx( 0, self.comboBox_polarity.currentText()) except InvalidFile: self.info_message( "Invalid mseed files. Please, make sure to select all the three components (Z, N, E) " "for polarization.") except ValueError as error: self.info_message(str(error)) def plot_particle_motion(self): self._plot_polarization = PlotPolarization(self._z, self._r, self._t) self._plot_polarization.show() def stationsInfo(self): files = [] try: if self.vertical_component_file and self.north_component_file and self.east_component_file: files = [ self.vertical_component_file, self.north_component_file, self.east_component_file ] except: pass sd = [] if len(files) == 3: for file in files: try: st = SeismogramDataAdvanced(file) station = [ st.stats.Network, st.stats.Station, st.stats.Location, st.stats.Channel, st.stats.StartTime, st.stats.EndTime, st.stats.Sampling_rate, st.stats.Npts ] sd.append(station) except: pass self._stations_info = StationsInfo(sd) self._stations_info.show() def save_rotated(self): import os root_path = os.path.dirname(os.path.abspath(__file__)) if "darwin" == platform: dir_path = pw.QFileDialog.getExistingDirectory( self, 'Select Directory', root_path) else: dir_path = pw.QFileDialog.getExistingDirectory( self, 'Select Directory', root_path, pw.QFileDialog.DontUseNativeDialog) if self._st: n = len(self._st) for j in range(n): tr = self._st[j] t1 = tr.stats.starttime id = tr.id + "." + "D" + "." + str(t1.year) + "." + str( t1.julday) print(tr.id, "Writing data processed") path_output = os.path.join(dir_path, id) tr.write(path_output, format="MSEED") def key_pressed(self, event): if event.key == 'q': x1, y1 = event.xdata, event.ydata tt = UTCDateTime(mdt.num2date(x1)) set_qdatetime(tt, self.dateTimeEdit_4) self.canvas.draw_arrow(x1, 0, arrow_label="st", color="purple", linestyles='--', picker=False) self.canvas.draw_arrow(x1, 1, arrow_label="st", color="purple", linestyles='--', picker=False) self.canvas.draw_arrow(x1, 2, arrow_label="st", color="purple", linestyles='--', picker=False) if event.key == 'e': x1, y1 = event.xdata, event.ydata tt = UTCDateTime(mdt.num2date(x1)) set_qdatetime(tt, self.dateTimeEdit_5) self.canvas.draw_arrow(x1, 0, arrow_label="et", color="purple", linestyles='--', picker=False) self.canvas.draw_arrow(x1, 1, arrow_label="st", color="purple", linestyles='--', picker=False) self.canvas.draw_arrow(x1, 2, arrow_label="st", color="purple", linestyles='--', picker=False)
def __init__(self): super(RealTimeFrame, self).__init__() self.setupUi(self) self.setWindowIcon(pqg.QIcon(':\\icons\\map-icon.png')) self.widget_map = None self.settings_dialog = SettingsDialog(self) self.inventory = {} self.files = [] self.events_times = [] self.total_items = 0 self.items_per_page = 1 self.__dataless_manager = None self.__metadata_manager = None self.st = None self.client = None self.stations_available = [] self.data_dict = {} self.dataless_not_found = set( ) # a set of mseed files that the dataless couldn't find. self.metadata_path_bind = BindPyqtObject(self.datalessPathForm, self.onChange_metadata_path) self.canvas = MatplotlibCanvas(self.plotMatWidget, nrows=self.numTracesCB.value(), constrained_layout=False) self.canvas.figure.tight_layout() self.timer_outdated = pyc.QTimer() self.timer_outdated.setInterval(1000) # 1 second self.timer_outdated.timeout.connect(self.outdated_stations) # Binding self.root_path_bind = BindPyqtObject(self.rootPathForm) self.dataless_path_bind = BindPyqtObject(self.datalessPathForm) # Bind self.selectDirBtn.clicked.connect( lambda: self.on_click_select_directory(self.root_path_bind)) #self.selectDatalessDirBtn.clicked.connect(lambda: self.on_click_select_directory(self.dataless_path_bind)) self.metadata_path_bind = BindPyqtObject(self.datalessPathForm, self.onChange_metadata_path) self.selectDatalessDirBtn.clicked.connect( lambda: self.on_click_select_metadata_file(self.metadata_path_bind )) self.actionSet_Parameters.triggered.connect( lambda: self.open_parameters_settings()) self.mapBtn.clicked.connect(self.show_map) # self.__metadata_manager = MetadataManager(self.dataless_path_bind.value) self.actionSet_Parameters.triggered.connect( lambda: self.open_parameters_settings()) self.actionArray_Anlysis.triggered.connect(self.open_array_analysis) self.actionMoment_Tensor_Inversion.triggered.connect( self.open_moment_tensor) self.actionTime_Frequency_Analysis.triggered.connect( self.time_frequency_analysis) self.actionReceiver_Functions.triggered.connect( self.open_receiver_functions) self.actionOpen_Settings.triggered.connect( lambda: self.settings_dialog.show()) self.actionOpen_Help.triggered.connect(lambda: self.open_help()) self.RetrieveBtn.clicked.connect(self.retrieve_data) self.stopBtn.clicked.connect(self.stop) # Parameters settings self.parameters = ParametersSettings() # Earth Model Viewer self.earthmodel = EarthModelViewer() # help Documentation self.help = HelpDoc()
def __init__(self): super(ArrayAnalysisFrame, self).__init__() self.setupUi(self) self.__stations_dir = None self.stream_frame = None self.__metadata_manager = None self.inventory = {} self._stations_info = {} self._stations_coords = {} self.stack = None self.canvas = MatplotlibCanvas(self.responseMatWidget) self.canvas_fk = MatplotlibCanvas(self.widget_fk, nrows=4) self.canvas_slow_map = MatplotlibCanvas(self.widget_slow_map) self.canvas_fk.on_double_click(self.on_click_matplotlib) self.canvas_stack = MatplotlibCanvas(self.widget_stack) self.cartopy_canvas = CartopyCanvas(self.widget_map) self.canvas.set_new_subplot(1, ncols=1) #Binding self.root_pathFK_bind = BindPyqtObject(self.rootPathFormFK) self.root_pathBP_bind = BindPyqtObject(self.rootPathFormBP) self.metadata_path_bind = BindPyqtObject(self.datalessPathForm, self.onChange_metadata_path) self.metadata_path_bindBP = BindPyqtObject(self.datalessPathFormBP, self.onChange_metadata_path) self.output_path_bindBP = BindPyqtObject(self.outputPathFormBP, self.onChange_metadata_path) self.fmin_bind = BindPyqtObject(self.fminSB) self.fmax_bind = BindPyqtObject(self.fmaxSB) self.grid_bind = BindPyqtObject(self.gridSB) self.smax_bind = BindPyqtObject(self.smaxSB) # On select self.canvas_fk.register_on_select(self.on_select, rectprops=dict(alpha=0.2, facecolor='red')) self.fminFK_bind = BindPyqtObject(self.fminFKSB) self.fmaxFK_bind = BindPyqtObject(self.fmaxFKSB) self.overlap_bind = BindPyqtObject(self.overlapSB) self.timewindow_bind = BindPyqtObject(self.timewindowSB) self.smaxFK_bind = BindPyqtObject(self.slowFKSB) self.slow_grid_bind = BindPyqtObject(self.gridFKSB) # Bind buttons self.selectDirBtnFK.clicked.connect( lambda: self.on_click_select_directory(self.root_pathFK_bind)) self.datalessBtn.clicked.connect( lambda: self.on_click_select_metadata_file(self.metadata_path_bind )) # Bind buttons BackProjection self.selectDirBtnBP.clicked.connect( lambda: self.on_click_select_directory(self.root_pathBP_bind)) self.datalessBtnBP.clicked.connect( lambda: self.on_click_select_metadata_file(self. metadata_path_bindBP)) self.outputBtn.clicked.connect( lambda: self.on_click_select_directory(self.output_path_bindBP)) #Action Buttons self.arfBtn.clicked.connect(lambda: self.arf()) self.runFKBtn.clicked.connect(lambda: self.FK_plot()) self.plotBtn.clicked.connect(lambda: self.plot_seismograms()) self.plotBtnBP.clicked.connect(lambda: self.plot_seismograms(FK=False)) self.actionSettings.triggered.connect( lambda: self.open_parameters_settings()) self.actionProcessed_Seimograms.triggered.connect(self.write) self.actionStacked_Seismograms.triggered.connect(self.write_stack) self.stationsBtn.clicked.connect(lambda: self.stationsInfo()) self.stationsBtnBP.clicked.connect(lambda: self.stationsInfo(FK=False)) self.mapBtn.clicked.connect(self.stations_map) self.actionCreate_Stations_File.triggered.connect( self.stations_coordinates) self.actionLoad_Stations_File.triggered.connect(self.load_path) self.actionRunVespagram.triggered.connect(self.open_vespagram) self.shortcut_open = pw.QShortcut(pqg.QKeySequence('Ctrl+O'), self) self.shortcut_open.activated.connect(self.open_solutions) self.create_gridBtn.clicked.connect(self.create_grid) self.actionOpen_Help.triggered.connect(lambda: self.open_help()) self.load_videoBtn.clicked.connect(self.loadvideoBP) # help Documentation self.help = HelpDoc() # Parameters settings self.__parameters = ParametersSettings() # Stations Coordinates self.__stations_coords = StationsCoords() # picks self.picks = { 'Time': [], 'Phase': [], 'BackAzimuth': [], 'Slowness': [], 'Power': [] } # video self.player = QMediaPlayer(None, QMediaPlayer.VideoSurface) self.player.setVideoOutput(self.backprojection_widget) self.player.stateChanged.connect(self.mediaStateChanged) self.player.positionChanged.connect(self.positionChanged) self.player.durationChanged.connect(self.durationChanged) self.playButton.setIcon(self.style().standardIcon(QStyle.SP_MediaPlay)) self.playButton.clicked.connect(self.play_bp) self.positionSlider.sliderMoved.connect(self.setPosition)