Skip to content

Commit 1c38c71

Browse files
authored
Merge pull request #562 from astrorama/feature/skip_wcserrors
Feature/skip wcserrors
2 parents 0241c70 + d56e962 commit 1c38c71

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

SEFramework/src/lib/CoordinateSystem/WCS.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,12 @@ ImageCoordinate WCS::worldToImage(WorldCoordinate world_coordinate) const {
253253

254254
int status = 0;
255255
int ret_val = wcss2p(&wcs_copy, 1, 1, wc_array, &phi, &theta, ic_array, pc_array, &status);
256-
wcsRaiseOnTransformError(&wcs_copy, ret_val);
256+
if (ret_val != WCSERR_SUCCESS) {
257+
logger.warn() << "Bad worldToImage from RA/Dec: " << wc_array[0] << "/" << wc_array[1];
258+
pc_array[0] = -std::numeric_limits<double>::infinity();
259+
pc_array[1] = -std::numeric_limits<double>::infinity();
260+
}
257261
wcsfree(&wcs_copy);
258-
259262
return ImageCoordinate(pc_array[0] - 1, pc_array[1] - 1); // -1 as fits standard coordinates start at 1
260263
}
261264

SEFramework/tests/src/CoordinateSystem/WCS_test.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using namespace SourceXtractor;
2424

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

4444
//-----------------------------------------------------------------------------
4545

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

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

5959
//-----------------------------------------------------------------------------
6060

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

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

86-
//-----------------------------------------------------------------------------
87-
88-
BOOST_FIXTURE_TEST_CASE(WordOutOfBounds_test, WCSFixture) {
89-
BOOST_CHECK_THROW(m_wcs->worldToImage(WorldCoordinate(231.42560781394292, 30.238717631401094)), InvalidCoordinatesException);
90-
}
91-
86+
////-----------------------------------------------------------------------------
87+
//
88+
//BOOST_FIXTURE_TEST_CASE(WorldOutOfBounds_test, WCSFixture) {
89+
// auto img = m_wcs->worldToImage(WorldCoordinate(231.42560781394292, 30.238717631401094));
90+
// std::cout << img.m_x << " " << img.m_y << "\n";
91+
//
92+
// BOOST_CHECK(std::isinf(img.m_x));
93+
//}
94+
//
9295
//-----------------------------------------------------------------------------
9396

9497
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)