-
Notifications
You must be signed in to change notification settings - Fork 1
synspec #17
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
base: master
Are you sure you want to change the base?
synspec #17
Changes from all commits
eec1f6c
b597924
fad52b0
01619ef
b6a355e
397d3a2
c8fc9d5
dfc48f2
e1cd58a
e10eb67
6d163ed
c8fb9b4
463965a
f015cb9
beed31b
c700ee9
a8049ed
6021ffa
255a413
186e909
69d4570
0cfbb40
805c5e9
6cd0d13
4fae02e
5aadf3c
c331ff0
6497ffe
5c2e3c8
1685ea6
c321987
3a501c3
53c2dab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| 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 |
| 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'): | ||
| """ | ||
| 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: | ||
|
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. I haven't though very hard about this yet, but is there a way to write this without a
Owner
Author
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. Will think more about this! 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. First of all, I don't think this can be vectorized easily as 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 dw = binset[1:] - binset[:-1] # Bin widths
wcen = binset[:-1] + dw / 2 # Recalculate bin centers
observed_R = wcen / dwAnd 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 Then I looked around in 🤔 |
||
| 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'): | ||
|
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. I don't see |
||
| """ | ||
| Returns a spectrum with bins defined by the wavelength array provided | ||
| by the user. | ||
| """ | ||
| return Observation(source_spectrum, bandpass, binset=waveset, force=force) | ||
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.
R is also another high level programming language. And typically uppercase variable signifies a constant, so I propose renaming
Rtoresolution,spectral_resolution, or something like that.