From 5881904542144b6f65fbbb3bc6b048333b2fa251 Mon Sep 17 00:00:00 2001 From: VChristiaens Date: Wed, 28 Jun 2023 12:59:33 +0200 Subject: [PATCH 1/6] version update --- vip_hci/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vip_hci/__init__.py b/vip_hci/__init__.py index ce02eff8..ed0d2a08 100644 --- a/vip_hci/__init__.py +++ b/vip_hci/__init__.py @@ -1,4 +1,4 @@ -__version__ = "1.4.2" +__version__ = "1.4.3" from . import preproc From 67ccb898c2f698297a03e3596489c5902520274a Mon Sep 17 00:00:00 2001 From: VChristiaens Date: Wed, 28 Jun 2023 14:22:12 +0200 Subject: [PATCH 2/6] Made peak_coordinates() function robust to NaN values --- vip_hci/metrics/detection.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/vip_hci/metrics/detection.py b/vip_hci/metrics/detection.py index 1e56e2c8..bae41141 100644 --- a/vip_hci/metrics/detection.py +++ b/vip_hci/metrics/detection.py @@ -366,7 +366,8 @@ def print_abort(): xx_final = np.array(xx_final) yy_out = np.array(yy_out) xx_out = np.array(xx_out) - table = pn.DataFrame({'y': yy_final.tolist(), 'x': xx_final.tolist(), 'px_snr': snr_final}) + table = pn.DataFrame( + {'y': yy_final.tolist(), 'x': xx_final.tolist(), 'px_snr': snr_final}) if plot: coords = tuple(zip(xx_out.tolist() + xx_final.tolist(), @@ -440,12 +441,12 @@ def peak_coordinates(obj_tmp, fwhm, approx_peak=None, search_box=None, med_filt_tmp = frame_filter_lowpass(obj_tmp, 'median', median_size=int(fwhm)) if approx_peak is None: - ind_max = np.unravel_index(med_filt_tmp.argmax(), + ind_max = np.unravel_index(med_filt_tmp.nanargmax(), med_filt_tmp.shape) else: sbox = med_filt_tmp[approx_peak[0]-sbox_y:approx_peak[0]+sbox_y+1, approx_peak[1]-sbox_x:approx_peak[1]+sbox_x+1] - ind_max_sbox = np.unravel_index(sbox.argmax(), sbox.shape) + ind_max_sbox = np.unravel_index(sbox.nanargmax(), sbox.shape) ind_max = (approx_peak[0]-sbox_y+ind_max_sbox[0], approx_peak[1]-sbox_x+ind_max_sbox[1]) @@ -462,23 +463,23 @@ def peak_coordinates(obj_tmp, fwhm, approx_peak=None, search_box=None, med_filt_tmp[zz] = frame_filter_lowpass(obj_tmp[zz], 'median', median_size=int(fwhm[zz])) if approx_peak is None: - ind_ch_max[zz] = np.unravel_index(med_filt_tmp[zz].argmax(), + ind_ch_max[zz] = np.unravel_index(med_filt_tmp[zz].nanargmax(), med_filt_tmp[zz].shape) else: sbox[zz] = med_filt_tmp[zz, approx_peak[0]-sbox_y: approx_peak[0]+sbox_y+1, approx_peak[1]-sbox_x: approx_peak[1]+sbox_x+1] - ind_max_sbox = np.unravel_index(sbox[zz].argmax(), + ind_max_sbox = np.unravel_index(sbox[zz].nanargmax(), sbox[zz].shape) ind_ch_max[zz] = (approx_peak[0]-sbox_y+ind_max_sbox[0], approx_peak[1]-sbox_x+ind_max_sbox[1]) if approx_peak is None: - ind_max = np.unravel_index(med_filt_tmp.argmax(), + ind_max = np.unravel_index(med_filt_tmp.nanargmax(), med_filt_tmp.shape) else: - ind_max_tmp = np.unravel_index(sbox.argmax(), + ind_max_tmp = np.unravel_index(sbox.nanargmax(), sbox.shape) ind_max = (ind_max_tmp[0]+approx_peak[0]-sbox_y, ind_max_tmp[1]+approx_peak[1]-sbox_x) @@ -561,4 +562,4 @@ def mask_sources(mask, ap_rad): rad_arr = dist_matrix(ny, cx=s_coords[1][s], cy=s_coords[0][s]) mask_out[np.where(rad_arr < ap_rad)] = 0 - return mask_out \ No newline at end of file + return mask_out From a99ed328370926ab4076a4b77ce14b4382cda8d9 Mon Sep 17 00:00:00 2001 From: VChristiaens Date: Thu, 29 Jun 2023 04:10:02 +0200 Subject: [PATCH 3/6] Removed welcome message mention in readme --- README.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 05c6aa99..8ed30b62 100644 --- a/README.rst +++ b/README.rst @@ -212,8 +212,7 @@ that you are able to import ``VIP``: import vip_hci as vip -If everything went fine with the installation, you will see a welcome message. -Now you can start finding exoplanets! +If everything went fine with the installation, you should not get any error message upon importation, and you can start finding exoplanets! Image conventions From d432b90d0fbaa57983d4201704257bb690859803 Mon Sep 17 00:00:00 2001 From: VChristiaens Date: Fri, 28 Jul 2023 23:11:43 +0200 Subject: [PATCH 4/6] removed deprecated import and code lines --- vip_hci/config/utils_conf.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/vip_hci/config/utils_conf.py b/vip_hci/config/utils_conf.py index 5675579e..f0ec5313 100644 --- a/vip_hci/config/utils_conf.py +++ b/vip_hci/config/utils_conf.py @@ -17,7 +17,7 @@ import numpy as np import itertools as itt -from inspect import getargspec, signature, Parameter +from inspect import signature, Parameter from functools import wraps import multiprocessing from vip_hci import __version__ @@ -246,11 +246,6 @@ def wrapper(self, *args, **kwargs): # get the kwargs the fkt sees. Note that this is a combination of # the *default* kwargs and the kwargs *passed* by the user - """Note : this is deprecated for a while now, and signature should be - the only way to do this task. See below.""" - # a = getargspec(fkt) - # all_kwargs = dict(zip(a.args[-len(a.defaults):], a.defaults)) - # all_kwargs.update(kwargs) sig = signature(fkt) params = sig.parameters all_kwargs = { From 6480a442b0ffbfcd23aa37e573f8797c963b9184 Mon Sep 17 00:00:00 2001 From: VChristiaens Date: Fri, 28 Jul 2023 23:12:50 +0200 Subject: [PATCH 5/6] Updated requirements and tests to drop support to 3.7 but include support to 3.11 --- .github/workflows/ci.yml | 2 +- README.rst | 92 +++++++++++++++++----------------------- requirements.txt | 5 +-- 3 files changed, 42 insertions(+), 57 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7ff96a3..a12dcb57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10", "3.11"] group: [1, 2, 3] steps: diff --git a/README.rst b/README.rst index 8ed30b62..9dff0766 100644 --- a/README.rst +++ b/README.rst @@ -50,16 +50,16 @@ VIP - Vortex Image Processing package Introduction ------------ -``VIP`` is a python package for high-contrast imaging of exoplanets and circumstellar disks. -``VIP`` is compatible with Python 3.7, 3.8 and 3.9 (Python 2 compatibility dropped with ``VIP`` 0.9.9). +VIP is a python package for high-contrast imaging of exoplanets and circumstellar disks. +VIP is compatible with Python 3.8, 3.9, 3.10 and 3.11 (Python 2 compatibility dropped with VIP 0.9.9, and Python 3.7 compatibility dropped with VIP 1.4.3). -The goal of ``VIP`` is to integrate open-source, efficient, easy-to-use and +The goal of VIP is to integrate open-source, efficient, easy-to-use and well-documented implementations of high-contrast image processing algorithms to -the interested scientific community. The main repository of ``VIP`` resides on +the interested scientific community. The main repository of VIP resides on `GitHub `_, the standard for scientific open source code distribution, using Git as a version control system. -Most of ``VIP``'s functionalities are mature but +Most of VIP's functionalities are mature but it does not mean it is free from bugs. The code is continuously evolving and therefore feedback/contributions are greatly appreciated. Please refer to `these instructions `_ if you want to report a bug, ask a question, suggest a new functionality or contribute to the code (the latter is particularly welcome)! @@ -69,12 +69,12 @@ a bug, ask a question, suggest a new functionality or contribute to the code (th Documentation ------------- -The documentation for ``VIP`` can be found here: http://vip.readthedocs.io. +The documentation for VIP can be found here: http://vip.readthedocs.io. Jupyter notebook tutorial ------------------------- -Tutorials, in the form of Jupyter notebooks, showcasing ``VIP``'s usage and +Tutorials, in the form of Jupyter notebooks, showcasing VIP's usage and other resources such as test datasets are available in the ``VIP-extras`` `repository `_. **In order to execute the notebook tutorials, you will have to download or clone the VIP-extras repository, and open each tutorial locally with jupyter notebook.** @@ -97,53 +97,52 @@ TL;DR setup guide Installation and dependencies ----------------------------- The benefits of using a Python package manager (distribution), such as -(ana)conda or Canopy, are many. Mainly, it brings easy and robust package +(ana)conda, are many. Mainly, it brings easy and robust package management and avoids messing up with your system's default python. An alternative is to use package managers like apt-get for Ubuntu or Homebrew/MacPorts/Fink for macOS. We recommend using `Miniconda `_. -``VIP`` depends on existing packages from the Python ecosystem, such as +VIP depends on existing packages from the Python ecosystem, such as ``numpy``, ``scipy``, ``matplotlib``, ``pandas``, ``astropy``, ``scikit-learn``, ``scikit-image``, ``photutils`` and others. There are different ways of -installing ``VIP`` suitable for different scenarios. +installing VIP suitable for different scenarios. - -Using pip -^^^^^^^^^ -The easiest way to install ``VIP`` is through the Python Package Index, aka -`PyPI `_, with the ``pip`` package manager. Simply run: +Before installing the package, it is **highly recommended to create a dedicated +conda environment** to not mess up with the package versions in your base +environment. This can be done easily with (replace ``vipenv`` by the name you want +for your environment): .. code-block:: bash - $ pip install vip_hci - -With ``pip`` you can easily uninstall, upgrade or install a specific version of -``VIP``. For upgrading the package run: + $ conda create -n vipenv python=3.10 ipython -.. code-block:: bash +.. note:: + Installing ipython while creating the environment, as in the example above, will + avoid a commonly reported issue which stems from trying to import VIP from + within a base python2.7 ipython console. - $ pip install --upgrade vip_hci -Alternatively, you can use ``pip install`` and point to the GitHub repo: +For users (not planning to contribute): +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Once within your new environment, the easiest way to install VIP is +through the Python Package Index, aka `PyPI `_, with +the ``pip`` package manager. Simply run: .. code-block:: bash - $ pip install git+https://github.com/vortex-exoplanet/VIP.git + $ pip install vip_hci -Using the setup.py file -^^^^^^^^^^^^^^^^^^^^^^^ -You can download ``VIP`` from its GitHub repository as a zip file. A ``setup.py`` -file (setuptools) is included in the root folder of ``VIP``. Enter the package's -root folder and run: +With ``pip`` you can easily uninstall, upgrade or install a specific version of +VIP. For upgrading the package, run: .. code-block:: bash - $ python setup.py install + $ pip install --upgrade vip_hci -Using Git -^^^^^^^^^ +For potential contributors: +^^^^^^^^^^^^^^^^^^^^^^^^^^^ If you plan to contribute or experiment with the code you need to make a fork of the repository (click on the fork button in the top right corner) and clone it: @@ -159,26 +158,13 @@ functionalities by cloning the repository (but will not be able to contribute): $ git clone https://github.com/vortex-exoplanet/VIP.git -Before installing the package, it is highly recommended to create a dedicated -conda environment to not mess up with the package versions in your base -environment. This can be done easily with (replace vipenv by the name you want -for your environment): - -.. code-block:: bash - - $ conda create -n vipenv python=3.9 ipython - -Note: installing ipython while creating the environment with the above line will -avoid a commonly reported issue which stems from trying to import VIP from -within a base python2.7 ipython console. -To install VIP, simply cd into the VIP directory and run the setup file -in 'develop' mode: +To install VIP, then simply cd into your local VIP directory and run the installation in editable mode: .. code-block:: bash $ cd VIP - $ python setup.py develop + $ pip install -e . If cloned from your fork, make sure to link your VIP directory to the upstream source, to be able to easily update your local copy when a new version comes @@ -194,19 +180,19 @@ also install the optional dependencies listed below. Optional dependencies ^^^^^^^^^^^^^^^^^^^^^ -The following dependencies are not automatically installed upon installation of ``VIP`` but may significantly improve your experience: +The following dependencies are not automatically installed upon installation of VIP but may significantly improve your experience: -- ``VIP`` contains a class ``vip_hci.vip_ds9`` that enables, through ``pyds9``, the interaction with a DS9 window (displaying numpy arrays, controlling the display options, etc). To enable this feature, ``pyds9`` must be installed from the latest development version: ``pip install git+git://github.com/ericmandel/pyds9.git#egg=pyds9`` -- ``VIP`` image operations (e.g. shifts, rotations, scaling) can be performed using ``OpenCV`` instead of the default FFT-based methods. While flux are less well preserved, ``OpenCV`` offers a significant speed improvement (up to a factor 50x), in particular for image rotations, which can be useful to get quick results. Installation: ``pip install opencv-python``. +- VIP contains a class ``vip_hci.vip_ds9`` that enables, through ``pyds9``, the interaction with a DS9 window (displaying numpy arrays, controlling the display options, etc). To enable this feature, ``pyds9`` must be installed from the latest development version: ``pip install git+git://github.com/ericmandel/pyds9.git#egg=pyds9`` +- VIP image operations (e.g. shifts, rotations, scaling) can be performed using ``OpenCV`` instead of the default FFT-based methods. While flux are less well preserved, ``OpenCV`` offers a significant speed improvement (up to a factor 50x), in particular for image rotations, which can be useful to get quick results. Installation: ``pip install opencv-python``. - Also, you can install the Intel Math Kernel Library (``mkl``) optimizations (provided that you have a recent version of ``conda``) or ``openblas`` libraries. Either of them can be installed with ``conda install``. -- ``VIP`` offers the possibility of computing SVDs on GPU by using ``CuPy`` (starting from version 0.8.0) or ``PyTorch`` (from version 0.9.2). These remain as optional requirements, to be installed by the user, as well as a proper CUDA environment (and a decent GPU card). +- VIP offers the possibility of computing SVDs on GPU by using ``CuPy`` (starting from version 0.8.0) or ``PyTorch`` (from version 0.9.2). These remain as optional requirements, to be installed by the user, as well as a proper CUDA environment (and a decent GPU card). - Finally, bad pixel correction routines can be optimised with ``Numba``, which converts some Python code, particularly ``NumPy``, into fast machine code. A factor up to ~50x times speed improvement can be obtained on large images compared to NumPy. Numba can be installed with ``conda install numba``. Loading VIP ^^^^^^^^^^^ Finally, start Python (or IPython or a Jupyter notebook if you prefer) and check -that you are able to import ``VIP``: +that you are able to import VIP: .. code-block:: python @@ -241,7 +227,7 @@ If you wish to be kept informed about major VIP updates and on-going/future deve Attribution ----------- -``VIP`` started as the effort of `Carlos Alberto Gomez Gonzalez `_, +VIP started as the effort of `Carlos Alberto Gomez Gonzalez `_, a former PhD student of `PSILab `_ (ULiege, Belgium), who has led the development of VIP from 2015 to 2020. Maintenance and current development is now led by `Valentin Christiaens `_. @@ -249,5 +235,5 @@ VIP benefitted from contributions made by collaborators from several teams, incl More details about the respective contributions are available `here `_. Please cite `Gomez Gonzalez et al. (2017) `_ and `Christiaens et al. (2023) `_ whenever -you publish data reduced with ``VIP`` (Astrophysics Source Code Library reference `ascl:1603.003`). +you publish data reduced with VIP (Astrophysics Source Code Library reference `ascl:1603.003`). In addition, please cite the relevant publication(s) for the algorithms you use within VIP (usually mentioned in the documentation, e.g. `Marois et al. 2006 `_ for median-ADI). diff --git a/requirements.txt b/requirements.txt index 0102b759..2095dab4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,12 +8,11 @@ emcee==2.2.1 nestle corner pandas -matplotlib<=3.4.3 +matplotlib psutil pyprind munch nbsphinx hciplot>=0.2.4 typing -dataclass_builder -urllib3 < 2.0 \ No newline at end of file +dataclass_builder \ No newline at end of file From 5a7c8ac42a92aca01728fe11eb2e7b931f1e01c2 Mon Sep 17 00:00:00 2001 From: VChristiaens Date: Mon, 31 Jul 2023 12:27:17 +0200 Subject: [PATCH 6/6] numpy nanargmax call fixed --- vip_hci/metrics/detection.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vip_hci/metrics/detection.py b/vip_hci/metrics/detection.py index bae41141..9f694597 100644 --- a/vip_hci/metrics/detection.py +++ b/vip_hci/metrics/detection.py @@ -441,12 +441,12 @@ def peak_coordinates(obj_tmp, fwhm, approx_peak=None, search_box=None, med_filt_tmp = frame_filter_lowpass(obj_tmp, 'median', median_size=int(fwhm)) if approx_peak is None: - ind_max = np.unravel_index(med_filt_tmp.nanargmax(), + ind_max = np.unravel_index(np.nanargmax(med_filt_tmp), med_filt_tmp.shape) else: sbox = med_filt_tmp[approx_peak[0]-sbox_y:approx_peak[0]+sbox_y+1, approx_peak[1]-sbox_x:approx_peak[1]+sbox_x+1] - ind_max_sbox = np.unravel_index(sbox.nanargmax(), sbox.shape) + ind_max_sbox = np.unravel_index(np.nanargmax(sbox), sbox.shape) ind_max = (approx_peak[0]-sbox_y+ind_max_sbox[0], approx_peak[1]-sbox_x+ind_max_sbox[1]) @@ -463,23 +463,23 @@ def peak_coordinates(obj_tmp, fwhm, approx_peak=None, search_box=None, med_filt_tmp[zz] = frame_filter_lowpass(obj_tmp[zz], 'median', median_size=int(fwhm[zz])) if approx_peak is None: - ind_ch_max[zz] = np.unravel_index(med_filt_tmp[zz].nanargmax(), + ind_ch_max[zz] = np.unravel_index(np.nanargmax(med_filt_tmp[zz]), med_filt_tmp[zz].shape) else: sbox[zz] = med_filt_tmp[zz, approx_peak[0]-sbox_y: approx_peak[0]+sbox_y+1, approx_peak[1]-sbox_x: approx_peak[1]+sbox_x+1] - ind_max_sbox = np.unravel_index(sbox[zz].nanargmax(), + ind_max_sbox = np.unravel_index(np.nanargmax(sbox[zz]), sbox[zz].shape) ind_ch_max[zz] = (approx_peak[0]-sbox_y+ind_max_sbox[0], approx_peak[1]-sbox_x+ind_max_sbox[1]) if approx_peak is None: - ind_max = np.unravel_index(med_filt_tmp.nanargmax(), + ind_max = np.unravel_index(np.nanargmax(med_filt_tmp), med_filt_tmp.shape) else: - ind_max_tmp = np.unravel_index(sbox.nanargmax(), + ind_max_tmp = np.unravel_index(np.nanargmax(sbox), sbox.shape) ind_max = (ind_max_tmp[0]+approx_peak[0]-sbox_y, ind_max_tmp[1]+approx_peak[1]-sbox_x)