def save(self, outpath, resolution=75., oversample=2., size=None, width=None, height=None): gmt = self.gmt self.draw_labels() self.draw_axes() self.draw_cities() size_factor = 9. if self.show_topo and self.show_topo_scale: self._draw_topo_scale() if self.stations: lats = [s.lat for s in self.stations] lons = [s.lon for s in self.stations] self.gmt.psxy( in_columns=(lons, lats), S='t10p', G='black', *self.jxyr) for i_station, s in enumerate(self.stations): if self.station_label_mapping: label = self.station_label_mapping[i_station] else: label = "%s"%s.station self.add_label(s.lat, s.lon, label) if self.event: e = self.event if e.moment_tensor: if e.magnitude == None: e.magnitude = e.moment_tensor.magnitude size_cm = math.sqrt(math.sqrt(mag2mom(e.magnitude) / 100e17)) * size_factor m = e.moment_tensor m6 = m.m6_up_south_east() data = (e.lon, e.lat, 10, m.strike1, m.dip1, m.rake1, 1, 0, 0, 'M %1.1f' % e.magnitude) if True: self.gmt.psmeca( S='%s%g' % ('a', size_cm*2.0), G='red', #W='thinnest,%i/%i/%i' % darken(gmtpy.color_tup(colors[e.cluster])), #L='thinnest,%i/%i/%i' % darken(gmtpy.color_tup(colors[e.cluster])), in_rows=[data], *self.jxyr) gmt = self._gmt if outpath.endswith('.eps'): tmppath = gmt.tempfilename() + '.eps' elif outpath.endswith('.ps'): tmppath = gmt.tempfilename() + '.ps' else: tmppath = gmt.tempfilename() + '.pdf' gmt.save(tmppath) if any(outpath.endswith(x) for x in ('.eps', '.ps', '.pdf')): shutil.copy(tmppath, outpath) else: convert_graph(tmppath, outpath, resolution=resolution, oversample=oversample, size=size, width=width, height=height)
def save( self, outpath, resolution=75.0, oversample=2.0, size=None, width=None, height=None, ): self.draw_labels() self.draw_axes() self.draw_cities() size_factor = 9.0 if self.show_topo and self.show_topo_scale: self._draw_topo_scale() if self.stations: lats = [s.lat for s in self.stations] lons = [s.lon for s in self.stations] self.gmt.psxy(in_columns=(lons, lats), S="t10p", G="black", *self.jxyr) for i_station, s in enumerate(self.stations): label = self.station_label_mapping.get(i_station, str(s.station)) self.add_label(s.lat, s.lon, label) if self.event: e = self.event if e.moment_tensor: if e.magnitude is None: e.magnitude = e.moment_tensor.magnitude size_cm = ( math.sqrt(math.sqrt(mag2mom(e.magnitude) / 100e17)) * size_factor ) m = e.moment_tensor data = ( e.lon, e.lat, 10, m.strike1, m.dip1, m.rake1, 1, 0, 0, "M %1.1f" % e.magnitude, ) if True: self.gmt.psmeca( S="%s%g" % ("a", size_cm * 2.0), G="red", # W='thinnest,%i/%i/%i' % darken(gmtpy.color_tup(colors[e.cluster])), # L='thinnest,%i/%i/%i' % darken(gmtpy.color_tup(colors[e.cluster])), in_rows=[data], *self.jxyr ) gmt = self._gmt if outpath.endswith(".eps"): tmppath = gmt.tempfilename() + ".eps" elif outpath.endswith(".ps"): tmppath = gmt.tempfilename() + ".ps" else: tmppath = gmt.tempfilename() + ".pdf" gmt.save(tmppath) if any(outpath.endswith(x) for x in (".eps", ".ps", ".pdf")): shutil.copy(tmppath, outpath) else: convert_graph( tmppath, outpath, resolution=resolution, oversample=oversample, size=size, width=width, height=height, )
def make_map(lat=None, lon=None, radius=None, outfn=None, stations=None, events=None, stations_label_mapping=None, map_parameters=None, show_topo=True): if map_parameters: lat = map_parameters.lat lon = map_parameters.lon radius = map_parameters.radius outfn = map_parameters.outfn stations = map_parameters.stations station_label_mapping = map_parameters.station_label_mapping events = map_parameters.events station_colors = map_parameters.station_colors show_topo = map_parameters.show_topo color_wet = map_parameters.color_wet color_dry = map_parameters.color_dry show_grid = map_parameters.show_grid height = map_parameters.height width = map_parameters.width _map = JMap(width=width, height=height, lat=lat, lon=lon, radius=radius, topo_resolution_max=200, topo_resolution_min=40., show_topo=show_topo, show_grid=show_grid, illuminate=True, illuminate_factor_land=0.5, illuminate_factor_ocean=0.25, color_wet=color_wet, color_dry=color_dry) #_map.draw_cities() if stations: for i_station, s in enumerate(stations): lats = [s.lat] lons = [s.lon] if station_colors: color = "%s" % station_colors[s.nsl()] else: color = "black" _map.gmt.psxy(in_columns=(lons, lats), S='t20p', G=color, *_map.jxyr) if station_label_mapping: label = station_label_mapping[i_station] else: label = "%s" % s.station _map.add_label(s.lat, s.lon, label) if events: shifts = [(-0.6, -0.6), (-0.6, 0.)] for i_e, e in enumerate(events): if e.moment_tensor: _map.gmt.psxy(in_columns=([e.lon], [e.lat]), S='a25p', G='red', *_map.jxyr) break size_cm = math.sqrt( math.sqrt(mag2mom(e.moment_tensor.magnitude) / 10e7)) * size_factor m = e.moment_tensor #mc = uniso(m) #mc = mc / e.moment_tensor.scalar_moment() * mag2mom(5.0) #m6 = to6(c) m6 = m.m6_up_south_east() #data = (e.lon), (e.lat) + (10,) + m6 + (1, 0, 0) #data = lonlat_to_en1_km(e.lon, e.lat) + (10,) + m6 + (1, 0, 0) #data = [e.lon, e.lat, 5, m6, 1,0,0] eshift, nshift = shifts[i_e] #data = (e.lon, e.lat, 10, m.strike1, m.dip1, m.rake1, 1, e.lon+eshift, e.lat+nshift, 'Test site') data = (e.lon, e.lat, 10, 1, 1, 1, 0, 0, 0, 1, e.lon, e.lat, 'Test site') if True: _map.gmt.psmeca( S='%s%g' % ('m', size_cm * 2.0), #G=gmtpy.color(colors[e.cluster]), #G=colors[i_e], G='red', C='3p,0/0/0', #W='thinnest,%i/%i/%i' % (255, 255, 255), #L='thinnest,%i/%i/%i' % (255, 255, 255), in_rows=[data], *_map.jxyr) _map.save(outpath=outfn)
def make_map(lat=None, lon=None, radius=None, outfn=None, stations=None, events=None, stations_label_mapping=None, map_parameters=None, show_topo=True): if map_parameters: lat=map_parameters.lat lon=map_parameters.lon radius=map_parameters.radius outfn = map_parameters.outfn stations = map_parameters.stations station_label_mapping = map_parameters.station_label_mapping events = map_parameters.events station_colors = map_parameters.station_colors show_topo = map_parameters.show_topo color_wet = map_parameters.color_wet color_dry = map_parameters.color_dry show_grid = map_parameters.show_grid height = map_parameters.height width = map_parameters.width _map = JMap(width=width, height=height, lat=lat, lon=lon, radius=radius, topo_resolution_max=200, topo_resolution_min=40., show_topo=show_topo, show_grid=show_grid, illuminate=True, illuminate_factor_land=0.5, illuminate_factor_ocean=0.25, color_wet=color_wet, color_dry=color_dry) #_map.draw_cities() if stations: for i_station, s in enumerate(stations): lats = [s.lat] lons = [s.lon] if station_colors: color = "%s" % station_colors[s.nsl()] else: color = "black" _map.gmt.psxy( in_columns=(lons, lats), S='t20p', G=color, *_map.jxyr) if station_label_mapping: label = station_label_mapping[i_station] else: label = "%s"%s.station _map.add_label(s.lat, s.lon, label) if events: shifts = [(-0.6, -0.6), (-0.6, 0.)] for i_e, e in enumerate(events): if e.moment_tensor: _map.gmt.psxy( in_columns=([e.lon], [e.lat]), S='a25p', G='red', *_map.jxyr) break size_cm = math.sqrt(math.sqrt(mag2mom(e.moment_tensor.magnitude) / 10e7)) * size_factor m = e.moment_tensor #mc = uniso(m) #mc = mc / e.moment_tensor.scalar_moment() * mag2mom(5.0) #m6 = to6(c) m6 = m.m6_up_south_east() #data = (e.lon), (e.lat) + (10,) + m6 + (1, 0, 0) #data = lonlat_to_en1_km(e.lon, e.lat) + (10,) + m6 + (1, 0, 0) #data = [e.lon, e.lat, 5, m6, 1,0,0] eshift, nshift = shifts[i_e] #data = (e.lon, e.lat, 10, m.strike1, m.dip1, m.rake1, 1, e.lon+eshift, e.lat+nshift, 'Test site') data = (e.lon, e.lat, 10, 1,1,1,0,0,0, 1, e.lon, e.lat, 'Test site') if True: _map.gmt.psmeca( S='%s%g' % ('m', size_cm*2.0), #G=gmtpy.color(colors[e.cluster]), #G=colors[i_e], G='red', C='3p,0/0/0', #W='thinnest,%i/%i/%i' % (255, 255, 255), #L='thinnest,%i/%i/%i' % (255, 255, 255), in_rows=[data], *_map.jxyr) _map.save(outpath=outfn)
def save(self, outpath, resolution=75., oversample=2., size=None, width=None, height=None): gmt = self.gmt self.draw_labels() self.draw_axes() self.draw_cities() size_factor = 9. if self.show_topo and self.show_topo_scale: self._draw_topo_scale() if self.stations: lats = [s.lat for s in self.stations] lons = [s.lon for s in self.stations] self.gmt.psxy(in_columns=(lons, lats), S='t10p', G='black', *self.jxyr) for i_station, s in enumerate(self.stations): label = self.station_label_mapping.get(i_station, str(s.station)) self.add_label(s.lat, s.lon, label) if self.event: e = self.event if e.moment_tensor: if e.magnitude == None: e.magnitude = e.moment_tensor.magnitude size_cm = math.sqrt(math.sqrt( mag2mom(e.magnitude) / 100e17)) * size_factor m = e.moment_tensor m6 = m.m6_up_south_east() data = (e.lon, e.lat, 10, m.strike1, m.dip1, m.rake1, 1, 0, 0, 'M %1.1f' % e.magnitude) if True: self.gmt.psmeca( S='%s%g' % ('a', size_cm * 2.0), G='red', #W='thinnest,%i/%i/%i' % darken(gmtpy.color_tup(colors[e.cluster])), #L='thinnest,%i/%i/%i' % darken(gmtpy.color_tup(colors[e.cluster])), in_rows=[data], *self.jxyr) gmt = self._gmt if outpath.endswith('.eps'): tmppath = gmt.tempfilename() + '.eps' elif outpath.endswith('.ps'): tmppath = gmt.tempfilename() + '.ps' else: tmppath = gmt.tempfilename() + '.pdf' gmt.save(tmppath) if any(outpath.endswith(x) for x in ('.eps', '.ps', '.pdf')): shutil.copy(tmppath, outpath) else: convert_graph(tmppath, outpath, resolution=resolution, oversample=oversample, size=size, width=width, height=height)