-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix center profile #329
Merged
Merged
Fix center profile #329
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6ed3fe2
Add option to show/hide item details
mwcraig f98c3ac
Fix error in test
mwcraig 5d33fa4
Address review comments
mwcraig eb556db
Add test for get 100% coverage
mwcraig 56ebc52
Add test that breaks CenterAndProfile
mwcraig 7fd2733
Subtract a rough background
mwcraig 4a20a8d
Subtract background from profile
mwcraig 317fcba
Add test of radial profile and subtract background
mwcraig 2bc733d
Remove redundant +
mwcraig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,8 @@ def test_find_center_no_star(): | |
|
||
|
||
def test_radial_profile(): | ||
# Test that both curve of growth and radial profile are correct | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like a reasonable test |
||
image = make_gaussian_sources_image(SHAPE, STARS) | ||
for row in STARS: | ||
cen = find_center(image, (row["x_mean"], row["y_mean"]), max_iters=10) | ||
|
@@ -81,13 +83,21 @@ def test_radial_profile(): | |
# cutout size around 60. | ||
rad_prof = CenterAndProfile(image, cen, cutout_size=60, profile_radius=30) | ||
|
||
# Test that the curve of growth is correct | ||
|
||
# Numerical value below is integral of input 2D gaussian, 2pi A sigma^2 | ||
expected_integral = 2 * np.pi * row["amplitude"] * row["x_stddev"] ** 2 | ||
|
||
np.testing.assert_allclose( | ||
rad_prof.curve_of_growth.profile[-1], expected_integral, atol=50 | ||
) | ||
|
||
# Test that the radial profile is correct by comparing pixel values to a | ||
# gaussian fit to the profile. | ||
data_radii, data_counts = rad_prof.pixel_values_in_profile | ||
expected_profile = rad_prof.radial_profile.gaussian_fit(data_radii) | ||
|
||
np.testing.assert_allclose(data_counts, expected_profile, atol=20) | ||
|
||
|
||
def test_radial_profile_exposure_is_nan(): | ||
# Check that using an exposure value of NaN returns NaN for the SNR and noise | ||
|
@@ -102,3 +112,32 @@ def test_radial_profile_exposure_is_nan(): | |
assert np.isnan(rad_prof.noise(c, np.nan)[-1]) | ||
assert all(np.isfinite(rad_prof.curve_of_growth.profile)) | ||
assert all(np.isfinite(rad_prof.radial_profile.profile)) | ||
|
||
|
||
def test_radial_profile_with_background(): | ||
# Regression test for #328 -- image with a background level | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, I believe the logic here is sound, though it took a bit for me to understand it. |
||
image = make_gaussian_sources_image(SHAPE, STARS) | ||
image = image + make_noise_image( | ||
image.shape, distribution="gaussian", mean=100, stddev=0.1 | ||
) | ||
for row in STARS: | ||
cen = find_center(image, (row["x_mean"], row["y_mean"]), max_iters=10) | ||
|
||
# The "stars" have FWHM around 9.5, so make the cutouts used for finding the | ||
# stars fairly big -- the bare minimum would be a radius of 3 FWHM, which is a | ||
# cutout size around 60. | ||
rad_prof = CenterAndProfile(image, cen, cutout_size=60, profile_radius=30) | ||
|
||
# Numerical value below is integral of input 2D gaussian, 2pi A sigma^2 | ||
expected_integral = 2 * np.pi * row["amplitude"] * row["x_stddev"] ** 2 | ||
|
||
np.testing.assert_allclose( | ||
rad_prof.curve_of_growth.profile[-1], expected_integral, atol=50 | ||
) | ||
|
||
# Test that the radial profile is correct by comparing pixel values to a | ||
# gaussian fit to the profile. | ||
data_radii, data_counts = rad_prof.pixel_values_in_profile | ||
expected_profile = rad_prof.radial_profile.gaussian_fit(data_radii) | ||
|
||
np.testing.assert_allclose(data_counts, expected_profile, atol=20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct, you have
grid_x
determined by: self._data.shape[0]
but you compute the distance from center using(grid_x - self._cen[1])
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah; this is the array vs image thing.