Note

Pyleoclim requires the use of Python 3.9 or above

Installing Pyleoclim

If you know what you are doing, you may install Pyleoclim in any suitable Python environment, with a Python version >=3.9.

However, we have not and cannot possibly, try every situation.

If you are new to Python, we recommend the use of Anaconda (or its minimal version Miniconda), to set up such an environment. Then you may install Pyleoclim via pip.

Installing Anaconda or Miniconda

To install Anaconda or Miniconda on your platform, follow the instructions from this page.

Click here for a quick tutorial on MacOs and Linux systems.

Creating a new conda environment

As of Nov 2023, we recommend Python 3.11. Create an environment via the command line (e.g. Terminal app in MacOS):

conda create -n pyleo python=3.11

To view a list of available environments:

conda env list

To activate the new environment:

conda activate pyleo

To view the list of packages in your environment:

conda list

To remove the environment:

conda remove --name pyleo --all

More information about managing conda environments can be found here.

Installing Pyleoclim

Once the pyleo environment is activated, simply run:

pip install pyleoclim

This will install the latest official release, which you can view here. To install the latest version, which contains the most up-to-date features, you can install directly from the GitHub source:

pip install git+https://github.com/LinkedEarth/Pyleoclim_util.git

This version may contain bugs not caught by our continuous integration test suite; if so, please report them via github issues If you would like to use Spyder for code development:

conda install spyder

If you intend on using Pyleoclim within a Jupyter Notebook, we recommend using ipykernel.

conda install ipykernel
python -m ipykernel install --user --name=pyleo

The first line will install ipykernel and its dependencies, including IPython, Jupyter, etc. The second line will make sure the pyleo environment is visible to Jupyter (see this page for context)

Building from source for the f2py feature of WWZ

The default version of WWZ that comes with the installation steps mentioned above is relying on Numba. It is fast enough for lightweight spectral & wavelet analysis tasks, in which case we recommend using the default installation.

However, it could be slow for heavy use (e.g. performing it hundreds of times on timeseries longer than 1000 points), in which case we recommend activating the f2py feature to achieve a speedup of ~50%.

To do that, a Fortran compiler (e.g. gfortran or ifort) is required on your local machine, and the related Fortran source code should be compiled locally following the steps below:

  • download the source code, either via git clone or just download the .zip file from the Github repo

  • go to the directory Pyleoclim_util/pyleoclim/f2py, and then type make to compile the .f90 source code with gfortran

  • one may also edit the Makefile to use ifort as the compiler to achieve further acceleration; just comment out the line for gfortran and use the line for ifort below

  • a .so file will be generated if the compilation is successful

  • copy the .so file into the directory Pyleoclim_util/pyleoclim/utils where Pyleoclim is installed on your machine. To find out the location, one may import the package in Python and “print” it:

import pyleoclim as pyleo
print(pyleo)

Again, unless you are planning to make heavy use of the WWZ functionality, we recommend using the default installation.

Docker Container

Docker containers with various versions of Pyleoclim are available on quay.io.

To pull an image:

docker pull quay.io/linkedearth/pyleoclim:latest

To run the image:

docker run -it -p 8888:8888 quay.io/linkedearth/pyleoclim:latest

The container will start a Jupyter server automatically. You need to copy the link to the server (localhost) into your web browser on your machine (the command -p 8888:8888 opens the communication port between your machine and the container). You can then create notebook and upload notebook and data using the Jupyter interface. Remember that the container will not save any of your work if you close it. So make sure you donwload your work before closing the container.