
Installation
============

``The latest version of astromorphlib is`` `[1.0.11] <https://pypi.org/project/astromorphlib/>`_.


The repository of ``astromorphlib`` is at  `Gitlab <https://https://gitlab.com/joseaher/astromorphlib>`_.


The easiest way to install this package is via an Environment manager:


- **Python version:** 3.13 or later
- **Operating system:** Linux or macOS
- **Environment manager:** ``conda`` (Anaconda or Miniconda)
- **Environment name (suggested):** ``astromorphlib``

It is highly recommended to create an isolated Conda environment before
installing ``astromorphlib``. This ensures all dependencies are handled
cleanly and avoids conflicts with other Python installations.

Creating the Environment
------------------------

1. **Create a new Conda environment with Python 3.13:**

   .. code-block:: bash

       conda create -n astromorphlib python=3.13.1

2. **Activate the environment:**

   .. code-block:: bash

       conda activate astromorphlib

3. **Install the required dependencies:**

   You can install them directly via  ``pip`` inside the environment:

   .. code-block:: bash

       pip install statmorph==0.6.1 splusdata astro-datalab astroplotlib \
                   astropy astroquery photutils==1.5.0 numpy matplotlib \
                   scipy pyvo wget colorama

4. **Finally, you can install** ``astromorphlib``:

   .. code-block:: bash

      pip install astromorphlib

5. **Additionally, you can either install Jupyterlab or Jupyter interactive notebook, for example installing Jupyterlab:**

    .. code-block:: bash

      pip install jupyterlab

Resolving Compatibility Issues with `photutils` (==1.5.0) and Newer Versions of `numpy` (>= 2.0)
=====================================================================================

When using `photutils` with `numpy` version 2.0 or higher, you may encounter a
compatibility issue. This occurs due to changes in how the `index_exp` function
is imported. To resolve this, you need to update the import statement in
the `background_2d.py` file.

Steps to Fix
------------

1. **Locate the `background_2d.py` file: - This file is typically located in a path like:**

  .. code-block:: bash

       home/user_name/anaconda3/envs/astromorphlib/lib/python3.13/site-packages/photutils/background/

2. **Open the file and find the following line of code:**

   .. code-block:: python

       from numpy.lib.index_tricks import index_exp

3. **Replace it with this updated import statement:**

   .. code-block:: python

       from numpy.lib._index_tricks_impl import index_exp

4. **Save the file.**

5. **Re-test your setup to ensure `photutils` works correctly with `numpy` version 2.0 and above.**

---

By following these steps, you can resolve the issue and ensure compatibility
with the latest `numpy` versions.


Requirements
=============

This is the list of all modules that ``astromorphlib`` requires to run:

    * statmorph (0.6.1)**
    * splusdata
    * astro-datalab
    * astroplotlib
    * astropy
    * astroquery
    * pyvo
    * photutils (1.5.0 <)**
    * numpy
    * scipy
    * matplotlib
    * wget
    * colorama

** To install these specific versions of these packages, for example for
photutils, you can try:

.. code:: bash

    pip install photutils==1.5.0

Uninstallation
=============

In order to uninstall ``astromorphlib`` just type on the terminal:

.. code:: bash

   pip uninstall astromorphlib
