diff --git a/CHANGES.rst b/CHANGES.rst index e0ef1393..daa8b79f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,13 +5,16 @@ New Features ^^^^^^^^^^^^ + Development of new data classes for handling source list, photometry, and catalog data which include data format validation. [#125] + Aperture photometry streamlined into ``single_image_photometry`` ``multi_image_photometry`` functions that use the new data classes. [#141] ++ Photometry related notebooks updated to use new data classes. [#151] + ``multi_image_photometry`` now is a wrapper for single_image_photometry instead of a completely separate function. ++ Logging has been implemented for photmetry, so all the output can now be logged to a file. [#150] Other Changes and Additions ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + Major reorganizaiton of code including moving functions to new modules. [#130, #133] + Now requires python 3.10 or later. [#147] + Use pydantic for aperture settings. [#154] ++ Stomped bug in handling of ``NaN``s in ``single_image_photometry``. [#157] Bug Fixes ^^^^^^^^^ diff --git a/stellarphot/photometry/photometry.py b/stellarphot/photometry/photometry.py index 46c2e338..b41df53e 100644 --- a/stellarphot/photometry/photometry.py +++ b/stellarphot/photometry/photometry.py @@ -249,7 +249,8 @@ def single_image_photometry(ccd_image, sourcelist, camera, observatory_location, "SKIPPING THIS IMAGE!") return None, None - # Set high pixels to NaN + # Set high pixels to NaN (make sure ccd_image.data is a float array first) + ccd_image.data = ccd_image.data.astype(float) ccd_image.data[ccd_image.data > max_adu] = np.nan # Extract necessary values from sourcelist structure diff --git a/stellarphot/photometry/tests/test_photometry.py b/stellarphot/photometry/tests/test_photometry.py index 94b0c0ca..8aa20896 100644 --- a/stellarphot/photometry/tests/test_photometry.py +++ b/stellarphot/photometry/tests/test_photometry.py @@ -221,8 +221,11 @@ def test_find_too_close(): coords2use='pixel' -def test_aperture_photometry_no_outlier_rejection(): +# The True case below is a regression test for #157 +@pytest.mark.parametrize('int_data', [True, False]) +def test_aperture_photometry_no_outlier_rejection(int_data): fake_CCDimage = FakeCCDImage() + sources = fake_CCDimage.sources aperture = sources['aperture'][0] inner_annulus = 2 * aperture @@ -234,6 +237,18 @@ def test_aperture_photometry_no_outlier_rejection(): found_sources = source_detection(fake_CCDimage, fwhm=sources['x_stddev'].mean(), threshold=10) + + # The scale_factor is used to rescale data to integers if needed. It + # needs to be set later on when the net counts are "unscaled" in the + # asserts that constitute the actual test. + scale_factor = 1.0 + if int_data: + scale_factor = 0.75 * max_adu / fake_CCDimage.data.max() + # For the moment, ensure the integer data is NOT larger than max_adu + # because until #161 is fixed then having NaN in the data will not succeed. + data = scale_factor * fake_CCDimage.data + fake_CCDimage.data = data.astype(int) + phot, missing_sources = single_image_photometry(fake_CCDimage, found_sources, fake_camera, @@ -265,7 +280,9 @@ def test_aperture_photometry_no_outlier_rejection(): # Here we just check whether any difference is consistent with # less than the expected one sigma deviation. - assert (np.abs(expected_flux - out['aperture_net_cnts'].value) < + + # We need to remove any scaling that has been done of the data values. + assert (np.abs(expected_flux - out['aperture_net_cnts'].value / scale_factor) < np.pi * aperture**2 * fake_CCDimage.noise_dev)