Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
eec1f6c
Initial commit - I'll give future branches more descriptive names
tcjansen Jun 4, 2019
b597924
Added comparison plot, more explicit variable names
tcjansen Jun 4, 2019
fad52b0
Query sdss filters from SVO, get rid of files
tcjansen Jun 6, 2019
01619ef
Added Gaia query for hat-p-11 parameters
tcjansen Jun 6, 2019
b6a355e
Cite Gillon 2017 for trappist-1 parameters
tcjansen Jun 6, 2019
397d3a2
Added preamble with links to parts of the tutorial
tcjansen Jun 7, 2019
c8fc9d5
Use pmv_kpno to simulate the atmospheric transmission
tcjansen Jun 10, 2019
dfc48f2
Uncommented some things (oops)
tcjansen Jun 10, 2019
e1cd58a
Added Kepler (ie space-based) example observation of the same stars
tcjansen Jun 12, 2019
e10eb67
Adjust 1-1 plot size for visability
tcjansen Jun 13, 2019
6d163ed
typo fix
tcjansen Jun 13, 2019
c8fb9b4
changed import style
tcjansen Jun 13, 2019
463965a
Addressed pllim's comments: fixed typos, changed variable names, took…
tcjansen Jun 13, 2019
f015cb9
push changes
tcjansen Jun 13, 2019
beed31b
small changes made for consistancy
tcjansen Jun 13, 2019
c700ee9
Added a query to SkyCalc for modeling the atmospheric transmission (n…
tcjansen Jun 13, 2019
a8049ed
not sure what to do with skycalc results?
tcjansen Jun 13, 2019
6021ffa
Skycalc query fully implemented
tcjansen Jun 14, 2019
255a413
Changed kepler example from count rates to counts
tcjansen Jun 14, 2019
186e909
Error when loading skycalc data on a different machine
tcjansen Jun 14, 2019
69d4570
Skycalc error resolved - had to do with strict network firewall
tcjansen Jun 14, 2019
0cfbb40
Moved the skycalc querying to its own script, atmospheric_transmittan…
tcjansen Jun 17, 2019
805c5e9
Implemented tynt for querying filter transmittance
tcjansen Jun 17, 2019
6cd0d13
Renamed atmospheric_transmittance.py to skymodel.py and changed the f…
tcjansen Jun 18, 2019
4fae02e
Initial commit
tcjansen Jul 12, 2019
5aadf3c
Changed bp model from Box1d to Const1D, plotting binflux in steps
tcjansen Jul 15, 2019
c331ff0
Muted warnings, set Observation(force='taper')
tcjansen Jul 15, 2019
6497ffe
Zoomed in on spectral features to show binning
tcjansen Jul 15, 2019
5c2e3c8
Minor changes
tcjansen Jul 22, 2019
1685ea6
Added snr examples
tcjansen Jul 22, 2019
c321987
Added snr examples
tcjansen Jul 22, 2019
3a501c3
Wrote first draft of synspec, implemented it into the tutorial
tcjansen Jul 23, 2019
53c2dab
Minor changes
tcjansen Jul 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.rst

This file was deleted.

69 changes: 69 additions & 0 deletions ccd_QE.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
100, 0.0, 0, 0
309.4560021465238, 70.30747424892068, 16, 40
319.539015188068, 73.11442326755378, 14, 30.35714285714286
329.9917387078021, 75.26541144025542, 15, 35.46666666666667
339.70504127115635, 76.58538173145493, 14, 30.35714285714286
349.7880543127005, 74.70200948669466, 10, 16.1
379.53294278525584, 77.10351031374742, 12, 23.66666666666667
390.00376402070555, 81.79762370567437, 13, 26.153846153846164
399.57293120532483, 84.52897199856781, 16, 41.1875
409.3114413012829, 87.18136275806562, 15, 35.46666666666667
419.59611460365807, 89.04058920481614, 15, 36.26666666666667
429.14136694965316, 91.16038905508852, 10, 17.700000000000003
439.5268703824437, 92.49142617037583, 12, 23
449.97959390217784, 93.66048522401442, 15, 35.46666666666667
459.69289646553193, 94.87582372383835, 14, 30.35714285714285
469.6078592897171, 95.64295584810637, 12, 23.58333333333333
479.8589225486203, 96.56602958452065, 14, 30.35714285714285
489.5638226011066, 97.20551595368505, 16, 41.1875
499.5983596184127, 98.01709917645256, 13, 28.615384615384617
509.9916192150812, 98.32588678561568, 13, 26.153846153846157
519.5607863997005, 98.26189461661147, 16, 41.1875
529.3044672715774, 98.79719418907516, 13, 26.92307692307692
539.8528501458082, 99.10133837554409, 14, 32.85714285714285
549.5997627526343, 99.09379281366604, 12, 22.916666666666668
559.5147255768194, 99.35788747939766, 12, 22
569.9467659928786, 99.30100555139393, 13, 28.000000000000014
579.6807516599077, 99.14661174681237, 12, 22
589.5957144840928, 98.81209183688566, 12, 23.58333333333333
599.9631202011678, 98.74843825078625, 13, 26.153846153846157
609.5600803063503, 98.30855134089073, 15, 35.46666666666667
619.6526962174579, 98.04495971261765, 14, 32.57142857142856
630.0958168676286, 97.9845952175933, 16, 40
639.6746792570956, 97.24513015354478, 16, 40
649.5056169726012, 96.85779131047175, 12, 22.91666666666666
659.840705340184, 96.40002722320364, 16, 40
669.7685951041659, 96.0343576860368, 13, 28.000000000000014
679.5025807711951, 95.87183789174043, 12, 23
689.9637068017972, 95.09275862783217, 16, 41.1875
699.7849493124552, 94.89671912596216, 13, 26.15384615384616
709.5355553306517, 94.49854562993605, 14, 30.357142857142854
719.8346329373718, 94.12126753603376, 14, 30.35714285714285
729.728589484387, 93.52139536672911, 16, 41.1875
739.8843165622885, 92.57268606752402, 13, 26.153846153846164
749.9673296038327, 91.77633907547178, 13, 26.153846153846157
759.6625344514713, 90.30410093890463, 17, 45.88235294117648
769.5904242154533, 88.68846298384065, 13, 29.692307692307693
780.3785430640984, 86.74856762101211, 11, 20.36363636363637
789.5964794185556, 84.85909033073233, 16, 41.1875
799.6067784237425, 82.8540023686008, 13, 26.153846153846164
810.0775996591923, 80.76562301189239, 16, 40
819.6564620486593, 78.18504084960068, 14, 30.35714285714286
829.5234105250274, 75.90628116243079, 14, 30.357142857142854
839.8224881317476, 72.63150730735885, 16, 40
849.6894366081158, 68.93418198711632, 14, 30.357142857142854
859.77244964966, 65.34249453316644, 14, 30.357142857142854
870.0715272563801, 61.79608045048484, 14, 30.35714285714286
879.7176097327907, 58.137992052008144, 15, 36.533333333333346
889.8109643261723, 54.49429826388342, 13, 28.61538461538462
899.9424533919547, 49.879751854580746, 16, 41.1875
909.7313785531205, 45.18326838232029, 12, 24.583333333333332
919.6943557251225, 41.57397461732164, 14, 32.857142857142854
930.065454853568, 36.82027063415269, 16, 40
939.644317243035, 32.80603171503223, 12, 22
949.7273302845791, 28.791792795911775, 12, 22
959.9586229296754, 25.094467475669248, 17, 45.882352941176464
969.6772918024916, 21.397142155426735, 14, 30.357142857142854
979.7603048440358, 18.43928189923271, 14, 30.357142857142854
990.0593824507558, 14.892867816551103, 14, 30.35714285714286
1100.0, 0.0, 0, 0
50 changes: 50 additions & 0 deletions synspec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from synphot.observation import Observation
import astropy.units as u
import numpy as np


def from_R(source_spectrum, bandpass, R, waverange, force='none'):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R is also another high level programming language. And typically uppercase variable signifies a constant, so I propose renaming R to resolution, spectral_resolution, or something like that.

"""
Returns a spectrum with bins defined by a spectral resolution
R and a given range of wavelengths. The bin width varies over the
range of wavelengths such that the ratio of the wavelength to the
bin width at that wavelength is equal to the given R.
"""
first_wl = waverange[0].to(u.angstrom).value
binset = np.array([first_wl])
binwidth = first_wl / R

while binset[-1] <= waverange[-1].to(u.angstrom).value:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't though very hard about this yet, but is there a way to write this without a while loop, to keep it speedy?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will think more about this!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, I don't think this can be vectorized easily as binset[i] depends on binset[i - 1]; and also we don't have to worry about speeding it up until it is proven to be a bottleneck; and even then Cythonizing it might be good enough.

However, I am concerned that this algorithm does not round-trip. For example:

waverange = [5000, 5500] * u.AA
R = 100 

Following the math, I think binset here is actually bin edges. And I think you mean in your docstring that you want the bin's central wavelength divided by its bin width is R, correct? So, having calculated binset with this algorithm, my attempt to round trip as follows:

dw = binset[1:] - binset[:-1]  # Bin widths
wcen = binset[:-1] + dw / 2  # Recalculate bin centers
observed_R = wcen / dw

And I get 200.5, not 200.

So then, I tried to calculate the bins by hand, knowing the starting wavelength and R (knowing ending wavelength does not help much at the start here, but it lets you know when to stop the bins). However, I got stuck after the first bin. This is because, given that every bin is defined as wcen / dw = R, and I know the edge of the first bin, for the second bin, I know neither the wcen nor its dw in advance, and it seems to me that I have to solve for two unknown at once. Am I going crazy here?

Then I looked around in specutils and only found spectral_resolution() that calculates the R given the wavelengths, but not the other way around. This makes me think that maybe requiring R to be constant throughout is not practical in the first place?

🤔

next_wl = binset[-1] + binwidth / 2
binset = np.append(binset, next_wl)
binwidth = next_wl / R

return Observation(source_spectrum, bandpass, binset=binset * u.angstrom,
force=force)


def from_wave_binwidth(source_spectrum, bandpass, binwidth, waverange=None,
force='none'):
"""
Returns a spectrum with bins defined by a constant bin width specified
by the user.
"""
if waverange is None:
waverange = bandpass.waveset

# make sure units are the same before stripping them for np.arange()
waverange = waverange.to(u.angstrom).value
binwidth = binwidth.to(u.angstrom).value

binset = (np.arange(waverange[0], waverange[-1] + binwidth, binwidth) *
u.angstrom)

return Observation(source_spectrum, bandpass, binset=binset, force=force)


def from_wave_array(source_spectrum, bandpass, waveset, force='none'):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see from_wave_array being used in the notebook, is this function necessary?

"""
Returns a spectrum with bins defined by the wavelength array provided
by the user.
"""
return Observation(source_spectrum, bandpass, binset=waveset, force=force)
Loading