ILAMB.ilamblib.FromNetCDF4

ILAMB.ilamblib.FromNetCDF4(filename, variable_name, alternate_vars=[], t0=None, tf=None, group=None, convert_calendar=True)[source]

Extracts data from a netCDF4 datafile for use in a Variable object.

Intended to be used inside of the Variable constructor. Some of the return arguments will be None depending on the contents of the netCDF4 file.

Parameters
  • filename (str) – Name of the netCDF4 file from which to extract a variable

  • variable_name (str) – Name of the variable to extract from the netCDF4 file

  • alternate_vars (list of str, optional) – A list of possible alternate variable names to find

  • t0 (float, optional) – If temporal, specifying the initial time can reduce memory usage and speed up access time.

  • tf (float, optional) – If temporal, specifying the final time can reduce memory usage and speed up access time.

Returns

  • data (numpy.ma.masked_array) – The array which contains the data which constitutes the variable

  • unit (str) – The unit of the input data

  • name (str) – The name of the variable, will be how it is saved in an output netCDF4 file

  • time (numpy.ndarray) – A 1D array of times in days since 1850-01-01 00:00:00

  • time_bnds (numpy.ndarray) – A 1D array of time bounds in days since 1850-01-01 00:00:00

  • lat (numpy.ndarray) – A 1D array of latitudes of cell centroids

  • lon (numpy.ndarray) – A 1D array of longitudes of cell centroids

  • area (numpy.ndarray) – A 2D array of the cell areas

  • ndata (int) – Number of data sites this data represents

  • depth_bnds (numpy.ndarray) – A 1D array of the depth boundaries of each cell