Skip to content

Commit

Permalink
Merge pull request #562 from astrorama/feature/skip_wcserrors
Browse files Browse the repository at this point in the history
Feature/skip wcserrors
  • Loading branch information
marcschefer authored Dec 15, 2023
2 parents 0241c70 + d56e962 commit 1c38c71
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
7 changes: 5 additions & 2 deletions SEFramework/src/lib/CoordinateSystem/WCS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,12 @@ ImageCoordinate WCS::worldToImage(WorldCoordinate world_coordinate) const {

int status = 0;
int ret_val = wcss2p(&wcs_copy, 1, 1, wc_array, &phi, &theta, ic_array, pc_array, &status);
wcsRaiseOnTransformError(&wcs_copy, ret_val);
if (ret_val != WCSERR_SUCCESS) {
logger.warn() << "Bad worldToImage from RA/Dec: " << wc_array[0] << "/" << wc_array[1];
pc_array[0] = -std::numeric_limits<double>::infinity();
pc_array[1] = -std::numeric_limits<double>::infinity();
}
wcsfree(&wcs_copy);

return ImageCoordinate(pc_array[0] - 1, pc_array[1] - 1); // -1 as fits standard coordinates start at 1
}

Expand Down
21 changes: 12 additions & 9 deletions SEFramework/tests/src/CoordinateSystem/WCS_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using namespace SourceXtractor;

// The wcs_header.fits file contains the headers extracted from
// EUC_MER_SCI-SWIN-NIR-J_41_20210512T213931.933876Z_00.00.fits
// That image is needed for the regression test WordOutOfBounds_test
// That image is needed for the regression test WorldOutOfBounds_test
// Other images with other projections do not trigger the error
struct WCSFixture {
std::string m_fits_path;
Expand All @@ -43,7 +43,7 @@ BOOST_AUTO_TEST_SUITE(WCS_test)

//-----------------------------------------------------------------------------

BOOST_FIXTURE_TEST_CASE(ImageToWord_test, WCSFixture) {
BOOST_FIXTURE_TEST_CASE(ImageToWorld_test, WCSFixture) {
std::vector<ImageCoordinate> img_coords{{0, 0}, {10, 8}, {55.5, 980.5}};
std::vector<WorldCoordinate> world_coords{{231.36456936, 30.74785202}, {231.36564296, 30.74838044}, {231.45474466, 30.72239679}};

Expand All @@ -58,7 +58,7 @@ BOOST_FIXTURE_TEST_CASE(ImageToWord_test, WCSFixture) {

//-----------------------------------------------------------------------------

BOOST_FIXTURE_TEST_CASE(WordToImage_test, WCSFixture) {
BOOST_FIXTURE_TEST_CASE(WorldToImage_test, WCSFixture) {
std::vector<ImageCoordinate> img_coords{{55.36653065, 980.05611646}, {616.01593595, 1818.83360301}, {10.54811223, 945.44992869}};
std::vector<WorldCoordinate> world_coords{{231.4547, 30.7224}, {231.55, 30.74}, {231.45, 30.72}};

Expand All @@ -83,12 +83,15 @@ BOOST_FIXTURE_TEST_CASE(ImageOutOfBounds_test, WCSFixture) {
BOOST_CHECK_CLOSE(world.m_delta, 30.8452462, 1e-4);
}

//-----------------------------------------------------------------------------

BOOST_FIXTURE_TEST_CASE(WordOutOfBounds_test, WCSFixture) {
BOOST_CHECK_THROW(m_wcs->worldToImage(WorldCoordinate(231.42560781394292, 30.238717631401094)), InvalidCoordinatesException);
}

////-----------------------------------------------------------------------------
//
//BOOST_FIXTURE_TEST_CASE(WorldOutOfBounds_test, WCSFixture) {
// auto img = m_wcs->worldToImage(WorldCoordinate(231.42560781394292, 30.238717631401094));
// std::cout << img.m_x << " " << img.m_y << "\n";
//
// BOOST_CHECK(std::isinf(img.m_x));
//}
//
//-----------------------------------------------------------------------------

BOOST_AUTO_TEST_SUITE_END()
Expand Down

0 comments on commit 1c38c71

Please sign in to comment.