.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_tutorials/tutorials/data_downloader.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_tutorials_tutorials_data_downloader.py: Data Downloader =============== This tutorial reviews ASPIRE's data downloading utility. .. GENERATED FROM PYTHON SOURCE LINES 9-19 Data Downloader Introduction ---------------------------- ASPIRE provides a data downloading utility for downloading and caching some common example datasets. When applicable, the data will be loaded as an appropriate ASPIRE data type, such a as a ``Volume``, ``Image``, or ``ImageSource`` instance. Below we take a look at the current list of datasets available for download. sphinx_gallery_start_ignore flake8: noqa sphinx_gallery_end_ignore .. GENERATED FROM PYTHON SOURCE LINES 19-23 .. code-block:: Python from aspire import downloader downloader.available_downloads() .. rst-class:: sphx-glr-script-out .. code-block:: none ['emdb_2660', 'emdb_8012', 'emdb_2984', 'emdb_8511', 'emdb_3645', 'emdb_4905', 'emdb_10835', 'emdb_5778', 'emdb_6287', 'emdb_2824', 'emdb_14621', 'emdb_2484', 'emdb_6458', 'simulated_channelspin'] .. GENERATED FROM PYTHON SOURCE LINES 24-28 Data Caching ------------ By default, the data downloader selects an appropriate cache directory based on the user operating system. Usually, the locations will be the following: .. GENERATED FROM PYTHON SOURCE LINES 30-41 .. list-table:: Default Cache Locations :header-rows: 1 * - OS - Cache Location * - Mac - ~/Library/Caches/ASPIRE-data * - Linux - ~/.cache/ASPIRE-data * - Windows - C:\\Users\\\\AppData\\Local\\\\ASPIRE-data\\Cache .. GENERATED FROM PYTHON SOURCE LINES 43-55 The cache location is configurable and can be overridden by creating a custom ``config.yaml``. For example, to change the cache folder to ``/tmp/ASPIRE-data`` create ``$HOME/.config/ASPIRE/config.yaml`` with the following contents: .. code-block:: yaml cache: cache_dir: /tmp/ASPIRE-data See the `ASPIRE Conguration `_ tutorial for more details on customizing your config. .. GENERATED FROM PYTHON SOURCE LINES 57-61 .. note:: All downloads can be cleared from the cache with the ``remove_downloads()`` method:: downloader.remove_downloads() .. GENERATED FROM PYTHON SOURCE LINES 63-68 Download an Example Dataset --------------------------- Below we will download ``emdb_2660``, a high resolution volume map of the 80s Ribosome which is sourced from EMDB at https://www.ebi.ac.uk/emdb/EMD-2660. This volume map will load as an instance of ASPIRE's ``Volume`` class. .. GENERATED FROM PYTHON SOURCE LINES 68-71 .. code-block:: Python vol = downloader.emdb_2660() vol .. rst-class:: sphx-glr-script-out .. code-block:: none 1 float32 volumes arranged as a (1,) stack each of size 360x360x360 with pixel_size=1.340000033378601 angstroms. .. GENERATED FROM PYTHON SOURCE LINES 72-75 View the Data ------------------ We can take a peek at this data by viewing some projections of the volume. .. GENERATED FROM PYTHON SOURCE LINES 75-82 .. code-block:: Python import numpy as np from aspire.utils import Rotation rots = Rotation.about_axis("y", [0, np.pi / 2]) projection = vol.project(rots) projection.show() .. image-sg:: /auto_tutorials/tutorials/images/sphx_glr_data_downloader_001.png :alt: data downloader :srcset: /auto_tutorials/tutorials/images/sphx_glr_data_downloader_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.416 seconds) .. _sphx_glr_download_auto_tutorials_tutorials_data_downloader.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: data_downloader.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: data_downloader.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: data_downloader.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_