Skip to content
Merged
57 changes: 23 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow will install Python depe:ndencies, run tests and lint with a variety of Python versions
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: ci
Expand All @@ -15,8 +15,20 @@ env:
COVERAGE_CORE: sysmon

jobs:
no_object_checks:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Run pre-commit
run: |
pip install pre-commit
pre-commit run --files src/**/*.py

no_object_checks:
needs: pre-commit
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -29,68 +41,45 @@ jobs:
group: [1, 2, 3]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --editable . --group dev
# Uncomment below when ready to deal with a lot of PEP8 formatting changes
- name: Verify files with pre-commit
run: |
# Setup pre-commit hooks
pre-commit clean
pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks
pre-commit install --hook-type pre-merge-commit
pre-commit install --hook-type pre-push
pre-commit install --hook-type post-rewrite
pre-commit install-hooks
pre-commit install
# Run pre-commit hooks
pre-commit run --files src/**/*.py
- name: Test with pytest
run: |
coverage run --source src -m pytest tests/pre_3_10 --splits 3 --group ${{ matrix.group }}
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v6

objects_check:

needs: pre-commit
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --editable . --group dev
- name: Verify files with pre-commit
run: |
# Setup pre-commit hooks
pre-commit clean
pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks
pre-commit install --hook-type pre-merge-commit
pre-commit install --hook-type pre-push
pre-commit install --hook-type post-rewrite
pre-commit install-hooks
pre-commit install
# Run pre-commit hooks
pre-commit run --files src/vip_hci/objects/*.py
- name: Test with pytest
run: |
coverage run --source=src/vip_hci/objects/ -m pytest tests/post_3_10
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v6
4 changes: 2 additions & 2 deletions .github/workflows/draft-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ jobs:
name: Paper Draft
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v6
- name: Build draft PDF
uses: openjournals/openjournals-draft-action@master
with:
journal: joss
# This should be the path to the paper within your repo.
paper-path: paper.md
- name: Upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: paper
# This is the output path where Pandoc will write the compiled
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand Down
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

15 changes: 0 additions & 15 deletions readthedocs_full_compilation_timeout_error.yml

This file was deleted.

7 changes: 3 additions & 4 deletions src/vip_hci/preproc/derotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def frame_rotate(array, angle, imlib='vip-fft', interpolation='lanczos4',
array_prep = array.copy()

# residual (non-interp) nans should be set to 0 to avoid bug in rotation
array_prep[np.where(np.isnan(array_prep))] = 0
array_prep[np.isnan(array_prep)] = 0

y, x = array_prep.shape

Expand Down Expand Up @@ -604,9 +604,8 @@ def rotate_fft(array, angle):
ori_y, ori_x = array_in.shape

cy, cx = frame_center(array)
arr_xy = np.mgrid[0:ori_y, 0:ori_x]
arr_y = arr_xy[0]-cy
arr_x = arr_xy[1]-cx
arr_y = np.broadcast_to((np.arange(ori_y) - cy)[:, np.newaxis], (ori_y, ori_x))
arr_x = np.broadcast_to((np.arange(ori_x) - cx)[np.newaxis, :], (ori_y, ori_x))

# TODO: make FFT padding work for other option than '0'.
s_x = _fft_shear(array_in, arr_x, a, ax=1, pad=0)
Expand Down
48 changes: 32 additions & 16 deletions src/vip_hci/psfsub/pca_fullfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1428,22 +1428,38 @@ def _adimsdi_doublepca(
for frame in range(n):
ind = _find_indices_adi(angle_list, frame, pa_thr,
truncate=truncate, max_frames=max_fr)

res_result = _project_subtract(
res_cube_channels[:n],
res_cube_channels[n:],
ncomp_adi,
scaling[1],
mask_center_px,
svd_mode,
verbose,
False,
ind,
frame,
cube_sig=cube_sig,
left_eigv=left_eigv,
min_frames_pca=min_frames_pca,
)
if 'A' in ref_strategy or cube_ref is None:
res_result = _project_subtract(
res_cube_channels[:n],
None,
ncomp_adi,
scaling[1],
mask_center_px,
svd_mode,
verbose,
False,
ind,
frame,
cube_sig=cube_sig,
left_eigv=left_eigv,
min_frames_pca=min_frames_pca,
)
else:
res_result = _project_subtract(
res_cube_channels[:n],
res_cube_channels[n:], # ref cube
ncomp_adi,
scaling[1],
mask_center_px,
svd_mode,
verbose,
False,
ind,
frame,
cube_sig=cube_sig,
left_eigv=left_eigv,
min_frames_pca=min_frames_pca,
)
res_ifs_adi[frame] = res_result[-1].reshape((y_in, x_in))

if verbose:
Expand Down
1 change: 1 addition & 0 deletions src/vip_hci/stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- distance (correlation) between a cube and a reference frame.

"""
from .bkg_proba import *
from .clip_sigma import *
from .distances import *
from .im_stats import *
Expand Down
28 changes: 21 additions & 7 deletions src/vip_hci/stats/bkg_proba.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
import numpy as np


def bkg_star_proba(n_dens, sep, n_bkg=1, verbose=True, full_output=False):
def bkg_star_proba(n_dens, sep, n_bkg=1, unit="deg", verbose=True,
full_output=False):
""" Given an input density of background star brighter than a certain
magnitude (obtained e.g. from the Besancon model or TRILEGAL), and the
magnitude (obtained e.g. from the Besançon model or TRILEGAL), and the
separation of n_bkg point source, estimate the probability of having n_bkg
or more background stars in a disk with radius equal to the largest
separation.
Expand All @@ -23,12 +24,15 @@ def bkg_star_proba(n_dens, sep, n_bkg=1, verbose=True, full_output=False):
----------
n_dens : float
Number density of background stars in the direction of the object of
interest, in arcsec^-2.
interest. Units are set by the ``unit`` parameter.
sep : float or numpy 1d array
Separation of the point sources with respect to central star, in arcsec.
n_bkg : int, opt
Number of point sources in the field, and for which the separation is
provided.
unit : str, opt
Unit of ``n_dens``. Either ``"deg"`` for deg^-2 (default, e.g. from
the Besançon model) or ``"arcsec"`` for arcsec^-2.
verbose: bool, opt
Whether to print the probabilities for 0 to n_bkg point sources.
full_output: bool, opt
Expand All @@ -46,6 +50,16 @@ def bkg_star_proba(n_dens, sep, n_bkg=1, verbose=True, full_output=False):
if n_bkg < 1 or not isinstance(n_bkg, int):
raise TypeError("n_bkg should be a strictly positive integer.")

if unit == "deg":
if verbose:
print("Input n_dens unit: deg^-2")
n_dens = n_dens / 3600**2
elif unit == "arcsec":
if verbose:
print("Input n_dens unit: arcsec^-2")
else:
raise ValueError("unit must be 'deg' or 'arcsec'.")

if not isinstance(sep, float):
if isinstance(sep, np.ndarray):
if sep.ndim != 1 or sep.shape[0] != n_bkg:
Expand All @@ -61,14 +75,14 @@ def bkg_star_proba(n_dens, sep, n_bkg=1, verbose=True, full_output=False):
probas[i] = np.exp(-n_dens*B)*(n_dens*B)**i/float(factorial(i))
if verbose:
msg = "Proba of having {:.0f} bkg star in a disk of "
msg += "{:.1}'' radius: {:.1f}%"
print(msg.format(i, sep, probas[i]))
msg += "{:.2g}'' radius: {:.4g}%"
print(msg.format(i, sep, probas[i]*100))

proba = 1-np.sum(probas)
if verbose:
msg = "Proba of having {:.0f} bkg star or more in a disk of "
msg += "{:.1}'' radius: {:.1f}%"
print(msg.format(n_bkg, sep, proba))
msg += "{:.2g}'' radius: {:.4g}%"
print(msg.format(n_bkg, sep, proba*100))

if full_output:
return proba, probas
Expand Down