-
Notifications
You must be signed in to change notification settings - Fork 0
Export selection and drawn regions as astropy regions #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 20 commits
ed743c2
74fff24
a88fdfe
cdf9957
3493ccb
39828a4
a3f0cc1
06bd9ab
74c7e8b
f2895f8
aa9a157
f2b441b
2687f10
720ecc9
45fec7c
a53307c
1633a37
44aa05d
3bd67c0
89f69e7
8df4537
6873b7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| { | ||
|
pcuste1 marked this conversation as resolved.
pcuste1 marked this conversation as resolved.
|
||
| "cells": [ | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "fb39c230", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "# Export Region Selection\n", | ||
| "This notebook shows how you can export the region selections you have made within ipyaladin" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "72180ae5-f9ec-4355-9497-200439da187b", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "from ipyaladin import Aladin\n", | ||
| "\n", | ||
| "from astropy.coordinates import SkyCoord\n", | ||
| "from astroquery.mast import Catalogs" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "b377a777-af46-4af3-b874-94726a45acd5", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "%load_ext autoreload\n", | ||
| "%autoreload 2" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "43c0c170", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "aladin = Aladin(\n", | ||
| " survey=\"SDSS9 colored\",\n", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realized that this isn't actually working since Aladin sets the HiPS (I've added this issue to our new discussion page.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we remove this from the example ipynb then too |
||
| " show_coo_grid=True,\n", | ||
| " target=\"TRAPPIST-1\",\n", | ||
| " coo_frame=\"icrs\",\n", | ||
| " fov=0.05,\n", | ||
| " height=400,\n", | ||
| " samp=True,\n", | ||
| ")\n", | ||
| "aladin" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "30b5ab5a", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "### Extract Region selections\n", | ||
| "First, load a custom catalog that will provide the sources to select from" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "e1dc08de", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "target_name = \"TRAPPIST-1\"\n", | ||
| "catalog_data = Catalogs.query_region(\n", | ||
| " coordinates=SkyCoord.from_name(target_name),\n", | ||
| " radius=0.01, # [deg]\n", | ||
| " catalog=\"Panstarrs\",\n", | ||
| ")\n", | ||
| "catalog_data.rename_columns([\"raMean\", \"decMean\"], [\"ra\", \"dec\"])\n", | ||
| "\n", | ||
| "aladin.add_table(\n", | ||
| " catalog_data, name=\"test-table\", color=\"lime\", shape=\"circle\", source_size=10\n", | ||
| ")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "018d9426", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "After that, select a region in the Aladin Lite widget (you can also trigger a selection with `right click` then `select sources`):" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "f290b822", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "aladin.selection(\"circle\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "bc529c0a", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "You can then access the list of selections made as astropy regions" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "89624109", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "aladin.selected_regions" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "4c5f9ed8", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "### Display the selected regions as graphic overlays \n", | ||
| "You can then display those selected regions as graphic overlays" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "a95e51c7", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "aladin.add_graphic_overlay_from_region(aladin.selected_regions)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "d3835c52", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "and access the list of graphic overlays drawn this way" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "3fc74ebf-1d21-4cf1-818d-03ce4d79e58f", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "### Reselect an old selected region\n", | ||
| "We can revisit the selected regions and trigger a new selection by passing one of them in. For this example, lets re-select our first selection." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "b024622e-cbb0-424a-8ae0-db939c3ca317", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "aladin.select_region(aladin.selected_regions[0])" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": {}, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import MessageHandler from "./message_handler"; | ||
| import { divNumber, setDivNumber, Lock, setDivHeight } from "../utils"; | ||
| import { SelectorToJson } from "./selection_handler"; | ||
|
|
||
| export default class EventHandler { | ||
| /** | ||
|
|
@@ -244,6 +245,12 @@ export default class EventHandler { | |
| event_type: "select", | ||
| content: objectsData, | ||
| }); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revisit with further discussion |
||
| this.model.set("_selected_regions", [ | ||
| ...(this.model.get("_selected_regions") ?? []), | ||
| SelectorToJson(this.aladin), | ||
| ]); | ||
| this.model.save_changes(); | ||
| }); | ||
|
|
||
| /* Aladin functionalities */ | ||
|
|
@@ -279,6 +286,7 @@ export default class EventHandler { | |
| change_colormap: this.messageHandler.handleChangeColormap, | ||
| get_JPG_thumbnail: this.messageHandler.handleGetJPGThumbnail, | ||
| trigger_selection: this.messageHandler.handleTriggerSelection, | ||
| trigger_select_region: this.messageHandler.handleTriggerSelectRegion, | ||
| add_table: this.messageHandler.handleAddTable, | ||
| }; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.