def dispMousePos(self, pos): # Display current mouse coords if over the scatter plot area as a tooltip x_coord = UTCDateTime( self.active_plot.vb.mapSceneToView(pos).toPoint().x()) time_tool = self.active_plot.setToolTip(x_coord.ctime())
def upd_xml_sql(self): # Look at the SQL database and create dictionary for start and end dates for each station # iterate through stations print( "\nQuerying SQLite database for start/end dates for each station") print("This may take a while.......") def overwrite_info(st, et): # fix the station inventory self.inv[0][i].start_date = st self.inv[0][i].end_date = et # Fix the channel for _j, chan in enumerate(self.inv[0][i]): self.inv[0][i][_j].start_date = st self.inv[0][i][_j].end_date = et for i, station_obj in enumerate(self.inv[0]): station = station_obj.code comp_regex = re.compile('..Z') if os.path.splitext(self.db_filename)[1] == ".db": for min_max in self.session.query(func.min(Waveforms.starttime), func.max(Waveforms.endtime)). \ filter(Waveforms.station == station, Waveforms.component.like('__Z')): start_time = UTCDateTime(min_max[0]) end_time = UTCDateTime(min_max[1]) elif os.path.splitext(self.db_filename)[1] == ".json": temp_extent = [] for key, matched_entry in self.network_dict.iteritems(): if (matched_entry['station'] == station) and re.match( comp_regex, matched_entry['component']): if len(temp_extent) == 0: # first iteration temp_extent = [ matched_entry['starttime'], matched_entry['endtime'] ] continue # check the current iterate if (matched_entry['starttime'] < temp_extent[0]): temp_extent[0] = matched_entry['starttime'] if (matched_entry['endtime'] > temp_extent[1]): temp_extent[1] = matched_entry['endtime'] start_time = UTCDateTime(temp_extent[0]) end_time = UTCDateTime(temp_extent[1]) print("\nRecording interval for: " + station) print("\tStart Date: " + start_time.ctime()) print("\tEnd Date: " + end_time.ctime()) overwrite_info(start_time, end_time) # Overwrite the original station XML file self.inv.write(self.stn_filename, format="STATIONXML") print("\nFinished Updating StationXML file: " + self.stn_filename)