Add weighted averages + bootstrapped errors #16
Merged
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.
Hi,
This pull request includes a few different additions to the stacking code. I think it should take care of issues #10 and #11 .
Weighted averages:
I have included ivar and irms weighted averages per wavelength bin. On top of that it is also possible to up of down weight specific (as in one weight per spectrum) spectra using the
weight
argument in the main stacking function. These two weights can be used in conjunction wheretotal_weight = wl_weight * spec_weight
.Bootstrap errors:
Errors using bootstrap sampling. The default setting is
bootstrap_samples=1000
. For each bootstrap we are sampling with replacement a bootstrap sample of equal length as the original sample. The bootstrap sampling can be run in parallel using then_workers
argument.Currently the stacking code will return a stacked spectrum when for the wl range covered by at least 1 spectrum but we might want to change this to a slightly more sane criterium at some point.
Stacking example with bootstrapped errors:
Add MW foreground correction to the main stacking function:
I have now added the MW foreground correction to the main stacking function.
Let me know if you think there are any changes that should be made before we integrate this into the main branch! 🙂