Aggregator documentation

Submodules

Aggregator.Aggregator module

class Aggregator.Aggregator.Aggregator(paths, points, progress=False, geographic=False)

Bases: Aggregator.Aggregator.AggregatorMapping

“Class for aggragation of high resolution data on coarser grids. The coarse grid needs to be defined by matplotlib.path.Path objects and high resolution data by an array of points. Initialisation of an Aggregator defines the mapping between the two grid and an object call aggregates a data field. Both, high and low resolution data need to be passed as 1D structures that are reshaped afterwards externally.

Variables:
  • indices (list of lists of integers) – Mappings of high resolution grid points to coarse grid polygons.
  • size (integer) – Number of coarse grid polygons.
  • paths (sequence of matplotlib.path.Path objects) – Polygons of coarse resolution grids.
  • points (sequence of coordinate pairs) – Cell centre points of high resolution grid pixels.
__init__(paths, points, progress=False, geographic=False)

Defines mappings of points to polygon paths.

Parameters:
  • paths (sequence of matplotlib.path.Path objects) – Polygons of coarse resolution grids.
  • points (sequence of coordinate pairs) – Cell centre points of high resolution grid pixels.
  • progress (integer,) – Interval in which to report mapping progress (message printing each “progress” polygons)
  • geographic – logical flag for coordinates in geographic lon,lat coordinates. Assumes points and polygon vertices to be defined with longitude as first coordinate, i.e. [[lon0,lat0],[lon1,lat1],…]. Not required if polygons and points share the same cyclic border and no polygon extends across it.
__module__ = 'Aggregator.Aggregator'
class Aggregator.Aggregator.AggregatorMapping(indices)

Bases: object

“Base class for aggregation of high resolution data on coarser grids. Based on list of lists contaning the indices in a 1D representation of the high resolution data for each point of the low resolution data. The actual definition of mappings is achieved via the subclass “Aggregator”, while this class may be used to read already defined mappings.

Variables:
  • indices (list of lists of integers) – Mappings of high resolution grid points to coarse grid points.
  • size (integer) – Number of coarse grid points.
__call__(data, method=<function median>, fv=1e+36, progress=False)

Aggregates high resolution data (in 1D) on coarse resolution 1D structure.

Parameters:
  • data (numpy.array or numpy.ma.array in 1D) – High resolution data.
  • method (function) – Method used for aggregating reducing a sequence of values passed as input arguments to a single value.
  • fv (same array dtype as data) – Fill value to be used for coarse data where no high resolution data is available.
  • progress (integer) – Interval in which to report mapping progress (message printing each “progress” polygons)
Returns:

coarse resolution data as 1D structure of same type as input data.

__dict__ = mappingproxy({'__module__': 'Aggregator.Aggregator', '__doc__': '"Base class for aggregation of high resolution data on coarser grids.\n Based on list of lists contaning the indices in a 1D representation of the\n high resolution data for each point of the low resolution data. The actual\n definition of mappings is achieved via the subclass "Aggregator", while this\n class may be used to read already defined mappings.\n\n Attributes:\n indices (list of lists of integers): Mappings of high resolution grid points to coarse grid points.\n size (integer): Number of coarse grid points.\n ', '__init__': <function AggregatorMapping.__init__>, '__call__': <function AggregatorMapping.__call__>, 'save_csv_gz': <function AggregatorMapping.save_csv_gz>, '__dict__': <attribute '__dict__' of 'AggregatorMapping' objects>, '__weakref__': <attribute '__weakref__' of 'AggregatorMapping' objects>})
__init__(indices)

Defines mappings of points to polygon paths.

Parameters:indices (sequence of list of integers) – Mappings of high resolution grid points to coarse grid points.
__module__ = 'Aggregator.Aggregator'
__weakref__

list of weak references to the object (if defined)

save_csv_gz(filename)

Save mapping to gzipped csv file.

Aggregator.Aggregator.load_csv_gz(filename)

Load mapping from gzipped csv file. :Parameters: filename (str) – name of csv.gz file to read

Returns:AggregatorMapping instance with mapping defined in csv file.

Module contents

Aggregator package initialisation.