-
Notifications
You must be signed in to change notification settings - Fork 14
Photo mags #367
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
Draft
andrew-saydjari
wants to merge
16
commits into
main
Choose a base branch
from
photo_mags
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Photo mags #367
Changes from 8 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1c9e6fe
init photo commit, DECam
andrew-saydjari 3f4a777
working photo mags (colors only)
andrew-saydjari 3f2e3d7
comment rearrange
andrew-saydjari 720bdd8
credit/blame Eddie for outline
andrew-saydjari 8a6418b
Update src/photo_mags.jl
andrew-saydjari a8ea6d1
Update src/photo_mags.jl
andrew-saydjari 8479ebf
Update src/photo_mags.jl
andrew-saydjari 6663657
Update src/photo_mags.jl
andrew-saydjari 677f651
Update src/photo_mags.jl
andrew-saydjari 0219d27
Update src/photo_mags.jl
andrew-saydjari 89a6a52
Update src/photo_mags.jl
andrew-saydjari e909715
Update src/photo_mags.jl
andrew-saydjari af7a5c1
wrap in module, light refactoring
ajwheeler 680c1d0
photometry as a package extension with PhotometricFilters.jl
andrew-saydjari d37f9a3
Merge branch 'main' into photo_mags
andrew-saydjari 28deeeb
errant url fix
andrew-saydjari 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
| # DECam filter curves from https://noirlab.edu/science/programs/ctio/filters/Dark-Energy-Camera |
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,56 @@ | ||
|
|
||
| import Interpolations: linear_interpolation | ||
| using Trapz, DelimitedFiles | ||
|
|
||
| # add atmospheric transmission separately later | ||
| # maybe I should pass a default resolution on which to compute the integral? | ||
| # adapted from Eddie Schlafly | ||
| function compute_magnitude(spec_flux, spec_wave, filter_trans, filter_wave) | ||
| # check spec_wave extends beyond filter_wave | ||
| if minimum(filter_wave) < minimum(spec_wave) || maximum(filter_wave) > maximum(spec_wave) | ||
| error("Spectrum does not cover the filter range") | ||
| end | ||
| # check spec_wave is longer than filter_wave | ||
| if length(spec_wave) < length(filter_wave) | ||
| error("Spectrum is lower resolution than the filter") | ||
| end | ||
|
|
||
| # interpolate filter_wave to spec_wave | ||
| interp_linear_extrap = linear_interpolation(filter_wave, filter_trans, extrapolation_bc=0) | ||
| filter_trans_interp = interp_linear_extrap(spec_wave) | ||
|
|
||
| # it is not clear to me that the units work out correctly here even if | ||
| # one uses erg/s/cm^2/Å (which requires using get_radius) | ||
| h = 6.62606957e-27 # erg * s | ||
| c = 2.99792458e10 # cm/s | ||
| flux_to_number = h*c ./(spec_wave*1e-8); # erg | ||
|
|
||
| spec_ref = 3631e-23*c ./(spec_wave*1e-8)./spec_wave # working Mgy | ||
| Iref = trapz(spec_wave,spec_ref.*filter_trans_interp.*flux_to_number) | ||
| Ispec = trapz(spec_wave,spec_flux.*filter_trans_interp.*flux_to_number) | ||
|
|
||
| return -2.5 * log10(Ispec/Iref) # AB magnitudes | ||
| end | ||
|
|
||
| # returns radius in cm given logg base 10 of cm/s^2 | ||
| # assumes 1 solar mass | ||
| function get_radius(logg) | ||
| # Constants | ||
| G = 6.67430e-8 # gravitational constant in cgs | ||
| M_sun = 1.989e33 # solar mass in g | ||
| # Surface gravity in cgs from log(g) | ||
| g = 10^logg # cm/s^2 | ||
| # Using g = GM/R², solve for R | ||
| # R = sqrt(GM/g) | ||
| radius = sqrt((G * M_sun) / g) # in cm | ||
| return radius | ||
| end | ||
|
|
||
| # takes filter name and returns lambda and throughput (including atm transparancy) | ||
| function parse_DECam_filter(filter_name) | ||
| base = "/uufs/chpc.utah.edu/common/home/u6039752/scratch1/working/2024_11_18/Korg.jl/data/filter_curves/DECam/DECam_" | ||
| data = readdlm(base * filter_name * ".txt"; comments=true) | ||
| # msk rows where data[:,2] is zero (no transmission) | ||
| msk = data[:, 2] .!= 0 | ||
| return data[msk, 1], data[msk, 2] | ||
| end | ||
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
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.