tracktable.render.histogram2d module

Module contents

tracktable.render.histogram2d.cartesian(point_source, bbox_lowerleft, bbox_upperright, resolution=(400, 400), colormap='gist_heat', colorscale=matplotlib.colors.Normalize, axes=None, zorder=2)[source]

Draw a 2D histogram of points in a Cartesian space.

For the purposes of this function, a ‘point2d’ is a tuple or list at least 2 elements long whose first two elements are numbers.

Since we only traverse the point iterable once we require that you supply a bounding box. Any points outside this bounding box will be ignored.

Parameters
  • point_source (iterable) – Sequence of 2D points. This will be traversed only once.

  • bbox_lowerleft (point2d) – Lower left corner of bounding box for histogram

  • bbox_upperright (point2d) – Upper right corner of bounding box

Keyword Arguments
  • resolution (two ints) – Resolution for histogram (Default: (400, 400))

  • colormap (str or Colormap) – Colors to use for histogram (Default: ‘gist_heat’)

  • colorscale (matplotlib.colors.Normalize or subclass) – Mapping from bin counts to color. Useful values are matplotlib.colors.Normalize() and matplotlib.colors.LogNorm(). (Default: matplotlib.colors.Normalize())

  • axes (matplotlib.axes.Axes) – Axes to render into. Defaults to “current axes” as defined by Matplotlib. (Default: None)

  • zorder (int) – Image priority for rendering. Higher values will be rendered on top of actors with lower z-order. (Default: 2)

Side Effects:

Actors will be added to the supplied axes.

Returns

A list of actors added to the Matplotlib figure.

tracktable.render.histogram2d.draw_density_array(density, map_projection, bounding_box, colormap=None, colorscale=None, zorder=10, axes=None)[source]

Render a histogram for the given map projection.

Parameters
  • density (iterable) – Density array that will be drawn onto the map

  • map_projection (Basemap) – Map to render onto

  • bounding_box (point2d) – Bounding box of area to gdraw the

Keyword Arguments
  • colormap (str or Colormap) – Colors to use for histogram (Default: None)

  • colorscale (matplotlib.colors.Normalize or subclass) – Mapping from bin counts to color. Useful values are matplotlib.colors.Normalize() and matplotlib.colors.LogNorm(). (Default: None)

  • zorder (int) – Image priority for rendering. Higher values will be rendered on top of actors with lower z-order. (Default: 10)

  • axes (matplotlib.axes.Axes) – Axes to render into. Defaults to “current axes” as defined by Matplotlib. (Default:None)

Returns

The density rendered onto the map.

tracktable.render.histogram2d.geographic(map_projection, point_source, bin_size=1, colormap='gist_heat', colorscale=matplotlib.colors.Normalize, zorder=10, axes=None)[source]

Render a 2D histogram (heatmap) onto a geographic map

Parameters
  • map_projection (Basemap) – Map to render onto

  • point_source (iterable) – Sequence of TrajectoryPoint objects

Keyword Arguments
  • bin_size (float) – Histogram bins will be this many degrees on each size. Defaults to 1. (Default: 1)

  • colormap (str or Matplotlib colormap) – Color map for resulting image. Defaults to ‘gist_heat’. (Default: ‘gist_heat’)

  • colorscale (matplotlib.colors.Normalize or subclass) – Mapping from histogram bin count to color. Defaults to a linear mapping (matplotlib.colors.Normalize(). The other useful value is matplotlib.colors.LogNorm() for a logarithmic mapping. You can specify a range if you want to but by default it will be adapted to the data. (Default: matplotlib.colors.Normalize())

  • zorder (int) – Rendering priority for the histogram. Objects with higher priority will be rendered on top of those with lower priority. Defaults to 2 (probably too low). (Default: 10)

  • axes (matplotlib.axes.Axes) – Axes instance to render into. If no value is specified we will use the current axes as returned by pyplot.gca(). (Default: None)

Returns

List of actors added to the axes

Side Effects:

Actors for the histogram will be added to the current Matplotlib figure.

Known Bugs:
  • The interface does not match the one for the Cartesian histogram. Most notably, you specify resolution explicitly for the Cartesian histogram and implicitly (via box size) for this one.

  • You can’t specify a histogram area that encloses the north or south pole.

  • You can’t specify a histogram area that crosses the longitude discontinuity at longitude = +/- 180. This should be relatively easy to fix.

tracktable.render.histogram2d.load_density_array(infile)[source]

Load the density array from a file.

Parameters

infile (str) – Filename for input

Returns

The density array in the file.

tracktable.render.histogram2d.render_histogram(map_projection, point_source, bounding_box, bin_size=1, colormap='gist_heat', colorscale=matplotlib.colors.Normalize, zorder=10, axes=None)[source]

Render a histogram for the given map projection.

Parameters
  • map_projection (Basemap) – Map to render onto

  • point_source (iterable) – Sequence of 2D points. This will be traversed only once.

  • bounding_box (point2d) – Bounding box of area to generate histogram

Keyword Arguments
  • bin_size (int) – Boundary size for bins (Default: 1)

  • colormap (str or Colormap) – Colors to use for histogram (Default: ‘gist_heat’)

  • colorscale (matplotlib.colors.Normalize or subclass) – Mapping from bin counts to color. Useful values are matplotlib.colors.Normalize() and matplotlib.colors.LogNorm(). (Default: matplotlib.colors.Normalize())

  • zorder (int) – Image priority for rendering. Higher values will be rendered on top of actors with lower z-order. (Default: 10)

  • axes (matplotlib.axes.Axes) – Axes to render into. Defaults to “current axes” as defined by Matplotlib. (Default:None)

Returns

A rendered histogram onto the map.

tracktable.render.histogram2d.save_density_array(density, outfile)[source]

Save and output the density array to a file.

Parameters
  • density (tuple) – Density to be saved to file

  • outfile (str) – Filename to save output

Returns

No return value.