diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 645d52164..b47662751 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -50,7 +50,7 @@ Added - Center-of-mass algorithm added to get_direct_beam_position (#845) - Added `VectorSignal1D` class to handle 1 dimensional signals - Added kwargs to find_beam_offset_cross_correlation allowing for parameters -to be passed to `phase_cross_correlation` (#907) + to be passed to `phase_cross_correlation` (#907) - Added `LazyVirtualDarkField` signal Changed @@ -108,6 +108,7 @@ Removed - lazy_* virtual imaging has been removed, use get_integrated_intensity (#722) - `big_data_utils` has been removed as this is not the modern way of attacking this problem - similarly, `TemplateIndexationGenerator` has been removed as the Accelerated approach is far better (#823) + Fixed ^^^^^ - Symmetry STEM Class updated to allow for better interpolation and lazy operation. (#809) diff --git a/doc/conf.py b/doc/conf.py index 692432dd5..42c73a15d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -79,6 +79,8 @@ linkcheck_ignore = [ "https://doi.org/10.1002/smll.201904738", # 403 Client Error: Forbidden for url "http://dx.doi.org/10.1088/0965-0393/23/8/083501", # 403 Client Error: Forbidden for url + "https://doi.org/10.1111/jmi.12065", # 403 Client Error: Forbidden for url + "https://doi.org/10.1111/j.0022-2720.2004.01293.x", # 403 Client Error: Forbidden for url ] diff --git a/doc/dev_guide/contributing.rst b/doc/dev_guide/contributing.rst index c047ef5d5..afceb0fe7 100644 --- a/doc/dev_guide/contributing.rst +++ b/doc/dev_guide/contributing.rst @@ -22,6 +22,7 @@ inquiries regarding the project? Feel free to repository. .. _setting-up-a-development-installation: + First Time Contributing ======================= diff --git a/doc/dev_guide/index.rst b/doc/dev_guide/index.rst index 9fbb48bcc..f538882b8 100644 --- a/doc/dev_guide/index.rst +++ b/doc/dev_guide/index.rst @@ -1,3 +1,5 @@ +.. _development: + .. toctree:: :maxdepth: 1 :hidden: diff --git a/doc/dev_guide/intro.rst b/doc/dev_guide/intro.rst index a41b69e8a..50f83ab6e 100644 --- a/doc/dev_guide/intro.rst +++ b/doc/dev_guide/intro.rst @@ -1,5 +1,3 @@ -.. _development: - ########## Contribute ########## diff --git a/doc/user_guide/bibliography.rst b/doc/user_guide/bibliography.rst index 7e4c4cf04..f6fb2240c 100644 --- a/doc/user_guide/bibliography.rst +++ b/doc/user_guide/bibliography.rst @@ -1,5 +1,5 @@ Bibliography ============= -.. bibliography:: bibliography.bib +.. bibliography:: ../bibliography.bib :all: diff --git a/doc/user_guide/distributed_big_data.rst b/doc/user_guide/distributed_big_data.rst index a9eee49e7..a40cfd1df 100644 --- a/doc/user_guide/distributed_big_data.rst +++ b/doc/user_guide/distributed_big_data.rst @@ -1,5 +1,3 @@ -.. _Big Data: - Big Data --------- @@ -12,8 +10,8 @@ discuss how to work with large datasets in ``pyxem``. .. note:: If you want more information on working with large datasets in ``pyxem``, please see the - `Big Data_` section of - the `HyperSpy User Guide`_. + `Big Data _` section of + the `HyperSpy User Guide _`. Loading and Plotting a Dataset ------------------------------ @@ -21,35 +19,38 @@ Loading and Plotting a Dataset Let's start by loading a dataset. We will use the ``load`` function to load a dataset from HyperSpy -.. code-block:: python +.. code-block:: - >>> import hyperspy.api as hs - >>> s = hs.load("big_data.zspy", lazy=True) - >>> s + import hyperspy.api as hs + s = hs.load("big_data.zspy", lazy=True) + s The dataset here is not loaded into memory here, so this should happen instantaneously. We can then plot the dataset. -.. code-block:: python +.. code-block:: - >>> s.plot() + s.plot() Which (in general) will be very slow. This is because entire dataset is loaded into memory (chuck by chunk) to create a navigator image. In many cases a HAADF dataset will be collected as well as a 4-D STEM dataset. In this case we can set the navigator to the HAADF dataset instead. .. code-block:: python - >>> haadf = hs.load("haadf.zspy") # load the HAADF dataset - >>> s.plot(navigator=haadf) # happens instantaneously + + haadf = hs.load("haadf.zspy") # load the HAADF dataset + s.plot(navigator=haadf) # happens instantaneously This is much faster as the navigator doesn't need to be computed and instead only 1 chunk needs to be loaded into memory before plotting! You can also set the navigator so that by default it is used when plotting. + .. code-block:: python - >>> haadf = hs.load("haadf.zspy") # load the HAADF dataset - >>> s.navigator = haadf - >>> s.plot() # (navigator=haadf) happens instantaneously + + haadf = hs.load("haadf.zspy") # load the HAADF dataset + s.navigator = haadf + s.plot() Distributed Computing @@ -62,10 +63,10 @@ in Python. It is very powerful and can be used to speed up many different types The first step is to set up a `Dask Client `_. This can be done using the distributed scheduler. -.. code-block:: python +.. code-block:: - >>> from dask.distributed import Client - >>> client = Client() + from dask.distributed import Client + client = Client() This will start a local cluster on your machine. @@ -73,9 +74,9 @@ If you want to use a remote cluster using a scheduler such as `Slurm `_ library. This is a library that allows you to use a scheduler to start a cluster on a remote machine. -.. code-block:: python +.. code-block:: - >>> from dask_jobqueue import SLURMCluster - >>> cluster = SLURMCluster() - >>> client = Client(cluster) + from dask_jobqueue import SLURMCluster + cluster = SLURMCluster() + client = Client(cluster) diff --git a/doc/user_guide/index.rst b/doc/user_guide/index.rst index 388481ba6..509179b6a 100644 --- a/doc/user_guide/index.rst +++ b/doc/user_guide/index.rst @@ -1,3 +1,5 @@ +.. _User Guide: + .. toctree:: :maxdepth: 1 :hidden: @@ -23,7 +25,7 @@ :caption: Resources :hidden: - reference/index.rst + ../reference/index.rst bibliography.rst cite.rst open_datasets_workflows.rst diff --git a/doc/user_guide/installing.rst b/doc/user_guide/installing.rst index b374178dc..4aba98074 100644 --- a/doc/user_guide/installing.rst +++ b/doc/user_guide/installing.rst @@ -1,11 +1,12 @@ .. _Installation: + ---------------- Installing pyxem ---------------- There are a couple of different ways to install pyxem. The easiest way is to use the hyperspy-bundle. If you don't have much experience with managing Python environments, we -highly recommend using the `hyperspy-bundle`. +highly recommend using the `hyperspy-bundle_`. The bundle is a pre-configured Python environment that includes pyxem and all its dependencies. It includes many other packages that are useful for electron microscopy data analysis, such @@ -27,40 +28,31 @@ into an existing environment. The easiest way to do this is using conda/mamba. but is particularly a pain sometimes. If you have having trouble you can always change your url from ``http://localhost:8888/lab`` to ``http://localhost:8888/notebooks`` and use the classic notebook instead. There are less features but it is more stable in my experience. +:: -``` conda install -c conda-forge pyxem -``` - Installing using pip -------------------- You can also install pyxem using pip if you want. In that case you can install pyxem -using +using:: -``` pip install pyxem -``` Installing from source ---------------------- If you want to install the development version of pyxem, you can install it from source. -First clone the repository using +First clone the repository using:: -``` git clone https://github.com/pyxem/pyxem.git -``` -Then navigate into the pyxem directory and install the dependencies using +Then navigate into the pyxem directory and install the dependencies using:: -``` pip install -r requirements.txt -``` -Finally, install pyxem using +Finally, install pyxem using:: -``` pip install -e . -``` + diff --git a/doc/user_guide/intro.rst b/doc/user_guide/intro.rst index f4af82aca..8ade78f25 100644 --- a/doc/user_guide/intro.rst +++ b/doc/user_guide/intro.rst @@ -1,5 +1,3 @@ -.. _User Guide: - Where do I start? ================= diff --git a/doc/user_guide/loading_data.rst b/doc/user_guide/loading_data.rst index 25fd17128..033239fa2 100644 --- a/doc/user_guide/loading_data.rst +++ b/doc/user_guide/loading_data.rst @@ -5,10 +5,12 @@ Loading Data ############ Data can be loaded from many different 4-D STEM detectors using the package -`rosettasciio`_. The file types currently supported are listed -`here`_. +`rosettasciio_`. The file types currently supported are listed +`here_`. -We are always looking to add more support for more file formats and detectors. If you have a files or detectors that you would like to see supported, please raise an `issue`_ +We are always looking to add more support for more file formats and detectors. +If you have a files or detectors that you would like to see supported, +please raise an `issue_` on the rosettasciio GitHub page and we will do our best to work with you to add it. We are also looking to add support for faster loading of data from detectors that we already @@ -26,27 +28,27 @@ and when possible it is done automatically. For example, loading:external+rsciio return :class:`~.signals.ElecttronDiffraction2D` object but in situations, where a generic signal is returned, a domain-specific signal can be specified as follow: -.. code-block:: python +.. code-block:: - >>> s = hs.load("data/4DSTEM_simulation.hspy", signal_type="electron_diffraction" - >>> s # ElectronDiffraction2D object (defined in pyxem!) + s = hs.load("data/4DSTEM_simulation.hspy", signal_type="electron_diffraction") + s # ElectronDiffraction2D object (defined in pyxem!) Or we can cast the signal to a specific signal type after loading it. For example, -.. code-block:: python +.. code-block:: - >>> s = hs.load("data/4DSTEM_simulation.hspy") - >>> s = s.set_signal_type("electron_diffraction") - >>> s # ElectronDiffraction2D object (defined in pyxem!) + s = hs.load("data/4DSTEM_simulation.hspy") + s = s.set_signal_type("electron_diffraction") + s # ElectronDiffraction2D object (defined in pyxem!) Note that when we save the signal to a ``.zspy`` file or a ``.hspy`` file, the signal type is saved as metadata. This means that when we load the signal, we no longer need to specify the signal type. For example, -.. code-block:: python +.. code-block:: - >>> s = hs.load("data/4DSTEM_simulation.zspy") - >>> s.set_signal_type("electron_diffraction") - >>> s.save("data/4DSTEM_simulation_2.zspy") - >>> s = hs.load("data/4DSTEM_simulation_2.zspy") - >>> s # ElectronDiffraction2D object (defined in pyxem!) \ No newline at end of file + s = hs.load("data/4DSTEM_simulation.zspy") + s.set_signal_type("electron_diffraction") + s.save("data/4DSTEM_simulation_2.zspy") + s = hs.load("data/4DSTEM_simulation_2.zspy") + s # ElectronDiffraction2D object (defined in pyxem!) \ No newline at end of file diff --git a/pyxem/signals/diffraction2d.py b/pyxem/signals/diffraction2d.py index c7a858b40..26d8f8dc1 100644 --- a/pyxem/signals/diffraction2d.py +++ b/pyxem/signals/diffraction2d.py @@ -1405,7 +1405,7 @@ def intensity_peaks( disk_r : int Radius of the disc chosen to take the mean value of lazy_result : bool, default True - If True, will return a LazyDiffraction2D object. If False, + If True, will return a :class:`~pyxem.signals.diffraction2d.LazyDiffraction2D` object. If False, will compute the result and return a Diffraction2D object. show_progressbar : bool, default True diff --git a/pyxem/signals/insitu_diffraction2d.py b/pyxem/signals/insitu_diffraction2d.py index e94a5a9a4..5978173c2 100644 --- a/pyxem/signals/insitu_diffraction2d.py +++ b/pyxem/signals/insitu_diffraction2d.py @@ -42,9 +42,9 @@ class InSituDiffraction2D(Diffraction2D): Parameters ---------- - *args + *args: See :class:`~hyperspy._signals.signal2d.Signal2D`. - **kwargs + **kwargs: See :class:`~hyperspy._signals.signal2d.Signal2D` """ @@ -55,12 +55,11 @@ def roll_time_axis(self, time_axis): return self.rollaxis(time_axis, 2) def get_time_series(self, roi=None, time_axis=2): - """ - Create a intensity time series from virtual aperture defined by roi. + """Create a intensity time series from virtual aperture defined by roi. Parameters ---------- - roi: :obj:`hyperspy.roi.BaseInteractiveROI` + roi: :obj:`~hyperspy.roi.BaseInteractiveROI` Roi for virtual detector. If None, full roi of diffraction plane is used time_axis: int Index of time axis. Default is 2 @@ -89,26 +88,24 @@ def get_time_series(self, roi=None, time_axis=2): def get_drift_vectors( self, time_axis=2, reference="cascade", sub_pixel_factor=10, **kwargs ): - """ - Calculate real space drift vectors from time series of images + """Calculate real space drift vectors from time series of images - Parameters + Parameters ---------- - s: Signal2D + s: :class:`~hyperspy.api.signals.Signal2D` Time series of reconstructed images reference: 'current', 'cascade', or 'stat' - reference argument passed to hs.signals.Signal2D.estimate_shift2D() + reference argument passed to :meth:`~hyperspy.api.signals.Signal2D.estimate_shift2D` function. Default is 'cascade' sub_pixel_factor: float - sub_pixel_factor passed to hs.signals.Signal2D.estimate_shift2D() + sub_pixel_factor passed to :meth:`~hyperspy.api.signals.Signal2D.estimate_shift2D` function. Default is 10 **kwargs: - Passed to the :meth:`get_time_series` function + Passed to the :meth:`~pyxem.signals.InSituDiffraction2D.get_time_series` function Returns ------- shift_vectors - """ roi = kwargs.pop("roi", None) ref = self.get_time_series(roi=roi, time_axis=time_axis) diff --git a/pyxem/utils/plotting_utils.py b/pyxem/utils/plotting_utils.py index b3f932304..eee6ebb9e 100644 --- a/pyxem/utils/plotting_utils.py +++ b/pyxem/utils/plotting_utils.py @@ -23,14 +23,13 @@ def plot_template_over_pattern( size_factor=1.0, **kwargs ): - """ - A quick utility function to plot a simulated pattern over an experimental image + """A quick utility function to plot a simulated pattern over an experimental image Parameters ---------- pattern : 2D np.ndarray The diffraction pattern - simulation : diffsims.sims.diffraction_simulation.DiffractionSimulation + simulation : :class:`~diffsims.sims.diffraction_simulation.DiffractionSimulation` The simulated diffraction pattern. It must be calibrated. axis : matplotlib.AxesSubplot, optional An axis object on which to plot. If None is provided, one will be created. @@ -38,7 +37,7 @@ def plot_template_over_pattern( An in-plane rotation angle to apply to the template in degrees max_r : float, optional Maximum radius to consider in the polar transform in pixel coordinates. - Will only influence the result if `coordinate_system`="polar". + Will only influence the result if ``coordinate_system="polar"``. find_direct_beam: bool, optional Roughly find the optimal direct beam position if it is not centered. direct_beam_position: 2-tuple @@ -48,14 +47,15 @@ def plot_template_over_pattern( Whether to mirror the given template coordinate_system : str, optional Type of coordinate system to plot the image and template in. Either - `cartesian` or `polar` + ``cartesian`` or ``polar`` marker_color : str, optional Color of the spot markers marker_type : str, optional Type of marker used for the spots size_factor : float, optional Scaling factor for the spots. See notes on size. - **kwargs : See imshow + **kwargs : + See :meth:`~matplotlib.pyplot.imshow` Returns -------