Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leliel12 committed Dec 6, 2017
1 parent 0e90539 commit 75e0022
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 8 deletions.
21 changes: 14 additions & 7 deletions doc/source/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ div.input_area {
border: none !important;
}

div.note {
background-color: #6595c5;
border: 1px solid #CCC;
}

table {
border-collapse: collapse;
Expand All @@ -26,9 +22,6 @@ table thead tr th,
table tbody tr td {
border: 1px solid #CCC;
margin: 0px;
font-size: 15px;
font-family: san-serif;

}

tr:nth-child(even) {
Expand All @@ -47,3 +40,17 @@ div.section#The-Features div.nboutput div.document {
div.section#The-Features div.nboutput div.prompt.empty {
display: none !important;
}


div.section#The-Features blockquote > span.math {
display: block !important;
margin-top: 10px;
margin-bottom: 10px;
}

/*
div.section#The-Features p span.math,
div.section#The-Features ol span.math, {
display: inline !important;
}
*/
3 changes: 3 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,6 @@ def __getattr__(cls, name):

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}

def setup(app):
app.add_stylesheet("custom.css")
96 changes: 95 additions & 1 deletion doc/source/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3232,7 +3232,101 @@
" <div id=\"collapse-feature-FourierComponents\" class=\"panel-collapse collapse\" role=\"tabpanel\" aria-labelledby=\"heading-feature-FourierComponents\">\n",
" <div class=\"panel-body\">\n",
" <p>\n",
" <p>FourierComponents</p>\n",
" <blockquote>\n",
" <p><strong>Periodic features extracted from light-curves using Lomb–Scargle</strong> <strong>(Richards et al., 2011)</strong></p>\n",
" <p>Here, we adopt a model where the time series of the photometric magnitudes of variable stars is modeled as a superposition of sines and cosines:</p>\n",
" <span class=\"math\">\\(y_i(t|f_i) = a_i\\sin(2\\pi f_i t) + b_i\\cos(2\\pi f_i t) + b_{i,\\circ}\\)</span>\n",
" <p>where\n",
" <span class=\"math\">\\(a\\)</span>\n",
" and\n",
" <span class=\"math\">\\(b\\)</span>\n",
" are normalization constants for the sinusoids of frequency\n",
" <span class=\"math\">\\(f_i\\)</span>\n",
" and\n",
" <span class=\"math\">\\(b_{i,\\circ}\\)</span>\n",
" is the magnitude offset.</p>\n",
" <p>To find periodic variations in the data, we fit the equation above by minimizing the sum of squares, which we denote\n",
" <span class=\"math\">\\(\\chi^2\\)</span>\n",
" :</p>\n",
" <span class=\"math\">\\(\\chi^2 = \\sum_k \\frac{(d_k - y_i(t_k))^2}{\\sigma_k^2}\\)</span>\n",
" <p>where\n",
" <span class=\"math\">\\(\\sigma_k\\)</span>\n",
" is the measurement uncertainty in data point\n",
" <span class=\"math\">\\(d_k\\)</span>\n",
" . We allow the mean to float, leading to more robust period estimates in the case where the periodic phase is not uniformly sampled; in these cases, the model light curve has a non-zero mean. This can be important when searching for periods on the order of the data span\n",
" <span class=\"math\">\\(T_{tot}\\)</span>\n",
" . Now, define</p>\n",
" <span class=\"math\">\\(\\chi^2_{\\circ} = \\sum_k \\frac{(d_k - \\mu)^2}{\\sigma_k^2}\\)</span>\n",
" <p>where\n",
" <span class=\"math\">\\(\\mu\\)</span>\n",
" is the weighted mean</p>\n",
" <span class=\"math\">\\(\\mu = \\frac{\\sum_k d_k / \\sigma_k^2}{\\sum_k 1/\\sigma_k^2}\\)</span>\n",
" <p>Then, the generalized Lomb-Scargle periodogram is:</p>\n",
" <span class=\"math\">\\(P_f(f) = \\frac{(N-1)}{2} \\frac{\\chi_{\\circ}^2 - \\chi_m^2(f)}\n",
" {\\chi_{\\circ}^2}\\)</span>\n",
" <p>where\n",
" <span class=\"math\">\\(\\chi_m^2(f)\\)</span>\n",
" is\n",
" <span class=\"math\">\\(\\chi^2\\)</span>\n",
" minimized with respect to\n",
" <span class=\"math\">\\(a, b\\)</span>\n",
" and\n",
" <span class=\"math\">\\(b_{\\circ}\\)</span>\n",
" .</p>\n",
" <p>Following Debosscher et al. (2007), we fit each light curve with a linear term plus a harmonic sum of sinusoids:</p>\n",
" <span class=\"math\">\\(y(t) = ct + \\sum_{i=1}^{3}\\sum_{j=1}^{4} y_i(t|jf_i)\\)</span>\n",
" <p>where each of the three test frequencies\n",
" <span class=\"math\">\\(f_i\\)</span>\n",
" is allowed to have four harmonics at frequencies\n",
" <span class=\"math\">\\(f_{i,j} = jf_i\\)</span>\n",
" . The three test frequencies\n",
" <span class=\"math\">\\(f_i\\)</span>\n",
" are found iteratively, by successfully finding and removing periodic signal producing a peak in\n",
" <span class=\"math\">\\(P_f(f)\\)</span>\n",
" , where\n",
" <span class=\"math\">\\(P_f(f)\\)</span>\n",
" is the Lomb-Scargle periodogram as defined above.</p>\n",
" <p>Given a peak in\n",
" <span class=\"math\">\\(P_f(f)\\)</span>\n",
" , we whiten the data with respect to that frequency by fitting away a model containing that frequency as well as components with frequencies at 2, 3, and 4 times that fundamental frequency (harmonics). Then, we subtract that model from the data, update\n",
" <span class=\"math\">\\(\\chi_{\\circ}^2\\)</span>\n",
" , and recalculate\n",
" <span class=\"math\">\\(P_f(f)\\)</span>\n",
" to find more periodic components.</p>\n",
" <p><strong>Algorithm:</strong></p>\n",
" <ol type=\"1\">\n",
" <li>For\n",
" <span class=\"math\">\\(i = {1, 2, 3}\\)</span>\n",
" </li>\n",
" <li>Calculate Lomb-Scargle periodogram\n",
" <span class=\"math\">\\(P_f(f)\\)</span>\n",
" for light curve.</li>\n",
" <li>Find peak in\n",
" <span class=\"math\">\\(P_f(f)\\)</span>\n",
" , subtract that model from data.</li>\n",
" <li>Update\n",
" <span class=\"math\">\\(\\chi_{\\circ}^2\\)</span>\n",
" , return to <em>Step 1</em>.</li>\n",
" </ol>\n",
" <p>Then, the features extracted are given as an amplitude and a phase:</p>\n",
" <div class=\"math\">\\begin{align*}\n",
"A_{i,j} = \\sqrt{a_{i,j}^2 + b_{i,j}^2}\\\\\n",
"\\textrm{PH}_{i,j} = \\arctan(\\frac{b_{i,j}}{a_{i,j}})\n",
"\\end{align*}</div>\n",
" <p>where\n",
" <span class=\"math\">\\(A_{i,j}\\)</span>\n",
" is the amplitude of the\n",
" <span class=\"math\">\\(j-th\\)</span>\n",
" harmonic of the\n",
" <span class=\"math\">\\(i-th\\)</span>\n",
" frequency component and\n",
" <span class=\"math\">\\(\\textrm{PH}_{i,j}\\)</span>\n",
" is the phase component, which we then correct to a relative phase with respect to the phase of the first component:</p>\n",
" <span class=\"math\">\\(\\textrm{PH}'_{i,j} = \\textrm{PH}_{i,j} - \\textrm{PH}_{00}\\)</span>\n",
" <p>and remapped to\n",
" <span class=\"math\">\\(|-\\pi, +\\pi|\\)</span>\n",
" </p>\n",
" </blockquote>\n",
"</p>\n",
" <h5>Required Data</h5>\n",
" <div>\n",
Expand Down
95 changes: 95 additions & 0 deletions feets/extractors/ext_fourier_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,101 @@
# =============================================================================

