This repository has been archived by the owner on Jan 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |