pyatoa.visuals.map_maker

Map making functionality for the Pyatoa package. Creates Cartopy basemaps featuring events and stations w/ optional moment tensors

Module Contents

Classes

MapMaker

A class to call on the Basemap package to generate a map with

Functions

scale_bar(ax[, length, location, linewidth, ...])

Create a scale bar on a Cartopy plot.

Attributes

DEGREE_CHAR

pyatoa.visuals.map_maker.DEGREE_CHAR = '°'[source]
class pyatoa.visuals.map_maker.MapMaker(cat, inv, dpi=100, figsize=None, figure=None, gridspec=None, corners=None, corner_buffer_deg=2.0, **kwargs)[source]

A class to call on the Basemap package to generate a map with source-receiver information

define_bounding_box(corners=None, corner_buffer_deg=2)[source]

Distribute the corners provided by the user, or determine corners using the event and station locations with a reasonable buffer.

Parameters:
  • corners (dict) – dict containing corner points, if None, lat lon values to be determiend by station and receiver locations

  • buffer (float) – if no corners are given, put a buffer of length ‘buffer’ in units of degrees, around the min and max lat and lon values, to ensure that atleast some extra extent of map is covered. Defaults to 1 deg or roughly 111.11 km. But, if the distance covered between source and receiver is greater than ‘buffer’, than a quarter that distance will be used as the buffer. Confusing?

  • corner_buffer_deg (float) – size of the bounding box to be generated around the source and receiver, units of degrees

Return type:

tuple of float

Preturn:

[lon_min, lon_max, lat_min, lat_max]

initiate_figure(figsize=None, dpi=100, figure=None, gridspec=None, **kwargs)[source]

Create a very barebones minimalist (black and white) map to plot data on

source(fm_type='focal_mechanism')[source]

Plot the source, either as a focal mechanism, moment tensor, or as a simple point, based on the input.

Note

scale_source kwarg was guessed with trial and error and is based on the guessed returned length from the scale_bar() function defined at the bottom, which tries to guess a reasonable length of the scale bar based on the dimensions of the map

Parameters:

fm_type (str) – choice to plot focal_mechanism: 6 component focal mechanism strike_dip_rake: classic double couple look

receiver()[source]

Plot the receiver with a standard look

connect()[source]

Plot a connecting line between source and receiver

annotate(location='lower-right', anno_latlon=False)[source]

Annotate event receiver information into bottom right corner of the map

TODO figure out where to put definition of ‘location’

Parameters:
  • location (str) – location of the annotation block, available: ‘upper-right’, ‘lower-right’, ‘upper-left’, ‘lower-left’, ‘center’

  • anno_latlon (bool) – annotate the latitude and longitude values of the source and receiver next to their markers. Not always very clean so defaults to off.

plot(show=True, save=None, **kwargs)[source]

Main function to generate the basemap, plot all the components, and show or save the figure

Parameters:
  • show (bool) – show the figure in the gui

  • save (str) – if not None, save to the given path stored in this var.

  • corners (dict) – dict containing corner points, if None, lat lon values to be determiend by station and receiver locations

pyatoa.visuals.map_maker.scale_bar(ax, length=None, location=(0.85, 0.95), linewidth=3, return_length=False, ref_proj=ccrs.PlateCarree())[source]

Create a scale bar on a Cartopy plot. Modifiedd from: https://stackoverflow.com/questions/32333870/

how-can-i-show-a-km-ruler-on-a-cartopy-matplotlib-plot

Parameters:
  • ax (matplotlib.pyplot.axes) – axes to draw the scalebar on.

  • length (float) – length of the scalebar in km.

  • location (tuple of floats) – center of the scalebar in axis coordinates. (ie. 0.5 is the middle of the plot)

  • linewidth (float) – the thickness of the scalebar.

  • return_length (bool) – Simply returns the scaled length of the bar, added to use for scaling of the moment tensor