class FourierComponents(Extractor):
r"""
**Periodic features extracted from light-curves using Lomb–Scargle**
**(Richards et al., 2011)**
Here, we adopt a model where the time series of the photometric magnitudes
of variable stars is modeled as a superposition of sines and cosines:
.. math::
y_i(t|f_i) = a_i\sin(2\pi f_i t) + b_i\cos(2\pi f_i t) + b_{i,\circ}
where :math:`a` and :math:`b` are normalization constants for the
sinusoids of frequency :math:`f_i` and :math:`b_{i,\circ}` is the
magnitude offset.
To find periodic variations in the data, we fit the equation above by
minimizing the sum of squares, which we denote :math:`\chi^2`:
.. math::
\chi^2 = \sum_k \frac{(d_k - y_i(t_k))^2}{\sigma_k^2}
where :math:`\sigma_k` is the measurement uncertainty in data point
:math:`d_k`. We allow the mean to float, leading to more robust period
estimates in the case where the periodic phase is not uniformly sampled;
in these cases, the model light curve has a non-zero mean. This can be
important when searching for periods on the order of the data span
:math:`T_{tot}`. Now, define
.. math::
\chi^2_{\circ} = \sum_k \frac{(d_k - \mu)^2}{\sigma_k^2}
where :math:`\mu` is the weighted mean
.. math::
\mu = \frac{\sum_k d_k / \sigma_k^2}{\sum_k 1/\sigma_k^2}
Then, the generalized Lomb-Scargle periodogram is:
.. math::
P_f(f) = \frac{(N-1)}{2} \frac{\chi_{\circ}^2 - \chi_m^2(f)}
{\chi_{\circ}^2}
where :math:`\chi_m^2(f)` is :math:`\chi^2` minimized with respect to
:math:`a, b` and :math:`b_{\circ}`.
Following Debosscher et al. (2007), we fit each light curve with a linear
term plus a harmonic sum of sinusoids:
.. math::
y(t) = ct + \sum_{i=1}^{3}\sum_{j=1}^{4} y_i(t|jf_i)
where each of the three test frequencies :math:`f_i` is allowed to have
four harmonics at frequencies :math:`f_{i,j} = jf_i`. The three test
frequencies :math:`f_i` are found iteratively, by successfully finding and
removing periodic signal producing a peak in :math:`P_f(f)` , where
:math:`P_f(f)` is the Lomb-Scargle periodogram as defined above.
Given a peak in :math:`P_f(f)`, we whiten the data with respect to that
frequency by fitting away a model containing that frequency as well as
components with frequencies at 2, 3, and 4 times that fundamental
frequency (harmonics). Then, we subtract that model from the data, update
:math:`\chi_{\circ}^2`, and recalculate :math:`P_f(f)` to find more
periodic components.
**Algorithm:**
1. For :math:`i = {1, 2, 3}`
2. Calculate Lomb-Scargle periodogram :math:`P_f(f)` for light curve.
3. Find peak in :math:`P_f(f)`, subtract that model from data.
4. Update :math:`\chi_{\circ}^2`, return to *Step 1*.
Then, the features extracted are given as an amplitude and a phase:
.. math::
A_{i,j} = \sqrt{a_{i,j}^2 + b_{i,j}^2}\\
\textrm{PH}_{i,j} = \arctan(\frac{b_{i,j}}{a_{i,j}})
where :math:`A_{i,j}` is the amplitude of the :math:`j-th` harmonic of the
:math:`i-th` frequency component and :math:`\textrm{PH}_{i,j}` is the
phase component, which we then correct to a relative phase with respect
to the phase of the first component:
.. math::
\textrm{PH}'_{i,j} = \textrm{PH}_{i,j} - \textrm{PH}_{00}
and remapped to :math:`|-\pi, +\pi|`
"""

data = ['magnitude', 'time']
features = ['Freq1_harmonics_amplitude_0',
Expand Down

0 comments on commit 75e0022

Please sign in to comment.