Skip to content

Commit

Permalink
Adding comparison notebook and updating pyproject.toml.
Browse files Browse the repository at this point in the history
  • Loading branch information
drewoldag committed Jun 13, 2024
1 parent bc984c8 commit 7f99a8d
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 1 deletion.
111 changes: 111 additions & 0 deletions docs/notebooks/mbls-comparison.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create some artificial data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"t = []\n",
"y = []\n",
"bands = []\n",
"dy = []\n",
"N = 60\n",
"for i, band in enumerate([\"u\", \"g\", \"r\", \"i\", \"z\"]):\n",
" rng = np.random.default_rng(i)\n",
" t_band = 300 * rng.random(N)\n",
" y_band = 3 + 2 * np.sin(2 * np.pi * t_band)\n",
" dy_band = 0.01 * (0.5 + rng.random(N)) # uncertainties\n",
" y_band += dy_band * rng.standard_normal(N)\n",
" t += list(t_band)\n",
" y += list(y_band)\n",
" dy += list(dy_band)\n",
" bands += [band] * N"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Example using astropy.timeseries"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from astropy.timeseries import LombScargleMultiband"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"model = LombScargleMultiband(t, y, bands, dy, nterms_base=1, nterms_band=1)\n",
"frequency, power = model.autopower(method=\"flexible\")\n",
"freq_maxpower = frequency[np.argmax(power)]\n",
"t_phase = np.linspace(0, 1 / freq_maxpower, 100)\n",
"y_fit = model.model(t_phase, freq_maxpower)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.plot(frequency, power)\n",
"print(f\"Frequency with peak power: {frequency[np.argmax(power)]}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "mapals",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dynamic = ["version"]
requires-python = ">=3.9"
dependencies = [
"cuda-python",
"numpy",
]

[project.urls]
Expand All @@ -28,8 +29,10 @@ dev = [
"black", # Used for static linting of files
"jupyter", # Clears output from Jupyter notebooks
"pre-commit", # Used to run checks before finalizing a git commit
"pytest",
"pytest", # Used to run tests
"pytest-cov", # Used to report total code coverage
"matplotlib", # Used to plot data
"astropy", # Used as the LS baseline for comparison
]

[build-system]
Expand Down

0 comments on commit 7f99a8d

Please sign in to comment.