MCPcopy Index your code
hub / github.com/pydata/xarray / thin

Method thin

xarray/core/dataarray.py:1827–1875  ·  view source on GitHub ↗

Return a new DataArray whose data is given by each `n` value along the specified dimension(s). Examples -------- >>> x_arr = np.arange(0, 26) >>> x_arr array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 1

(
        self,
        indexers: Mapping[Any, int] | int | None = None,
        **indexers_kwargs: Any,
    )

Source from the content-addressed store, hash-verified

1825 return self._from_temp_dataset(ds)
1826
1827 def thin(
1828 self,
1829 indexers: Mapping[Any, int] | int | None = None,
1830 **indexers_kwargs: Any,
1831 ) -> Self:
1832 """Return a new DataArray whose data is given by each `n` value
1833 along the specified dimension(s).
1834
1835 Examples
1836 --------
1837 >>> x_arr = np.arange(0, 26)
1838 >>> x_arr
1839 array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1840 17, 18, 19, 20, 21, 22, 23, 24, 25])
1841 >>> x = xr.DataArray(
1842 ... np.reshape(x_arr, (2, 13)),
1843 ... dims=("x", "y"),
1844 ... coords={"x": [0, 1], "y": np.arange(0, 13)},
1845 ... )
1846 >>> x
1847 <xarray.DataArray (x: 2, y: 13)> Size: 208B
1848 array([[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
1849 [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]])
1850 Coordinates:
1851 * x (x) int64 16B 0 1
1852 * y (y) int64 104B 0 1 2 3 4 5 6 7 8 9 10 11 12
1853
1854 >>>
1855 >>> x.thin(3)
1856 <xarray.DataArray (x: 1, y: 5)> Size: 40B
1857 array([[ 0, 3, 6, 9, 12]])
1858 Coordinates:
1859 * x (x) int64 8B 0
1860 * y (y) int64 40B 0 3 6 9 12
1861 >>> x.thin({"x": 2, "y": 5})
1862 <xarray.DataArray (x: 1, y: 3)> Size: 24B
1863 array([[ 0, 5, 10]])
1864 Coordinates:
1865 * x (x) int64 8B 0
1866 * y (y) int64 24B 0 5 10
1867
1868 See Also
1869 --------
1870 Dataset.thin
1871 DataArray.head
1872 DataArray.tail
1873 """
1874 ds = self._to_temp_dataset().thin(indexers, **indexers_kwargs)
1875 return self._from_temp_dataset(ds)
1876
1877 def broadcast_like(
1878 self,

Callers

nothing calls this directly

Calls 2

_to_temp_datasetMethod · 0.95
_from_temp_datasetMethod · 0.95

Tested by

no test coverage detected