Skip to content

Commit

Permalink
Suppressed performance warning for many small chunks in reorder(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
thijsvl committed Jun 20, 2024
1 parent 3fe96b6 commit 824799c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion stmtools/stm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import dask.array as da
import geopandas as gpd
import numpy as np
import pandas as pd
import pymorton as pm
import xarray as xr
import warnings
from scipy.spatial import KDTree
from shapely.geometry import Point
from shapely.strtree import STRtree
Expand Down Expand Up @@ -392,6 +394,9 @@ def reorder(self, xlabel="azimuth", ylabel="range", xscale=1.0, yscale=1.0):
resolution of the ordering: only the whole-number part influences the order.
While coordinates could also be offset, this has limited effect on the relative order.
Also note that reordering a dataset may be an expensive operation. Because it is applied
lazily, this preformance cost will only manifest once the elements are evaluated.
Parameters
----------
self : SpaceTimeMatrix
Expand All @@ -416,7 +421,12 @@ def reorder(self, xlabel="azimuth", ylabel="range", xscale=1.0, yscale=1.0):
"space": self._obj.chunksizes["space"][0],
"time": self._obj.chunksizes["time"][0],
}
self._obj = self._obj.sortby(self._obj.order)
with warnings.catch_warnings():
# Trying to supporess only [...]/lib/python3.12/site-packages/xarray/core/indexing.py:1620: PerformanceWarning: Slicing with an out-of-order index is generating [...] times more chunks
# but unable to find the warning category.
#warnings.simplefilter(action="ignore", category=pd.errors.PerformanceWarning)
warnings.simplefilter(action="ignore")
self._obj = self._obj.sortby(self._obj.order)
self._obj = self._obj.chunk(chunks)

return self._obj
Expand Down

0 comments on commit 824799c

Please sign in to comment.