Skip to content

Commit

Permalink
add test for dask array and rechunk if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
jkingslake committed Oct 21, 2024
1 parent 801630e commit 4cd73b4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion xapres/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import numpy as np
import xarray as xr
import datetime
import dask.array as da




Expand Down Expand Up @@ -382,6 +384,9 @@ def freq2range(frequencies):
# roll
s_wpr = s_wp.roll(chirp_time=int(Nt*pad_factor/2))

if contains_dask_array(s_wpr):
s_wpr = s_wpr.chunk({'chirp_time':-1})

# fft
S_wpr = xr.apply_ufunc(np.fft.fft,
s_wpr,
Expand Down Expand Up @@ -439,4 +444,7 @@ def add_methods_to_xarrays():

ds_methods = [addProfileToDs]
for method in ds_methods:
setattr(xr.Dataset, method.__name__, method)
setattr(xr.Dataset, method.__name__, method)

def contains_dask_array(dataarray):
return isinstance(dataarray.data, da.Array)

0 comments on commit 4cd73b4

Please sign in to comment.