crawtools.mapping.bathy_map
Class to plot GMT-like bathymetry maps
BathyMap
Create a bathymetry map figure and axis
Source code in crawtools/mapping/bathy_map.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
__init__
__init__(map_extent, bathy_file, grid_x=None, grid_y=None, intens_file=None)
Set up a bathymetric map
:param map_extent [list]: [minlon,maxlon,minlat,maxlat] :param bathy_file [str]: name of netcdf bathymetry file :param intens_file: name of netcdf intensity file :kind intens_file: str, optional :param grid_x: x grid spacing for the plot axis :param grid_y: y grid spacing for the plot axis
Source code in crawtools/mapping/bathy_map.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
arrow
arrow(x, y, dx, dy, **kwargs)
plot a arrow
:param x: longitude :param y: latitude :param dx: arrow length :param dy: arrow length :param kwargs: keyword arguments to pass on to pyplot.arrow()
Source code in crawtools/mapping/bathy_map.py
202 203 204 205 206 207 208 209 210 211 212 | |
plot
plot(lon, lat, sym='o', color='deepskyblue', mec='k', ms=8, **kwargs)
plot a point
:param lon: longitude :param lat: latitude :param sym: symbol :param color: marker face color :param kwargs: keyword arguments to pass on to pyplot.plot()
Source code in crawtools/mapping/bathy_map.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
plot_coastlines
plot_coastlines(resolution)
Plot coastlines
:param resolution: what resolution coastlines to include. Must correspond to a NaturalEarth resolution ('10m', '50m', '110m') or a GSHSS resolution ('auto', 'low', 'high', 'full'...)
Source code in crawtools/mapping/bathy_map.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
plot_contours
plot_contours(levels=500, linewidth=1, color='k')
Plot the bathymetric contours
:param levels: list of contours, or contour interval (m) :param linewidth: contour linewidth (1) :param colors: contour line color ('k')
Source code in crawtools/mapping/bathy_map.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
plot_image
plot_image(cmap=cm.jet, pastel=False, shaded=False, intens_file=None, **kwargs)
Plot the bathymetric image
:param cmap: colormap (e.g matplotlib.colors.LinearSegmentedColormap instance) :param pastel: lighten colors to make pastel :param shaded: [bool] apply shading :param intens_file: file containing intensities to plot (generally for shading) :param **kwargs: arguments to pass to hillshade (scale, azdeg, altdeg)
Source code in crawtools/mapping/bathy_map.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
save_map
save_map(filename, title, fontsize=12)
Saves map to a file
:param filename: :param title: plot title :param timedelta_total: total time spent (datetime.timedelta) :returns: figure object, base_name of output file
Source code in crawtools/mapping/bathy_map.py
234 235 236 237 238 239 240 241 242 243 244 | |
show
show()
Show the plot on the screen
Source code in crawtools/mapping/bathy_map.py
158 159 160 161 162 | |
text
text(lon, lat, name, text_box=True, ha='left', va='center', color='black', **kwargs)
plot a station label
:param m: map object :param lon: longitude :param lat: latitude :param name: station name :param text_box: Put a semi-opaque box under the text :param ha: horizontal text alignment ('left', 'center', 'right') :param va: vertical text alignment ('center', 'middle', 'bottom') :param color: text color :param kwargs: keyword arguments to pass on to pyplot.text()
Source code in crawtools/mapping/bathy_map.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
crawtools.mapping.map_cross_section
Class to create map and two cross-sections, all with no vertical exageration
Currently returns three axes, to which one needs to plot using any Axes routine.
Would be nice if you could use pseudo-routines with z in addition to x and y, then the class would dispatch the appropriate coordinates to the different Axis routines
MapCrossSection
Create axes map with cross-sections to right (east) and below (south)
the axis attributes to use are .ax_map, .ax_xz and .ax_zy .ax_map is a Mercator projection, when you plot to it you must specify transform=cartopy.crs.PlateCarree()
Source code in crawtools/mapping/map_cross_section.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
__init__
__init__(figsize=None, fill_figure=True, pad_left=0.6, pad_right=0.6, pad_top=0.4, pad_bottom=0.4, map_extent=None, depth_extent=None, extent_buffer=0.2, latitudes=None, longitudes=None, depths=None, gridlines=True, coastlines=None)
:param figsize: width, height in inches :kind figsize: (float, float), optional :param fill_figure: Expand map bounds to fill the figure :param pad_left: inches to left of axes for labels/text/emptiness :param pad_right: inches to right of axes for labels/text/emptiness :param pad_top: inches above axes for labels/text/emptiness :param pad_bottom: inches below axes for labels/text/emptiness :param map_extent: bounds of map (x0, x1, y0, y1) or None :param depth_extent: depth bounds (z0, z1) or None :param latitudes: list of "event" latitudes, used to calculate map extents if map_extents == None :param longitudes: list of "event" longitudes, used to calculate map extents if map_extents == None :param longitudes: list of "event" depths, used to calculate depth extents if depth_extents == None :param extent_buffer: extents will exceed event limits by this fraction of the event range :param gridlines: Put gridlines on map view (boolean) :param coastlines: what resolution coastlines to include. Must correspond to a NaturalEarth resolution ('10m', '50m', '110m') or a GSHSS resolution ('auto', 'low', 'high', 'full'...)
Source code in crawtools/mapping/map_cross_section.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
crawtools.mapping.shape_selection
Classes to select events within different shapes
Circle
Bases: ShapeSelection
Selects events within a given distance of a given point
Source code in crawtools/mapping/shape_selection.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
__init__
__init__(longitude, latitude, radius)
:param latitude: latitude at the center of the circle :param longitude: longitude at the center of the circle :param radius: radius of the circle in degrees latitude :kind latitude, longitude, radius_km: num
Circle(-12.3, 45.6, 10) Circle(-12.3, 45.6, 10)
Source code in crawtools/mapping/shape_selection.py
47 48 49 50 51 52 53 54 55 56 57 58 59 | |
contains
contains(event_longitude, event_latitude)
Returns True if event is inside or on the Circle, False if not
:param event_latitude: latitude of the event :param event_longitude: longitude of the event :type event_latitude, event_longitude: numeric
Circle(-12.3, 45.6, 10)._iswithin(-12.35, 45.65) True Circle(-12.3, 45.6, 10)._iswithin(-12.4, 45.7) False
Source code in crawtools/mapping/shape_selection.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
Polygon
Bases: ShapeSelection
Selection of events within or outside of a polygon
Source code in crawtools/mapping/shape_selection.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
__init__
__init__(polygon)
:param polygon: list of [longitudes, latitudes]
No need to close the polygon
Source code in crawtools/mapping/shape_selection.py
103 104 105 106 107 108 109 | |
add_patch
add_patch(ax=None, **kwargs)
Adds a patch corresponding to the shape
Source code in crawtools/mapping/shape_selection.py
136 137 138 139 140 141 142 | |
contains
contains(event_longitude, event_latitude)
Returns True if event is inside or on the Polygon, False if not
:param event_longitude: longitude of the event :param event_latitude: latitude of the event :type event_latitude, event_longitude: numeric
Polygon([[12, 45], [12, 47], [14, 47], [14, 45]])._iswithin(13, 46) True Polygon([[12, 45], [12, 47], [14, 47], [14, 45]])._iswithin(15, 46) False
Source code in crawtools/mapping/shape_selection.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
plot
plot(ax=None, **kwargs)
Plots the shape's outline
Source code in crawtools/mapping/shape_selection.py
127 128 129 130 131 132 133 134 | |
ShapeSelection
Bases: object
Superclass for including or excluding events within the shape
Source code in crawtools/mapping/shape_selection.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
exclude
exclude(catalog)
Return catalog without any events in the shape
:param catalog: earthquake catalog
:kind catalog: ~class obspy.core.event.catalog.Catalog
Source code in crawtools/mapping/shape_selection.py
28 29 30 31 32 33 34 35 36 37 38 39 40 | |
include
include(catalog)
Return catalog with events within the shape
:param catalog: earthquake catalog
:kind catalog: ~class obspy.core.event.catalog.Catalog
Source code in crawtools/mapping/shape_selection.py
14 15 16 17 18 19 20 21 22 23 24 25 26 | |