Skip to content

Commit

Permalink
Merge pull request #235 from lincc-frameworks/rrlyr-nb
Browse files Browse the repository at this point in the history
S82 RRLyr notebook
  • Loading branch information
hombit authored Sep 20, 2023
2 parents 7561df3 + 7b747be commit 84c8a20
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Examples
========================================================================================

Some examples of how to use the TAPE package are provided in these notebooks.

.. toctree::

Use Lomb–Scargle Periodograms for SDSS Stripe 82 RR Lyrae <examples/rrlyr-period>
136 changes: 136 additions & 0 deletions docs/examples/rrlyr-period.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "7bc777c97b317198",
"metadata": {
"collapsed": false
},
"source": [
"# Explore SDSS Stripe 82 RR Lyrae catalog with period-folding\n",
"\n",
"This short example notebook demonstrates how to use TAPE to explore the SDSS Stripe 82 RR Lyrae catalog. We will use a Lomb–Scargle periodogram to extract periods from r-band light curves and select the RR Lyrae star with the most confident period determination. Then, we will plot the period-folded light curve for this RR Lyrae star."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "initial_id",
"metadata": {
"ExecuteTime": {
"end_time": "2023-09-20T13:16:49.339804Z",
"start_time": "2023-09-20T13:16:48.655140Z"
}
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"from light_curve import Periodogram\n",
"from tape import Ensemble"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fecf2313f49ad1ac",
"metadata": {
"ExecuteTime": {
"end_time": "2023-09-20T13:16:53.703300Z",
"start_time": "2023-09-20T13:16:49.340873Z"
}
},
"outputs": [],
"source": [
"# Load SDSS Stripe 82 RR Lyrae catalog\n",
"ens = Ensemble(client=False).from_dataset('s82_rrlyrae')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5c2dd5a5fd58ce00",
"metadata": {
"ExecuteTime": {
"end_time": "2023-09-20T13:17:00.548389Z",
"start_time": "2023-09-20T13:16:53.706738Z"
}
},
"outputs": [],
"source": [
"%%time\n",
"\n",
"# Filter out invalid detections, \"flux\" denotes magnitude column\n",
"ens = ens.query(\"10 < flux < 25\", table=\"source\")\n",
"\n",
"# Find periods using Lomb-Scargle periodogram\n",
"periodogram = Periodogram(peaks=1, nyquist=0.1, max_freq_factor=10, fast=False)\n",
"\n",
"# Use r band only\n",
"df = ens.batch(periodogram, band_to_calc='r')\n",
"display(df)\n",
"\n",
"# Find RR Lyr with the most confient period\n",
"id = df.index[df['period_s_to_n_0'].argmax()]\n",
"period = df['period_0'].loc[id]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f79ad1eb83d0d125",
"metadata": {
"ExecuteTime": {
"end_time": "2023-09-20T13:17:00.655691Z",
"start_time": "2023-09-20T13:17:00.548017Z"
}
},
"outputs": [],
"source": [
"# Plot folded light curve\n",
"ts = ens.to_timeseries(id)\n",
"COLORS = {'u': 'blue', 'g': 'green', 'r': 'orange', 'i': 'red', 'z': 'purple'}\n",
"color = [COLORS[band] for band in ts.band]\n",
"plt.title(f'{id} P={period:.3f} d')\n",
"plt.gca().invert_yaxis()\n",
"plt.scatter(ts.time % period / period, ts.flux, c=color, s=7)\n",
"plt.xlim([0, 1])\n",
"plt.xlabel('Phase')\n",
"plt.ylabel('Magnitude')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cf157e25e291651a",
"metadata": {
"ExecuteTime": {
"end_time": "2023-09-20T13:17:00.655819Z",
"start_time": "2023-09-20T13:17:00.647036Z"
}
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ API Reference section.
Home page <self>
Getting Started <gettingstarted>
Tutorials <tutorials>
Examples <examples>
API Reference <autoapi/index>

0 comments on commit 84c8a20

Please sign in to comment.