Data reading and writing modules

class cis.data_io.data_reader.DataReader(get_data_func=<function get_data>, get_coords_func=<function get_coordinates>, get_variables_func=<function get_variables>)

Bases: object

High level class to manage reading data from a file. Principally, manages operations between one or multiple variables, and gridded or un-gridded data.

read_coordinates(filenames, product=None)

Read the coordinates from a file :param filenames: The filename of the files to read :return: A CoordList object

read_data_list(filenames, variables, product=None, aliases=None)

Read multiple data objects. Files can be either gridded or ungridded but not a mix of both.

  • filenames (string or list) – One or more filenames of the files to read
  • variables (string or list) – One or more variables to read from the files
  • product (str) – Name of data product to use (optional)
  • aliases – List of variable aliases to put on each variables data object as an alternative means of identifying them. (Optional)

A list of the data read out (either a GriddedDataList or UngriddedDataList depending on the type of data contained in the files)


Read data from a set of datagroups


A list of datagroups. Each datagroup represents a grouping of files and variables, where the set of files may be logically considered to represent the same data (an example would be 2D model data split into monthly output files where the grid is the same). The following should be true of a datagroup:

  1. All variables in a datagroup are present in all the files in that datagroup
  2. The shape of the data returned from each variable must be the same in each file, so that they may be concatenated
  3. They should all be openable by the same CIS data product
  4. They should be dictionaries of the following format:
    {'filenames': ['filename1.nc', 'filename2.nc'],
      'variables': ['variable1', 'variable2'],
      'product' : 'Aerosol_CCI'}
Returns:A list of data (either a GriddedDataList or an UngriddedDataList, depending on the data format)
Parameters:filelist – A single element, or list, or comma seperated string of filenames, wildcarded filenames or directories
Returns:A flat list of files which exist - with no duplicates
Raises ValueError:
 if any of the files in the list do not exist.
class cis.data_io.data_writer.DataWriter

Bases: object

High level class for writing data to a file

write_data(data, output_file)

Write data to a file.

  • data (CommonData) – Data to write
  • output_file (str) – Output file name