Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Merge 9bd04f0 into 44823cb
Browse files Browse the repository at this point in the history
  • Loading branch information
hover2pi committed Jan 22, 2019
2 parents 44823cb + 9bd04f0 commit ea57b4b
Show file tree
Hide file tree
Showing 22 changed files with 132,683 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ That’s it! Now we can take a look at the extracted time-series spectra:
obs.plot()
.. figure:: specialsoss/figures/extracted_spectra.png
.. figure:: specialsoss/files/extracted_spectra.png
:alt: SOSS Extraction
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'specialsoss=specialsoss.cli:main',
],
},
install_requires=requirements,
install_requires=['numpy', 'astropy', 'bokeh'],
license="MIT license",
long_description=readme + '\n\n' + history,
include_package_data=True,
Expand Down
Binary file modified specialsoss/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions specialsoss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
__author__ = """Joe Filippazzo"""
__email__ = 'jfilippazzo@stsci.edu'
__version__ = '0.1.0'

from .crossdispersion import *
from .specialsoss import *
178 changes: 178 additions & 0 deletions specialsoss/crossdispersion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# -*- coding: utf-8 -*-
"""A module of functions that can be use to approximate the SOSS psf in the
cross dispersion direction"""

import os

import numpy as np


def batman(x, mu0, sigma0, A0, sigma1, A1, sep):
"""
Generate a batman function of the given parameters
Parameters
----------
x: array-like
The x-axis on which to generate the function
mu0: float
The x-position of the center peak
sigma0: float
The stanfard deviation of the center peak
A0: float
The amplitude of the center peak
sigma1: float
The stanfard deviation of the outer peaks
A1: float
The amplitude of the outer peaks
sep: float
The separation of the outer peaks from the center peak
Returns
-------
np.ndarray
The y-axis values of the mixed Gaussian
"""
peak1 = gaussian(x, mu0-sep, sigma1, A1)
peak2 = gaussian(x, mu0, sigma0, A0)
peak3 = gaussian(x, mu0+sep, sigma1, A1)

return peak1 + peak2 + peak3


def batmen(x, mu0_1, sigma0_1, A0_1, sigma1_1, A1_1, sep_1, mu0_2, sigma0_2, A0_2, sigma1_2, A1_2, sep_2):
"""
Generate two batman functions of the given parameters
Parameters
----------
x: array-like
The x-axis on which to generate the function
mu0_1: float
The x-position of the center peak, first psf
sigma0_1: float
The stanfard deviation of the center peak, first psf
A0_1: float
The amplitude of the center peak, first psf
sigma1_1: float
The stanfard deviation of the outer peaks, first psf
A1_1: float
The amplitude of the outer peaks, first psf
sep_1: float
The separation of the outer peaks from the center peak, first psf
mu0_2: float
The x-position of the center peak, second psf
sigma0_2: float
The stanfard deviation of the center peak, second psf
A0_2: float
The amplitude of the center peak, second psf
sigma1_2: float
The stanfard deviation of the outer peaks, second psf
A1_2: float
The amplitude of the outer peaks, second psf
sep_2: float
The separation of the outer peaks from the center peak, second psf
Returns
-------
np.ndarray
The y-axis values of the mixed Gaussian
"""
batman1 = batman(x, mu0_1, sigma0_1, A0_1, sigma1_1, A1_1, sep_1)
batman2 = batman(x, mu0_2, sigma0_2, A0_2, sigma1_2, A1_2, sep_2)

return batman1 + batman2


def bimodal(x, mu1, sigma1, A1, mu2, sigma2, A2):
"""
Generate a bimodal function of two Gaussians of the given parameters
Parameters
----------
x: array-like
The x-axis on which to generate the function
mu1: float
The x-position of the first peak center
sigma1: float
The stanfard deviation of the first distribution
A1: float
The amplitude of the first peak
mu2: float
The x-position of the second peak center
sigma2: float
The stanfard deviation of the second distribution
A2: float
The amplitude of the second peak
Returns
-------
np.ndarray
The y-axis values of the mixed Gaussian
"""
g1 = gaussian(x, mu1, sigma1, A1)
g2 = gaussian(x, mu2, sigma2, A2)

return g1 + g2


def gaussian(x, mu, sigma, A):
"""
Generate a Gaussian function of the given parameters
Parameters
----------
x: array-like
The x-axis on which to generate the Gaussian
mu: float
The x-position of the peak center
sigma: float
The stanfard deviation of the distribution
A: float
The amplitude of the peak
Returns
-------
np.ndarray
The y-axis values of the Gaussian
"""
return A*np.exp(-(x-mu)**2/2/sigma**2)


def trimodal(x, mu1, sigma1, A1, mu2, sigma2, A2, mu3, sigma3, A3):
"""
Generate a trimodal function of three Gaussians of the given parameters
Parameters
----------
x: array-like
The x-axis on which to generate the function
mu1: float
The x-position of the first peak center
sigma1: float
The stanfard deviation of the first distribution
A1: float
The amplitude of the first peak
mu2: float
The x-position of the second peak center
sigma2: float
The stanfard deviation of the second distribution
A2: float
The amplitude of the second peak
mu3: float
The x-position of the third peak center
sigma3: float
The stanfard deviation of the third distribution
A3: float
The amplitude of the third peak
Returns
-------
np.ndarray
The y-axis values of the mixed Gaussian
"""
g1 = gaussian(x, mu1, sigma1, A1)
g2 = gaussian(x, mu2, sigma2, A2)
g3 = gaussian(x, mu3, sigma3, A3)

return g1 + g2 + g3
Binary file added specialsoss/files/.DS_Store
Binary file not shown.

0 comments on commit ea57b4b

Please sign in to comment.