module

avl.dataset

Dataset manipulation and analysis functions

Functions
  • from_crs84(coord, crs_to) Convert co-ordinates from CRS:84</>
  • get_geospatial_attrs(bbox, res, crs) (dict(str: any)) Return a dictionary of geospatial attributes</>
  • get_time_coverage_attrs(time_range, time_period) (dict(str: any)) Return a dictionary of time coverage attributes</>
  • new_dataset(xy_size, xy_tile_size, xy_names, xy_dtype, xy_units, xy_res, xy_start, inverse_y, time_name, time_dtype, time_units, time_calendar, time_periods, time_res, time_start, use_cftime, drop_bounds, variables, crs, metadata) (Dataset) Create a new sample dataset. Useful for creating cubes templates with predefined coordinate variables and metadata.</>
function

avl.dataset.new_dataset(xy_size=(3600, 1800), xy_tile_size=None, xy_names=('lon', 'lat'), xy_dtype='float64', xy_units=('degrees_east', 'degrees_north'), xy_res=0.1, xy_start=(-180, -90), inverse_y=False, time_name='time', time_dtype='datetime64[s]', time_units='seconds since 1970-01-01T00:00:00', time_calendar='proleptic_gregorian', time_periods=5, time_res='1D', time_start='2010-01-01T00:00:00', use_cftime=False, drop_bounds=False, variables=None, crs=None, metadata=None)

Create a new sample dataset. Useful for creating cubes templates with predefined coordinate variables and metadata.

The 3-tuple items of the variables list are 1. variable name 2. numpy data type 3. variable metadata

Parameters
  • xy_size (int, int), optional Number of spatial x,y grid cells. Defaults to (3600, 1800).
  • xy_tile_size (Union(int, (int, int)), optional) Optional spatial tile size in grid cells. Defaults to None (= automatic chunking).
  • xy_names (str, str), optional Names of the x,y coordinate variables. Defaults to ('lon', 'lat).
  • xy_dtype (dtype, optional) Data type of both x and y coordinate. Defaults to 'float64'.
  • xy_units (Union(str, (str, str)), optional) Units of the x,y coordinates. Defaults to ('degrees_east', 'degrees_north').
  • xy_res (Union(float, (float, float)), optional) Spatial resolution in x,y directions. Defaults to 1.0.
  • xy_start (float, float), optional Minimum x,y values. Defaults to (-180, -90).
  • inverse_y (bool, optional) Whether to create an inverse y axis. Defaults to False.
  • time_name (str, optional) Name of the time coordinate variable. Defaults to 'time'.
  • time_dtype (dtype, optional) Numpy data type for time coordinates. Defaults to 'datetime64[s]'. If used, parameter 'use_cftime' must be False.
  • time_units (str, optional) Units for time coordinates. Defaults to 'seconds since 1970-01-01T00:00:00'.
  • time_calendar (str, optional) Calender for time coordinates. Defaults to 'proleptic_gregorian'.
  • time_periods (int, optional) Number of time steps. Defaults to 5.
  • time_res (str, optional) Duration of each time step. Defaults to `1D'.
  • time_start (str, optional) First time value. Defaults to '2010-01-01T00:00:00'.
  • use_cftime (bool, optional) If True, the time will be given as data types according to the 'cftime' package. If used, the time_calendar parameter must be also be given with an appropriate value such as 'gregorian' or 'julian'. If used, parameter 'time_dtype' must be None.
  • drop_bounds (bool, optional) If True, coordinate bounds variables are not created. Defaults to False.
  • variables (list of (str, str, dict(str: any)), optional) Dictionary of data variables to be added. None by default.
  • crs (str or CRS, optional) pyproj-compatible CRS string or instance of pyproj.CRS or None
  • metadata (dict(str: any), optional) Metadata to be included in global attributes.
Returns (Dataset)

A dataset instance

function

avl.dataset.get_geospatial_attrs(bbox, res, crs)

Return a dictionary of geospatial attributes

Parameters
  • bbox (float, float, float, float) bounding box
  • res (float, float) resolution
  • crs (CRS) co-ordinate reference system
Returns (dict(str: any))

a dictionary of geospatial attributes for the specified parameters

function

avl.dataset.get_time_coverage_attrs(time_range, time_period)

Return a dictionary of time coverage attributes

Parameters
  • time_range (Timestamp, Timestamp) a time range specified as a 2-tuple of timestamps
  • time_period (str) a time resolution in ISO 8601:2004 time duration format
Returns (dict(str: any))

A dictionary of time coverage attributes for the specified parameters

function

avl.dataset.from_crs84(coord, crs_to)

Convert co-ordinates from CRS:84

Parameters
  • coord (float, float) Co-ordinates in the CRS:84 co-ordinate reference system
  • crs_to (CRS) CRS to which to convert the co-ordinates

Result: Corresponding co-ordinates in the requested CRS