diff --git a/doc/user_guide/signal1d.rst b/doc/user_guide/signal1d.rst index c76537a5cb..626c64466a 100644 --- a/doc/user_guide/signal1d.rst +++ b/doc/user_guide/signal1d.rst @@ -12,14 +12,14 @@ signals in the Signal1D class. Cropping -------- -The :py:meth:`~._signals.signal1d.Signal1D.crop_signal1D` crops the +The :py:meth:`~._signals.signal1d.Signal1D.crop_signal` crops the spectral energy range *in-place*. If no parameter is passed, a user interface appears in which to crop the one dimensional signal. For example: .. code-block:: python - s = hs.datasets.example_signals.EDS_TEM_Spectrum() - s.crop_signal1D(5, 15) # s is cropped in place + >>> s = hs.datasets.example_signals.EDS_TEM_Spectrum() + >>> s.crop_signal(5, 15) # s is cropped in place Additionally, cropping in HyperSpy can be performed using the :ref:`Signal indexing ` syntax. For example, the following crops a spectrum @@ -27,17 +27,17 @@ to the 5 keV-15 keV region: .. code-block:: python - s = hs.datasets.example_signals.EDS_TEM_Spectrum() - sc = s.isig[5.:15.] # s is not cropped, sc is a "cropped view" of s + >>> s = hs.datasets.example_signals.EDS_TEM_Spectrum() + >>> sc = s.isig[5.:15.] # s is not cropped, sc is a "cropped view" of s It is possible to crop interactively using :ref:`roi-label`. For example: .. code-block:: python - s = hs.datasets.example_signals.EDS_TEM_Spectrum() - roi = hs.roi.SpanROI(left=5, right=15) - s.plot() - sc = roi.interactive(s) + >>> s = hs.datasets.example_signals.EDS_TEM_Spectrum() + >>> roi = hs.roi.SpanROI(left=5, right=15) + >>> s.plot() + >>> sc = roi.interactive(s) .. _interactive_signal1d_cropping_image: @@ -60,7 +60,7 @@ The :py:meth:`~._signals.signal1d.Signal1D.remove_background` method provides background removal capabilities through both a CLI and a GUI. The GUI displays an interactive preview of the remainder after background subtraction. Currently, the following background types are supported: Doniach, Exponential, Gaussian, -Lorentzian, Polynomial, Power law (default), Offset, Skew normal, Split Voigt +Lorentzian, Polynomial, Power law (default), Offset, Skew normal, Split Voigt and Voigt. By default, the background parameters are estimated using analytical approximations (keyword argument ``fast=True``). The fast option is not accurate for most background types - except Gaussian, Offset and Power law - @@ -72,8 +72,8 @@ Example of usage: .. code-block:: python - s = hs.datasets.artificial_data.get_core_loss_eels_signal(add_powerlaw=True) - s.remove_background(zero_fill=False) + >>> s = hs.datasets.artificial_data.get_core_loss_eels_signal(add_powerlaw=True) + >>> s.remove_background(zero_fill=False) .. figure:: images/signal_1d_remove_background.png :align: center @@ -177,7 +177,7 @@ For asymmetric peaks, `fitted functions ` may not provide an accurate description of the peak, in particular the peak width. The function :py:meth:`~._signals.signal1d.Signal1D.estimate_peak_width` determines the width of a peak at a certain fraction of its maximum value. - + Other methods ------------- diff --git a/doc/user_guide/signal2d.rst b/doc/user_guide/signal2d.rst index a5d2754193..872fe6b57b 100644 --- a/doc/user_guide/signal2d.rst +++ b/doc/user_guide/signal2d.rst @@ -69,13 +69,13 @@ the scheduler of the :ref:`dask backend `. Cropping a Signal2D ------------------- -The :py:meth:`~._signals.signal2d.Signal2D.crop_signal2D` method crops the +The :py:meth:`~._signals.signal2d.Signal2D.crop_signal` method crops the image *in-place* e.g.: .. code-block:: python >>> im = hs.datasets.example_signals.object_hologram() - >>> im.crop_signal2D(left=120, top=300, bottom=560) # im is cropped in-place + >>> im.crop_signal(left=120, top=300, bottom=560) # im is cropped in-place Cropping in HyperSpy is performed using the :ref:`Signal indexing diff --git a/hyperspy/_signals/signal1d.py b/hyperspy/_signals/signal1d.py index 9fff7bae90..c4a1ed1e76 100644 --- a/hyperspy/_signals/signal1d.py +++ b/hyperspy/_signals/signal1d.py @@ -1215,8 +1215,8 @@ def remove_background( remove_background.__doc__ %= (SHOW_PROGRESSBAR_ARG, DISPLAY_DT, TOOLKIT_DT) @interactive_range_selector - def crop_signal1D(self, left_value=None, right_value=None,): - """Crop in place the spectral dimension. + def crop_signal(self, left_value=None, right_value=None,): + """Crop in place in the signal space. Parameters ---------- diff --git a/hyperspy/_signals/signal2d.py b/hyperspy/_signals/signal2d.py index c2032988d3..94c8a10e94 100644 --- a/hyperspy/_signals/signal2d.py +++ b/hyperspy/_signals/signal2d.py @@ -764,7 +764,7 @@ def align2D( int(np.floor(_min1)) if _min1 < 0 else None, int(np.ceil(_max1)) if _max1 > 0 else 0, ) - self.crop_signal2D(top, bottom, left, right) + self.crop_signal(top, bottom, left, right) shifts = -shifts self.events.data_changed.trigger(obj=self) @@ -863,9 +863,10 @@ def _get_signal2d_scale(self, x0, y0, x1, y1, length): scale = length / old_length return scale - def crop_signal2D(self, top=None, bottom=None, - left=None, right=None, convert_units=False): - """Crops an image in place. + def crop_signal(self, top=None, bottom=None, left=None, right=None, + convert_units=False): + """ + Crops in signal space and in place. Parameters ---------- diff --git a/hyperspy/tests/signals/test_2D.py b/hyperspy/tests/signals/test_2D.py index 4a2265ce9e..438f4ce832 100644 --- a/hyperspy/tests/signals/test_2D.py +++ b/hyperspy/tests/signals/test_2D.py @@ -211,7 +211,7 @@ def test_crop_image_unit_convertion_signal2D(self): s.axes_manager[1].name = "y" s.axes_manager[1].scale = 0.01 s.axes_manager[1].units = "µm" - s.crop_signal2D(0, 0.5, 0.0, 0.5) + s.crop_signal(0, 0.5, 0.0, 0.5) np.testing.assert_almost_equal(s.axes_manager[0].scale, 0.01) np.testing.assert_almost_equal(s.axes_manager[1].scale, 0.01) assert s.axes_manager[0].units == "µm" @@ -227,7 +227,7 @@ def test_crop_image_unit_convertion_signal2D(self): s.axes_manager[1].name = "y" s.axes_manager[1].scale = 0.01 s.axes_manager[1].units = "µm" - s.crop_signal2D(0, 0.5, 0.0, 0.5, convert_units=True) + s.crop_signal(0, 0.5, 0.0, 0.5, convert_units=True) np.testing.assert_almost_equal(s.axes_manager[0].scale, 10.0) np.testing.assert_almost_equal(s.axes_manager[1].scale, 10.0) assert s.axes_manager[0].units == "nm" @@ -243,7 +243,7 @@ def test_crop_image_unit_convertion_signal2D(self): s.axes_manager[1].name = "y" s.axes_manager[1].scale = 0.01 s.axes_manager[1].units = "µm" - s.crop_signal2D(0, 5.0, 0.0, 5.0, convert_units=True) + s.crop_signal(0, 5.0, 0.0, 5.0, convert_units=True) np.testing.assert_almost_equal(s.axes_manager[0].scale, 0.01) np.testing.assert_almost_equal(s.axes_manager[1].scale, 0.01) assert s.axes_manager[0].units == "µm" diff --git a/upcoming_changes/3197.api.rst b/upcoming_changes/3197.api.rst index b135b5112c..a9e31123f8 100644 --- a/upcoming_changes/3197.api.rst +++ b/upcoming_changes/3197.api.rst @@ -1 +1 @@ -Renamed ``Signal2D.crop_image`` to :meth:`~.api.signals.Signal2D.crop_signal2D` \ No newline at end of file +Renamed ``Signal2D.crop_image`` to :meth:`~.api.signals.Signal2D.crop_signal`