Skip to content

Commit

Permalink
Added checking for input errors: case of user requesting oversampling…
Browse files Browse the repository at this point in the history
…, but not regions for oversampling.
  • Loading branch information
perwin committed Jun 20, 2024
1 parent 3d1cc7d commit 72db752
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions core/getimages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ int GetOversampledPsfInfo( const std::shared_ptr<OptionsBase> options, int xOffs
long nPixels_psf_oversampled;
int psfOversamplingScale;

if (options->nOversampleRegions < 1) {
fprintf(stderr, "\n*** ERROR: when specifying use of an oversampled PSF, you must ");
fprintf(stderr, "supply at least one instance of \"--overpsf_region\"\n\n");
return -1;
}

int nOversampledPsfImages = (int)options->psfOversampledFileNames.size();
int nOversampledScales = (int)options->psfOversamplingScales.size();
if (nOversampledPsfImages != nOversampledScales) {
Expand Down
2 changes: 1 addition & 1 deletion core/makeimage_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* NAXIS2 = naxes[1] = nRows = sizeY.
*/

// Copyright 2010--2022 by Peter Erwin.
// Copyright 2010--2024 by Peter Erwin.
//
// This file is part of Imfit.
//
Expand Down
14 changes: 14 additions & 0 deletions do_makeimage_tests
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ echo "Running tests for makeimage..."
# tests of PSF oversampling with PointSource model
./makeimage tests/makeimage_reference/config_makeimage_pointsource-oversample.dat -o temptest/oversampled_pointsource.fits --psf tests/psf_standard.fits --overpsf tests/psf_oversamp.fits --overpsf_scale 3 --overpsf_region 80:120,80:120 > temptest/test_dump_null

# Tests that we catch bad input
# testing that bad config files are caught (redirect stderr to temptest/test_dump* files):
./makeimage tests/makeimage_reference/config_makeimage_sersictest512_bad1.dat &> temptest/test_dump6
./makeimage tests/makeimage_reference/config_makeimage_sersictest512_bad2.dat &> temptest/test_dump7
Expand All @@ -90,8 +91,11 @@ echo "Running tests for makeimage..."
./makeimage tests/makeimage_reference/config_makeimage_sersic+exp512.dat --psf=tests/testimage_3x3_allzeros.fits &> temptest/test_dump13c
./makeimage tests/makeimage_reference/config_makeimage_sersic+exp512.dat --psf=_nofilewiththisname_wehope.fits &> temptest/test_dump14

# more bad config file tests
./makeimage tests/imfit_reference/config_imfit_badparamline.dat &> temptest/test_dump15

# specifying oversampling PSF image but failing to specify one or more oversampling regions
./makeimage tests/makeimage_reference/config_makeimage_gauss-oversample.dat -o temptest/oversampled.fits --psf tests/psf_standard.fits --overpsf tests/psf_oversamp.fits --overpsf_scale 3 &> temptest/test_dump16



Expand Down Expand Up @@ -379,6 +383,16 @@ else
STATUS+=1
fi

echo -n "*** Diff comparison with archives: oversampled PSF supplied, but no oversampling regions... "
if (diff --brief temptest/test_dump16 tests/makeimage_reference/makeimage_textout16)
then
echo " OK"
else
echo -e " ${RED}Failed:${NC}Diff output:"
diff temptest/test_dump16 tests/makeimage_reference/makeimage_textout16
STATUS+=1
fi


echo ""
if [ $STATUS -eq 1 ]
Expand Down

0 comments on commit 72db752

Please sign in to comment.