mpas_analysis.shared.mpas_xarray.mpas_xarray.preprocess
- mpas_analysis.shared.mpas_xarray.mpas_xarray.preprocess(ds, calendar, simulationStartTime, timeVariableName, variableList, selValues, iselValues)[source]
- Builds correct time specification for MPAS, allowing a date offset because the time must be between 1678 and 2262 based on the xarray library. Also, if slicing information (selValues and/or iselValues) was provided in openMultifileDataSet, this function performs the appropriate slicing on the data set. - Parameters:
- ds ( - xarray.DataSetobject) – The data set containing an MPAS time variable to be used to build an xarray time coordinate.
- calendar ({'gregorian', 'noleap'}) – The name of one of the calendars supported by MPAS cores 
- simulationStartTime (string, optinal) – - 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. - simulationStartTimetakes one of the following forms:- 0001-01-01 0001-01-01 00:00:00 - simulationStartTimeis 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 - 'xtime'or- 'Time').
- variableList (list of strings) – If present, a list of variables to be included in the data set 
- selectCorrdValues (dict) – - 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) – - 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} 
 
- Returns:
- ds ( - xarray.DataSetobject) – A copy of the data set with the time coordinate set and which has been sliced.