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.DataSet
object The data set containing an MPAS time variable to be used to build an xarray time coordinate.
- calendar{
'gregorian'
,'gregorian_noleap'
} The name of one of the calendars supported by MPAS cores
- simulationStartTimestring, 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.
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 bytimeVariableName
) is a number of days since the start of the simulation.- timeVariableNamestring, optional
The name of the time variable (typically
'xtime'
or'Time'
).- variableListlist of strings
If present, a list of variables to be included in the data set
- selectCorrdValuesdict
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}
- iselValuesdict
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}
- ds
- Returns
- ds
xarray.DataSet
object A copy of the data set with the time coordinate set and which has been sliced.
- ds