MCPcopy
hub / github.com/pydata/xarray / pad

Method pad

xarray/core/dataset.py:9001–9196  ·  view source on GitHub ↗

Pad this dataset along one or more dimensions. .. warning:: This function is experimental and its behaviour is likely to change especially regarding padding of dimension coordinates (or IndexVariables). When using one of the modes ("edge", "reflect", "symmet

(
        self,
        pad_width: Mapping[Any, int | tuple[int, int]] | None = None,
        mode: PadModeOptions = "constant",
        stat_length: (
            int | tuple[int, int] | Mapping[Any, tuple[int, int]] | None
        ) = None,
        constant_values: T_DatasetPadConstantValues | None = None,
        end_values: int | tuple[int, int] | Mapping[Any, tuple[int, int]] | None = None,
        reflect_type: PadReflectOptions = None,
        keep_attrs: bool | None = None,
        **pad_width_kwargs: Any,
    )

Source from the content-addressed store, hash-verified

8999 return polyfit_impl(self, dim, deg, skipna, rcond, w, full, cov)
9000
9001 def pad(
9002 self,
9003 pad_width: Mapping[Any, int | tuple[int, int]] | None = None,
9004 mode: PadModeOptions = "constant",
9005 stat_length: (
9006 int | tuple[int, int] | Mapping[Any, tuple[int, int]] | None
9007 ) = None,
9008 constant_values: T_DatasetPadConstantValues | None = None,
9009 end_values: int | tuple[int, int] | Mapping[Any, tuple[int, int]] | None = None,
9010 reflect_type: PadReflectOptions = None,
9011 keep_attrs: bool | None = None,
9012 **pad_width_kwargs: Any,
9013 ) -> Self:
9014 """Pad this dataset along one or more dimensions.
9015
9016 .. warning::
9017 This function is experimental and its behaviour is likely to change
9018 especially regarding padding of dimension coordinates (or IndexVariables).
9019
9020 When using one of the modes ("edge", "reflect", "symmetric", "wrap"),
9021 coordinates will be padded with the same mode, otherwise coordinates
9022 are padded using the "constant" mode with fill_value dtypes.NA.
9023
9024 Parameters
9025 ----------
9026 pad_width : mapping of hashable to tuple of int
9027 Mapping with the form of {dim: (pad_before, pad_after)}
9028 describing the number of values padded along each dimension.
9029 {dim: pad} is a shortcut for pad_before = pad_after = pad
9030 mode : {"constant", "edge", "linear_ramp", "maximum", "mean", "median", \
9031 "minimum", "reflect", "symmetric", "wrap"}, default: "constant"
9032 How to pad the DataArray (taken from numpy docs):
9033
9034 - "constant": Pads with a constant value.
9035 - "edge": Pads with the edge values of array.
9036 - "linear_ramp": Pads with the linear ramp between end_value and the
9037 array edge value.
9038 - "maximum": Pads with the maximum value of all or part of the
9039 vector along each axis.
9040 - "mean": Pads with the mean value of all or part of the
9041 vector along each axis.
9042 - "median": Pads with the median value of all or part of the
9043 vector along each axis.
9044 - "minimum": Pads with the minimum value of all or part of the
9045 vector along each axis.
9046 - "reflect": Pads with the reflection of the vector mirrored on
9047 the first and last values of the vector along each axis.
9048 - "symmetric": Pads with the reflection of the vector mirrored
9049 along the edge of the array.
9050 - "wrap": Pads with the wrap of the vector along the axis.
9051 The first values are used to pad the end and the
9052 end values are used to pad the beginning.
9053
9054 stat_length : int, tuple or mapping of hashable to tuple, default: None
9055 Used in 'maximum', 'mean', 'median', and 'minimum'. Number of
9056 values at edge of each axis used to calculate the statistic value.
9057 {dim_1: (before_1, after_1), ... dim_N: (before_N, after_N)} unique
9058 statistic lengths along each dimension.

Callers 15

test_pad_keep_attrsMethod · 0.95
test_padMethod · 0.95
cumulative_trapezoidFunction · 0.45
padFunction · 0.45
_numbagg_reduceMethod · 0.45
_bottleneck_reduceMethod · 0.45
crossFunction · 0.45
test_upsampleMethod · 0.45
test_upsample_ndMethod · 0.45
test_padMethod · 0.45
test_pad_constantMethod · 0.45
test_pad_coordsMethod · 0.45

Calls 8

either_dict_or_kwargsFunction · 0.90
_get_keep_attrsFunction · 0.90
itemsMethod · 0.80
get_all_dimsMethod · 0.80
keysMethod · 0.80
from_variablesMethod · 0.45
create_variablesMethod · 0.45

Tested by 15

test_pad_keep_attrsMethod · 0.76
test_padMethod · 0.76
test_upsampleMethod · 0.36
test_upsample_ndMethod · 0.36
test_padMethod · 0.36
test_pad_constantMethod · 0.36
test_pad_coordsMethod · 0.36
test_pad_stat_lengthMethod · 0.36
test_pad_linear_rampMethod · 0.36
test_pad_reflectMethod · 0.36
test_padMethod · 0.36
test_padMethod · 0.36