Skip to content

Commit

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

0 comments on commit 2b0d7dc

Please sign in to comment.