sp_validation.plots

PLOTS.

Name:

plots.py

Description:

This script contains methods for plots.

Author:

Martin Kilbinger

class SquareRootScale(axis, **kwargs)[source]

Bases: ScaleBase

ScaleBase class for generating square root scale.

Usage example: axis.set_yscale(‘squareroot’)

name = 'squareroot'
set_default_locators_and_formatters(axis)[source]

Set the locators and formatters of axis to instances suitable for this scale.

limit_range_for_scale(vmin, vmax, minpos)[source]

Return the range vmin, vmax, restricted to the domain supported by this scale (if any).

minpos should be the minimum positive value in the data. This is used by log scales to determine a minimum value.

class SquareRootTransform(shorthand_name=None)[source]

Bases: Transform

input_dims = 1

The number of input dimensions of this transform. Must be overridden (with integers) in the subclass.

output_dims = 1

The number of output dimensions of this transform. Must be overridden (with integers) in the subclass.

is_separable = True

True if this transform is separable in the x- and y- dimensions.

transform_non_affine(a)[source]

Apply only the non-affine part of this transformation.

transform(values) is always equivalent to transform_affine(transform_non_affine(values)).

In non-affine transformations, this is generally equivalent to transform(values). In affine transformations, this is always a no-op.

Parameters:

values (array) – The input values as an array of length input_dims or shape (N, input_dims).

Returns:

The output values as an array of length output_dims or shape (N, output_dims), depending on the input.

Return type:

array

inverted()[source]

Return the corresponding inverse transformation.

It holds x == self.inverted().transform(self.transform(x)).

The return value of this method should be treated as temporary. An update to self does not cause a corresponding update to its inverted copy.

has_inverse = True

True if this transform has a corresponding inverse transform.

class InvertedSquareRootTransform(shorthand_name=None)[source]

Bases: Transform

input_dims = 1

The number of input dimensions of this transform. Must be overridden (with integers) in the subclass.

output_dims = 1

The number of output dimensions of this transform. Must be overridden (with integers) in the subclass.

is_separable = True

True if this transform is separable in the x- and y- dimensions.

transform(a)[source]

Apply this transformation on the given array of values.

Parameters:

values (array-like) – The input values as an array of length input_dims or shape (N, input_dims).

Returns:

The output values as an array of length output_dims or shape (N, output_dims), depending on the input.

Return type:

array

inverted()[source]

Return the corresponding inverse transformation.

It holds x == self.inverted().transform(self.transform(x)).

The return value of this method should be treated as temporary. An update to self does not cause a corresponding update to its inverted copy.

has_inverse = True

True if this transform has a corresponding inverse transform.

get_transform()[source]

Return the .Transform object associated with this scale.

plot_spatial_density(ra, dec, title, x_label, y_label, cbar_label, out_path, n_grid=1000, verbose=False)[source]

Plot Spatial Density.

Plot spatial density distribution of objects.

Parameters:
  • ra (array of float) – coordinates

  • dec (array of float) – coordinates

  • title (string) – plot title

  • x_label (string) – x-/y-axis label

  • y_label (string) – x-/y-axis label

  • cbar_label (string) – color bar label

  • out_path (string) – output file path

  • n_grid (int, optional, default=1000) – number of hex grid points

  • verbose (bool, optional, default=False) – verbose output if True

get_ticks(loc, N, new_min, new_max)[source]

Get ticks.

Return formatted axis ticks for plots.

Parameters:
  • loc (array of floats) – original tick locations

  • N (number of pixels (in origina coordinates))

  • new_min (float) – new coordinate minimum

  • new_max (float) – new coordinate maximum

Returns:

  • loc_new (array of floats) – new tick locations

  • labels_new (array of strings) – new tick labels

plot_map(m, ra, dec, min_x, max_x, min_y, max_y, Nx, Ny, title, out_path, vlim=None, grid=True, clusters=None, map_cut_coords=None, dpi=100, colorbar=True)[source]

Plot Map.

Plots 2D map.

Parameters:
  • m (2D array of float) – map

  • ra (array of float) – coordinates, for axis ticks

  • dec (array of float) – coordinates, for axis ticks

  • title (string) – plot title

  • out_path (string) – output file path

  • vlim (array(2) of float, optional, default=None) – limits of map values, if not given compute from map

  • grid (bool, optional) – if True (default) plot grid lines

  • clusters – dictionary of cluster information, optional, default=None

plot_binned_one(ax, quantity, bin_edges_x, bin_edges_y, vmin=None, vmax=None, title=None, xlabel=None, ylabel=None)[source]
plot_binned(quantities, key, bin_edges_x, bin_edges_y, title_base, vmin=None, vmax=None, xlabel=None, ylabel=None)[source]
hsp_map_logical_or(maps, verbose=False)[source]

Hsp Map Logical Or.

Logical AND of HealSparseMaps.

plot_area_mask(ra, dec, zoom, mask=None)[source]

Plot Area Mask.

Create sky plot of objects.

Parameters:
  • ra (list) – R.A. coordinates

  • dec (list) – Dec. coordinates

  • zoom (TBD)

  • mask (TBD, optional)

sky_plots(dat, masks, labels, zoom_ra, zoom_dec)[source]

Sky Plots.

Plot sky regions with different masks.

Parameters:
  • masks (list) – masks to be applied

  • labels (dict) – labels for masks

  • zoom_ra (list) – min and max R.A. for zoom-in plot

  • zoom_dec (list) – min and max Dec. for zoom-in plot