@@ -352,6 +352,26 @@ def forge_dts():
352352 return dc .spool (path )[0 ]
353353
354354
355+ @register_func (EXAMPLE_PATCHES , key = "nd_patch" )
356+ def nd_patch (dim_count = 3 , coord_lens = 10 ):
357+ """
358+ Make an N dimensional Patch.
359+
360+ Parameters
361+ ----------
362+ dim_count
363+ The number of dimensions.
364+ coord_lens
365+ The length of the coordinates.
366+ """
367+ ran = np .random .RandomState (42 )
368+ dims = tuple (f"dim_{ i + 1 } " for i in range (dim_count ))
369+ coords = {d : np .arange (coord_lens ) for d in dims }
370+ shape = tuple (len (coords [d ]) for d in dims )
371+ data = ran .randn (* shape )
372+ return dc .Patch (data = data , coords = coords , dims = dims )
373+
374+
355375@register_func (EXAMPLE_PATCHES , key = "ricker_moveout" )
356376def ricker_moveout (
357377 frequency = 15 ,
@@ -392,6 +412,7 @@ def ricker_moveout(
392412
393413 def _ricker (time , delay ):
394414 # shift time vector to account for different peak times.
415+ delay = 0 if not np .isfinite (delay ) else delay
395416 new_time = time - delay
396417 f = frequency
397418 # get amplitude and exp term of ricker
@@ -407,7 +428,10 @@ def _ricker(time, delay):
407428 # iterate each distance channel and update data
408429 for ind , dist in enumerate (distance ):
409430 dist_to_source = np .abs (dist - source_distance )
410- time_delay = peak_time + (dist_to_source / velocity )
431+ with np .errstate (divide = "ignore" , invalid = "ignore" ):
432+ shift = dist_to_source / velocity
433+ actual_shift = shift if np .isfinite (shift ) else 0
434+ time_delay = peak_time + actual_shift
411435 data [:, ind ] = _ricker (time , time_delay )
412436
413437 coords = {"time" : to_timedelta64 (time ), "distance" : distance }
@@ -508,7 +532,7 @@ def delta_patch(
508532 # Get data with ones centered on selected dimensions.
509533 shape = patch .shape
510534 index = tuple (
511- shape [patch .dims . index (dimension )] // 2 if dimension in used_dims else 0
535+ shape [patch .get_axis (dimension )] // 2 if dimension in used_dims else 0
512536 for dimension in patch .dims
513537 )
514538 data = np .zeros_like (patch .data )
0 commit comments