Dataset Module


class dataset.Bounds(boundary_type='rectangular', us_states=None, countries=None, user_mask_file=None, mask_variable_name=None, longitude_name=None, latitude_name=None, lat_min=-90, lat_max=90, lon_min=-180, lon_max=180, start=None, end=None)

Container for holding spatial and temporal bounds information.

Certain operations require valid bounding information to be present for correct functioning. Bounds guarantees that a function receives well formed information without the need to do the validation manually.

boundary_type may be one of the following: * ‘rectangular’ * ‘CORDEX (CORDEX region name)’: pre-defined CORDEX boundary * ‘us_states’: an array of US states abbreviation is required (ex) us_states = [‘CA’,’NV’]) * ‘countries’: an array of county names is required (ex) countries = [‘United States’,’Canada’,’Mexico’] * ‘user’: user_mask_file in a netCDF format with two dimensional mask variable is required.

If boundary_type == ‘rectangular’, spatial and temporal bounds must follow the following guidelines.

  • Latitude values must be in the range [-90, 90]
  • Longitude values must be in the range [-180, 180]
  • Lat/Lon Min values must be less than the corresponding Lat/Lon Max values.

Temporal bounds must a valid datetime object

Default Bounds constructor :param boundary_type: The type of spatial subset boundary. :type boundary_type: :mod:`string’

  • lat_min (float) – The minimum latitude bound.
  • lat_min – The minimum latitude bound.
  • lat_max (float) – The maximum latitude bound.
  • lon_min (float) – The minimum longitude bound.
  • lon_max (float) – The maximum longitude bound.
  • start (datetime.datetime) – An optional datetime object for the starting datetime bound.
  • end (datetime.datetime) – An optional datetime object for the ending datetime bound.



class dataset.Dataset(lats, lons, times, values, variable=None, units=None, origin=None, name='')

Container for a dataset’s attributes and data.

Default Dataset constructor

  • lats (numpy.ndarray) – One dimensional numpy array of unique latitude values.
  • lons (numpy.ndarray) – One dimensional numpy array of unique longitude values.
  • times (numpy.ndarray) – One dimensional numpy array of unique python datetime objects.
  • values (numpy.ndarray) – Three dimensional numpy array of parameter values with shape [timesLength, latsLength, lonsLength].
  • variable (string) – Name of the value variable.
  • units (string) – Name of the value units
  • name (string) – An optional string name for the Dataset.
  • origin (dict) – An optional object used to specify information on where this dataset was loaded from.



Calculate the spatial boundaries.

Returns:The Dataset’s bounding latitude and longitude values as a tuple in the form (min_lat, max_lat, min_lon, max_lon)
Return type:tuple() of the form (float, float, float, float).

Calculate the latitudinal and longitudinal spatial resolution.

If self.lats and self.lons are from curvilinear coordinates, the output resolutions are approximate values.
Returns:The Dataset’s latitudinal and longitudinal spatial resolution as a tuple of the form (lat_resolution, lon_resolution).
Return type:(float, float)

Calculate the temporal range

Returns:The start and end date of the Dataset’s temporal range as a tuple in the form (start_time, end_time).
Return type:tuple() of the form (datetime.datetime, datetime.datetime)

Calculate the temporal resolution.

Raises:ValueError – If timedelta.days as calculated from the sorted list of times is an unrecognized value a ValueError is raised.
Returns:The temporal resolution.
Return type:string