Skip to content

Commit

Permalink
Merge branch 'validation_tables' of github.com:tjgalvin/flint into va…
Browse files Browse the repository at this point in the history
…lidation_tables
  • Loading branch information
Tim Galvin committed Jan 13, 2024
2 parents 4cff6d2 + 46fc9dc commit 45180fd
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
Binary file not shown.
7 changes: 6 additions & 1 deletion flint/ms.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ def get_field_id_for_field(self, field_name: str) -> Union[int, None]:
"""Return the FIELD_ID for an elected field in a measurement set. See
`flink.ms.get_field_id_for_field` for full details.
"""

# TODO: I think this should be removed. The young pirate in me was
# going to go in a different direction
return get_field_id_for_field(ms=self, field_name=field_name)

@property
def ms(self) -> MS:
return self

@classmethod
def cast(cls, ms: Union[MS, Path]) -> MS:
"""Create a MS instance, if necessary, given eith a Path or MS.
Expand Down
13 changes: 13 additions & 0 deletions tests/test_ms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Small tests for items related to measurement sets
and the MS class
"""
from pathlib import Path

from flint.ms import MS


def test_ms_self_attribute():
ex = Path("example/jack_sparrow.ms")
ms = MS(path=ex)

assert ms.ms.path == ex
33 changes: 33 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Items related to test functions in the validation stage of flint
"""
from pathlib import Path

import numpy as np
import pkg_resources
import pytest

from flint.validation import RMSImageInfo, get_rms_image_info


@pytest.fixture
def rms_path(tmpdir):
rms_path = Path(
pkg_resources.resource_filename(
"flint", "data/tests/SB39400.RACS_0635-31.beam0-MFS-subimage_rms.fits"
)
)

return rms_path


def test_rms_image_info(rms_path):
rms_info = get_rms_image_info(rms_path=rms_path)

assert isinstance(rms_info, RMSImageInfo)
assert rms_info.path == rms_path
assert rms_info.no_valid_pixels == 150
assert rms_info.shape == (10, 15)
assert np.isclose(0.0001515522, rms_info.median)
assert np.isclose(0.00015135764, rms_info.minimum)
assert np.isclose(0.0001518184, rms_info.maximum)
assert np.isclose(1.1098655e-07, rms_info.std)

0 comments on commit 45180fd

Please sign in to comment.