-
Notifications
You must be signed in to change notification settings - Fork 1
Register #19
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
Merged
Merged
Register #19
Changes from 12 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
5eea46e
cleanup
icweaver 31ae4ff
Merge branch 'main' into photometry-migration
icweaver 094e895
README cleanup
icweaver 95def04
interpolator typo
icweaver b284dd2
toml cleanup
icweaver fd7a128
docs up
icweaver e66baf3
doc meta cleanup
icweaver 16eb116
update CI workflow
icweaver 1e9ee37
tests up
icweaver ffa1ac0
add Photometry.jl #75
icweaver 4cd479d
import --> using
icweaver a91961d
explicit imports
icweaver 84f8190
set prettyurls to true
icweaver b9790c5
v2 test framework
icweaver af24ac7
use [workspace]
icweaver 12cbc8e
ci: auto threads
icweaver 744f54c
just use single threaded parallel tests
icweaver 8091c59
update test discovery
icweaver bfaac38
Update test/runtests.jl
icweaver bea83de
add compat
icweaver 471c582
what u doin
icweaver 0b45b12
ci: args test
icweaver 25c64ab
ci: --verbose test
icweaver cf3c4d0
read a book ian
icweaver 1d1dd1c
doc permissions
icweaver f40900d
ci: try to fix docs syntax
icweaver 2197535
not needed, added keys separately
icweaver 512480b
Update docs/make.jl
icweaver c5e0fc5
Update src/BackgroundMeshes.jl
icweaver b3e6342
Update test/Project.toml
icweaver c5c39c0
typo
icweaver 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # 2. Background Estimation on Real Data | ||
|
|
||
| Estimating backgrounds is an important step in performing photometry. Ideally, we could perfectly describe the background with a scalar value or with some distribution. Unfortunately, it's impossible for us to precisely separate the background and foreground signals. Here, we use mixture of robust statistical estimators and meshing to let us get the spatially varying background from an astronomical photo. | ||
|
|
||
| Let's show an example: | ||
|
|
||
| ```@example ex | ||
| using AstroImages | ||
| using BackgroundMeshes | ||
| using FITSIO | ||
| using Plots | ||
|
|
||
| # Download our image, courtesy of astropy | ||
| url = "https://rawcdn.githack.com/astropy/photutils-datasets/8c97b4fa3a6c9e6ea072faeed2d49a20585658ba/data/M6707HH.fits" | ||
| hdu = FITS(download(url)) | ||
| image = read(hdu[1]) | ||
|
|
||
| # Plot | ||
| function imshow(image; kwargs...) | ||
| xs, ys = axes(image) | ||
| data = transpose(image) | ||
| heatmap(xs, ys, data; | ||
| aspect_ratio = 1, | ||
| xlim = extrema(xs), | ||
| ylim = extrema(ys), | ||
| kwargs... | ||
| ) | ||
| end | ||
|
|
||
| imshow(image) | ||
| ``` | ||
|
|
||
| Now let's try and estimate the background using [`estimate_background`](@ref). First, we'll sigma-clip to try and remove the signals from the stars. Then, the background is broken down into boxes, in this case of size `(50, 50)`. Within each box, the given statistical estimators get the background value and RMS. By default, we use [`SourceExtractorBackground`](@ref) and [`StdRMS`](@ref). This creates a low-resolution image, which we then need to resize. We can accomplish this using an interpolator, by default a cubic-spline interpolator via [`ZoomInterpolator`](@ref). The end result is a smooth estimate of the spatially varying background and background RMS. | ||
|
|
||
| ```@example ex | ||
| # Sigma-clip | ||
| clipped = sigma_clip(image, 1; fill=NaN) | ||
|
|
||
| # Get background and background rms with box-size (50, 50) | ||
| bkg, bkg_rms = estimate_background(clipped, 50) | ||
|
|
||
| # Plot | ||
| plot( | ||
| imshow(image; title="Original"), | ||
| imshow(clipped; title="Sigma-Clipped"), | ||
| imshow(bkg; title="Background"), | ||
| imshow(bkg_rms; title="Background RMS"); | ||
| layout = (2, 2), | ||
| ticks = false, | ||
| ) | ||
| ``` | ||
|
|
||
| We could apply a median filter, too, by specifying `filter_size`: | ||
|
|
||
| ```@example ex | ||
| # Get background and background rms with box-size (50, 50) and filter_size (5, 5) | ||
| bkg_f, bkg_rms_f = estimate_background(clipped, 50; filter_size = 5) | ||
|
|
||
| # Plot | ||
| plot( | ||
| imshow(bkg; title="Unfiltered", ylabel="Background"), | ||
| imshow(bkg_f; title="Filtered"), | ||
| imshow(bkg_rms; ylabel="RMS"), | ||
| imshow(bkg_rms_f); | ||
| layout = (2, 2), | ||
| ticks = false, | ||
| ) | ||
| ``` | ||
|
|
||
| Now we can see our image after subtracting the filtered background and ready for further analysis! | ||
|
|
||
| ```@example ex | ||
| subt = image .- bkg_f[axes(image)...] | ||
|
|
||
| # Plot | ||
| plot( | ||
| imshow(image; title="Original", colorbar=false), | ||
| imshow(subt; title="Subtracted"); | ||
| layout = (1, 2), | ||
| size = (600, 260), | ||
| xlims = (400, 800), | ||
| ylims = ( 400, 800), | ||
| clims = (minimum(subt), maximum(image)), | ||
| ticks = false, | ||
| aspect_ratio = 1, | ||
| ) | ||
| ``` | ||
|
|
||
| ### IDW Interpolator | ||
|
|
||
| Here is a quick example using the [`IDWInterpolator`](@ref): | ||
|
|
||
| ```@example ex | ||
| b1, r1 = estimate_background(clipped, 50; filter_size=5) | ||
| b2, r2 = estimate_background(clipped, 50; itp=IDWInterpolator(50), filter_size=5) | ||
|
|
||
| # Plot | ||
| plot( | ||
| imshow(b1; title="ZoomInterpolator", ylabel="Background"), | ||
| imshow(b2; title="IDWInterpolator"), | ||
| imshow(r1; ylabel="RMS"), | ||
| imshow(r2); | ||
| layout = (2, 2), | ||
| ticks = false, | ||
| ) | ||
| ``` |
This file contains hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.