{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Aladin commands" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from astropy.coordinates import Angle, SkyCoord\n", "from ipyaladin import Aladin, Marker\n", "from pathlib import Path" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "`ipyaladin`'s full list of methods can be found in the documentation [here](https://cds-astro.github.io/ipyaladin/autoapi/ipyaladin/widget/index.html). A few of them are illustrated in the next cells. Let's first, create the widget with a few initial parameters:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aladin = Aladin(\n", " target=SkyCoord(10, 20, unit=\"deg\"),\n", " fov=Angle(20, \"deg\"),\n", " reticle_size=64,\n", " reticle_color=\"#ff89ff\",\n", ")\n", "aladin" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can always see the current state of the widget target, field of view and rotation:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(aladin.target)\n", "print(aladin.fov)\n", "print(aladin.rotation)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "And then, these values can be modified either interactively (with your mouse on the widget) or programmatically in the next cells with an interactive effect on the generated view." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aladin.target = \"sgr a*\" # either an object name or a SkyCoord\n", "aladin.target" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The field of view `fov` sets the zoom factor on the x-axis:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aladin.fov = 2 # either a number in degrees or an astropy angle\n", "aladin.fov" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The orientation of the view (view center to north pole angle in degrees) can be set:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aladin.rotation = 180 # either a number in degrees or an astropy angle\n", "aladin.rotation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The overlay survey is always on top of the base layer" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aladin.overlay_survey = \"P/allWISE/color\"\n", "aladin.overlay_survey_opacity = 0.5" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can change the coordinate frame (the choices are `ICRS`, `ICRSd` or `Galactic`)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aladin.coo_frame = \"ICRSd\" # ICRS, and angles expressed in degrees" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aladin.coo_frame" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The target, rotation, and field of view can be set with astropy objects" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aladin.target = SkyCoord(\"12h00m00s\", \"-30d00m00s\", frame=\"icrs\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aladin.rotation = Angle(0, \"deg\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aladin.fov = Angle(5, \"deg\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can add a FITS image to the view of the widget, either as a path (string of pathlib.Path object) or as an\n", "astropy HDU object." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "aladin.add_fits(Path(\"images/m31.fits\"), name=\"M31\", opacity=0.5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can add markers to the view of the widget with custom popup title and description.\n", "Here we will add markers for Messier objects M1 to M10." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "markers = []\n", "for i in range(1, 11):\n", " name = f\"M{i}\"\n", " markers.append(\n", " Marker(\n", " position=name,\n", " title=name,\n", " # the title and description can be written as plain text or as html elements\n", " description=(\n", " ' '\n", " \"Read more on SIMBAD\"\n", " ),\n", " )\n", " )\n", "aladin.add_markers(markers, name=\"M1-M10\", color=\"pink\", shape=\"cross\", source_size=15)\n", "aladin.target = \"M1\"\n", "aladin.fov = 0.2" ] } ], "metadata": {}, "nbformat": 4, "nbformat_minor": 4 }