From 1502c9ab708feeb9df24bf10835f4582dc13303e Mon Sep 17 00:00:00 2001 From: Eric Koch Date: Mon, 5 Aug 2024 13:46:09 -0400 Subject: [PATCH] Fix creation of binary dilation structure --- masking_and_moments/masking_and_moments_guide.ipynb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/masking_and_moments/masking_and_moments_guide.ipynb b/masking_and_moments/masking_and_moments_guide.ipynb index 226bdc4..f57d78c 100644 --- a/masking_and_moments/masking_and_moments_guide.ipynb +++ b/masking_and_moments/masking_and_moments_guide.ipynb @@ -85,7 +85,7 @@ " cache=True, show_progress=True)\n", "\n", "# Note that the datafile will not end in \".fits\". Because of that, we need to specify the format\n", - "# When the file name end in \"fits\", `format` will not need to be specified \n", + "# When the file name end in \"fits\", `format` will not need to be specified\n", "cube = SpectralCube.read(filename, format='fits', use_dask=False)\n", "\n", "# Convert to km/s for the spectral unit\n", @@ -460,7 +460,7 @@ "\n", "# Add 1 spectral element on each side of the spatial structure.\n", "# np.dstack stacks the arrays along a new 3rd dimension:\n", - "structure = np.dstack([structure_spec, structure, structure_spec])\n", + "structure = np.swapaxes(np.dstack([structure_spec, structure, structure_spec]), 0, 2)\n", "\n", "signal_mask = nd.binary_dilation(signal_mask, structure=structure, iterations=1)\n" ] @@ -956,7 +956,7 @@ "source": [ "with warnings.catch_warnings():\n", " warnings.simplefilter('ignore')\n", - " \n", + "\n", " # Load cube\n", " cube = SpectralCube.read(filename, format='fits', use_dask=True)\n", " # Convert to km/s for the spectral unit\n", @@ -996,10 +996,10 @@ " label_image=low_snr_mask_labels,\n", " index=range(1, num_labels + 1)) # +1 offset for mask labels\n", "\n", - " # To preserve the low_snr_mask, we will create a new signal mask where we will remove \n", + " # To preserve the low_snr_mask, we will create a new signal mask where we will remove\n", " # regions that do not pass the criteria.\n", " signal_mask = low_snr_mask\n", - " # NOTE: this is memory efficient but may be slower than defining a new empty array and adding the \n", + " # NOTE: this is memory efficient but may be slower than defining a new empty array and adding the\n", " # (often fewer) number of regions that pass the minimum pixel criteria. See the scipy example\n", " # above on using this alternative approach.\n", "\n",