Skip to content

Commit

Permalink
📝 Update example 9 with new supported pixel regions
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed May 15, 2024
1 parent c0b218c commit 96e4f16
Showing 1 changed file with 113 additions and 16 deletions.
129 changes: 113 additions & 16 deletions examples/9_Shapes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,22 @@
{
"cell_type": "markdown",
"metadata": {},
"source": "# Add shapes from regions objects"
"source": [
"# Add shapes from regions objects\n",
"## From sky coordinates"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"aladin = Aladin(\n",
"b = Aladin(\n",
" target=\"m31\",\n",
" fov=10,\n",
")\n",
"aladin"
"b"
]
},
{
Expand All @@ -90,9 +93,9 @@
"metadata": {},
"outputs": [],
"source": [
"circle = CircleSkyRegion(center=aladin.target, radius=Angle(0.5, \"deg\"))\n",
"circle = CircleSkyRegion(center=b.target, radius=Angle(0.5, \"deg\"))\n",
"\n",
"aladin.add_overlay(circle, color=\"red\")"
"b.add_overlay(circle, color=\"red\")"
]
},
{
Expand All @@ -102,12 +105,12 @@
"outputs": [],
"source": [
"ellipse = EllipseSkyRegion(\n",
" center=aladin.target,\n",
" center=b.target,\n",
" height=Angle(0.5, \"deg\"),\n",
" width=Angle(1, \"deg\"),\n",
" angle=Angle(45, \"deg\"),\n",
")\n",
"aladin.add_overlay(ellipse, color=\"blue\", alpha=0.5)"
"b.add_overlay(ellipse, color=\"blue\")"
]
},
{
Expand All @@ -117,10 +120,10 @@
"outputs": [],
"source": [
"line = LineSkyRegion(\n",
" start=aladin.target,\n",
" end=aladin.target.directional_offset_by(Angle(0, \"deg\"), Angle(0.5, \"deg\")),\n",
" start=b.target,\n",
" end=b.target.directional_offset_by(Angle(0, \"deg\"), Angle(0.5, \"deg\")),\n",
")\n",
"aladin.add_overlay(line, color=\"green\", alpha=0.5)"
"b.add_overlay(line, color=\"green\")"
]
},
{
Expand All @@ -132,15 +135,15 @@
"polygon = PolygonSkyRegion(\n",
" vertices=SkyCoord(\n",
" [\n",
" aladin.target.directional_offset_by(Angle(0, \"deg\"), Angle(0.5, \"deg\")),\n",
" aladin.target.directional_offset_by(Angle(90, \"deg\"), Angle(0.5, \"deg\")),\n",
" aladin.target.directional_offset_by(Angle(-90, \"deg\"), Angle(0.5, \"deg\")),\n",
" b.target.directional_offset_by(Angle(0, \"deg\"), Angle(0.5, \"deg\")),\n",
" b.target.directional_offset_by(Angle(90, \"deg\"), Angle(0.5, \"deg\")),\n",
" b.target.directional_offset_by(Angle(-90, \"deg\"), Angle(0.5, \"deg\")),\n",
" ],\n",
" frame=\"icrs\",\n",
" unit=\"deg\",\n",
" )\n",
")\n",
"aladin.add_overlay(polygon, color=\"yellow\", alpha=0.5)"
"b.add_overlay(polygon, color=\"yellow\")"
]
},
{
Expand All @@ -150,12 +153,106 @@
"outputs": [],
"source": [
"rectangle = RectangleSkyRegion(\n",
" center=aladin.target,\n",
" center=b.target,\n",
" width=Angle(0.5, \"deg\"),\n",
" height=Angle(0.5, \"deg\"),\n",
" angle=Angle(45, \"deg\"),\n",
")\n",
"aladin.add_overlay(rectangle, color=\"purple\", alpha=0.5)"
"b.add_overlay(rectangle, color=\"purple\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": "## From pixel coordinates"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"c = Aladin(\n",
" target=\"m31\",\n",
" fov=10,\n",
")\n",
"c"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from regions import (\n",
" CirclePixelRegion,\n",
" EllipsePixelRegion,\n",
" LinePixelRegion,\n",
" PolygonPixelRegion,\n",
" RectanglePixelRegion,\n",
" PixCoord,\n",
")\n",
"from astropy.coordinates import Angle"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"circle = CirclePixelRegion(\n",
" center=PixCoord(x=200, y=200),\n",
" radius=50,\n",
" visual={\n",
" \"edgecolor\": \"red\",\n",
" },\n",
")\n",
"c.add_overlay(circle)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ellipse = EllipsePixelRegion(\n",
" center=PixCoord(x=200, y=200), height=50, width=100, angle=Angle(90, \"deg\")\n",
")\n",
"c.add_overlay(ellipse, color=\"blue\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"line = LinePixelRegion(start=PixCoord(x=200, y=200), end=PixCoord(x=200, y=150))\n",
"c.add_overlay(line, color=\"green\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"polygon = PolygonPixelRegion(vertices=PixCoord(x=[200, 250, 150], y=[150, 200, 200]))\n",
"c.add_overlay(polygon, color=\"yellow\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"rectangle = RectanglePixelRegion(\n",
" center=PixCoord(x=200, y=200), width=100, height=100, angle=Angle(45, \"deg\")\n",
")"
]
}
],
Expand Down

0 comments on commit 96e4f16

Please sign in to comment.