def plot_events(self, plot_type="map"): """ Plots the domain and beachballs for all events on the map. :param plot_type: Determines the type of plot created. * ``map`` (default) - a map view of the events * ``depth`` - a depth distribution histogram * ``time`` - a time distribution histogram """ from lasif import visualization events = self.comm.events.get_all_events().values() if plot_type == "map": domain = self.comm.project.domain if domain == "global": map = visualization.plot_domain() else: bounds = domain["bounds"] map = visualization.plot_domain( bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=domain["rotation_axis"], rotation_angle_in_degree=domain["rotation_angle"], plot_simulation_domain=False, zoom=True) visualization.plot_events(events, map_object=map, project=self) elif plot_type == "depth": visualization.plot_event_histogram(events, "depth") elif plot_type == "time": visualization.plot_event_histogram(events, "time") else: msg = "Unknown plot_type" raise LASIFError(msg)
def plot_domain(self): """ Plots the simulation domain and the actual physical domain. Wrapper around one of the visualization routines. """ from lasif import visualization bounds = self.domain["bounds"] visualization.plot_domain(bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=self.domain["rotation_axis"], rotation_angle_in_degree=self.domain["rotation_angle"], plot_simulation_domain=True, show_plot=True)
def __setup_plots(self): # Some actual plots. self.plot_axis_z = plt.subplot2grid((6, 20), (0, 0), colspan=18) self.plot_axis_n = plt.subplot2grid((6, 20), (1, 0), colspan=18) self.plot_axis_e = plt.subplot2grid((6, 20), (2, 0), colspan=18) self.misfit_axis = plt.subplot2grid((6, 20), (3, 0), colspan=11, rowspan=3) self.colorbar_axis = plt.subplot2grid((6, 20), (3, 12), colspan=1, rowspan=3) #self.adjoint_source_axis = plt.subplot2grid((6, 8), (4, 0), colspan=4, #rowspan=1) self.map_axis = plt.subplot2grid((6, 20), (3, 13), colspan=8, rowspan=3) # Plot the map and the beachball. bounds = self.project.domain["bounds"] self.map_obj = visualization.plot_domain(bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=self.project.domain["rotation_axis"], rotation_angle_in_degree=self.project.domain["rotation_angle"], plot_simulation_domain=False, show_plot=False, zoom=True) visualization.plot_events([self.event], map_object=self.map_obj) # All kinds of buttons [left, bottom, width, height] self.axnext = plt.axes([0.90, 0.95, 0.08, 0.03]) self.axprev = plt.axes([0.90, 0.90, 0.08, 0.03]) self.axreset = plt.axes([0.90, 0.85, 0.08, 0.03]) self.bnext = Button(self.axnext, 'Next') self.bprev = Button(self.axprev, 'Prev') self.breset = Button(self.axreset, 'Reset Station')
def plot_event(self, event_name): """ Plots information about one event on the map. """ from lasif import visualization import matplotlib.pyplot as plt # Plot the domain. bounds = self.domain["bounds"] map = visualization.plot_domain(bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=self.domain["rotation_axis"], rotation_angle_in_degree=self.domain["rotation_angle"], plot_simulation_domain=False, show_plot=False, zoom=True) all_events = self.get_event_dict() if event_name not in all_events: msg = "Event '%s' not found in project." % event_name raise ValueError(msg) event = self.get_event(event_name) event_info = self.get_event_info(event_name) stations = self.get_stations_for_event(event_name) visualization.plot_stations_for_event(map_object=map, station_dict=stations, event_info=event_info) # Plot the beachball for one event. visualization.plot_events([event], map_object=map) plt.show()
def plot_domain(self): """ Plots the simulation domain and the actual physical domain. Wrapper around one of the visualization routines. """ from lasif import visualization bounds = self.domain["bounds"] visualization.plot_domain( bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=self.domain["rotation_axis"], rotation_angle_in_degree=self.domain["rotation_angle"], plot_simulation_domain=True, show_plot=True)
def plot_domain(self): """ Plots the simulation domain and the actual physical domain. Wrapper around one of the visualization routines. """ from lasif import visualization domain = self.comm.project.domain if domain == "global": visualization.plot_domain() else: bounds = domain["bounds"] visualization.plot_domain( bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=domain["rotation_axis"], rotation_angle_in_degree=domain["rotation_angle"], plot_simulation_domain=True, zoom=True)
def plot_event(self, event_name): """ Plots information about one event on the map. """ if not self.comm.events.has_event(event_name): msg = "Event '%s' not found in project." % event_name raise ValueError(msg) from lasif import visualization # Plot the domain. domain = self.comm.project.domain if domain == "global": map_object = visualization.plot_domain() else: bounds = domain["bounds"] map_object = visualization.plot_domain( bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=domain["rotation_axis"], rotation_angle_in_degree=domain["rotation_angle"], plot_simulation_domain=False, zoom=True) # Get the event and extract information from it. event_info = self.comm.events.get(event_name) # Get a dictionary containing all stations that have data for the # current event. stations = self.comm.query.get_all_stations_for_event(event_name) # Plot the stations. This will also plot raypaths. visualization.plot_stations_for_event( map_object=map_object, station_dict=stations, event_info=event_info, project=self) # Plot the beachball for one event. visualization.plot_events([event_info], map_object=map_object)
def __setup_plots(self): # Some actual plots. self.plot_axis_z = plt.subplot2grid((6, 20), (0, 0), colspan=18) self.plot_axis_n = plt.subplot2grid((6, 20), (1, 0), colspan=18) self.plot_axis_e = plt.subplot2grid((6, 20), (2, 0), colspan=18) # Append another attribute to the plot axis to be able to later on # identify which component they belong to. self.plot_axis_z.seismic_component = "Z" self.plot_axis_n.seismic_component = "N" self.plot_axis_e.seismic_component = "E" self._activate_multicursor() self.misfit_axis = plt.subplot2grid((6, 20), (3, 0), colspan=11, rowspan=3) self.colorbar_axis = plt.subplot2grid((6, 20), (3, 12), colspan=1, rowspan=3) # self.adjoint_source_axis = plt.subplot2grid((6, 8), (4, 0), # colspan=4, rowspan=1) self.map_axis = plt.subplot2grid((6, 20), (3, 14), colspan=7, rowspan=3) # Plot the map and the beachball. bounds = self.project.domain["bounds"] self.map_obj = visualization.plot_domain( bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=self.project.domain["rotation_axis"], rotation_angle_in_degree=self.project.domain["rotation_angle"], plot_simulation_domain=False, zoom=True) visualization.plot_events([self.event], map_object=self.map_obj) # All kinds of buttons [left, bottom, width, height] self.axnext = plt.axes([0.90, 0.95, 0.08, 0.03]) self.axprev = plt.axes([0.90, 0.90, 0.08, 0.03]) self.axreset = plt.axes([0.90, 0.85, 0.08, 0.03]) self.axautopick = plt.axes([0.90, 0.80, 0.08, 0.03]) self.bnext = Button(self.axnext, 'Next') self.bprev = Button(self.axprev, 'Prev') self.breset = Button(self.axreset, 'Reset Station') self.bautopick = Button(self.axautopick, 'Autoselect') # Axis displaying the current weight self.axweight = plt.axes([0.90, 0.75, 0.08, 0.03]) self._update_current_weight(1.0)
def plot_raydensity(self, save_plot=True): """ Plots the raydensity. """ from lasif import visualization import matplotlib.pyplot as plt plt.figure(figsize=(20, 21)) domain = self.comm.project.domain bounds = domain["bounds"] map_object = visualization.plot_domain( bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=domain["rotation_axis"], rotation_angle_in_degree=domain["rotation_angle"], plot_simulation_domain=False, zoom=True, resolution="l") event_stations = [] for event_name, event_info in \ self.comm.events.get_all_events().iteritems(): try: stations = \ self.comm.query.get_all_stations_for_event(event_name) except LASIFError: stations = {} event_stations.append((event_info, stations)) visualization.plot_raydensity( map_object, event_stations, bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], domain["rotation_axis"], domain["rotation_angle"]) visualization.plot_events(self.comm.events.get_all_events().values(), map_object=map_object) plt.tight_layout() if save_plot: outfile = os.path.join( self.comm.project.get_output_folder("raydensity_plot"), "raydensity.png") plt.savefig(outfile, dpi=200, transparent=True) print "Saved picture at %s" % outfile
def plot_events(self): """ Plots the domain and beachballs for all events on the map. """ from lasif import visualization import matplotlib.pyplot as plt bounds = self.domain["bounds"] map = visualization.plot_domain(bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=self.domain["rotation_axis"], rotation_angle_in_degree=self.domain["rotation_angle"], plot_simulation_domain=False, show_plot=False, zoom=True) events = self.get_all_events() visualization.plot_events(events, map_object=map) plt.show()
def plot_raydensity(self): """ Plots the raydensity. """ from lasif import visualization import matplotlib.pyplot as plt plt.figure(figsize=(20, 21)) bounds = self.domain["bounds"] map = visualization.plot_domain( bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=self.domain["rotation_axis"], rotation_angle_in_degree=self.domain["rotation_angle"], plot_simulation_domain=False, show_plot=False, zoom=True, resolution="l") event_stations = [] for event_name in self.get_event_dict().keys(): event = self.get_event(event_name) stations = self.get_stations_for_event(event_name) event_stations.append((event, stations)) visualization.plot_raydensity( map, event_stations, bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], self.domain["rotation_axis"], self.domain["rotation_angle"]) events = self.get_all_events() visualization.plot_events(events, map_object=map) plt.tight_layout() outfile = os.path.join(self.get_output_folder("raydensity_plot"), "raydensity.png") plt.savefig(outfile, dpi=200) print "Saved picture at %s" % outfile
def __setup_plots(self): # Some actual plots. self.plot_axis_z = plt.subplot2grid((6, 20), (0, 0), colspan=18) self.plot_axis_n = plt.subplot2grid((6, 20), (1, 0), colspan=18) self.plot_axis_e = plt.subplot2grid((6, 20), (2, 0), colspan=18) self.misfit_axis = plt.subplot2grid((6, 20), (3, 0), colspan=11, rowspan=3) self.colorbar_axis = plt.subplot2grid((6, 20), (3, 12), colspan=1, rowspan=3) #self.adjoint_source_axis = plt.subplot2grid((6, 8), (4, 0), colspan=4, #rowspan=1) self.map_axis = plt.subplot2grid((6, 20), (3, 13), colspan=8, rowspan=3) # Plot the map and the beachball. bounds = self.project.domain["bounds"] self.map_obj = visualization.plot_domain( bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=self.project.domain["rotation_axis"], rotation_angle_in_degree=self.project.domain["rotation_angle"], plot_simulation_domain=False, show_plot=False, zoom=True) visualization.plot_events([self.event], map_object=self.map_obj) # All kinds of buttons [left, bottom, width, height] self.axnext = plt.axes([0.90, 0.95, 0.08, 0.03]) self.axprev = plt.axes([0.90, 0.90, 0.08, 0.03]) self.axreset = plt.axes([0.90, 0.85, 0.08, 0.03]) self.bnext = Button(self.axnext, 'Next') self.bprev = Button(self.axprev, 'Prev') self.breset = Button(self.axreset, 'Reset Station')
def plot_events(self): """ Plots the domain and beachballs for all events on the map. """ from lasif import visualization import matplotlib.pyplot as plt bounds = self.domain["bounds"] map = visualization.plot_domain( bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=self.domain["rotation_axis"], rotation_angle_in_degree=self.domain["rotation_angle"], plot_simulation_domain=False, show_plot=False, zoom=True) events = self.get_all_events() visualization.plot_events(events, map_object=map) plt.show()
def plot_raydensity(self): """ Plots the raydensity. """ from lasif import visualization import matplotlib.pyplot as plt plt.figure(figsize=(20, 21)) bounds = self.domain["bounds"] map = visualization.plot_domain(bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=self.domain["rotation_axis"], rotation_angle_in_degree=self.domain["rotation_angle"], plot_simulation_domain=False, show_plot=False, zoom=True, resolution="l") event_stations = [] for event_name in self.get_event_dict().keys(): event = self.get_event(event_name) stations = self.get_stations_for_event(event_name) event_stations.append((event, stations)) visualization.plot_raydensity(map, event_stations, bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], self.domain["rotation_axis"], self.domain["rotation_angle"]) events = self.get_all_events() visualization.plot_events(events, map_object=map) plt.tight_layout() outfile = os.path.join(self.get_output_folder("raydensity_plot"), "raydensity.png") plt.savefig(outfile, dpi=200) print "Saved picture at %s" % outfile
def plot_event(self, event_name): """ Plots information about one event on the map. """ from lasif import visualization import matplotlib.pyplot as plt # Plot the domain. bounds = self.domain["bounds"] map = visualization.plot_domain( bounds["minimum_latitude"], bounds["maximum_latitude"], bounds["minimum_longitude"], bounds["maximum_longitude"], bounds["boundary_width_in_degree"], rotation_axis=self.domain["rotation_axis"], rotation_angle_in_degree=self.domain["rotation_angle"], plot_simulation_domain=False, show_plot=False, zoom=True) all_events = self.get_event_dict() if event_name not in all_events: msg = "Event '%s' not found in project." % event_name raise ValueError(msg) event = self.get_event(event_name) event_info = self.get_event_info(event_name) stations = self.get_stations_for_event(event_name) visualization.plot_stations_for_event(map_object=map, station_dict=stations, event_info=event_info) # Plot the beachball for one event. visualization.plot_events([event], map_object=map) plt.show()