@@ -95,13 +95,41 @@ def binary_erosion(data, *args, **kwargs):
95
95
"""
96
96
import xarray as xr
97
97
from scipy .ndimage import binary_erosion
98
- # Perform binary erosion on the NumPy array data
99
98
array = binary_erosion (data .values , * args , ** kwargs )
100
- # Create a new DataArray from the eroded NumPy array
101
- array = xr .DataArray (
102
- array ,
103
- coords = data .coords ,
104
- dims = data .dims ,
105
- attrs = data .attrs ,
106
- )
107
- return array
99
+ return xr .DataArray (array , coords = data .coords , dims = data .dims , attrs = data .attrs )
100
+
101
+ @staticmethod
102
+ def binary_dilation (data , * args , ** kwargs ):
103
+ """
104
+ https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.binary_dilation.html
105
+ """
106
+ import xarray as xr
107
+ from scipy .ndimage import binary_dilation
108
+ array = binary_dilation (data .values , * args , ** kwargs )
109
+ return xr .DataArray (array , coords = data .coords , dims = data .dims , attrs = data .attrs )
110
+
111
+ @staticmethod
112
+ def binary_opening (data , * args , ** kwargs ):
113
+ """
114
+ https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.binary_opening.html
115
+
116
+ corrmask = utils.binary_closing(corrmask, structure=np.ones((10,10)))
117
+ corrmask = utils.binary_opening(corrmask, structure=np.ones((10,10)))
118
+ """
119
+ import xarray as xr
120
+ from scipy .ndimage import binary_opening
121
+ array = binary_opening (data .values , * args , ** kwargs )
122
+ return xr .DataArray (array , coords = data .coords , dims = data .dims , attrs = data .attrs )
123
+
124
+ @staticmethod
125
+ def binary_closing (data , * args , ** kwargs ):
126
+ """
127
+ https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.binary_opening.html
128
+
129
+ corrmask = utils.binary_closing(corrmask, structure=np.ones((10,10)))
130
+ corrmask = utils.binary_opening(corrmask, structure=np.ones((10,10)))
131
+ """
132
+ import xarray as xr
133
+ from scipy .ndimage import binary_closing
134
+ array = binary_closing (data .values , * args , ** kwargs )
135
+ return xr .DataArray (array , coords = data .coords , dims = data .dims , attrs = data .attrs )
0 commit comments