Skip to content

Commit

Permalink
some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tgalvin committed Jan 17, 2024
1 parent 25718c6 commit 4b4360a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions flint/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ class SourceCounts(NamedTuple):
"""Euclidean normalised source counts"""
euclid_counts_err: np.ndarray
"""Rough estimate of error on the euclidean normalised source counts"""
area: float
"""The area in square degrees that the sources cover, i.e. image footprint sky-area"""
area_fraction: Optional[np.ndarray] = None
"""The fraction of the image that was above a sigma level per flux bin. This may be used as a rough term to scale the Euclidean Normalised source counts. This is not intended to be a robust way of correcting the source counts - just quick"""

Expand Down Expand Up @@ -592,6 +594,7 @@ def get_source_counts(
counts_per_bin_err=counts_err,
euclid_counts=scount,
euclid_counts_err=scount_err,
area=area,
area_fraction=area_fraction,
)

Expand Down
23 changes: 23 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
import pkg_resources
import pytest

import matplotlib.pyplot as plt

from flint.validation import (
RMSImageInfo,
SourceCounts,
calculate_area_correction_per_flux,
get_source_counts,
get_parser,
get_rms_image_info,
)
Expand All @@ -30,6 +34,25 @@ def rms_path(tmpdir):
return rms_path


def test_source_counts():
fluxes = np.linspace(0.00003, 0.01, 10000)

source_counts = get_source_counts(fluxes=fluxes, area=10)

assert isinstance(source_counts, SourceCounts)
assert source_counts.area == 10.0


def test_source_counts_with_rms(rms_path):
fluxes = np.linspace(0.00003, 0.01, 10000)

source_counts = get_source_counts(fluxes=fluxes, area=10, rms_image_path=rms_path)

assert isinstance(source_counts, SourceCounts)
assert source_counts.area == 10.0
assert isinstance(source_counts.area_fraction, np.ndarray)


def test_calculate_area_correction(rms_path):
"""This is not an entirely robust check as the rms image is only
10 x 15 pixels. More testing for errors in the calling."""
Expand Down

0 comments on commit 4b4360a

Please sign in to comment.