Calculates and removes the median of the given dimension(s) at all other dimensions.
Available in version 5.1.1 and later.
function dim_rmvmed_n ( x : numeric, dims [*] : integer ) return_val [dimsizes(x)] : float or double
A variable of numeric type and any dimensionality.dims
The dimension(s) of x on which to calculate and remove the median. Must be consecutive and monotonically increasing.
The output is of type double if the input is double, and float otherwise.
The dimensionality is the same as the input dimensionality.
The dim_rmvmed_n function calculates and removes the median from all elements of the dimensions indicated by dims for each index of the remaining dimensions. Missing values are ignored. Use dim_rmvmed_n_Wrap if retention of metadata is desired.
Let x be a 1-dimensional array: (a) Create a new variable, xNew, that contains just the deviations from the median; (b) replace the variable x with the deviations.
xNew = dim_rmvmed_n(x,0) ; new variable x = dim_rmvmed_n(x,0) ; overwrite with deviationsNote: when operating across the rightmost dimension, it is simpler to use dim_rmvmed.
Let x be a 3-dimensional array with dimension sizes (ntim, nlat, nlon). To remove the medians of the "nlon" dimension:
xRmvLon = dim_rmvmed_n (x,2) ; new variable containing deviations (no metadata) x = dim_rmvmed_n (x,2) ; overwrite with deviations from medianExample 3:
Let x be a 3-dimensional array with named dimensions (time, lat, lon) and dimension sizes (ntim, nlat, nlon). To remove the median of the time dimension from all lat/lon indices:
xRmvTime = dim_rmvmed_n(x,0) xRmvTime = dim_rmvmed_n_Wrap(x,0) ; retain metadataExample 4:
Let x be a 4-dimensional array with named dimensions (time, lev, lat, lon) and dimension sizes (ntim, nlev, nlat, nlon). To remove the median of the time/lev dimensions from all lat/lon indices:
xRmv = dim_rmvmed_n(x,(/0,1/)) xRmv = dim_rmvmed_n_Wrap(x,(/0,1/)) ; retain metadataExample 5:
Let x be as in Example 3 and let x contain monthly medians for (say) 10 years of data (ntim=120). Monthly anomalies for each month could be calculated using array subscripting.
xRmvJan = dim_rmvmed_n(x(0:ntim-1:12,:,:),0) xRmvJuly = dim_rmvmed_n(x(6:ntim-1:12,:,:),0)