Skip to content

Commit

Permalink
Add an example use of the angle TrajectoryExplorer to notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremykubica committed Mar 21, 2024
1 parent 93d31d3 commit f1622e0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
52 changes: 49 additions & 3 deletions notebooks/TrajectoryExplorer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,45 @@
" axs[i, j].imshow(result.all_stamps[ind], cmap=\"gray\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Using (RA, dec)\n",
"\n",
"You can also use the `TrajectoryExplorer` with a WCS and (RA, dec) coordinates. Both RA and dec are specified in degrees and the corresponding velocities are expressed as degrees per day.\n",
"\n",
"We start by creating a fake WCS to match our fake images. Then we evaluate the trajectory based on this WCS."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from astropy.wcs import WCS\n",
"\n",
"my_wcs = WCS(naxis=2)\n",
"my_wcs.wcs.crpix = [201.0, 251.0] # Reference point on the image (center of the image 1-indexed)\n",
"my_wcs.wcs.crval = [45.0, -15.0] # Reference pointing on the sky\n",
"my_wcs.wcs.cdelt = [0.1, 0.1] # Pixel step size\n",
"my_wcs.wcs.ctype = [\"RA---TAN-SIP\", \"DEC--TAN-SIP\"]\n",
"\n",
"# Use the WCS to compute the angular coordinates of the inserted object at two times.\n",
"sky_pos0 = my_wcs.pixel_to_world(50, 60)\n",
"sky_pos1 = my_wcs.pixel_to_world(55, 58)\n",
"\n",
"ra0 = sky_pos0.ra.deg\n",
"dec0 = sky_pos0.dec.deg\n",
"v_ra = sky_pos1.ra.deg - ra0\n",
"v_dec = sky_pos1.dec.deg - dec0\n",
"print(f\"Object starts at ({ra0}, {dec0}) with velocity ({v_ra}, {v_dec}).\")\n",
"\n",
"result = explorer.evaluate_angle_trajectory(ra0, dec0, v_ra, v_dec, my_wcs)\n",
"print(result.trajectory)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -178,13 +217,20 @@
"explorer.apply_sigma_g(result)\n",
"print(f\"Valid time steps={result.valid_indices}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (.conda-kbmod)",
"display_name": "Jeremy's KBMOD",
"language": "python",
"name": "conda-env-.conda-kbmod-py"
"name": "kbmod_jk"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -196,7 +242,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.1"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
1 change: 1 addition & 0 deletions src/kbmod/trajectory_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import numpy as np

from astropy.coordinates import SkyCoord
from astropy.wcs import WCS
from yaml import dump, safe_load

Expand Down

0 comments on commit f1622e0

Please sign in to comment.