mpas_analysis.shared.generalized_reader.generalized_reader.open_multifile_dataset

mpas_analysis.shared.generalized_reader.generalized_reader.open_multifile_dataset(fileNames, calendar, config, simulationStartTime=None, timeVariableName='Time', variableList=None, selValues=None, iselValues=None, variableMap=None, startDate=None, endDate=None, chunking=None)[source]

Opens and returns an xarray data set given file name(s) and the MPAS calendar name.

Parameters:
  • fileNames (list of strings) – A lsit of file paths to read

  • calendar ({'gregorian', 'noleap'}, optional) – The name of one of the calendars supported by MPAS cores

  • config (mpas_tools.config.MpasConfigParser) – Contains configuration options

  • simulationStartTime (string, optional) –

    The start date of the simulation, used to convert from time variables expressed as days since the start of the simulation to days since the reference date. simulationStartTime takes one of the following forms:

    0001-01-01
    0001-01-01 00:00:00
    

    simulationStartTime is only required if the MPAS time variable (identified by timeVariableName) is a number of days since the start of the simulation.

  • timeVariableName (string, optional) – The name of the time variable (typically 'Time' if using a variableMap or 'xtime' if not using a variableMap)

  • variableList (list of strings, optional) – If present, a list of variables to be included in the data set

  • selValues (dict, optional) –

    A dictionary of coordinate names (keys) and values or arrays of values used to slice the variales in the data set. See xarray.DataSet.sel() for details on how this dictonary is used. An example:

    selectCorrdValues = {'cellLon': 180.0}
    

  • iselValues (dict, optional) –

    A dictionary of coordinate names (keys) and indices, slices or arrays of indices used to slice the variales in the data set. See xarray.DataSet.isel() for details on how this dictonary is used. An example:

    iselValues = {'nVertLevels': slice(0, 3),
                  'nCells': cellIDs}
    

  • variableMap (dict, optional) – A dictionary with keys that are variable names used by MPAS-Analysis and values that are lists of possible names for the same variable in the MPAS dycore that produced the data set (which may differ between versions).

  • startDate (string or datetime.datetime, optional) – If present, the first and last dates to be used in the data set. The time variable is sliced to only include dates within this range.

  • endDate (string or datetime.datetime, optional) – If present, the first and last dates to be used in the data set. The time variable is sliced to only include dates within this range.

  • chunking (None, int, True, dict, optional) – If integer is present, applies maximum chunk size from config file value maxChunkSize, otherwise if None do not perform chunking. If True, use automated chunking using default config value maxChunkSize. If chunking is a dict use dictionary values for chunking.

Returns:

ds (xarray.Dataset)

Raises:
  • TypeError – If the time variable has an unsupported type (not a date string, a floating-pont number of days since the start of the simulation or a numpy.datatime64 object).

  • ValueError – If the time variable is not found in the data set or if the time variable is a number of days since the start of the simulation but simulationStartTime is None.